BeRTOS
Data Structures | Defines | Typedefs | Enumerations | Functions
eeprom.h File Reference

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

#include "cfg/cfg_eeprom.h"
#include <cfg/compiler.h>
#include <cfg/debug.h>
#include <drv/i2c.h>
#include <io/kblock.h>
#include <io/kfile.h>
#include <io/kfile_block.h>
#include <cpu/attr.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 KBT_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 uint8_t e2dev_addr_t
 On the same I2C bus can live more than one EEPROM 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.

Enumerations

enum  EepromType
 Values for Eeprom types.

Functions

EepromEEPROM_CAST_KBLOCK (KBlock *blk)
 Convert + ASSERT from generic KFile to Eeprom.
bool eeprom_erase (Eeprom *eep, e2addr_t addr, e2_size_t count)
 Erase EEPROM.
void eeprom_init_5 (Eeprom *eep, I2c *i2c, EepromType type, e2dev_addr_t addr, 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 137 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 86 of file eeprom.h.


Function Documentation

bool eeprom_erase ( Eeprom eep,
e2addr_t  addr,
e2_size_t  size 
)

Erase EEPROM.

Parameters:
eepis the Kblock context.
addreeprom address where start to erase
sizenumber of byte to erase

Definition at line 117 of file eeprom.c.

void eeprom_init_5 ( Eeprom eep,
I2c *  i2c,
EepromType  type,
e2dev_addr_t  addr,
bool  verify 
)

Initialize EEPROM module.

Parameters:
eepis the Kblock context.
typeis the eeprom device we want to initialize (
See also:
EepromType)
Parameters:
i2ccontext for i2c channel
addris the i2c devide address (usually pins A0, A1, A2).
verifyenable the write check.

Definition at line 334 of file eeprom.c.