MAGIC value for powerReason should be stored in RTC backup on Horus (#7096)
- Allows the radio main application to start correctly when coming from an app in RAM - Refactoring of the `UNEXPECTED_SHUTDOWN()` process - Saves the RTC battery as BACKUP RAM is not needed on normal shutdown - On PWR OFF on an ALERT, the radio won't show the next alert before shutting down - Bootloader flashable through the SD Manager
This commit is contained in:
+20
-10
@@ -109,7 +109,7 @@ void per10ms()
|
||||
|
||||
if (watchdogTimeout) {
|
||||
watchdogTimeout -= 1;
|
||||
wdt_reset(); // Retrigger hardware watchdog
|
||||
WDG_RESET(); // Retrigger hardware watchdog
|
||||
}
|
||||
|
||||
#if defined(GUI)
|
||||
@@ -932,7 +932,7 @@ void checkAll()
|
||||
tmr10ms_t tgtime = get_tmr10ms() + 500;
|
||||
while (tgtime != get_tmr10ms()) {
|
||||
RTOS_WAIT_MS(1);
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -999,6 +999,8 @@ void checkThrottleStick()
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
uint32_t power = pwrCheck();
|
||||
if (power == e_power_off) {
|
||||
drawSleepBitmap();
|
||||
boardOff();
|
||||
break;
|
||||
}
|
||||
else if (power == e_power_press) {
|
||||
@@ -1016,7 +1018,7 @@ void checkThrottleStick()
|
||||
|
||||
doLoopCommonActions();
|
||||
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
|
||||
RTOS_WAIT_MS(10);
|
||||
}
|
||||
@@ -1047,7 +1049,7 @@ void alert(const char * title, const char * msg , uint8_t sound)
|
||||
bool refresh = false;
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
RTOS_WAIT_MS(10);
|
||||
|
||||
if (keyDown()) // wait for key release
|
||||
@@ -1055,7 +1057,7 @@ void alert(const char * title, const char * msg , uint8_t sound)
|
||||
|
||||
doLoopCommonActions();
|
||||
|
||||
wdt_reset();
|
||||
WDG_RESET();
|
||||
|
||||
const uint32_t pwr_check = pwrCheck();
|
||||
if (pwr_check == e_power_off) {
|
||||
@@ -1858,6 +1860,10 @@ void opentxInit()
|
||||
globalData.unexpectedShutdown = 1;
|
||||
}
|
||||
|
||||
#if defined(RTC_BACKUP_RAM)
|
||||
SET_POWER_REASON(0);
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
// SDCARD related stuff, only done if not unexpectedShutdown
|
||||
if (!globalData.unexpectedShutdown) {
|
||||
@@ -1909,7 +1915,7 @@ void opentxInit()
|
||||
|
||||
// handling of storage for radios that have no EEPROM
|
||||
#if !defined(EEPROM)
|
||||
#if defined(RAMBACKUP) && !defined(SIMU)
|
||||
#if defined(RTC_BACKUP_RAM) && !defined(SIMU)
|
||||
if (globalData.unexpectedShutdown) {
|
||||
// SDCARD not available, try to restore last model from RAM
|
||||
TRACE("rambackupRestore");
|
||||
@@ -1966,20 +1972,22 @@ void opentxInit()
|
||||
opentxStart();
|
||||
}
|
||||
|
||||
// TODO Horus does not need this
|
||||
#if !defined(RTC_BACKUP_RAM)
|
||||
if (!g_eeGeneral.unexpectedShutdown) {
|
||||
g_eeGeneral.unexpectedShutdown = 1;
|
||||
storageDirty(EE_GENERAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GUI)
|
||||
lcdSetContrast();
|
||||
#endif
|
||||
|
||||
backlightOn();
|
||||
|
||||
startPulses();
|
||||
|
||||
wdt_enable(WDTO_500MS);
|
||||
WDG_ENABLE(WDG_DURATION);
|
||||
}
|
||||
|
||||
#if defined(SIMU)
|
||||
@@ -2001,7 +2009,7 @@ int main()
|
||||
|
||||
// G: The WDT remains active after a WDT reset -- at maximum clock speed. So it's
|
||||
// important to disable it before commencing with system initialisation (or
|
||||
// we could put a bunch more wdt_reset()s in. But I don't like that approach
|
||||
// we could put a bunch more WDG_RESET()s in. But I don't like that approach
|
||||
// during boot up.)
|
||||
#if defined(PCBTARANIS)
|
||||
g_eeGeneral.contrast = LCD_CONTRAST_DEFAULT;
|
||||
@@ -2018,7 +2026,9 @@ int main()
|
||||
#endif
|
||||
|
||||
#if defined(SPLASH) && !defined(STARTUP_ANIMATION)
|
||||
drawSplash();
|
||||
if (!UNEXPECTED_SHUTDOWN()) {
|
||||
drawSplash();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
|
||||
Reference in New Issue
Block a user