altos/ao_storage: allow erased byte value to be set by application
authorKeith Packard <keithp@keithp.com>
Tue, 23 Jun 2020 23:15:28 +0000 (16:15 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 8 Aug 2020 03:30:11 +0000 (20:30 -0700)
External flash is usually 0xff for erased bytes, but other memory may
use different values

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_storage.c

index 1554cee777254740a0d98f1bd8d7e3b71f8dad7c..213ec2d6872825cda21173ff15a13bfd8d6a5a6b 100644 (file)
@@ -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;
                        }