Skip to content
Snippets Groups Projects
Commit 50f19d1d authored by Alexandre Abadie's avatar Alexandre Abadie
Browse files

drivers/periph_eeprom: add clear and erase functions

parent 90db0bf2
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,25 @@ void eeprom_write_byte(uint32_t pos, uint8_t data);
*/
size_t eeprom_write(uint32_t pos, const uint8_t *data, size_t len);
/**
* @brief Clear @p len bytes from the given position @p pos
*
* Clearing a byte in EEPROM simply consists in setting it to 0
*
* @param[in] pos start position in eeprom
* @param[in] len the number of bytes to clear
*
* @return the number of bytes cleared
*/
size_t eeprom_clear(uint32_t pos, size_t len);
/**
* @brief Erase the whole EEPROM content
*
* @return the EEPROM_SIZE
*/
size_t eeprom_erase(void);
#ifdef __cplusplus
}
#endif
......
......@@ -40,4 +40,19 @@ void eeprom_write_byte(uint32_t pos, uint8_t byte)
eeprom_write(pos, &byte, 1);
}
size_t eeprom_clear(uint32_t pos, size_t len)
{
assert(pos + len <= EEPROM_SIZE);
for (size_t i = 0; i < len; i++) {
eeprom_write_byte(pos++, 0);
}
return len;
}
size_t eeprom_erase(void)
{
return eeprom_clear(0, EEPROM_SIZE);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment