X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Feeprom.c;h=1729a8949d73394385fae4d16192b5ac691d18e6;hb=9250b166f2d62d6e38bca6cea5c6210266a12128;hp=85b2e20de5457d795b100cbba8893df145915bac;hpb=6f8beb702446d9cf0d4474598199357c4b8a5bd2;p=bertos.git diff --git a/drv/eeprom.c b/drv/eeprom.c index 85b2e20d..1729a894 100755 --- a/drv/eeprom.c +++ b/drv/eeprom.c @@ -15,25 +15,46 @@ * \note This implementation is AVR specific. */ -/* - * $Log$ - * Revision 1.3 2004/07/29 22:57:09 bernie - * Add 24LC16 support. - * - * Revision 1.2 2004/07/22 01:24:43 bernie - * Document AVR dependency. - * - * Revision 1.1 2004/07/20 17:11:18 bernie - * Import into DevLib. - * - */ +/*#* + *#* $Log$ + *#* Revision 1.8 2004/08/25 14:12:08 rasky + *#* Aggiornato il comment block dei log RCS + *#* + *#* Revision 1.7 2004/08/24 16:48:40 bernie + *#* Note reason for including + *#* + *#* Revision 1.6 2004/08/24 14:27:20 bernie + *#* Doxygen fix. + *#* + *#* Revision 1.5 2004/08/24 13:46:48 bernie + *#* Include . + *#* + *#* Revision 1.4 2004/08/10 06:57:22 bernie + *#* eeprom_erase(): New function. + *#* + *#* Revision 1.3 2004/07/29 22:57:09 bernie + *#* Add 24LC16 support. + *#* + *#* Revision 1.2 2004/07/22 01:24:43 bernie + *#* Document AVR dependency. + *#* + *#* Revision 1.1 2004/07/20 17:11:18 bernie + *#* Import into DevLib. + *#* + *#*/ + #include "eeprom.h" + #include /* cpu_to_be16() */ #include #include +#include // MIN() + +#include // memset() #include + /* Wait for TWINT flag set: bus is ready */ #define WAIT_TWI_READY do {} while (!(TWCR & BV(TWINT))) @@ -326,6 +347,28 @@ int eeprom_read_char(e2addr_t addr) } +/*! + * Erase specified part of eeprom, writing 0xFF. + * + * \param addr starting address + * \param count length of block to erase + */ +void eeprom_erase(e2addr_t addr, size_t count) +{ + uint8_t buf[EEPROM_BLKSIZE]; + memset(buf, 0xFF, sizeof buf); + + // Clear all but struct hw_info at start of eeprom + while (count) + { + size_t size = MIN(count, sizeof buf); + eeprom_write(addr, buf, size); + addr += size; + count -= size; + } +} + + /*! * Initialize TWI module. */