diff --git a/units/neopixel/ws2812.c b/units/neopixel/ws2812.c index 00981ba..3ff9eaa 100644 --- a/units/neopixel/ws2812.c +++ b/units/neopixel/ws2812.c @@ -4,7 +4,7 @@ #define FREQ_STEP (PLAT_AHB_MHZ/20.0f) #define NPX_DELAY_SHORT (uint32_t)(FREQ_STEP*1.5f) #define NPX_DELAY_LONG (uint32_t)(FREQ_STEP*3.5f) -#define NPX_DELAY_SHOW (uint32_t)(FREQ_STEP*60) +#define NPX_DELAY_SHOW (uint32_t)(FREQ_STEP*50) static inline __attribute__((always_inline)) void ws2812_byte(GPIO_TypeDef *port, uint32_t ll_pin, uint8_t b) @@ -42,10 +42,6 @@ void ws2812_load_raw(GPIO_TypeDef *port, uint32_t ll_pin, uint8_t *rgbs, uint32_ } vPortExitCritical(); __asm_loop(NPX_DELAY_SHOW); - - LL_GPIO_SetOutputPin(port, ll_pin); - __asm_loop(NPX_DELAY_SHORT); - LL_GPIO_ResetOutputPin(port, ll_pin); } /** Set many RGBs from uint32 stream */ @@ -72,10 +68,6 @@ void ws2812_load_sparse(GPIO_TypeDef *port, uint32_t ll_pin, uint8_t *rgbs, uint } vPortExitCritical(); __asm_loop(NPX_DELAY_SHOW); - - LL_GPIO_SetOutputPin(port, ll_pin); - __asm_loop(NPX_DELAY_SHORT); - LL_GPIO_ResetOutputPin(port, ll_pin); } /** Set many RGBs */ @@ -87,8 +79,4 @@ void ws2812_clear(GPIO_TypeDef *port, uint32_t ll_pin, uint32_t count) } vPortExitCritical(); __asm_loop(NPX_DELAY_SHOW); - - LL_GPIO_SetOutputPin(port, ll_pin); - __asm_loop(NPX_DELAY_SHORT); - LL_GPIO_ResetOutputPin(port, ll_pin); } diff --git a/utils/cortex_utils.h b/utils/cortex_utils.h index a344e7d..1a4db8a 100644 --- a/utils/cortex_utils.h +++ b/utils/cortex_utils.h @@ -26,15 +26,14 @@ static inline bool isDynAlloc(const void *obj) /** Tight asm loop */ #define __asm_loop(cycles) \ do { \ - register uint32_t _count = cycles; \ + register uint32_t _count asm ("r4") = cycles; \ asm volatile( \ ".syntax unified\n" \ ".thumb\n" \ - "ldr r4, =%0\n" \ "0:" \ - "subs r4, #1\n" \ + "subs %0, #1\n" \ "bne 0b\n" \ - : /* no outputs */ : "g" (cycles) : "r4"); \ + : "+r" (_count)); \ } while(0) #endif //GEX_CORTEX_UTILS_H