summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ao_flash.c4
-rw-r--r--src/at45db161d.h2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/ao_flash.c b/src/ao_flash.c
index 0120382d..3ea3e40b 100644
--- a/src/ao_flash.c
+++ b/src/ao_flash.c
@@ -169,6 +169,7 @@ static __pdata uint8_t ao_flash_write_pending;
static __pdata uint8_t ao_flash_setup_done;
static __data uint32_t ao_flash_device_size;
static __data uint8_t ao_flash_block_shift;
+static __data uint16_t ao_flash_block_size;
static void
ao_flash_setup(void)
@@ -183,7 +184,6 @@ ao_flash_setup(void)
ao_mutex_put(&ao_flash_mutex);
return;
}
- ao_flash_setup_done = 1;
/* On first use, check to see if the flash chip has
* been programmed to use 512 byte pages. If not, do so.
@@ -238,6 +238,8 @@ ao_flash_setup(void)
default:
ao_panic(AO_PANIC_FLASH);
}
+ ao_flash_block_size = 1 << ao_flash_block_shift;
+ ao_flash_setup_done = 1;
ao_mutex_put(&ao_flash_mutex);
}
diff --git a/src/at45db161d.h b/src/at45db161d.h
index 66869733..8b72e647 100644
--- a/src/at45db161d.h
+++ b/src/at45db161d.h
@@ -28,7 +28,7 @@
#define FLASH_BLOCK_SIZE_MAX 512
#define FLASH_BLOCK_SHIFT (ao_flash_block_shift)
-#define FLASH_BLOCK_SIZE (1 << FLASH_BLOCK_SHIFT)
+#define FLASH_BLOCK_SIZE (ao_flash_block_size)
#define FLASH_BLOCK_MASK (FLASH_BLOCK_SIZE - 1)
#define FLASH_DEVICE_SIZE (ao_flash_device_size)
#define FLASH_DATA_SIZE (FLASH_DEVICE_SIZE - (uint32_t) FLASH_BLOCK_SIZE)