feat(radio): OS compatibility layer (#5840)
This commit is contained in:
+9
-46
@@ -19,6 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "os/sleep.h"
|
||||
#if !defined(SIMU)
|
||||
#include "stm32_ws2812.h"
|
||||
#include "boards/generic_stm32/rgb_leds.h"
|
||||
@@ -45,6 +46,7 @@
|
||||
|
||||
#include "tasks.h"
|
||||
#include "tasks/mixer_task.h"
|
||||
#include "os/async.h"
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
#include "bluetooth_driver.h"
|
||||
@@ -167,7 +169,7 @@ void checkValidMCU(void)
|
||||
static bool evalFSok = false;
|
||||
#endif
|
||||
|
||||
void timer_10ms()
|
||||
void per10ms()
|
||||
{
|
||||
DEBUG_TIMER_START(debugTimerPer10ms);
|
||||
DEBUG_TIMER_SAMPLE(debugTimerPer10msPeriod);
|
||||
@@ -245,44 +247,6 @@ void timer_10ms()
|
||||
DEBUG_TIMER_STOP(debugTimerPer10ms);
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
// Handle 10ms timer asynchronously
|
||||
#include <FreeRTOS/include/FreeRTOS.h>
|
||||
#include <FreeRTOS/include/timers.h>
|
||||
|
||||
static volatile bool _timer_10ms_cb_in_queue = false;
|
||||
|
||||
static void _timer_10ms_cb(void *pvParameter1, uint32_t ulParameter2)
|
||||
{
|
||||
(void)pvParameter1;
|
||||
(void)ulParameter2;
|
||||
_timer_10ms_cb_in_queue = false;
|
||||
timer_10ms();
|
||||
}
|
||||
|
||||
void per10ms()
|
||||
{
|
||||
|
||||
if (!_timer_10ms_cb_in_queue && xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
BaseType_t xReturn = pdFALSE;
|
||||
|
||||
xReturn = xTimerPendFunctionCallFromISR(_timer_10ms_cb, nullptr, 0, &xHigherPriorityTaskWoken);
|
||||
|
||||
if (xReturn == pdPASS) {
|
||||
_timer_10ms_cb_in_queue = true;
|
||||
} else {
|
||||
TRACE("xTimerPendFunctionCallFromISR() queue full");
|
||||
}
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
}
|
||||
|
||||
#else // !defined(SIMU)
|
||||
void per10ms() { timer_10ms(); }
|
||||
#endif
|
||||
|
||||
|
||||
FlightModeData *flightModeAddress(uint8_t idx)
|
||||
{
|
||||
return &g_model.flightModeData[idx];
|
||||
@@ -757,7 +721,7 @@ void checkAll(bool isBootCheck)
|
||||
showMessageBox(STR_KEYSTUCK);
|
||||
tmr10ms_t tgtime = get_tmr10ms() + 500;
|
||||
while (tgtime != get_tmr10ms()) {
|
||||
RTOS_WAIT_MS(1);
|
||||
sleep_ms(1);
|
||||
WDG_RESET();
|
||||
}
|
||||
}
|
||||
@@ -875,8 +839,7 @@ void checkThrottleStick()
|
||||
checkBacklight();
|
||||
|
||||
WDG_RESET();
|
||||
|
||||
RTOS_WAIT_MS(10);
|
||||
sleep_ms(10);
|
||||
}
|
||||
|
||||
LED_ERROR_END();
|
||||
@@ -907,7 +870,7 @@ void alert(const char * title, const char * msg , uint8_t sound)
|
||||
#endif
|
||||
|
||||
while (true) {
|
||||
RTOS_WAIT_MS(10);
|
||||
sleep_ms(10);
|
||||
|
||||
if (getEvent()) // wait for key release
|
||||
break;
|
||||
@@ -1131,10 +1094,10 @@ void edgeTxClose(uint8_t shutdown)
|
||||
storageCheck(true);
|
||||
|
||||
while (IS_PLAYING(ID_PLAY_PROMPT_BASE + AU_BYE)) {
|
||||
RTOS_WAIT_MS(10);
|
||||
sleep_ms(10);
|
||||
}
|
||||
|
||||
RTOS_WAIT_MS(100);
|
||||
sleep_ms(100);
|
||||
|
||||
#if defined(COLORLCD)
|
||||
cancelShutdownAnimation(); // To prevent simulator crash
|
||||
@@ -1887,7 +1850,7 @@ uint32_t pwrCheck()
|
||||
RAISE_ALERT(STR_MODEL, STR_MODEL_STILL_POWERED, STR_PRESS_ENTER_TO_CONFIRM, AU_MODEL_STILL_POWERED);
|
||||
while (TELEMETRY_STREAMING()) {
|
||||
resetForcePowerOffRequest();
|
||||
RTOS_WAIT_MS(20);
|
||||
sleep_ms(20);
|
||||
if (pwrPressed()) {
|
||||
return e_power_on;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user