From 5846b40f7444af96b0d8ddf3af9b558193c2475d Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 2 Jul 2022 15:18:50 +1000 Subject: RP2040 emulated EEPROM. (#17519) --- quantum/wear_leveling/wear_leveling.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum/wear_leveling') diff --git a/quantum/wear_leveling/wear_leveling.c b/quantum/wear_leveling/wear_leveling.c index 0a519639ea..429df45df5 100644 --- a/quantum/wear_leveling/wear_leveling.c +++ b/quantum/wear_leveling/wear_leveling.c @@ -421,7 +421,7 @@ static wear_leveling_status_t wear_leveling_write_raw(uint32_t address, const vo #if BACKING_STORE_WRITE_SIZE == 2 // Small-write optimizations - uint16_t, 0 or 1, address is even, address <16384: if (remaining >= 2 && address % 2 == 0 && address < 16384) { - const uint16_t v = *(const uint16_t *)p; + const uint16_t v = ((uint16_t)p[1]) << 8 | p[0]; // don't just dereference a uint16_t here -- if unaligned it generates faults on some MCUs if (v == 0 || v == 1) { const write_log_entry_t log = LOG_ENTRY_MAKE_WORD_01(address, v); status = wear_leveling_append_raw(log.raw16[0]); @@ -765,4 +765,4 @@ __attribute__((weak)) bool backing_store_write_bulk(uint32_t address, backing_st } } return true; -} \ No newline at end of file +} -- cgit v1.2.3