feat(radio): OS compatibility layer (#5840)
This commit is contained in:
+13
-16
@@ -25,7 +25,9 @@
|
||||
#include "mixer_scheduler.h"
|
||||
#include "heartbeat_driver.h"
|
||||
#include "hal/module_port.h"
|
||||
#include "os/sleep.h"
|
||||
#include "tasks/mixer_task.h"
|
||||
#include "os/async.h"
|
||||
|
||||
#include "pulses/pxx2.h"
|
||||
#include "pulses/flysky.h"
|
||||
@@ -106,7 +108,7 @@ void restartModule(uint8_t module)
|
||||
|
||||
// wait for the power output to be drained
|
||||
pulsesStopModule(module);
|
||||
RTOS_WAIT_MS(200);
|
||||
sleep_ms(200);
|
||||
|
||||
mixerTaskStart();
|
||||
}
|
||||
@@ -124,21 +126,21 @@ void pulsesRestartModuleUnsafe(uint8_t module)
|
||||
mod_drv->ctx = drv->init(module);
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
#include <FreeRTOS/include/FreeRTOS.h>
|
||||
#include <FreeRTOS/include/timers.h>
|
||||
static volatile bool _module_restart_queued[NUM_MODULES] = {false};
|
||||
|
||||
static void _setup_async_module_restart(void* p1, uint32_t p2)
|
||||
{
|
||||
uint8_t module = (uint8_t)(uintptr_t)p1;
|
||||
_module_restart_queued[module] = false;
|
||||
|
||||
if (!mixerTaskTryLock()) {
|
||||
// In case the mixer cannot be locked, try again later
|
||||
// and make the same function pending again.
|
||||
PendedFunction_t cb = _setup_async_module_restart;
|
||||
xTimerPendFunctionCall(cb, p1, p2, 0/* do not wait */);
|
||||
async_call(_setup_async_module_restart, &_module_restart_queued[module], p1,
|
||||
p2);
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t module = (uint8_t)(uintptr_t)p1;
|
||||
moduleState[module].forced_off = 1;
|
||||
|
||||
uint32_t timeout = p2;
|
||||
@@ -146,18 +148,13 @@ static void _setup_async_module_restart(void* p1, uint32_t p2)
|
||||
|
||||
mixerTaskUnlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
// return true if the request could be posted to the timer queue
|
||||
bool restartModuleAsync(uint8_t module, uint8_t cnt_delay)
|
||||
{
|
||||
#if !defined(SIMU)
|
||||
PendedFunction_t cb = _setup_async_module_restart;
|
||||
return xTimerPendFunctionCall(cb, (void*)(uintptr_t)module, cnt_delay,
|
||||
0/* do not wait */) == pdPASS;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
void* param1 = (void*)(uintptr_t)module;
|
||||
return async_call(_setup_async_module_restart,
|
||||
&_module_restart_queued[module], param1, cnt_delay);
|
||||
}
|
||||
|
||||
void pulsesModuleSettingsUpdate(uint8_t module)
|
||||
@@ -497,7 +494,7 @@ void pulsesStopModule(uint8_t module)
|
||||
while(_telemetryIsPolling) {
|
||||
// In case the telemetry timer is currently polling the port,
|
||||
// we give the timer task a chance to run and finish the polling.
|
||||
RTOS_WAIT_MS(1);
|
||||
sleep_ms(1);
|
||||
}
|
||||
_deinit_module(module);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "io/frsky_firmware_update.h"
|
||||
#include "os/sleep.h"
|
||||
#include "tasks/mixer_task.h"
|
||||
|
||||
#include "pxx2_ota.h"
|
||||
@@ -37,7 +38,7 @@ bool Pxx2OtaUpdate::waitStep(uint8_t step, uint8_t timeout)
|
||||
if (elapsed++ > timeout) {
|
||||
return false;
|
||||
}
|
||||
RTOS_WAIT_MS(1);
|
||||
sleep_ms(1);
|
||||
telemetryWakeup();
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ void Pxx2OtaUpdate::flashFirmware(const char * filename, ProgressHandler progres
|
||||
mixerTaskStop();
|
||||
|
||||
watchdogSuspend(100 /*1s*/);
|
||||
RTOS_WAIT_MS(100);
|
||||
sleep_ms(100);
|
||||
|
||||
moduleState[module].mode = MODULE_MODE_OTA_UPDATE;
|
||||
const char * result = doFlashFirmware(filename, progressHandler);
|
||||
@@ -152,7 +153,7 @@ void Pxx2OtaUpdate::flashFirmware(const char * filename, ProgressHandler progres
|
||||
}
|
||||
|
||||
watchdogSuspend(100);
|
||||
RTOS_WAIT_MS(100);
|
||||
sleep_ms(100);
|
||||
|
||||
mixerTaskStart();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user