Merge pull request #11297 from SteveCEvans/baro_state
[betaflight.git] / src / main / drivers / persistent.h
blob2b7ba80b18f889c8814ea626be606592316eb8f7
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 // Available RTC backup registers (4-byte words) per MCU type
24 // F4: 20 words
25 // F7: 32 words
26 // H7: 32 words
28 typedef enum {
29 PERSISTENT_OBJECT_MAGIC = 0,
30 PERSISTENT_OBJECT_HSE_VALUE,
31 PERSISTENT_OBJECT_OVERCLOCK_LEVEL,
32 #ifdef USE_SPRACING_PERSISTENT_RTC_WORKAROUND
33 // SPRACING H7 firmware always leaves this value reset so only use this location to invoke DFU
34 PERSISTENT_OBJECT_RESET_REASON_FWONLY,
35 #else
36 PERSISTENT_OBJECT_RESET_REASON,
37 #endif
38 PERSISTENT_OBJECT_RTC_HIGH, // high 32 bits of rtcTime_t
39 PERSISTENT_OBJECT_RTC_LOW, // low 32 bits of rtcTime_t
40 PERSISTENT_OBJECT_COUNT,
41 #ifdef USE_SPRACING_PERSISTENT_RTC_WORKAROUND
42 // On SPRACING H7 firmware use this alternate location for all reset reasons interpreted by this firmware
43 PERSISTENT_OBJECT_RESET_REASON,
44 #endif
45 } persistentObjectId_e;
47 // Values for PERSISTENT_OBJECT_RESET_REASON
48 #define RESET_NONE 0
49 #define RESET_BOOTLOADER_REQUEST_ROM 1 // Boot loader invocation was requested
50 #define RESET_BOOTLOADER_POST 2 // Reset after boot loader activity
51 #define RESET_MSC_REQUEST 3 // MSC invocation was requested
52 #define RESET_FORCED 4 // Reset due to unknown reset reason
53 #define RESET_BOOTLOADER_REQUEST_FLASH 5
55 void persistentObjectInit(void);
56 uint32_t persistentObjectRead(persistentObjectId_e id);
57 void persistentObjectWrite(persistentObjectId_e id, uint32_t value);