eeprom.h
Go to the documentation of this file.00001
00045 #ifndef DRV_EEPROM_H
00046 #define DRV_EEPROM_H
00047
00048 #include <cfg/compiler.h>
00049
00050 #include <kern/kfile.h>
00051
00052
00056 typedef enum EepromType
00057 {
00058 EEPROM_24XX16,
00059 EEPROM_24XX256,
00060 EEPROM_24XX512,
00061 EEPROM_CNT,
00062 } EepromType;
00063
00069 typedef uint8_t e2dev_addr_t;
00070
00075 typedef struct Eeprom
00076 {
00077 KFile fd;
00078 EepromType type;
00079 e2dev_addr_t addr;
00080 } Eeprom;
00081
00085 #define KFT_EEPROM MAKE_ID('E', 'E', 'P', 'R')
00086
00090 INLINE Eeprom * EEPROM_CAST(KFile *fd)
00091 {
00092 ASSERT(fd->_type == KFT_EEPROM);
00093 return (Eeprom *)fd;
00094 }
00095
00097 typedef uint16_t e2addr_t;
00098
00108 #define e2addr(type, field) ((e2addr_t)&(((type *)0)->field))
00109
00113 typedef uint16_t e2blk_size_t;
00114
00118 typedef uint32_t e2_size_t;
00119
00124 typedef struct EepromInfo
00125 {
00126 bool has_dev_addr;
00127 e2blk_size_t blk_size;
00128 e2_size_t e2_size;
00129 } EepromInfo;
00130
00131 bool eeprom_erase(Eeprom *fd, e2addr_t addr, e2_size_t count);
00132 bool eeprom_verify(Eeprom *fd, const void *buf, size_t count);
00133 void eeprom_init(Eeprom *fd, EepromType, e2dev_addr_t, bool verify);
00134
00135 #endif