diff options
| author | Dimitris Mantzouranis <d3xter93@gmail.com> | 2022-01-06 12:44:34 +0200 |
|---|---|---|
| committer | Dimitris Mantzouranis <d3xter93@gmail.com> | 2022-01-06 12:44:34 +0200 |
| commit | 849ddeb4e91ed42f4f170dd39e48daae178d9223 (patch) | |
| tree | bcd2ddf5ca4a151fa34579b8a3d203d90171e607 | |
| parent | 38af76006d7e78f120ed230c6c0f004cdbdef450 (diff) | |
sn32 eeprom: obey the FEE_DENSITY_BYTES
| -rw-r--r-- | platforms/chibios/eeprom_sn32.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/platforms/chibios/eeprom_sn32.c b/platforms/chibios/eeprom_sn32.c index 5b4f5512b..f534c8774 100644 --- a/platforms/chibios/eeprom_sn32.c +++ b/platforms/chibios/eeprom_sn32.c @@ -125,7 +125,7 @@ uint8_t EEPROM_WriteDataByte(uint16_t Address, uint8_t DataByte) { uint8_t EEPROM_WriteDataWord(uint16_t Address, uint16_t DataWord) { /* if the address is out-of-bounds, do nothing */ - if (Address >= FEE_DENSITY_BYTES) { + if (Address > FEE_DENSITY_BYTES) { eeprom_printf("EEPROM_WriteDataWord(0x%04x, 0x%04x) [BAD ADDRESS]\n", Address, DataWord); return FLASH_FAIL; } @@ -163,7 +163,7 @@ uint8_t EEPROM_WriteDataWord(uint16_t Address, uint16_t DataWord) { uint8_t EEPROM_ReadDataByte(uint16_t Address) { uint8_t DataByte = 0xFF; - if (Address < FEE_DENSITY_BYTES) { + if (Address <= FEE_DENSITY_BYTES) { // Get Byte from specified address DataByte = (*(__IO uint8_t *)(FEE_PAGE_BASE_ADDRESS + FEE_ADDR_OFFSET(Address))); } @@ -176,7 +176,7 @@ uint8_t EEPROM_ReadDataByte(uint16_t Address) { uint16_t EEPROM_ReadDataWord(uint16_t Address) { uint16_t DataWord = 0xFFFF; - if (Address < FEE_DENSITY_BYTES - 1) { + if (Address <= FEE_DENSITY_BYTES) { /* Check word alignment */ if (Address % 2) { DataWord = EEPROM_ReadDataByte(Address) | (EEPROM_ReadDataByte(Address + 1) << 8); |
