Detailed Description

I2C EEPROM Driver.

EEPROM I2C driver for 24AA024 (2Kbit) EEPROM device on the EFM32 Development Kits.

Macros

#define EEPROM_DVK_ADDR 0xA0
#define EEPROM_DVK_LEN 0x100
#define EEPROM_DVK_PAGESIZE 16

Functions

static int EEPROM_AckPoll (I2C_TypeDef *i2c, uint8_t addr)
Do acknowledge polling on EEPROM device.
int EEPROM_Read (I2C_TypeDef *i2c, uint8_t addr, unsigned int offset, uint8_t *data, unsigned int len)
Read data from EEPROM.
int EEPROM_Write (I2C_TypeDef *i2c, uint8_t addr, unsigned int offset, uint8_t *data, unsigned int len)
Write data to EEPROM.

Macro Definition Documentation

#define EEPROM_DVK_ADDR   0xA0

I2C device address for EEPROM on DK

Definition at line 55 of file eeprom.h .

#define EEPROM_DVK_LEN   0x100

Number of bytes in EEPROM

Definition at line 57 of file eeprom.c .

Referenced by EEPROM_Read() , and EEPROM_Write() .

#define EEPROM_DVK_PAGESIZE   16

Pagesize in EEPROM

Definition at line 60 of file eeprom.c .

Referenced by EEPROM_Write() .

Function Documentation

static int EEPROM_AckPoll ( I2C_TypeDef * i2c,
uint8_t addr
)
static

Do acknowledge polling on EEPROM device.

When writing to an EEPROM, the EEPROM device will be busy for some time after issuing a (page) write. During this time, the EEPROM is not accessible, and will therefore not ACK any requests. This feature can be used to determine when the write is actually completed, and is denoted acknowledgement polling.

Note
This function will not return until the EEPROM device acknowledges (or some sort of I2C failure occurs). If trying to acknowledge poll a non-existing device, NACK will always result and this function will never return. Thus, it should not be used unless the EEPROM device is actually present.
Parameters
[in] i2c Pointer to I2C peripheral register block.
[in] addr I2C address for EEPROM, in 8 bit format, where LSB is reserved for R/W bit.
Returns
Returns 0 when EEPROM acknowledges. Negative value is returned is some sort of error occurred during acknowledgement polling.

Definition at line 94 of file eeprom.c .

References I2C_TransferSeq_TypeDef::addr , I2C_TransferSeq_TypeDef::buf , I2C_TransferSeq_TypeDef::data , I2C_TransferSeq_TypeDef::flags , I2C_FLAG_WRITE , I2CSPM_Transfer() , i2cTransferDone , i2cTransferNack , and I2C_TransferSeq_TypeDef::len .

Referenced by EEPROM_Write() .

int EEPROM_Read ( I2C_TypeDef * i2c,
uint8_t addr,
unsigned int offset,
uint8_t * data,
unsigned int len
)

Read data from EEPROM.

Parameters
[in] i2c Pointer to I2C peripheral register block.
[in] addr I2C address for EEPROM, in 8 bit format, where LSB is reserved for R/W bit.
[in] offset Offset in EEPROM to start reading from.
[out] data Location to place read data, must be at least len long.
[in] len Number of bytes to read.
Returns
Returns number of bytes read. Less than specified number of bytes is returned if reading beyond end of EEPROM. Negative value is returned is some sort of error occurred during read.

Definition at line 150 of file eeprom.c .

References I2C_TransferSeq_TypeDef::addr , I2C_TransferSeq_TypeDef::buf , I2C_TransferSeq_TypeDef::data , EEPROM_DVK_LEN , I2C_TransferSeq_TypeDef::flags , I2C_FLAG_WRITE_READ , I2CSPM_Transfer() , i2cTransferDone , and I2C_TransferSeq_TypeDef::len .

int EEPROM_Write ( I2C_TypeDef * i2c,
uint8_t addr,
unsigned int offset,
uint8_t * data,
unsigned int len
)

Write data to EEPROM.

Parameters
[in] i2c Pointer to I2C peripheral register block.
[in] addr I2C address for EEPROM, in 8 bit format, where LSB is reserved for R/W bit.
[in] offset Offset in EEPROM to start writing to.
[out] data Location holding data to write, must be at least len long.
[in] len Number of bytes to write.
Returns
Returns number of bytes written. Less than specified number of bytes is returned if writing beyond end of EEPROM. Negative value is returned is some sort of error occurred during write.

Definition at line 211 of file eeprom.c .

References I2C_TransferSeq_TypeDef::addr , I2C_TransferSeq_TypeDef::buf , I2C_TransferSeq_TypeDef::data , EEPROM_AckPoll() , EEPROM_DVK_LEN , EEPROM_DVK_PAGESIZE , I2C_TransferSeq_TypeDef::flags , I2C_FLAG_WRITE_WRITE , I2CSPM_Transfer() , i2cTransferDone , and I2C_TransferSeq_TypeDef::len .