40 #define WS2812_SERVO_HZ 800000
41 #define WS2812_PWM_FREQUENCY (STM32_SYSCLK/2)
43 #define WS2812_DUTYCYCLE_0 (WS2812_PWM_FREQUENCY/(1000000000/350))
44 #define WS2812_DUTYCYCLE_1 (WS2812_PWM_FREQUENCY/(1000000000/800))
46 #define WS2812_RESET_BIT_N (50)
47 #define WS2812_COLOR_BIT_N (WS2812_NB_LEDS * 24)
48 #define WS2812_BIT_N (WS2812_COLOR_BIT_N + WS2812_RESET_BIT_N)
51 #ifndef WS2812_CFG_DEF
52 #define WS2812_GPIO WS2812D1_GPIO
53 #define WS2812_PIN WS2812D1_PIN
54 #define WS2812_AF WS2812D1_AF
55 #define WS2812_CFG_DEF WS2812D1_CFG_DEF
58 #define WS2812_DMA_IRQ_PRIORITY 6
111 .inc_peripheral_addr =
false,
112 .inc_memory_addr =
true,
127 .mode = PWM_OUTPUT_DISABLED,
131 .mode = PWM_OUTPUT_DISABLED,
135 .mode = PWM_OUTPUT_DISABLED,
139 .mode = PWM_OUTPUT_DISABLED,
144 .dier = STM32_TIM_DIER_UDE
156 #define WS2812_BIT(led, byte, bit) (24*(led) + 8*(byte) + (7 - (bit)))
157 #define WS2812_RED_BIT(led, bit) WS2812_BIT((led), 1, (bit))
158 #define WS2812_GREEN_BIT(led, bit) WS2812_BIT((led), 0, (bit))
159 #define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 2, (bit))
165 for (bit = 0; bit < 8; bit++) {
void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
Setup a gpio for input or output with alternate function.
Some architecture independent helper functions for GPIOs.
void dmaObjectInit(DMADriver *dmap)
bool dmaStartTransfert(DMADriver *dmap, volatile void *periphp, void *mem0p, const size_t size)
Starts a DMA transaction.
bool dmaStart(DMADriver *dmap, const DMAConfig *cfg)
Configures and activates the DMA peripheral.
STM32 DMA subsystem driver header.
@ DMA_CONTINUOUS_HALF_BUFFER
Continuous mode to/from the same buffer.
@ DMA_DIR_M2P
MEMORY to PERIPHERAL
uint32_t stream
stream associated with transaction
DMA stream configuration structure.
Structure representing a DMA driver.
#define WS2812_GREEN_BIT(led, bit)
#define WS2812_DMA_IRQ_PRIORITY
static WS2812Driver WS2812D
#define WS2812_BLUE_BIT(led, bit)
#define WS2812_RESET_BIT_N
static WS2812Config WS2812CFG
#define WS2812_PWM_FREQUENCY
#define WS2812_DUTYCYCLE_0
const WS2812Config * config
#define WS2812_COLOR_BIT_N
void light_ws2812_arch_set(uint32_t led_number, uint8_t r, uint8_t g, uint8_t b)
set color RGB color of one led
void light_ws2812_arch_init(void)
uint32_t buf[WS2812_BIT_N+1]
#define WS2812_DUTYCYCLE_1
#define WS2812_RED_BIT(led, bit)
ws2812 driver based on ChibiOS
#define WS2812_NB_LEDS
Number of LEDs.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.