eeprom.c File Reference

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

#include "eeprom.h"
#include <cfg/debug.h>
#include <appconfig.h>
#include <cfg/macros.h>
#include <cpu/attr.h>
#include <CPU_HEADER(twi)>
#include <drv/wdt.h>
#include <mware/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)) << 1))
 This macros form the correct slave address for EEPROMs.

Functions

static bool eeprom_writeRaw (e2addr_t addr, const void *buf, size_t count)
 Copy count bytes from buffer buf to eeprom at address addr.
bool eeprom_read (e2addr_t addr, void *buf, size_t count)
 Copy count bytes at address addr from eeprom to RAM to buffer buf.
bool eeprom_write_char (e2addr_t addr, char c)
 Write a single character c at address addr.
int eeprom_read_char (e2addr_t addr)
 Read a single character at address addr.
void eeprom_erase (e2addr_t addr, size_t count)
 Erase specified part of eeprom, writing 0xFF.
void eeprom_init (void)
 Initialize TWI module.

Detailed Description

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

Note:
This implementation is AVR specific.
Version:
Id
eeprom.c 930 2007-10-23 14:48:48Z batt
Author:
Stefano Fedrigo <aleph@develer.com>

Bernardo Innocenti <bernie@develer.com>

Definition in file eeprom.c.


Function Documentation

void eeprom_erase ( e2addr_t  addr,
size_t  count 
)

Erase specified part of eeprom, writing 0xFF.

Parameters:
addr starting address
count length of block to erase

Definition at line 276 of file eeprom.c.

bool eeprom_read ( e2addr_t  addr,
void *  buf,
size_t  count 
)

Copy count bytes at address addr from eeprom to RAM to buffer buf.

Returns:
true on success.

Definition at line 205 of file eeprom.c.

int eeprom_read_char ( e2addr_t  addr  ) 

Read a single character at address addr.

Returns:
the requested character or -1 in case of failure.

Definition at line 259 of file eeprom.c.