aboutsummaryrefslogtreecommitdiff
path: root/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'platforms')
-rw-r--r--platforms/avr/drivers/audio_pwm_hardware.c6
-rw-r--r--platforms/avr/drivers/ws2812_bitbang.c4
-rw-r--r--platforms/avr/drivers/ws2812_i2c.c8
-rw-r--r--platforms/chibios/boards/BONSAI_C4/configs/config.h8
-rw-r--r--platforms/chibios/drivers/audio_dac_additive.c6
-rw-r--r--platforms/chibios/drivers/audio_dac_basic.c6
-rw-r--r--platforms/chibios/drivers/audio_pwm_hardware.c6
-rw-r--r--platforms/chibios/drivers/audio_pwm_software.c6
-rw-r--r--platforms/chibios/drivers/i2c_master.c2
-rw-r--r--platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c35
-rw-r--r--platforms/chibios/drivers/ws2812_bitbang.c8
-rw-r--r--platforms/chibios/drivers/ws2812_pwm.c74
-rw-r--r--platforms/chibios/drivers/ws2812_spi.c10
-rw-r--r--platforms/chibios/platform.mk9
-rw-r--r--platforms/eeprom.h4
-rw-r--r--platforms/test/drivers/audio_pwm_hardware.c6
16 files changed, 93 insertions, 105 deletions
diff --git a/platforms/avr/drivers/audio_pwm_hardware.c b/platforms/avr/drivers/audio_pwm_hardware.c
index d484fba00f..16264cf0a2 100644
--- a/platforms/avr/drivers/audio_pwm_hardware.c
+++ b/platforms/avr/drivers/audio_pwm_hardware.c
@@ -213,7 +213,7 @@ void channel_2_stop(void) {
}
#endif
-void audio_driver_initialize(void) {
+void audio_driver_initialize_impl(void) {
#ifdef AUDIO1_PIN_SET
channel_1_stop();
gpio_set_pin_output(AUDIO1_PIN);
@@ -254,7 +254,7 @@ void audio_driver_initialize(void) {
#endif
}
-void audio_driver_stop(void) {
+void audio_driver_stop_impl(void) {
#ifdef AUDIO1_PIN_SET
channel_1_stop();
#endif
@@ -264,7 +264,7 @@ void audio_driver_stop(void) {
#endif
}
-void audio_driver_start(void) {
+void audio_driver_start_impl(void) {
#ifdef AUDIO1_PIN_SET
channel_1_start();
if (playing_note) {
diff --git a/platforms/avr/drivers/ws2812_bitbang.c b/platforms/avr/drivers/ws2812_bitbang.c
index 116053591f..be127e501c 100644
--- a/platforms/avr/drivers/ws2812_bitbang.c
+++ b/platforms/avr/drivers/ws2812_bitbang.c
@@ -37,9 +37,11 @@
static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi);
-void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds) {
+void ws2812_init(void) {
DDRx_ADDRESS(WS2812_DI_PIN) |= pinmask(WS2812_DI_PIN);
+}
+void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds) {
uint8_t masklo = ~(pinmask(WS2812_DI_PIN)) & PORTx_ADDRESS(WS2812_DI_PIN);
uint8_t maskhi = pinmask(WS2812_DI_PIN) | PORTx_ADDRESS(WS2812_DI_PIN);
diff --git a/platforms/avr/drivers/ws2812_i2c.c b/platforms/avr/drivers/ws2812_i2c.c
index f52a037b8e..86a5ac8394 100644
--- a/platforms/avr/drivers/ws2812_i2c.c
+++ b/platforms/avr/drivers/ws2812_i2c.c
@@ -1,7 +1,7 @@
#include "ws2812.h"
#include "i2c_master.h"
-#ifdef RGBW
+#ifdef WS2812_RGBW
# error "RGBW not supported"
#endif
@@ -19,11 +19,5 @@ void ws2812_init(void) {
// Setleds for standard RGB
void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
- static bool s_init = false;
- if (!s_init) {
- ws2812_init();
- s_init = true;
- }
-
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(rgb_led_t) * leds, WS2812_I2C_TIMEOUT);
}
diff --git a/platforms/chibios/boards/BONSAI_C4/configs/config.h b/platforms/chibios/boards/BONSAI_C4/configs/config.h
index 193b028bde..e933cd6fd1 100644
--- a/platforms/chibios/boards/BONSAI_C4/configs/config.h
+++ b/platforms/chibios/boards/BONSAI_C4/configs/config.h
@@ -77,11 +77,11 @@
# ifndef WS2812_PWM_PAL_MODE
# define WS2812_PWM_PAL_MODE 1
# endif
-# ifndef WS2812_DMA_STREAM
-# define WS2812_DMA_STREAM STM32_DMA2_STREAM5
+# ifndef WS2812_PWM_DMA_STREAM
+# define WS2812_PWM_DMA_STREAM STM32_DMA2_STREAM5
# endif
-# ifndef WS2812_DMA_CHANNEL
-# define WS2812_DMA_CHANNEL 6
+# ifndef WS2812_PWM_DMA_CHANNEL
+# define WS2812_PWM_DMA_CHANNEL 6
# endif
#endif
diff --git a/platforms/chibios/drivers/audio_dac_additive.c b/platforms/chibios/drivers/audio_dac_additive.c
index d6fde42b68..8e29053301 100644
--- a/platforms/chibios/drivers/audio_dac_additive.c
+++ b/platforms/chibios/drivers/audio_dac_additive.c
@@ -303,7 +303,7 @@ static const DACConfig dac_conf = {.init = AUDIO_DAC_OFF_VALUE, .datamode = DAC_
*/
static const DACConversionGroup dac_conv_cfg = {.num_channels = 1U, .end_cb = dac_end, .error_cb = dac_error, .trigger = DAC_TRG(0b000)};
-void audio_driver_initialize(void) {
+void audio_driver_initialize_impl(void) {
if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
palSetLineMode(A4, PAL_MODE_INPUT_ANALOG);
dacStart(&DACD1, &dac_conf);
@@ -350,11 +350,11 @@ void audio_driver_initialize(void) {
gptStart(&GPTD6, &gpt6cfg1);
}
-void audio_driver_stop(void) {
+void audio_driver_stop_impl(void) {
state = OUTPUT_SHOULD_STOP;
}
-void audio_driver_start(void) {
+void audio_driver_start_impl(void) {
gptStartContinuous(&GPTD6, 2U);
for (uint8_t i = 0; i < AUDIO_MAX_SIMULTANEOUS_TONES; i++) {
diff --git a/platforms/chibios/drivers/audio_dac_basic.c b/platforms/chibios/drivers/audio_dac_basic.c
index 9a3f3fea1f..99b938e610 100644
--- a/platforms/chibios/drivers/audio_dac_basic.c
+++ b/platforms/chibios/drivers/audio_dac_basic.c
@@ -190,7 +190,7 @@ static void gpt_audio_state_cb(GPTDriver *gptp) {
}
}
-void audio_driver_initialize(void) {
+void audio_driver_initialize_impl(void) {
if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
dacStart(&DACD1, &dac_conf_ch1);
@@ -223,7 +223,7 @@ void audio_driver_initialize(void) {
gptStart(&AUDIO_STATE_TIMER, &gptStateUpdateCfg);
}
-void audio_driver_stop(void) {
+void audio_driver_stop_impl(void) {
if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
gptStopTimer(&GPTD6);
@@ -241,7 +241,7 @@ void audio_driver_stop(void) {
gptStopTimer(&AUDIO_STATE_TIMER);
}
-void audio_driver_start(void) {
+void audio_driver_start_impl(void) {
if ((AUDIO_PIN == A4) || (AUDIO_PIN_ALT == A4)) {
dacStartConversion(&DACD1, &dac_conv_grp_ch1, (dacsample_t *)dac_buffer_1, AUDIO_DAC_BUFFER_SIZE);
}
diff --git a/platforms/chibios/drivers/audio_pwm_hardware.c b/platforms/chibios/drivers/audio_pwm_hardware.c
index 21b5c6892c..1ba7ec13bc 100644
--- a/platforms/chibios/drivers/audio_pwm_hardware.c
+++ b/platforms/chibios/drivers/audio_pwm_hardware.c
@@ -87,7 +87,7 @@ static void audio_callback(virtual_timer_t *vtp, void *p) {
chSysUnlockFromISR();
}
-void audio_driver_initialize(void) {
+void audio_driver_initialize_impl(void) {
pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
// connect the AUDIO_PIN to the PWM hardware
@@ -100,7 +100,7 @@ void audio_driver_initialize(void) {
chVTObjectInit(&audio_vt);
}
-void audio_driver_start(void) {
+void audio_driver_start_impl(void) {
channel_1_stop();
channel_1_start();
@@ -115,7 +115,7 @@ void audio_driver_start(void) {
}
}
-void audio_driver_stop(void) {
+void audio_driver_stop_impl(void) {
channel_1_stop();
chVTReset(&audio_vt);
}
diff --git a/platforms/chibios/drivers/audio_pwm_software.c b/platforms/chibios/drivers/audio_pwm_software.c
index 663a9eca16..f48323900b 100644
--- a/platforms/chibios/drivers/audio_pwm_software.c
+++ b/platforms/chibios/drivers/audio_pwm_software.c
@@ -121,7 +121,7 @@ GPTConfig gptCFG = {
.callback = gpt_callback,
};
-void audio_driver_initialize(void) {
+void audio_driver_initialize_impl(void) {
pwmStart(&AUDIO_PWM_DRIVER, &pwmCFG);
palSetLineMode(AUDIO_PIN, PAL_MODE_OUTPUT_PUSHPULL);
@@ -138,7 +138,7 @@ void audio_driver_initialize(void) {
gptStart(&AUDIO_STATE_TIMER, &gptCFG);
}
-void audio_driver_start(void) {
+void audio_driver_start_impl(void) {
channel_1_stop();
channel_1_start();
@@ -147,7 +147,7 @@ void audio_driver_start(void) {
}
}
-void audio_driver_stop(void) {
+void audio_driver_stop_impl(void) {
channel_1_stop();
gptStopTimer(&AUDIO_STATE_TIMER);
}
diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c
index ad11d850dd..0d5fb1e985 100644
--- a/platforms/chibios/drivers/i2c_master.c
+++ b/platforms/chibios/drivers/i2c_master.c
@@ -206,5 +206,5 @@ __attribute__((weak)) i2c_status_t i2c_ping_address(uint8_t address, uint16_t ti
// Best effort instead tries reading register 0 which will either succeed or timeout.
// This approach may produce false negative results for I2C devices that do not respond to a register 0 read request.
uint8_t data = 0;
- return i2c_readReg(address, 0, &data, sizeof(data), timeout);
+ return i2c_read_register(address, 0, &data, sizeof(data), timeout);
} \ No newline at end of file
diff --git a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c
index de317e269a..41a5311719 100644
--- a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c
+++ b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c
@@ -136,7 +136,7 @@ static const pio_program_t ws2812_program = {
};
static uint32_t WS2812_BUFFER[WS2812_LED_COUNT];
-static const rp_dma_channel_t* WS2812_DMA_CHANNEL;
+static const rp_dma_channel_t* dma_channel;
static uint32_t RP_DMA_MODE_WS2812;
static int STATE_MACHINE = -1;
@@ -161,7 +161,7 @@ static void ws2812_dma_callback(void* p, uint32_t ct) {
// FIFO is already empty.
rtcnt_t time_to_completion = (pio_sm_get_tx_fifo_level(pio, STATE_MACHINE) + 1) * MAX(WS2812_T1H + WS2812_T1L, WS2812_T0H + WS2812_T0L);
-#if defined(RGBW)
+#if defined(WS2812_RGBW)
time_to_completion *= 32;
#else
time_to_completion *= 24;
@@ -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);
@@ -222,7 +222,7 @@ bool ws2812_init(void) {
sm_config_set_sideset(&config, 1, false, false);
#endif
-#if defined(RGBW)
+#if defined(WS2812_RGBW)
sm_config_set_out_shift(&config, false, true, 32);
#else
sm_config_set_out_shift(&config, false, true, 24);
@@ -236,9 +236,9 @@ bool ws2812_init(void) {
pio_sm_init(pio, STATE_MACHINE, offset, &config);
pio_sm_set_enabled(pio, STATE_MACHINE, true);
- WS2812_DMA_CHANNEL = dmaChannelAlloc(RP_DMA_CHANNEL_ID_ANY, RP_DMA_PRIORITY_WS2812, (rp_dmaisr_t)ws2812_dma_callback, NULL);
- dmaChannelEnableInterruptX(WS2812_DMA_CHANNEL);
- dmaChannelSetDestinationX(WS2812_DMA_CHANNEL, (uint32_t)&pio->txf[STATE_MACHINE]);
+ dma_channel = dmaChannelAlloc(RP_DMA_CHANNEL_ID_ANY, RP_DMA_PRIORITY_WS2812, (rp_dmaisr_t)ws2812_dma_callback, NULL);
+ dmaChannelEnableInterruptX(dma_channel);
+ dmaChannelSetDestinationX(dma_channel, (uint32_t)&pio->txf[STATE_MACHINE]);
// clang-format off
RP_DMA_MODE_WS2812 = DMA_CTRL_TRIG_INCR_READ |
@@ -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) {
@@ -256,7 +254,7 @@ static inline void sync_ws2812_transfer(void) {
// count of LEDs in milliseconds. This is safely much longer than it
// would take to push all the data out.
dprintln("ERROR: WS2812 DMA transfer has stalled, aborting!");
- dmaChannelDisableX(WS2812_DMA_CHANNEL);
+ dmaChannelDisableX(dma_channel);
pio_sm_clear_fifos(pio, STATE_MACHINE);
pio_sm_restart(pio, STATE_MACHINE);
chSemReset(&TRANSFER_COUNTER, 0);
@@ -269,23 +267,18 @@ 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++) {
-#if defined(RGBW)
+#if defined(WS2812_RGBW)
WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w);
#else
WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, 0);
#endif
}
- dmaChannelSetSourceX(WS2812_DMA_CHANNEL, (uint32_t)WS2812_BUFFER);
- dmaChannelSetCounterX(WS2812_DMA_CHANNEL, leds);
- dmaChannelSetModeX(WS2812_DMA_CHANNEL, RP_DMA_MODE_WS2812);
- dmaChannelEnableX(WS2812_DMA_CHANNEL);
+ dmaChannelSetSourceX(dma_channel, (uint32_t)WS2812_BUFFER);
+ dmaChannelSetCounterX(dma_channel, leds);
+ dmaChannelSetModeX(dma_channel, RP_DMA_MODE_WS2812);
+ dmaChannelEnableX(dma_channel);
}
diff --git a/platforms/chibios/drivers/ws2812_bitbang.c b/platforms/chibios/drivers/ws2812_bitbang.c
index 1ed87c4381..96378ec0ac 100644
--- a/platforms/chibios/drivers/ws2812_bitbang.c
+++ b/platforms/chibios/drivers/ws2812_bitbang.c
@@ -82,12 +82,6 @@ void ws2812_init(void) {
// Setleds for standard RGB
void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
- static bool s_init = false;
- if (!s_init) {
- ws2812_init();
- s_init = true;
- }
-
// this code is very time dependent, so we need to disable interrupts
chSysLock();
@@ -107,7 +101,7 @@ void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
sendByte(ledarray[i].r);
#endif
-#ifdef RGBW
+#ifdef WS2812_RGBW
sendByte(ledarray[i].w);
#endif
}
diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c
index 6bba22767f..1e9d2ebb41 100644
--- a/platforms/chibios/drivers/ws2812_pwm.c
+++ b/platforms/chibios/drivers/ws2812_pwm.c
@@ -2,9 +2,21 @@
#include "gpio.h"
#include "chibios_config.h"
+// ======== DEPRECATED DEFINES - DO NOT USE ========
+#ifdef WS2812_DMA_STREAM
+# define WS2812_PWM_DMA_STREAM WS2812_DMA_STREAM
+#endif
+#ifdef WS2812_DMA_CHANNEL
+# define WS2812_PWM_DMA_CHANNEL WS2812_DMA_CHANNEL
+#endif
+#ifdef WS2812_DMAMUX_ID
+# define WS2812_PWM_DMAMUX_ID WS2812_DMAMUX_ID
+#endif
+// ========
+
/* Adapted from https://github.com/joewa/WS2812-LED-Driver_ChibiOS/ */
-#ifdef RGBW
+#ifdef WS2812_RGBW
# define WS2812_CHANNELS 4
#else
# define WS2812_CHANNELS 3
@@ -19,14 +31,14 @@
#ifndef WS2812_PWM_PAL_MODE
# define WS2812_PWM_PAL_MODE 2 // DI Pin's alternate function value
#endif
-#ifndef WS2812_DMA_STREAM
-# define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP
+#ifndef WS2812_PWM_DMA_STREAM
+# define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP
#endif
-#ifndef WS2812_DMA_CHANNEL
-# define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP
+#ifndef WS2812_PWM_DMA_CHANNEL
+# define WS2812_PWM_DMA_CHANNEL 2 // DMA Channel for TIMx_UP
#endif
-#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE) && !defined(WS2812_DMAMUX_ID)
-# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP"
+#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE) && !defined(WS2812_PWM_DMAMUX_ID)
+# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_PWM_DMAMUX_ID STM32_DMAMUX1_TIM?_UP"
#endif
/* Summarize https://www.st.com/resource/en/application_note/an4013-stm32-crossseries-timer-overview-stmicroelectronics.pdf to
@@ -250,7 +262,7 @@
# define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 0, (bit))
#endif
-#ifdef RGBW
+#ifdef WS2812_RGBW
/**
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given white bit
*
@@ -270,20 +282,20 @@
// For all other STM32 DMA transfer will automatically zero pad. We only need to set the right peripheral width.
#if defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32F7XX)
# if defined(WS2812_PWM_TIMER_32BIT)
-# define WS2812_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_WORD
-# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_WORD
+# define WS2812_PWM_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_WORD
+# define WS2812_PWM_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_WORD
typedef uint32_t ws2812_buffer_t;
# else
-# define WS2812_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_HWORD
-# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_HWORD
+# define WS2812_PWM_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_HWORD
+# define WS2812_PWM_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_HWORD
typedef uint16_t ws2812_buffer_t;
# endif
#else
-# define WS2812_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_BYTE
+# define WS2812_PWM_DMA_MEMORY_WIDTH STM32_DMA_CR_MSIZE_BYTE
# if defined(WS2812_PWM_TIMER_32BIT)
-# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_WORD
+# define WS2812_PWM_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_WORD
# else
-# define WS2812_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_HWORD
+# define WS2812_PWM_DMA_PERIPHERAL_WIDTH STM32_DMA_CR_PSIZE_HWORD
# endif
typedef uint8_t ws2812_buffer_t;
#endif
@@ -326,26 +338,26 @@ void ws2812_init(void) {
// Configure DMA
// dmaInit(); // Joe added this
#if defined(WB32F3G71xx) || defined(WB32FQ95xx)
- dmaStreamAlloc(WS2812_DMA_STREAM - WB32_DMA_STREAM(0), 10, NULL, NULL);
- dmaStreamSetSource(WS2812_DMA_STREAM, ws2812_frame_buffer);
- dmaStreamSetDestination(WS2812_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register
- dmaStreamSetMode(WS2812_DMA_STREAM, WB32_DMA_CHCFG_HWHIF(WS2812_DMA_CHANNEL) | WB32_DMA_CHCFG_DIR_M2P | WB32_DMA_CHCFG_PSIZE_WORD | WB32_DMA_CHCFG_MSIZE_WORD | WB32_DMA_CHCFG_MINC | WB32_DMA_CHCFG_CIRC | WB32_DMA_CHCFG_TCIE | WB32_DMA_CHCFG_PL(3));
+ dmaStreamAlloc(WS2812_PWM_DMA_STREAM - WB32_DMA_STREAM(0), 10, NULL, NULL);
+ dmaStreamSetSource(WS2812_PWM_DMA_STREAM, ws2812_frame_buffer);
+ dmaStreamSetDestination(WS2812_PWM_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register
+ dmaStreamSetMode(WS2812_PWM_DMA_STREAM, WB32_DMA_CHCFG_HWHIF(WS2812_PWM_DMA_CHANNEL) | WB32_DMA_CHCFG_DIR_M2P | WB32_DMA_CHCFG_PSIZE_WORD | WB32_DMA_CHCFG_MSIZE_WORD | WB32_DMA_CHCFG_MINC | WB32_DMA_CHCFG_CIRC | WB32_DMA_CHCFG_TCIE | WB32_DMA_CHCFG_PL(3));
#else
- dmaStreamAlloc(WS2812_DMA_STREAM - STM32_DMA_STREAM(0), 10, NULL, NULL);
- dmaStreamSetPeripheral(WS2812_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register
- dmaStreamSetMemory0(WS2812_DMA_STREAM, ws2812_frame_buffer);
- dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | WS2812_DMA_PERIPHERAL_WIDTH | WS2812_DMA_MEMORY_WIDTH | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
+ dmaStreamAlloc(WS2812_PWM_DMA_STREAM - STM32_DMA_STREAM(0), 10, NULL, NULL);
+ dmaStreamSetPeripheral(WS2812_PWM_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register
+ dmaStreamSetMemory0(WS2812_PWM_DMA_STREAM, ws2812_frame_buffer);
+ dmaStreamSetMode(WS2812_PWM_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_PWM_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | WS2812_PWM_DMA_PERIPHERAL_WIDTH | WS2812_PWM_DMA_MEMORY_WIDTH | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
#endif
- dmaStreamSetTransactionSize(WS2812_DMA_STREAM, WS2812_BIT_N);
+ dmaStreamSetTransactionSize(WS2812_PWM_DMA_STREAM, WS2812_BIT_N);
// M2P: Memory 2 Periph; PL: Priority Level
#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE)
// If the MCU has a DMAMUX we need to assign the correct resource
- dmaSetRequestSource(WS2812_DMA_STREAM, WS2812_DMAMUX_ID);
+ dmaSetRequestSource(WS2812_PWM_DMA_STREAM, WS2812_PWM_DMAMUX_ID);
#endif
// Start DMA
- dmaStreamEnable(WS2812_DMA_STREAM);
+ dmaStreamEnable(WS2812_PWM_DMA_STREAM);
// Configure PWM
// NOTE: It's required that preload be enabled on the timer channel CCR register. This is currently enabled in the
@@ -369,7 +381,7 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b,
ws2812_frame_buffer[WS2812_RED_BIT(led_number, bit)] = ((r >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
ws2812_frame_buffer[WS2812_GREEN_BIT(led_number, bit)] = ((g >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
ws2812_frame_buffer[WS2812_BLUE_BIT(led_number, bit)] = ((b >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
-#ifdef RGBW
+#ifdef WS2812_RGBW
ws2812_frame_buffer[WS2812_WHITE_BIT(led_number, bit)] = ((w >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
#endif
}
@@ -377,14 +389,8 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b,
// Setleds for standard RGB
void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
- static bool s_init = false;
- if (!s_init) {
- ws2812_init();
- s_init = true;
- }
-
for (uint16_t i = 0; i < leds; i++) {
-#ifdef RGBW
+#ifdef WS2812_RGBW
ws2812_write_led_rgbw(i, ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w);
#else
ws2812_write_led(i, ledarray[i].r, ledarray[i].g, ledarray[i].b);
diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c
index 01162f07f4..ad2e87781c 100644
--- a/platforms/chibios/drivers/ws2812_spi.c
+++ b/platforms/chibios/drivers/ws2812_spi.c
@@ -76,7 +76,7 @@
#endif
#define BYTES_FOR_LED_BYTE 4
-#ifdef RGBW
+#ifdef WS2812_RGBW
# define WS2812_CHANNELS 4
#else
# define WS2812_CHANNELS 3
@@ -131,7 +131,7 @@ static void set_led_color_rgb(rgb_led_t color, int pos) {
for (int j = 0; j < 4; j++)
tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.r, j);
#endif
-#ifdef RGBW
+#ifdef WS2812_RGBW
for (int j = 0; j < 4; j++)
tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 4 + j] = get_protocol_eq(color.w, j);
#endif
@@ -188,12 +188,6 @@ void ws2812_init(void) {
}
void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
- static bool s_init = false;
- if (!s_init) {
- ws2812_init();
- s_init = true;
- }
-
for (uint8_t i = 0; i < leds; i++) {
set_led_color_rgb(ledarray[i], i);
}
diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk
index b13eed39be..169707966f 100644
--- a/platforms/chibios/platform.mk
+++ b/platforms/chibios/platform.mk
@@ -258,8 +258,8 @@ endif
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
--include $(CHIBIOS)/os/hal/osal/rt/osal.mk # ChibiOS <= 19.x
--include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk # ChibiOS >= 20.x
+include $(CHIBIOS)/os/oslib/oslib.mk
+include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
# Other files (optional).
@@ -270,6 +270,7 @@ PLATFORM_SRC = \
$(KERNSRC) \
$(PORTSRC) \
$(OSALSRC) \
+ $(OSLIBSRC) \
$(HALSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
@@ -285,11 +286,11 @@ QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM)
PLATFORM_SRC := $(patsubst $(TOP_DIR)/%,%,$(PLATFORM_SRC))
-EXTRAINCDIRS += $(CHIBIOS)/os/license $(CHIBIOS)/os/oslib/include \
+EXTRAINCDIRS += $(CHIBIOS)/os/license \
$(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs \
$(TOP_DIR)/platforms/chibios/boards/common/configs \
$(HALCONFDIR) $(CHCONFDIR) \
- $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
+ $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) $(OSLIBINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
$(STREAMSINC) $(CHIBIOS)/os/various $(COMMON_VPATH)
diff --git a/platforms/eeprom.h b/platforms/eeprom.h
index fbfef20334..8e69eecc4c 100644
--- a/platforms/eeprom.h
+++ b/platforms/eeprom.h
@@ -22,6 +22,10 @@ void eeprom_update_dword(uint32_t *__p, uint32_t __value);
void eeprom_update_block(const void *__src, void *__dst, size_t __n);
#endif
+static inline void eeprom_write_qword(uint64_t *__p, uint64_t __value) {
+ eeprom_update_block(&__value, __p, sizeof(uint64_t));
+}
+
#if defined(EEPROM_CUSTOM)
# ifndef EEPROM_SIZE
# error EEPROM_SIZE has not been defined for custom driver.
diff --git a/platforms/test/drivers/audio_pwm_hardware.c b/platforms/test/drivers/audio_pwm_hardware.c
index 336e4f5844..3a0384117a 100644
--- a/platforms/test/drivers/audio_pwm_hardware.c
+++ b/platforms/test/drivers/audio_pwm_hardware.c
@@ -15,6 +15,6 @@
#include "audio.h"
-void audio_driver_initialize(void) {}
-void audio_driver_start() {}
-void audio_driver_stop() {}
+void audio_driver_initialize_impl(void) {}
+void audio_driver_start_impl() {}
+void audio_driver_stop_impl() {}