X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fao_flash.c;h=00e9639869cdf0a0a5b1345cbb3da4c22213c1ff;hb=4a507898d6de631bb2e8ed4aa3e0933d97222323;hp=1201a0e5799821de32bf23af92ee459f6970da5e;hpb=569a1dac55b70c30f01afa7bcb74442ecdd85d85;p=fw%2Faltos diff --git a/src/ao_flash.c b/src/ao_flash.c index 1201a0e5..00e96398 100644 --- a/src/ao_flash.c +++ b/src/ao_flash.c @@ -19,16 +19,16 @@ #include "at45db161d.h" /* Total bytes of available storage */ -__xdata uint32_t ao_storage_total; +__pdata uint32_t ao_storage_total; /* Block size - device is erased in these units. At least 256 bytes */ -__xdata uint32_t ao_storage_block; +__pdata uint32_t ao_storage_block; /* Byte offset of config block. Will be ao_storage_block bytes long */ -__xdata uint32_t ao_storage_config; +__pdata uint32_t ao_storage_config; /* Storage unit size - device reads and writes must be within blocks of this size. Usually 256 bytes. */ -__xdata uint16_t ao_storage_unit; +__pdata uint16_t ao_storage_unit; #define FLASH_CS P1_1 #define FLASH_CS_INDEX 1 @@ -93,12 +93,12 @@ static __pdata uint16_t ao_flash_block = FLASH_BLOCK_NONE; static __pdata uint8_t ao_flash_block_dirty; static __pdata uint8_t ao_flash_write_pending; static __pdata uint8_t ao_flash_setup_done; -static __data uint8_t ao_flash_block_shift; -static __data uint16_t ao_flash_block_size; -static __data uint16_t ao_flash_block_mask; +static __pdata uint8_t ao_flash_block_shift; +static __pdata uint16_t ao_flash_block_size; +static __pdata uint16_t ao_flash_block_mask; void -ao_storage_setup(void) +ao_storage_setup(void) __reentrant { uint8_t status; @@ -289,10 +289,9 @@ ao_storage_flush(void) __reentrant uint8_t ao_storage_erase(uint32_t pos) __reentrant { - uint16_t block = (uint16_t) (pos >> ao_flash_block_shift); - ao_mutex_get(&ao_flash_mutex); { - ao_flash_fill(block); + ao_flash_flush_internal(); + ao_flash_block = (uint16_t) (pos >> ao_flash_block_shift); memset(ao_flash_data, 0xff, ao_flash_block_size); ao_flash_block_dirty = 1; } ao_mutex_put(&ao_flash_mutex);