From: bernie Date: Wed, 13 Sep 2006 18:29:54 +0000 (+0000) Subject: e2addr(): New macro. X-Git-Tag: 1.0.0~552 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=0ec7a71ae68cbdc79718c5c165a615d943e03293;p=bertos.git e2addr(): New macro. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@689 38d2e660-2303-0410-9eaa-f027e97ec537 --- 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);