diff --git a/src/main/drivers/light_ws2811strip.c b/src/main/drivers/light_ws2811strip.c index 149c9b6129..ad10af7173 100644 --- a/src/main/drivers/light_ws2811strip.c +++ b/src/main/drivers/light_ws2811strip.c @@ -89,6 +89,9 @@ void ws2811LedStripInit(ioTag_t ioTag) { memset(&ledStripDMABuffer, 0, WS2811_DMA_BUFFER_SIZE); ws2811LedStripHardwareInit(ioTag); + + const hsvColor_t hsv_white = { 0, 255, 255}; + setStripColor(&hsv_white); ws2811UpdateStrip(); } diff --git a/src/main/drivers/light_ws2811strip.h b/src/main/drivers/light_ws2811strip.h index 894ef4b1d6..2a1f708e7f 100644 --- a/src/main/drivers/light_ws2811strip.h +++ b/src/main/drivers/light_ws2811strip.h @@ -19,23 +19,34 @@ #include "io_types.h" -#define WS2811_LED_STRIP_LENGTH 32 -#define WS2811_BITS_PER_LED 24 -#define WS2811_DELAY_BUFFER_LENGTH 42 // for 50us delay +#define WS2811_LED_STRIP_LENGTH 32 +#define WS2811_BITS_PER_LED 24 +// for 50us delay +#define WS2811_DELAY_BUFFER_LENGTH 42 #define WS2811_DATA_BUFFER_SIZE (WS2811_BITS_PER_LED * WS2811_LED_STRIP_LENGTH) - -#define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE + WS2811_DELAY_BUFFER_LENGTH) // number of bytes needed is #LEDs * 24 bytes + 42 trailing bytes) +// number of bytes needed is #LEDs * 24 bytes + 42 trailing bytes) +#define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE + WS2811_DELAY_BUFFER_LENGTH) #if defined(STM32F40_41xxx) -#define BIT_COMPARE_1 67 // timer compare value for logical 1 -#define BIT_COMPARE_0 33 // timer compare value for logical 0 +#define WS2811_TIMER_HZ 84000000 +#define WS2811_TIMER_PERIOD 104 +// timer compare value for logical 1 +#define BIT_COMPARE_1 67 +// timer compare value for logical 0 +#define BIT_COMPARE_0 33 #elif defined(STM32F7) -#define BIT_COMPARE_1 76 // timer compare value for logical 1 -#define BIT_COMPARE_0 38 // timer compare value for logical 0 +// timer compare value for logical 1 +#define BIT_COMPARE_1 76 +// timer compare value for logical 0 +#define BIT_COMPARE_0 38 #else -#define BIT_COMPARE_1 17 // timer compare value for logical 1 -#define BIT_COMPARE_0 9 // timer compare value for logical 0 +#define WS2811_TIMER_HZ 24000000 +#define WS2811_TIMER_PERIOD 29 +// timer compare value for logical 1 +#define BIT_COMPARE_1 17 +// timer compare value for logical 0 +#define BIT_COMPARE_0 9 #endif void ws2811LedStripInit(ioTag_t ioTag); diff --git a/src/main/drivers/light_ws2811strip_hal.c b/src/main/drivers/light_ws2811strip_hal.c index 3c53cd03cd..8de162c280 100644 --- a/src/main/drivers/light_ws2811strip_hal.c +++ b/src/main/drivers/light_ws2811strip_hal.c @@ -132,9 +132,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) return; } - const hsvColor_t hsv_white = { 0, 255, 255}; ws2811Initialised = true; - setStripColor(&hsv_white); } @@ -146,9 +144,9 @@ void ws2811LedStripDMAEnable(void) return; } - if( HAL_TIM_PWM_Start_DMA(&TimHandle, timerChannel, ledStripDMABuffer, WS2811_DMA_BUFFER_SIZE) != HAL_OK) + if (HAL_TIM_PWM_Start_DMA(&TimHandle, timerChannel, ledStripDMABuffer, WS2811_DMA_BUFFER_SIZE) != HAL_OK) { - /* Starting PWM generation Error */ + /* Starting PWM generation Error */ ws2811LedDataTransferInProgress = 0; return; } diff --git a/src/main/drivers/light_ws2811strip_stm32f10x.c b/src/main/drivers/light_ws2811strip_stm32f10x.c index 476fc6125f..f8aef69ff3 100644 --- a/src/main/drivers/light_ws2811strip_stm32f10x.c +++ b/src/main/drivers/light_ws2811strip_stm32f10x.c @@ -30,9 +30,6 @@ #include "rcc.h" #include "timer.h" -#define WS2811_TIMER_HZ 24000000 -#define WS2811_TIMER_PERIOD 29 - static IO_t ws2811IO = IO_NONE; bool ws2811Initialised = false; static DMA_Channel_TypeDef *dmaChannel = NULL; @@ -93,6 +90,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) /* configure DMA */ /* DMA1 Channel6 Config */ + dmaChannel = timerHardware->dmaChannel; DMA_DeInit(dmaChannel); DMA_StructInit(&DMA_InitStructure); @@ -118,10 +116,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) dmaInit(timerHardware->dmaIrqHandler, OWNER_LED_STRIP, 0); dmaSetHandler(timerHardware->dmaIrqHandler, WS2811_DMA_IRQHandler, NVIC_PRIO_WS2811_DMA, 0); - const hsvColor_t hsv_white = { 0, 255, 255}; ws2811Initialised = true; - setStripColor(&hsv_white); - ws2811UpdateStrip(); } void ws2811LedStripDMAEnable(void) diff --git a/src/main/drivers/light_ws2811strip_stm32f30x.c b/src/main/drivers/light_ws2811strip_stm32f30x.c index cb37a9cf62..7fe643af4e 100644 --- a/src/main/drivers/light_ws2811strip_stm32f30x.c +++ b/src/main/drivers/light_ws2811strip_stm32f30x.c @@ -31,9 +31,6 @@ #include "rcc.h" #include "timer.h" -#define WS2811_TIMER_HZ 24000000 -#define WS2811_TIMER_PERIOD 29 - static IO_t ws2811IO = IO_NONE; bool ws2811Initialised = false; static DMA_Channel_TypeDef *dmaChannel = NULL; @@ -100,10 +97,9 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) TIM_CtrlPWMOutputs(timer, ENABLE); - dmaChannel = timerHardware->dmaChannel; - /* configure DMA */ /* DMA1 Channel Config */ + dmaChannel = timerHardware->dmaChannel; DMA_DeInit(dmaChannel); DMA_StructInit(&DMA_InitStructure); @@ -128,10 +124,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) dmaInit(timerHardware->dmaIrqHandler, OWNER_LED_STRIP, 0); dmaSetHandler(timerHardware->dmaIrqHandler, WS2811_DMA_IRQHandler, NVIC_PRIO_WS2811_DMA, 0); - const hsvColor_t hsv_white = { 0, 255, 255}; ws2811Initialised = true; - setStripColor(&hsv_white); - ws2811UpdateStrip(); } void ws2811LedStripDMAEnable(void) diff --git a/src/main/drivers/light_ws2811strip_stm32f4xx.c b/src/main/drivers/light_ws2811strip_stm32f4xx.c index 13d00c0724..c7e01f7e2b 100644 --- a/src/main/drivers/light_ws2811strip_stm32f4xx.c +++ b/src/main/drivers/light_ws2811strip_stm32f4xx.c @@ -33,9 +33,6 @@ #include "timer_stm32f4xx.h" #include "io.h" -#define WS2811_TIMER_HZ 84000000 -#define WS2811_TIMER_PERIOD 104 - static IO_t ws2811IO = IO_NONE; bool ws2811Initialised = false; static DMA_Stream_TypeDef *stream = NULL; @@ -141,10 +138,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) dmaInit(timerHardware->dmaIrqHandler, OWNER_LED_STRIP, 0); dmaSetHandler(timerHardware->dmaIrqHandler, WS2811_DMA_IRQHandler, NVIC_PRIO_WS2811_DMA, 0); - const hsvColor_t hsv_white = { 0, 255, 255 }; ws2811Initialised = true; - setStripColor(&hsv_white); - ws2811UpdateStrip(); } void ws2811LedStripDMAEnable(void) diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index d1d09f6043..f048215e40 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -157,7 +157,9 @@ // USART2, PA3 #define BIND_PIN PA3 +#if !defined(BRUSHED_MOTORS) #define USE_SERIAL_4WAY_BLHELI_INTERFACE +#endif #define DEFAULT_RX_FEATURE FEATURE_RX_PPM