eeprom.c File Reference

Driver for the 24xx16 and 24xx256 I2C EEPROMS (implementation). More...

#include "eeprom.h"
#include <cfg/macros.h>
#include <cfg/debug.h>
#include <cfg/module.h>
#include <cpu/attr.h>
#include <drv/i2c.h>
#include <drv/wdt.h>
#include <cpu/byteorder.h>
#include <string.h>

Go to the source code of this file.


Defines

#define EEPROM_ID   0xA0
 EEPROM ID code.
#define EEPROM_ADDR(x)   (EEPROM_ID | (((uint8_t)((x) & 0x07)) << 1))
 This macros form the correct slave address for EEPROMs.

Functions

static size_t eeprom_writeRaw (struct KFile *_fd, const void *buf, size_t size)
 Copy size bytes from buffer buf to eeprom.
static size_t eeprom_writeVerify (struct KFile *_fd, const void *_buf, size_t size)
 Copy size bytes from buffer _buf to eeprom.
static size_t eeprom_read (struct KFile *_fd, void *_buf, size_t size)
 Copy size bytes from eeprom to RAM to buffer _buf.
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.
bool eeprom_erase (Eeprom *fd, e2addr_t addr, e2_size_t count)
 Erase specified part of eeprom, writing 0xFF.
void eeprom_init (Eeprom *fd, EepromType type, e2dev_addr_t addr, bool verify)
 Initialize EEPROM module.

Variables

static const EepromInfo mem_info []
 Array used to describe EEPROM memory devices currently supported.

Detailed Description

Driver for the 24xx16 and 24xx256 I2C EEPROMS (implementation).

Version:
Id
eeprom.c 2887 2009-09-07 14:38:31Z batt
Author:
Stefano Fedrigo <aleph@develer.com>

Bernie Innocenti <bernie@codewiz.org>

Definition in file eeprom.c.


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 315 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 369 of file eeprom.c.

static size_t eeprom_read ( struct KFile _fd,
void *  _buf,
size_t  size 
) [static]

Copy size bytes from eeprom to RAM to buffer _buf.

Returns:
the number of bytes read.

Definition at line 205 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 269 of file eeprom.c.

static size_t eeprom_writeVerify ( struct KFile _fd,
const void *  _buf,
size_t  size 
) [static]

Copy size bytes from buffer _buf to eeprom.

Note:
Writes are verified and if buffer content is not matching we retry 5 times max.

Definition at line 176 of file eeprom.c.