diff options
| author | Keith Packard <keithp@keithp.com> | 2019-06-18 23:16:12 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2019-06-18 23:16:12 -0700 |
| commit | c4b8aff07d5366cef2c7209729f6cd22fa67de0c (patch) | |
| tree | 9028f2421cf2217d5501c5aee6e335ac700396e0 /src/stmf0 | |
| parent | 835faccc2c1141f7cd8ff93629d583fcaf785e48 (diff) | |
altos/micropeak-v2: Erase log space at end of BOOST_DELAY
We have to erase the log before the flight starts, so this seems like
the latest possible moment.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stmf0')
| -rw-r--r-- | src/stmf0/ao_storage_stm.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/stmf0/ao_storage_stm.c b/src/stmf0/ao_storage_stm.c index 17c934a5..c6f1defe 100644 --- a/src/stmf0/ao_storage_stm.c +++ b/src/stmf0/ao_storage_stm.c @@ -127,9 +127,24 @@ _ao_flash_write(uint32_t pos, void *sv, uint16_t len) stm_flash.cr &= ~(1 << STM_FLASH_CR_PG); } +static bool +ao_storage_is_erased(uint32_t pos) +{ + uint16_t *flash = _ao_flash_addr(pos); + uint32_t i = ao_storage_block >> 1; + + while (i--) + if (*flash++ != 0xffff) + return false; + return true; +} + uint8_t ao_storage_erase(uint32_t pos) { + if (ao_storage_is_erased(pos)) + return 1; + ao_arch_block_interrupts(); ao_flash_unlock(); |
