X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Feeprom.h;h=922fc9d815e2e752dc1ce9441b625bd2164d0506;hb=450741a2b0b851ba6f71cb6e87fd5f61fe311beb;hp=6c6cd9117a78b6e083490769e2600c4a2c74ea14;hpb=95e8847d266f3a03c4e93372f815b628632ebc7a;p=bertos.git diff --git a/bertos/drv/eeprom.h b/bertos/drv/eeprom.h index 6c6cd911..922fc9d8 100644 --- a/bertos/drv/eeprom.h +++ b/bertos/drv/eeprom.h @@ -32,24 +32,22 @@ * * \brief Driver for the 24xx16 and 24xx256 I2C EEPROMS. * - * \version $Id$ - * * \author Stefano Fedrigo * \author Bernie Innocenti * - * $WIZARD_MODULE = { - * "name" : "eeprom", - * "depends" : ["kfile"], - * "configuration" : "" - * } + * $WIZ$ module_name = "eeprom" + * $WIZ$ module_depends = "kfile", "i2c" */ #ifndef DRV_EEPROM_H #define DRV_EEPROM_H #include +#include + +#include -#include +#include /** @@ -57,9 +55,11 @@ */ typedef enum EepromType { + EEPROM_24XX08, EEPROM_24XX16, EEPROM_24XX256, EEPROM_24XX512, + EEPROM_24XX1024, EEPROM_CNT, } EepromType; @@ -76,7 +76,8 @@ typedef uint8_t e2dev_addr_t; */ typedef struct Eeprom { - KFile fd; ///< File descriptor. + KBlock b; + I2c *i2c; EepromType type; ///< EEPROM type e2dev_addr_t addr; ///< Device address. } Eeprom; @@ -84,15 +85,15 @@ typedef struct Eeprom /** * ID for eeproms. */ -#define KFT_EEPROM MAKE_ID('E', 'E', 'P', 'R') +#define KBT_EEPROM MAKE_ID('E', 'E', 'P', 'R') /** * Convert + ASSERT from generic KFile to Eeprom. */ -INLINE Eeprom * EEPROM_CAST(KFile *fd) +INLINE Eeprom * EEPROM_CAST(KBlock *b) { - ASSERT(fd->_type == KFT_EEPROM); - return (Eeprom *)fd; + ASSERT(b->priv.type == KBT_EEPROM); + return (Eeprom *)b; } /// Type for EEPROM addresses @@ -130,8 +131,12 @@ typedef struct EepromInfo e2_size_t e2_size; ///< eeprom size } EepromInfo; +#if 0 bool eeprom_erase(Eeprom *fd, e2addr_t addr, e2_size_t count); bool eeprom_verify(Eeprom *fd, const void *buf, size_t count); void eeprom_init(Eeprom *fd, EepromType, e2dev_addr_t, bool verify); +#endif + +void eeprom_init(Eeprom *b, I2c *i2c, EepromType type, e2dev_addr_t addr); #endif /* DRV_EEPROM_H */