Implement flash config storage

Calibration needs to be saved for each badge in continuity mode. Added a flash-backed user config storing option with basic wear leveling. Have NOT yet tested the write and erase functions.
This commit is contained in:
true
2023-11-01 07:45:44 -07:00
parent ad383a76ac
commit 6394c3aaff
8 changed files with 267 additions and 24 deletions

View File

@@ -16,9 +16,39 @@
#define FLASH_HSI_24MHz (uint32_t *)0x1FFF0F6C
#define UCONF_FLASH_SIZE 512
#define UCONF_FLASH_START (FLASH_END + 1) - UCONF_FLASH_SIZE
#define UCONF_SIZE 64 // size in bytes
#define UCONF_COUNT (UCONF_FLASH_SIZE / UCONF_SIZE)
#define UCONF_KEY 0x3713
typedef struct UConf {
uint16_t conf_key; // should read 0x3713
uint8_t cont_buzzer; // continuity buzzer on/off
uint8_t cont_sensitivity; // continuity sensitivity high/low
uint16_t cont_shorted; // ADC counts when probes shorted in continuity mode
uint16_t diode_shorted; // unused, unneeded
uint32_t rsvd_1[4];
uint32_t rsvd_2[8];
uint32_t vctr; // increment every update of config
uint32_t crc32; // CRC of preceding 60 bytes
} UConf; // 64 bytes
extern struct UConf conf;
void flash_init();
void flash_load_conf();
void flash_commit_conf();
#endif /* _INC_FLASH_H */

View File

@@ -14,7 +14,7 @@
void rgbprog_run();
void rgbprog_error_flasher(uint8_t r, uint8_t g, uint8_t b);
void rgbprog_error_flasher(uint8_t scale, uint8_t r, uint8_t g, uint8_t b);