Skip to content

Commit

Permalink
periph/eeprom: fix off-by-one error in debug statement
Browse files Browse the repository at this point in the history
Since p is incremented DEBUG prints the next value instead of the current
I also took the liberty to add debugs to the `write` function
  • Loading branch information
FlapKap committed Feb 21, 2024
1 parent ef0e3fb commit 9e62763
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cpu/stm32/periph/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ size_t eeprom_read(uint32_t pos, void *data, size_t len)
for (size_t i = 0; i < len; i++) {
_wait_for_pending_operations();
*p++ = *(__IO uint8_t *)(EEPROM_START_ADDR + pos++);
DEBUG("0x%02X ", *p);
DEBUG("0x%02X ", *(p-1));
}
DEBUG("\n");

Expand All @@ -110,8 +110,10 @@ size_t eeprom_write(uint32_t pos, const void *data, size_t len)

_unlock();

DEBUG("Writing data to EEPROM at pos %" PRIu32 ": ", pos);
for (size_t i = 0; i < len; i++) {
_write_byte((EEPROM_START_ADDR + pos++), *p++);
DEBUG("0x%02X ", *(p-1));
}

_lock();
Expand Down

0 comments on commit 9e62763

Please sign in to comment.