From 45b00da14ea814cf8f14dcb2cfaccaddd0fbb38d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 23 Jun 2020 16:15:28 -0700 Subject: [PATCH] altos/ao_storage: allow erased byte value to be set by application External flash is usually 0xff for erased bytes, but other memory may use different values Signed-off-by: Keith Packard --- src/kernel/ao_storage.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kernel/ao_storage.c b/src/kernel/ao_storage.c index 1554cee7..213ec2d6 100644 --- a/src/kernel/ao_storage.c +++ b/src/kernel/ao_storage.c @@ -86,6 +86,10 @@ ao_storage_write(ao_pos_t pos, void *v_buf, uint16_t len) return 1; } +#ifndef AO_STORAGE_ERASED_BYTE +#define AO_STORAGE_ERASED_BYTE 0xff +#endif + uint8_t ao_storage_is_erased(uint32_t pos) { @@ -107,7 +111,7 @@ ao_storage_is_erased(uint32_t pos) goto done; } for (i = 0; i < this_time; i++) - if (storage_data[i] != 0xff) { + if (storage_data[i] != AO_STORAGE_ERASED_BYTE) { ret = 0; goto done; } -- 2.30.2