PDL for FM0+  Version1.0
Peripheral Driverl Library for FM0+
I2C AT24CXX Function

Defines

#define AT24CXX_7BIT_DEVICE_ADDR   (0x50u)
#define AT24CXX_PAGE_SIZE   8
#define AT24CXX_ADDR_LENGTH   1
#define InitI2cIo(void)   {SetPinFunc_SOT1_1();SetPinFunc_SCK1_1();}
#define EE_I2C_CH   &I2C1

Functions

en_result_t At24cxx_Init (void)
 Initialize AT24CXX.
en_result_t At24cxx_ByteWrite (uint8_t u8DevAddr, uint16_t u16Addr, uint8_t u8Data)
 Write byte at a certain address of AT24CXX.
en_result_t At24cxx_PageWrite (uint8_t u8DevAddr, uint16_t u16PageAddr, uint8_t *pu8Data, uint8_t u8Size)
 Write a page bytes at a page address of AT24CXX.
en_result_t At24cxx_CurrentAddrRead (uint8_t u8DevAddr, uint8_t *pu8CurData)
 Read the data of current data address of AT24CXX.
en_result_t At24cxx_RandomRead (uint8_t u8DevAddr, uint16_t u16Addr, uint8_t *pu8Data)
 Read a byte data of ramdon data address of AT24CXX.
en_result_t At24cxx_SequentialRead (uint8_t u8DevAddr, uint8_t *pu8Data, uint8_t u8Size)
 Read data bytes following by random read or current address read.
void At24cxx_Delayms (uint32_t u32Cnt)
 ms delay function

Detailed Description

Provided functions of AT24CXX driver:

At24cxx_Init() initializes the I2C channel to access AT24CXX.

At24cxx_ByteWrite() writes a byte at a ramdon address in the EEPROM memory.

At24cxx_PageWrite() can write up to 1 page bytes.

At24cxx_CurrentAddrRead() reads the data at the current address.

At24cxx_RandomRead() can read a byte at a ramdon address in the EEPROM memory.

At24cxx_SequentialRead() can read as many bytes as whole EEPROM memory, which should follow At24cxx_CurrentAddrRead() or At24cxx_RandomRead().


Define Documentation

#define AT24CXX_7BIT_DEVICE_ADDR   (0x50u)

AT24CXX device address [A0=A1=A2=0]

Definition at line 116 of file i2c_at24cxx.h.

#define AT24CXX_ADDR_LENGTH   1

AT24CXX address byte length

Definition at line 137 of file i2c_at24cxx.h.

Referenced by At24cxx_ByteWrite(), At24cxx_PageWrite(), and At24cxx_RandomRead().

#define AT24CXX_PAGE_SIZE   8

AT24CXX page size

Definition at line 121 of file i2c_at24cxx.h.

Referenced by At24cxx_PageWrite().

#define InitI2cIo (   void)    {SetPinFunc_SOT1_1();SetPinFunc_SCK1_1();}

I2C IO function initialization

Definition at line 143 of file i2c_at24cxx.h.

Referenced by At24cxx_Init().


Function Documentation

en_result_t At24cxx_ByteWrite ( uint8_t  u8DevAddr,
uint16_t  u16Addr,
uint8_t  u8Data 
)

Write byte at a certain address of AT24CXX.

Parameters:
[in]u8DevAddr7-bit device address
[in]u16AddrData address
[in]u8DataData byte
Return values:
OkWrite byte normally
ErrorWrite byte failed

Definition at line 576 of file i2c_int_at24cxx.c.

References AT24CXX_ADDR_LENGTH, Error, I2cSendData(), I2cStart(), I2cStop(), I2cTxData(), and Ok.

Here is the call graph for this function:

en_result_t At24cxx_CurrentAddrRead ( uint8_t  u8DevAddr,
uint8_t *  pu8CurData 
)

Read the data of current data address of AT24CXX.

Parameters:
[in]u8DevAddr7-bit device address
[out]pu8CurDataPointer to the data read
Return values:
OkRead data normally
ErrorRead data failed

Definition at line 652 of file i2c_int_at24cxx.c.

References Error, I2cRead(), I2cRxData(), I2cStart(), I2cStop(), and Ok.

Here is the call graph for this function:

void At24cxx_Delayms ( uint32_t  u32Cnt)

ms delay function

Parameters:
[in]u32Cntms count

Definition at line 723 of file i2c_int_at24cxx.c.

References SystemCoreClock.

Initialize AT24CXX.

Return values:
OkI2C start normally
ErrorOther errors

Definition at line 543 of file i2c_int_at24cxx.c.

References stc_mfs_i2c_config::bDmaEnable, stc_mfs_i2c_config::bEnableFifo, stc_mfs_i2c_config::bWaitSelection, EE_I2C_CH, stc_mfs_i2c_config::enMsMode, Error, FALSE, I2cMaster, InitI2cIo, Mfs_I2c_Init(), Ok, PDL_ZERO_STRUCT, and stc_mfs_i2c_config::u32BaudRate.

Here is the call graph for this function:

en_result_t At24cxx_PageWrite ( uint8_t  u8DevAddr,
uint16_t  u16PageAddr,
uint8_t *  pu8Data,
uint8_t  u8Size 
)

Write a page bytes at a page address of AT24CXX.

Parameters:
[in]u8DevAddr7-bit device address
[in]u16PageAddrRandom addess within EEPROM memory
[in]pu8DataPointer to data array
[in]u8SizeData size (shoudl be less than page size)
Return values:
OkWrite page normally
ErrorWrite page failed
Parameters:
u8DevAddr7-bit device address
[in]u16PageAddrRandom addess within EEPROM memory
[in]pu8DataPointer to data array
[in]u8SizeData size (shoudl be less than page size)
Return values:
OkWrite page normally
ErrorWrite page failed

Definition at line 612 of file i2c_int_at24cxx.c.

References AT24CXX_ADDR_LENGTH, AT24CXX_PAGE_SIZE, Error, ErrorInvalidParameter, I2cSendData(), I2cStart(), I2cStop(), I2cTxData(), and Ok.

Here is the call graph for this function:

en_result_t At24cxx_RandomRead ( uint8_t  u8DevAddr,
uint16_t  u16Addr,
uint8_t *  pu8Data 
)

Read a byte data of ramdon data address of AT24CXX.

Parameters:
[in]u8DevAddr7-bit device address
[in]u16AddrData address
[out]pu8DataPointer to the data read
Return values:
OkRead data normally
ErrorRead data failed

Definition at line 674 of file i2c_int_at24cxx.c.

References AT24CXX_ADDR_LENGTH, Error, I2cRead(), I2cRestart(), I2cSendData(), I2cStart(), I2cStop(), I2cTxRxData(), Ok, and SystemCoreClock.

Here is the call graph for this function:

en_result_t At24cxx_SequentialRead ( uint8_t  u8DevAddr,
uint8_t *  pu8Data,
uint8_t  u8Size 
)

Read data bytes following by random read or current address read.

Parameters:
[in]u8DevAddr7-bit device address
[out]pu8DataPointer to the data read
[in]u8SizeData size
Return values:
OkRead data normally
ErrorRead data failed

Definition at line 706 of file i2c_int_at24cxx.c.

References Error, I2cRead(), I2cRxData(), I2cStart(), I2cStop(), and Ok.

Here is the call graph for this function: