}
#endif
-void
-ao_storage_setup(void)
-{
-}
-
static ao_pos_t write_pos;
static uint8_t write_pending;
static union {
flash_write_select(this_pos);
/* Update write buffer with new contents */
- int this_word = 4 - (pos & 3);
+ uint16_t this_word = 4 - (pos & 3);
if (this_word > len)
this_word = len;
memcpy(&write_buf.u8[pos & 3], b8, this_word);
return 1;
}
-/* Erase device from pos through pos + ao_storage_block */
-uint8_t
-ao_storage_device_erase(uint32_t pos)
+bool
+ao_storage_device_is_erased(uint32_t pos)
{
- ao_flash_erase_page(__storage + pos);
- return 1;
-}
+ uint8_t *m = ((uint8_t *) __storage) + pos;
+ uint32_t i;
-/* Initialize low-level device bits */
-void
-ao_storage_device_init(void)
-{
+ for (i = 0; i < STM_FLASH_PAGE_SIZE; i++)
+ if (*m++ != AO_STORAGE_ERASED_BYTE)
+ return false;
+ return true;
}
-/* Print out information about flash chips */
-void
-ao_storage_device_info(void)
+/* Erase device from pos through pos + ao_storage_block */
+uint8_t
+ao_storage_device_erase(uint32_t pos)
{
- printf("Detected chips 1 size %d\n", ao_storage_total);
+ ao_flash_erase_page(__storage + (pos >> 2));
+ return 1;
}