EFR32 Blue Gecko 12 Software Documentation  efr32bg12-doc-5.1.2
eeprom.c File Reference

Detailed Description

EEPROM driver for 24AA024 (2Kbit) EEPROM device on the DK.

Version
5.1.1

License

Copyright 2015 Silicon Labs, Inc. http://www.silabs.com

This file is licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.

Definition in file eeprom.c.

#include <stddef.h>
#include "i2cspm.h"
#include "eeprom.h"

Go to the source code of this file.

Macros

#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. More...
 
int EEPROM_Read (I2C_TypeDef *i2c, uint8_t addr, unsigned int offset, uint8_t *data, unsigned int len)
 Read data from EEPROM. More...
 
int EEPROM_Write (I2C_TypeDef *i2c, uint8_t addr, unsigned int offset, uint8_t *data, unsigned int len)
 Write data to EEPROM. More...
 

Macro Definition Documentation

#define EEPROM_DVK_LEN   0x100

Number of bytes in EEPROM

Definition at line 25 of file eeprom.c.

Referenced by EEPROM_Read(), and EEPROM_Write().

#define EEPROM_DVK_PAGESIZE   16

Pagesize in EEPROM

Definition at line 28 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]i2cPointer to I2C peripheral register block.
[in]addrI2C 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 63 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().