1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Use RTC backup register for persistent storage

This commit is contained in:
jflyper 2018-12-03 09:45:36 +09:00
parent 8a4ea0785e
commit 99fde1a0ff
9 changed files with 170 additions and 26 deletions

View file

@ -27,6 +27,7 @@
#include "drivers/exti.h"
#include "drivers/nvic.h"
#include "drivers/system.h"
#include "drivers/persistent.h"
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
@ -38,12 +39,11 @@ void systemReset(void)
NVIC_SystemReset();
}
PERSISTENT uint32_t bootloaderRequest = 0;
#define BOOTLOADER_REQUEST_COOKIE 0xDEADBEEF
void systemResetToBootloader(void)
{
bootloaderRequest = BOOTLOADER_REQUEST_COOKIE;
persistentObjectWrite(PERSISTENT_OBJECT_BOOTLOADER_REQUEST, BOOTLOADER_REQUEST_COOKIE);
__disable_irq();
NVIC_SystemReset();
@ -58,12 +58,14 @@ typedef struct isrVector_s {
void checkForBootLoaderRequest(void)
{
uint32_t bootloaderRequest = persistentObjectRead(PERSISTENT_OBJECT_BOOTLOADER_REQUEST);
persistentObjectWrite(PERSISTENT_OBJECT_BOOTLOADER_REQUEST, 0);
if (bootloaderRequest != BOOTLOADER_REQUEST_COOKIE) {
return;
}
bootloaderRequest = 0;
extern isrVector_t system_isr_vector_table_base;
__set_MSP(system_isr_vector_table_base.stackEnd);