X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Feeprom.h;h=e23cd138371da8bda3a624a5fc7061cd041bfb2c;hb=27fef4ed34eb237817defa14242e726ccad70948;hp=ec2f52861fb03957e5b1f9d745d08f0b886c9778;hpb=888d1c49ed7cea0f272f520a74be35a32032bd6e;p=bertos.git diff --git a/drv/eeprom.h b/drv/eeprom.h old mode 100755 new mode 100644 index ec2f5286..e23cd138 --- a/drv/eeprom.h +++ b/drv/eeprom.h @@ -1,8 +1,33 @@ -/*! +/** * \file * * * \version $Id$ @@ -15,6 +40,12 @@ /*#* *#* $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. + *#* *#* Revision 1.8 2005/11/27 23:33:40 bernie *#* Use appconfig.h instead of cfg/config.h. *#* @@ -46,7 +77,7 @@ #include #include -/*! +/** * \name Values for CONFIG_EEPROM_TYPE * \{ */ @@ -55,18 +86,29 @@ /*\}*/ #if CONFIG_EEPROM_TYPE == EEPROM_24XX16 - #define EEPROM_BLKSIZE 0x10 //!< Eeprom block size (16byte) - #define EEPROM_SIZE 0x800 //!< Eeprom total size (2kB) + #define EEPROM_BLKSIZE 0x10 ///< Eeprom block size (16byte) + #define EEPROM_SIZE 0x800 ///< Eeprom total size (2kB) #elif CONFIG_EEPROM_TYPE == EEPROM_24XX256 - #define EEPROM_BLKSIZE 0x40 //!< Eeprom block size (64byte) - #define EEPROM_SIZE 0x8000 //!< Eeprom total size (32kB) + #define EEPROM_BLKSIZE 0x40 ///< Eeprom block size (64byte) + #define EEPROM_SIZE 0x8000 ///< Eeprom total size (32kB) #else #error Unsupported EEPROM type. #endif -//! Type for EEPROM addresses +/// 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);