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:
Bertrand Songis
2019-11-21 11:50:33 +01:00
committed by GitHub
parent 103534bdcf
commit 4cdd17f0d7
41 changed files with 235 additions and 190 deletions
+1 -1
View File
@@ -729,7 +729,7 @@ void RlcFile::nextRlcWriteStep()
void RlcFile::flush()
{
while (!eepromIsTransferComplete())
wdt_reset();
WDG_RESET();
ENABLE_SYNC_WRITE(true);
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _RAM_BACKUP_H_
#define _RAM_BACKUP_H_
#include "definitions.h"
PACK(struct RamBackup {
uint16_t size;
uint8_t data[4094];
});
extern RamBackup * ramBackup;
#endif // _RAM_BACKUP_H_
-7
View File
@@ -38,11 +38,4 @@ const char * createModel();
const char * loadRadioSettings(const char * path);
const char * loadRadioSettings();
PACK(struct RamBackup {
uint16_t size;
uint8_t data[4094];
});
extern RamBackup * ramBackup;
#endif // _SDCARD_RAW_H_
+5 -4
View File
@@ -23,7 +23,7 @@
#if defined(SIMU)
#define WRITE_DELAY_10MS 100
#elif defined(RAMBACKUP)
#elif defined(RTC_BACKUP_RAM)
#define WRITE_DELAY_10MS 1500 /* 15s */
#elif defined(PCBTARANIS)
#define WRITE_DELAY_10MS 500
@@ -37,10 +37,11 @@ extern uint8_t storageDirtyMsk;
extern tmr10ms_t storageDirtyTime10ms;
#define TIME_TO_WRITE() (storageDirtyMsk && (tmr10ms_t)(get_tmr10ms() - storageDirtyTime10ms) >= (tmr10ms_t)WRITE_DELAY_10MS)
#if defined(RAMBACKUP)
#if defined(RTC_BACKUP_RAM)
#include "storage/rtc_backup.h"
extern uint8_t rambackupDirtyMsk;
extern tmr10ms_t rambackupDirtyTime10ms;
#define TIME_TO_RAMBACKUP() (rambackupDirtyMsk && (tmr10ms_t)(get_tmr10ms() - rambackupDirtyTime10ms) >= (tmr10ms_t)100)
#define TIME_TO_BACKUP_RAM() (rambackupDirtyMsk && (tmr10ms_t)(get_tmr10ms() - rambackupDirtyTime10ms) >= (tmr10ms_t)100)
#endif
void storageEraseAll(bool warn);
@@ -64,7 +65,7 @@ void checkExternalAntenna();
#include "sdcard_raw.h"
#endif
#if defined(RAMBACKUP)
#if defined(RTC_BACKUP_RAM)
void rambackupWrite();
bool rambackupRestore();
unsigned int compress(uint8_t * dst, unsigned int dstsize, const uint8_t * src, unsigned int len);
+2 -2
View File
@@ -24,7 +24,7 @@
uint8_t storageDirtyMsk;
tmr10ms_t storageDirtyTime10ms;
#if defined(RAMBACKUP)
#if defined(RTC_BACKUP_RAM)
uint8_t rambackupDirtyMsk;
tmr10ms_t rambackupDirtyTime10ms;
#endif
@@ -34,7 +34,7 @@ void storageDirty(uint8_t msk)
storageDirtyMsk |= msk;
storageDirtyTime10ms = get_tmr10ms();
#if defined(RAMBACKUP)
#if defined(RTC_BACKUP_RAM)
rambackupDirtyMsk = storageDirtyMsk;
rambackupDirtyTime10ms = storageDirtyTime10ms;
#endif