diff options
Diffstat (limited to 'platforms/chibios/drivers/ws2812_bitbang.c')
-rw-r--r-- | platforms/chibios/drivers/ws2812_bitbang.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/platforms/chibios/drivers/ws2812_bitbang.c b/platforms/chibios/drivers/ws2812_bitbang.c index 883a845d88..1ed87c4381 100644 --- a/platforms/chibios/drivers/ws2812_bitbang.c +++ b/platforms/chibios/drivers/ws2812_bitbang.c @@ -3,18 +3,23 @@ #include "gpio.h" #include "chibios_config.h" +// DEPRECATED - DO NOT USE +#if defined(NOP_FUDGE) +# define WS2812_BITBANG_NOP_FUDGE NOP_FUDGE +#endif + /* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ -#ifndef NOP_FUDGE +#ifndef WS2812_BITBANG_NOP_FUDGE # if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(WB32F3G71xx) || defined(WB32FQ95xx) -# define NOP_FUDGE 0.4 +# define WS2812_BITBANG_NOP_FUDGE 0.4 # else # if defined(RP2040) # error "Please use `vendor` WS2812 driver for RP2040" # else -# error "NOP_FUDGE configuration required" +# error "WS2812_BITBANG_NOP_FUDGE configuration required" # endif -# define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot +# define WS2812_BITBANG_NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot # endif #endif @@ -33,7 +38,7 @@ #endif #define NUMBER_NOPS 6 -#define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * NOP_FUDGE) +#define CYCLES_PER_SEC (CPU_CLOCK / NUMBER_NOPS * WS2812_BITBANG_NOP_FUDGE) #define NS_PER_SEC (1000000000L) // Note that this has to be SIGNED since we want to be able to check for negative values of derivatives #define NS_PER_CYCLE (NS_PER_SEC / CYCLES_PER_SEC) #define NS_TO_CYCLES(n) ((n) / NS_PER_CYCLE) @@ -57,15 +62,15 @@ void sendByte(uint8_t byte) { // using something like wait_ns(is_one ? T1L : T0L) here throws off timings if (is_one) { // 1 - writePinHigh(WS2812_DI_PIN); + gpio_write_pin_high(WS2812_DI_PIN); wait_ns(WS2812_T1H); - writePinLow(WS2812_DI_PIN); + gpio_write_pin_low(WS2812_DI_PIN); wait_ns(WS2812_T1L); } else { // 0 - writePinHigh(WS2812_DI_PIN); + gpio_write_pin_high(WS2812_DI_PIN); wait_ns(WS2812_T0H); - writePinLow(WS2812_DI_PIN); + gpio_write_pin_low(WS2812_DI_PIN); wait_ns(WS2812_T0L); } } |