From: bernie Date: Tue, 10 Aug 2004 06:57:22 +0000 (+0000) Subject: eeprom_erase(): New function. X-Git-Tag: 1.0.0~1115 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=283ff66de6da462b9c7f03e58d259951b05de863;p=bertos.git eeprom_erase(): New function. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@126 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/drv/eeprom.c b/drv/eeprom.c index 85b2e20d..718a52de 100755 --- a/drv/eeprom.c +++ b/drv/eeprom.c @@ -17,6 +17,9 @@ /* * $Log$ + * 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. * @@ -31,6 +34,7 @@ #include /* cpu_to_be16() */ #include #include +#include // memset() #include @@ -326,6 +330,28 @@ int eeprom_read_char(e2addr_t addr) } +/*! + * Erase specified part of eeprom, writing 0xFF. + * + * \param addr starting address + * \param len 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. */ diff --git a/drv/eeprom.h b/drv/eeprom.h index 287a9ce3..e1793c28 100755 --- a/drv/eeprom.h +++ b/drv/eeprom.h @@ -15,6 +15,9 @@ /* * $Log$ + * Revision 1.3 2004/08/10 06:57:22 bernie + * eeprom_erase(): New function. + * * Revision 1.2 2004/07/29 22:57:09 bernie * Add 24LC16 support. * @@ -53,6 +56,7 @@ bool eeprom_write(e2addr_t addr, const void *buf, size_t count); bool eeprom_read(e2addr_t addr, void *buf, size_t count); bool eeprom_write_char(e2addr_t addr, char c); int eeprom_read_char(e2addr_t addr); +void eeprom_erase(e2addr_t addr, size_t count); void eeprom_init(void); void eeprom_test(void);