Add init function to RGBLight driver struct (#23076)
This commit is contained in:
parent
23b7a02ebe
commit
f7cf40fa77
42 changed files with 306 additions and 93 deletions
|
|
@ -177,7 +177,7 @@ static void ws2812_dma_callback(void* p, uint32_t ct) {
|
|||
osalSysUnlockFromISR();
|
||||
}
|
||||
|
||||
bool ws2812_init(void) {
|
||||
void ws2812_init(void) {
|
||||
uint pio_idx = pio_get_index(pio);
|
||||
/* Get PIOx peripheral out of reset state. */
|
||||
hal_lld_peripheral_unreset(pio_idx == 0 ? RESETS_ALLREG_PIO0 : RESETS_ALLREG_PIO1);
|
||||
|
|
@ -196,7 +196,7 @@ bool ws2812_init(void) {
|
|||
STATE_MACHINE = pio_claim_unused_sm(pio, true);
|
||||
if (STATE_MACHINE < 0) {
|
||||
dprintln("ERROR: Failed to acquire state machine for WS2812 output!");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
uint offset = pio_add_program(pio, &ws2812_program);
|
||||
|
|
@ -246,8 +246,6 @@ bool ws2812_init(void) {
|
|||
DMA_CTRL_TRIG_TREQ_SEL(pio == pio0 ? STATE_MACHINE : STATE_MACHINE + 8) |
|
||||
DMA_CTRL_TRIG_PRIORITY(RP_DMA_PRIORITY_WS2812);
|
||||
// clang-format on
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void sync_ws2812_transfer(void) {
|
||||
|
|
@ -269,11 +267,6 @@ static inline void sync_ws2812_transfer(void) {
|
|||
}
|
||||
|
||||
void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
|
||||
static bool is_initialized = false;
|
||||
if (unlikely(!is_initialized)) {
|
||||
is_initialized = ws2812_init();
|
||||
}
|
||||
|
||||
sync_ws2812_transfer();
|
||||
|
||||
for (int i = 0; i < leds; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue