feat(radio): OS compatibility layer (#5840)

This commit is contained in:
Raphael Coeffic
2025-05-03 19:07:49 +10:00
committed by GitHub
parent c996612b0a
commit ab2a19e153
92 changed files with 1740 additions and 896 deletions
+9 -24
View File
@@ -30,18 +30,13 @@
#include "stm32_dma.h"
#include "stm32_gpio.h"
#include "hal/gpio.h"
#if !defined(SIMU)
#include <FreeRTOS/include/FreeRTOS.h>
#include <FreeRTOS/include/timers.h>
#endif
#include "os/timer.h"
static uint8_t _led_colors[WS2812_BYTES_PER_LED * LED_STRIP_LENGTH];
extern const stm32_pulse_timer_t _led_timer;
static TimerHandle_t rgbLedTimer = nullptr;
static StaticTimer_t rgbLedTimerBuffer;
static timer_handle_t _refresh_timer = TIMER_INITIALIZER;
void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
{
@@ -77,35 +72,25 @@ void rgbLedClearAll()
ws2812_update(&_led_timer);
}
static void rgbLedTimerCb(TimerHandle_t xTimer)
static void _refresh_cb(timer_handle_t* timer)
{
(void)xTimer;
(void)timer;
ws2812_update(&_led_timer);
}
void rgbLedStart()
{
if (!rgbLedTimer) {
rgbLedTimer =
xTimerCreateStatic("rgbLed", LED_STRIP_REFRESH_PERIOD / RTOS_MS_PER_TICK, pdTRUE, (void*)0,
rgbLedTimerCb, &rgbLedTimerBuffer);
if (!timer_is_created(&_refresh_timer)) {
timer_create(&_refresh_timer, _refresh_cb, "rgbled",
LED_STRIP_REFRESH_PERIOD, true);
}
if (rgbLedTimer) {
if( xTimerStart( rgbLedTimer, 0 ) != pdPASS ) {
/* The timer could not be set into the Active state. */
}
}
timer_start(&_refresh_timer);
}
void rgbLedStop()
{
if (rgbLedTimer) {
if( xTimerStop( rgbLedTimer, 5 / RTOS_MS_PER_TICK ) != pdPASS ) {
/* The timer could not be stopped. */
}
}
timer_stop(&_refresh_timer);
}
const stm32_pulse_timer_t _led_timer = {