From d8c9684239b67a69a4a3d24202a6df0d73c4f7f5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 7 Jan 2011 17:54:54 -0800 Subject: [PATCH] altos: Speed up at45 and 25lc erase speeds No need to read the block to be erased before erasing it. Signed-off-by: Keith Packard --- src/ao_ee.c | 9 +++++---- src/ao_flash.c | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ao_ee.c b/src/ao_ee.c index 7de05b7b..e3b41103 100644 --- a/src/ao_ee.c +++ b/src/ao_ee.c @@ -19,6 +19,7 @@ #include "25lc1024.h" #define EE_BLOCK_SIZE ((uint16_t) (256)) +#define EE_BLOCK_SHIFT 8 #define EE_DEVICE_SIZE ((uint32_t) 128 * (uint32_t) 1024) /* Total bytes of available storage */ @@ -166,7 +167,7 @@ ao_ee_fill(uint16_t block) uint8_t ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant { - uint16_t block = (uint16_t) (pos >> 8); + uint16_t block = (uint16_t) (pos >> EE_BLOCK_SHIFT); /* Transfer the data */ ao_mutex_get(&ao_ee_mutex); { @@ -185,7 +186,7 @@ ao_storage_device_write(uint32_t pos, __xdata void *buf, uint16_t len) __reentra uint8_t ao_storage_device_read(uint32_t pos, __xdata void *buf, uint16_t len) __reentrant { - uint16_t block = (uint16_t) (pos >> 8); + uint16_t block = (uint16_t) (pos >> EE_BLOCK_SHIFT); /* Transfer the data */ ao_mutex_get(&ao_ee_mutex); { @@ -207,8 +208,8 @@ uint8_t ao_storage_erase(uint32_t pos) __reentrant { ao_mutex_get(&ao_ee_mutex); { - uint16_t block = (uint16_t) (pos >> 8); - ao_ee_fill(block); + ao_ee_flush_internal(); + ao_ee_block = (uint16_t) (pos >> EE_BLOCK_SHIFT); memset(ao_ee_data, 0xff, EE_BLOCK_SIZE); ao_ee_block_dirty = 1; } ao_mutex_put(&ao_ee_mutex); diff --git a/src/ao_flash.c b/src/ao_flash.c index 1201a0e5..3a264ceb 100644 --- a/src/ao_flash.c +++ b/src/ao_flash.c @@ -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); -- 2.30.2