![]() |
PDL for FM0+
Version1.0
Peripheral Driverl Library for FM0+
|
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 |
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 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 |
I2C channel used for AT24C02
Definition at line 146 of file i2c_at24cxx.h.
Referenced by At24cxx_Init(), I2cCheckErrorStatus(), I2cIntCallback(), I2cRead(), I2cRestart(), I2cRxCallback(), I2cRxData(), I2cSendData(), I2cStart(), I2cStop(), I2cStopDetectCallback(), I2cTxCallback(), I2cTxData(), and I2cTxRxData().
#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().
en_result_t At24cxx_ByteWrite | ( | uint8_t | u8DevAddr, |
uint16_t | u16Addr, | ||
uint8_t | u8Data | ||
) |
Write byte at a certain address of AT24CXX.
[in] | u8DevAddr | 7-bit device address |
[in] | u16Addr | Data address |
[in] | u8Data | Data byte |
Ok | Write byte normally |
Error | Write byte failed |
Definition at line 576 of file i2c_int_at24cxx.c.
References AT24CXX_ADDR_LENGTH, Error, I2cSendData(), I2cStart(), I2cStop(), I2cTxData(), and Ok.
en_result_t At24cxx_CurrentAddrRead | ( | uint8_t | u8DevAddr, |
uint8_t * | pu8CurData | ||
) |
Read the data of current data address of AT24CXX.
[in] | u8DevAddr | 7-bit device address |
[out] | pu8CurData | Pointer to the data read |
Ok | Read data normally |
Error | Read data failed |
Definition at line 652 of file i2c_int_at24cxx.c.
References Error, I2cRead(), I2cRxData(), I2cStart(), I2cStop(), and Ok.
void At24cxx_Delayms | ( | uint32_t | u32Cnt | ) |
ms delay function
[in] | u32Cnt | ms count |
Definition at line 723 of file i2c_int_at24cxx.c.
References SystemCoreClock.
en_result_t At24cxx_Init | ( | void | ) |
Initialize AT24CXX.
Ok | I2C start normally |
Error | Other 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.
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.
[in] | u8DevAddr | 7-bit device address |
[in] | u16PageAddr | Random addess within EEPROM memory |
[in] | pu8Data | Pointer to data array |
[in] | u8Size | Data size (shoudl be less than page size) |
Ok | Write page normally |
Error | Write page failed |
u8DevAddr | 7-bit device address | |
[in] | u16PageAddr | Random addess within EEPROM memory |
[in] | pu8Data | Pointer to data array |
[in] | u8Size | Data size (shoudl be less than page size) |
Ok | Write page normally |
Error | Write 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.
en_result_t At24cxx_RandomRead | ( | uint8_t | u8DevAddr, |
uint16_t | u16Addr, | ||
uint8_t * | pu8Data | ||
) |
Read a byte data of ramdon data address of AT24CXX.
[in] | u8DevAddr | 7-bit device address |
[in] | u16Addr | Data address |
[out] | pu8Data | Pointer to the data read |
Ok | Read data normally |
Error | Read 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.
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.
[in] | u8DevAddr | 7-bit device address |
[out] | pu8Data | Pointer to the data read |
[in] | u8Size | Data size |
Ok | Read data normally |
Error | Read data failed |
Definition at line 706 of file i2c_int_at24cxx.c.
References Error, I2cRead(), I2cRxData(), I2cStart(), I2cStop(), and Ok.