mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Bsongis/issue 3600 emergency shutdown (#3602)
* [ARM] Fixes #3600 - Emergency shutdown * Compilation fix * Function renamed * Compilation fix * Compilation fix * Compilation fix * Suggestion from projectkk2glider
This commit is contained in:
parent
238943f4a2
commit
4445f7cdec
7 changed files with 89 additions and 41 deletions
|
@ -91,6 +91,32 @@ uint16_t stackAvailable()
|
|||
}
|
||||
#endif
|
||||
|
||||
volatile uint16_t timeForcePowerOffPressed = 0;
|
||||
|
||||
void resetForcePowerOffRequest()
|
||||
{
|
||||
timeForcePowerOffPressed = 0;
|
||||
}
|
||||
|
||||
bool isForcePowerOffRequested()
|
||||
{
|
||||
if (pwroffPressed()) {
|
||||
if (timeForcePowerOffPressed == 0) {
|
||||
timeForcePowerOffPressed = get_tmr10ms();
|
||||
}
|
||||
else {
|
||||
uint16_t delay = (uint16_t)get_tmr10ms() - timeForcePowerOffPressed;
|
||||
if (delay > 1000/*10s*/) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
resetForcePowerOffRequest();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t nextMixerTime[NUM_MODULES];
|
||||
|
||||
void mixerTask(void * pdata)
|
||||
|
@ -111,6 +137,10 @@ void mixerTask(void * pdata)
|
|||
|
||||
CoTickDelay(1);
|
||||
|
||||
if (isForcePowerOffRequested()) {
|
||||
pwrOff();
|
||||
}
|
||||
|
||||
uint32_t now = CoGetOSTime();
|
||||
bool run = false;
|
||||
if ((now - lastRunTime) > 10) { // run at least every 20ms
|
||||
|
@ -160,7 +190,7 @@ void mixerTask(void * pdata)
|
|||
|
||||
void scheduleNextMixerCalculation(uint8_t module, uint16_t delay)
|
||||
{
|
||||
// Schedule next mixer calculation time,
|
||||
// Schedule next mixer calculation time,
|
||||
// for now assume mixer calculation takes 2 ms.
|
||||
nextMixerTime[module] = (uint32_t)CoGetOSTime() + (delay)/2 - 1/*2ms*/;
|
||||
DEBUG_TIMER_STOP(debugTimerMixerCalcToUsage);
|
||||
|
@ -197,6 +227,8 @@ void menusTask(void * pdata)
|
|||
CoTickDelay(MENU_TASK_PERIOD_TICKS - runtime);
|
||||
}
|
||||
|
||||
resetForcePowerOffRequest();
|
||||
|
||||
#if defined(SIMU)
|
||||
if (main_thread_running == 0)
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue