summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitris Mantzouranis <d3xter93@gmail.com>2022-01-06 15:43:41 +0200
committerDimitris Mantzouranis <d3xter93@gmail.com>2022-01-06 15:44:22 +0200
commit06e673ed80d1b3a0638e825974fc63e82e7c9fff (patch)
treee13a22d09661134ec5148dceb0f5fc8fe6676063
parent67e99089a90691c727c491f761908f96df076c10 (diff)
sn32 eeprom: read word
-rw-r--r--platforms/chibios/eeprom_sn32.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/platforms/chibios/eeprom_sn32.c b/platforms/chibios/eeprom_sn32.c
index 3e77bafea..97a706d58 100644
--- a/platforms/chibios/eeprom_sn32.c
+++ b/platforms/chibios/eeprom_sn32.c
@@ -102,14 +102,14 @@ uint8_t EEPROM_WriteDataByte(uint16_t Address, uint8_t DataByte) {
eeprom_printf("EEPROM_WriteDataByte(0x%04x, 0x%02x) [BAD ADDRESS]\n", Address, DataByte);
return FLASH_FAIL;
}
+ uint32_t addr = FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address);
/* if the value is the same, don't bother writing it */
- if (DataByte == *(__IO uint8_t *)(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address))) {
+ if (DataByte == *(__IO uint8_t *)addr) {
eeprom_printf("EEPROM_WriteDataByte(0x%04x, 0x%02x) [SKIP SAME]\n", Address, DataByte);
return FLASH_OKAY;
}
- uint32_t addr = FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address);
// update the data byte aligned in a 32-bit dword
uint32_t value = *((uint32_t*)(addr & 0xFFFFFFFC));
@@ -143,7 +143,7 @@ uint8_t EEPROM_WriteDataWord(uint16_t Address, uint16_t DataWord) {
}
/* if the value is the same, don't bother writing it */
- uint8_t storedData = EEPROM_ReadDataByte(Address);
+ uint16_t storedData = EEPROM_ReadDataWord(Address);
uint16_t oldValue = *(uint16_t *)(&storedData);
if (oldValue == DataWord) {
eeprom_printf("EEPROM_WriteDataWord(0x%04x, 0x%04x) [SKIP SAME]\n", Address, DataWord);