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
00047 #include <kern/kfile.h>
00048
00049
00053 typedef enum EepromType
00054 {
00055 EEPROM_24XX08,
00056 EEPROM_24XX16,
00057 EEPROM_24XX256,
00058 EEPROM_24XX512,
00059 EEPROM_24XX1024,
00060 EEPROM_CNT,
00061 } EepromType;
00062
00068 typedef uint8_t e2dev_addr_t;
00069
00074 typedef struct Eeprom
00075 {
00076 KFile fd;
00077 EepromType type;
00078 e2dev_addr_t addr;
00079 } Eeprom;
00080
00084 #define KFT_EEPROM MAKE_ID('E', 'E', 'P', 'R')
00085
00089 INLINE Eeprom * EEPROM_CAST(KFile *fd)
00090 {
00091 ASSERT(fd->_type == KFT_EEPROM);
00092 return (Eeprom *)fd;
00093 }
00094
00096 typedef uint16_t e2addr_t;
00097
00107 #define e2addr(type, field) ((e2addr_t)&(((type *)0)->field))
00108
00112 typedef uint16_t e2blk_size_t;
00113
00117 typedef uint32_t e2_size_t;
00118
00123 typedef struct EepromInfo
00124 {
00125 bool has_dev_addr;
00126 e2blk_size_t blk_size;
00127 e2_size_t e2_size;
00128 } EepromInfo;
00129
00130 bool eeprom_erase(Eeprom *fd, e2addr_t addr, e2_size_t count);
00131 bool eeprom_verify(Eeprom *fd, const void *buf, size_t count);
00132 void eeprom_init(Eeprom *fd, EepromType, e2dev_addr_t, bool verify);
00133
00134 #endif