feat(radio): OS compatibility layer (#5840)
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user