eeprom.h File Reference

Driver for the 24xx16 and 24xx256 I2C EEPROMS. More...

#include <cfg/compiler.h>
#include <kern/kfile.h>

Go to the source code of this file.

Data Structures

struct  Eeprom
 Describe an EEPROM context, used by the driver to access the single device. More...
struct  EepromInfo
 Descrive all EEPROM informations needed by the driver. More...

Defines

#define KFT_EEPROM   MAKE_ID('E', 'E', 'P', 'R')
 ID for eeproms.
#define e2addr(type, field)   ((e2addr_t)&(((type *)0)->field))
 Macro for E2Layout offset calculation.

Typedefs

typedef enum EepromType EepromType
 Values for Eeprom types.
typedef uint8_t e2dev_addr_t
 On the same I2C bus can live more than one EEPROM device.
typedef struct Eeprom Eeprom
 Describe an EEPROM context, used by the driver to access the single device.
typedef uint16_t e2addr_t
 Type for EEPROM addresses.
typedef uint16_t e2blk_size_t
 Type for EEPROM block size.
typedef uint32_t e2_size_t
 Type for accessing EEPROM whole size.
typedef struct EepromInfo EepromInfo
 Descrive all EEPROM informations needed by the driver.

Enumerations

enum  EepromType
 

Values for Eeprom types.


Functions

EepromEEPROM_CAST (KFile *fd)
 Convert + ASSERT from generic KFile to Eeprom.
bool eeprom_erase (Eeprom *fd, e2addr_t addr, e2_size_t count)
 Erase specified part of eeprom, writing 0xFF.
bool eeprom_verify (Eeprom *fd, const void *buf, size_t count)
 Check that the contents of an EEPROM range match with a provided data buffer.
void eeprom_init (Eeprom *fd, EepromType, e2dev_addr_t, bool verify)
 Initialize EEPROM module.

Detailed Description

Driver for the 24xx16 and 24xx256 I2C EEPROMS.

Author:
Stefano Fedrigo <aleph@develer.com>
Bernie Innocenti <bernie@codewiz.org>

Definition in file eeprom.h.


Define Documentation

#define e2addr ( type,
field   )     ((e2addr_t)&(((type *)0)->field))

Macro for E2Layout offset calculation.

Note:
We can't just use offsetof() here because we could use non-constant expressions to access array elements.
'type' is the structure type holding eeprom layout and must be defined in user files.

Definition at line 107 of file eeprom.h.


Typedef Documentation

typedef uint8_t e2dev_addr_t

On the same I2C bus can live more than one EEPROM device.

Each device can be addressed by one or more pins.

Definition at line 68 of file eeprom.h.


Function Documentation

bool eeprom_erase ( Eeprom fd,
e2addr_t  addr,
e2_size_t  count 
)

Erase specified part of eeprom, writing 0xFF.

addr starting address count length of block to erase

Note:
Seek position is unchanged.
Returns:
true if ok, false otherwise.

Definition at line 324 of file eeprom.c.

void eeprom_init ( Eeprom fd,
EepromType  type,
e2dev_addr_t  addr,
bool  verify 
)

Initialize EEPROM module.

fd is the Kfile context. type is the eeprom device we want to initialize (

See also:
EepromType) addr is the i2c devide address (usually pins A0, A1, A2). verify is true if you want that every write operation will be verified.

Definition at line 378 of file eeprom.c.

bool eeprom_verify ( Eeprom fd,
const void *  buf,
size_t  count 
)

Check that the contents of an EEPROM range match with a provided data buffer.

Returns:
true on success.
Note:
Seek position of fd will not change.

Definition at line 278 of file eeprom.c.