eeprom.h
Go to the documentation of this file.00001
00042 #ifndef DRV_EEPROM_H
00043 #define DRV_EEPROM_H
00044
00045 #include <cfg/compiler.h>
00046 #include <kern/kfile.h>
00047
00048
00052 typedef enum EepromType
00053 {
00054 EEPROM_24XX16,
00055 EEPROM_24XX256,
00056 EEPROM_24XX512,
00057 EEPROM_CNT,
00058 } EepromType;
00059
00065 typedef uint8_t e2dev_addr_t;
00066
00071 typedef struct Eeprom
00072 {
00073 KFile fd;
00074 EepromType type;
00075 e2dev_addr_t addr;
00076 } Eeprom;
00077
00081 #define KFT_EEPROM MAKE_ID('E', 'E', 'P', 'R')
00082
00086 INLINE Eeprom * EEPROM_CAST(KFile *fd)
00087 {
00088 ASSERT(fd->_type == KFT_EEPROM);
00089 return (Eeprom *)fd;
00090 }
00091
00093 typedef uint16_t e2addr_t;
00094
00104 #define e2addr(type, field) ((e2addr_t)&(((type *)0)->field))
00105
00109 typedef uint16_t e2blk_size_t;
00110
00114 typedef uint32_t e2_size_t;
00115
00120 typedef struct EepromInfo
00121 {
00122 bool has_dev_addr;
00123 e2blk_size_t blk_size;
00124 e2_size_t e2_size;
00125 } EepromInfo;
00126
00127 bool eeprom_erase(Eeprom *fd, e2addr_t addr, e2_size_t count);
00128 bool eeprom_verify(Eeprom *fd, const void *buf, size_t count);
00129 void eeprom_init(Eeprom *fd, EepromType, e2dev_addr_t, bool verify);
00130
00131 #endif