X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_flash.c;h=bb40f6f708b95515d165da8e131031639474593b;hp=3a264ceb19a29459d5b8e4f8adc606f02b56dc4f;hb=c3314dae2d3df82e188daf6ba8520cce833592c6;hpb=d8c9684239b67a69a4a3d24202a6df0d73c4f7f5 diff --git a/src/ao_flash.c b/src/ao_flash.c index 3a264ceb..bb40f6f7 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 @@ -43,19 +43,9 @@ __xdata uint8_t ao_flash_mutex; _asm nop _endasm; \ } while(0) -void ao_flash_cs_low(void) -{ - ao_flash_delay(); - FLASH_CS = 0; - ao_flash_delay(); -} +#define ao_flash_cs_low() ao_spi_get_bit(FLASH_CS) -void ao_flash_cs_high(void) -{ - ao_flash_delay(); - FLASH_CS = 1; - ao_flash_delay(); -} +#define ao_flash_cs_high() ao_spi_put_bit(FLASH_CS) struct ao_flash_instruction { uint8_t instruction; @@ -93,12 +83,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;