good L8 update

This commit is contained in:
Yunhorn 2025-03-19 22:39:00 +08:00
parent d88844cca2
commit b333ba212c
25 changed files with 52 additions and 46 deletions

View File

@ -354,7 +354,7 @@ void Error_Handler(void);
*/
#define STS_LAMP_BAR_PWM_TIM_PERIOD (240 - 1)
#define STS_LAMP_BAR_HTIM htim1
#define STS_LAMP_BAR_LED_NUM (60) //60 for 46CM length LED strip
//#define STS_LAMP_BAR_LED_NUM (14) //60 for 46CM length LED strip
#define WSDATA_PORT_PIN_PA8
//#define WSDATA_PORT_PIN_PA9

View File

@ -47,7 +47,7 @@ extern "C" {
/**
* @brief Verbose level for all trace logs
*/
#define VERBOSE_LEVEL VLEVEL_L
#define VERBOSE_LEVEL VLEVEL_H
/**
* @brief Enable trace logs

View File

@ -117,11 +117,13 @@ int main(void)
MX_I2C2_Init();
MX_DMA_Init();
MX_TIM1_Init();
MX_USART2_UART_Init();
MX_LoRaWAN_Init();
//STS_Lamp_Bar_Self_Test();
}
printf("\r\n Start O7");
/* USER CODE BEGIN 2 */

View File

@ -28,25 +28,25 @@
#include "yunhorn_sts_sensors.h"
#define ONE_PULSE (40) //36
#define ZERO_PULSE (20)
#define ONE_PULSE (24) //36
#define ZERO_PULSE (12)
#define STS_LAMP_BAR_LED_NUM (27) //60 for 46CM length LED strip
#define LED_DATA_LEN 24
#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM))
#define RESET_PULSE (24) //(80) TO FIX DARK_COLOR AND SM2
#define RESET_PULSE (16) //(80) TO FIX DARK_COLOR AND SM2
typedef struct ws2812b_e {
//uint16_t head[3];
uint16_t GRB[WS2812B_DATA_LEN];
uint16_t tail;
uint16_t GRB[WS2812B_DATA_LEN+RESET_PULSE];
uint16_t tail[RESET_PULSE];
} WS2812B_FrameTypeDef;
volatile WS2812B_FrameTypeDef rgb_buf = {
// .head[0] = 0,
// .head[1] = 0,
// .head[2] = 0,
.tail = 0
// .head[0] = 10,
// .head[1] = 10,
// .head[2] = 10,
//.tail = 00
};
uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
@ -101,7 +101,7 @@ void STS_WS2812B_Refresh(void)
{
HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (WS2812B_DATA_LEN+RESET_PULSE));
//HAL_TIM_PWM_Start_IT(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
HAL_TIM_PWM_Start_IT(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
}
void STS_Lamp_Bar_Init(void)
@ -140,26 +140,30 @@ void STS_WS2812B_Set_RGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t idx)
{
for (uint8_t j = 0; j < 8; j ++)
{
rgb_buf.GRB[idx*24+j] = (uint16_t)(((green<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[idx*24+8+j] = (uint16_t)(((red<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[idx*24+16+j] = (uint16_t)(((blue<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[idx*24+j] = (uint8_t)(((green<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[idx*24+8+j] = (uint8_t)(((red<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[idx*24+16+j] = (uint8_t)(((blue<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
}
}
void STS_Lamp_Bar_Set_RGB_Color(uint8_t red, uint8_t green, uint8_t blue )
{
uint8_t i =0;
UTIL_MEM_set_8((void*)rgb_buf.GRB,0x00,(WS2812B_DATA_LEN+RESET_PULSE));
uint8_t i =0, j=0;
uint32_t bits=0;
// UTIL_MEM_set_8((void*)rgb_buf.GRB,0x00,(WS2812B_DATA_LEN+RESET_PULSE));
for(i = 0; i < STS_LAMP_BAR_LED_NUM; i++)
{
for (uint8_t j = 0; j < 8; j ++)
for (j = 0; j < 8; j ++)
{
rgb_buf.GRB[i*24+j] = (uint16_t)(((green<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[i*24+8+j] = (uint16_t)(((red<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[i*24+16+j] = (uint16_t)(((blue<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[i*24+j] = (uint8_t)(((green<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[i*24+8+j] = (uint8_t)(((red<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
rgb_buf.GRB[i*24+16+j] = (uint8_t)(((blue<<j)&0x80)? ONE_PULSE : ZERO_PULSE);
bits++;
}
}
for (i=0; i < RESET_PULSE; i++)
rgb_buf.tail[i] = 0;
STS_WS2812B_Refresh();
}
@ -205,7 +209,7 @@ void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum)
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
{
__HAL_TIM_SetCompare(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL,0);
//__HAL_TIM_SetCompare(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL,0);
HAL_TIM_PWM_Stop_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
}

View File

@ -131,9 +131,9 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
hdma_tim1_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim1_ch1.Init.MemInc = DMA_MINC_ENABLE;
hdma_tim1_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_tim1_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_HALFWORD;
hdma_tim1_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_HALFWORD;
hdma_tim1_ch1.Init.Mode = DMA_CIRCULAR;
hdma_tim1_ch1.Init.Priority = DMA_PRIORITY_HIGH; //was HIGH
hdma_tim1_ch1.Init.Priority = DMA_PRIORITY_LOW; //was HIGH
if (HAL_DMA_Init(&hdma_tim1_ch1) != HAL_OK)
{
@ -168,7 +168,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
*/
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP; //GPIO_NOPULL;
GPIO_InitStruct.Pull = GPIO_PULLDOWN; //GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

View File

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-316576647475584104" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-859626784961551925" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-316576647475584104" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-859626784961551925" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
-include ../makefile.init

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
USER_OBJS :=

View File

@ -1,6 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (12.3.rel1)
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
ELF_SRCS :=