X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Feeprom.h;h=7a80f177976f5c825677d9dc98dd5e7a9e28f5d5;hb=46ac2c9347e738ee3c23109b83d522023ac4e7c9;hp=c41519d7244cc0427c5c6394d8d8cb0a2c7762d7;hpb=bcf38f772b397e7a8ba781a69aacb9380e54b32a;p=bertos.git diff --git a/drv/eeprom.h b/drv/eeprom.h index c41519d7..7a80f177 100755 --- a/drv/eeprom.h +++ b/drv/eeprom.h @@ -15,6 +15,9 @@ /*#* *#* $Log$ + *#* Revision 1.10 2006/09/13 18:29:54 bernie + *#* e2addr(): New macro. + *#* *#* Revision 1.9 2006/07/19 12:56:25 bernie *#* Convert to new Doxygen style. *#* @@ -70,6 +73,17 @@ /// Type for EEPROM addresses typedef uint16_t e2addr_t; +/** + * Macro for E2Layout offset calculation + * + * \note We can't just use offsetof() here because we could use + * non-constant expressions to access array elements. + * + * \note E2Layout is a structure that must be defined in user files. + */ +#define e2addr(x) ((e2addr_t)&(((struct E2Layout *)0)->x)) + + 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);