| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Typedefs | Enumerations | Functions | Variables
C:/pdl_v10/library/utility/at24cxx/i2c_int_at24cxx.c File Reference
`#include "i2c_at24cxx.h"`
`#include <string.h>`
Include dependency graph for i2c_int_at24cxx.c:

Go to the source code of this file.

## Data Structures
struct | stc_i2c_info
| I2C transfer information structure. More...
## Typedefs
typedef enum en_i2c_rw_mode | en_i2c_rw_mode_t
| I2C read and write mode.
typedef enum en_i2c_seq | en_i2c_seq_t
| I2C transfer sequence.
typedef struct stc_i2c_info | stc_i2c_info_t
| I2C transfer information structure.
## Enumerations
enum | en_i2c_rw_mode { I2cTxMode = 0, I2cRxMode, I2cTxRxMode }
| I2C read and write mode. More...
enum | en_i2c_seq { I2cSeqStart = 0u, I2cSeqWrite, I2cSeqRestart, I2cSeqRead, I2cSeqStop }
| I2C transfer sequence. More...
## Functions
static boolean_t | I2cCheckErrorStatus (void)
| Check the error status of I2C.
static void | Delay (uint32_t u32Cnt)
| Delay function.
static void | I2cTxCallback (void)
| I2C TX callback function.
static void | I2cRxCallback (void)
| I2C RX callback function.
static void | I2cIntCallback (void)
| I2C interrupt callback function.
static void | I2cStopDetectCallback (void)
| I2C stop detection callback function.
static en_result_t | I2cTxData (uint8_t u8DevAddr, uint8_t *pu8Data, uint32_t u32Size)
| Write I2C data.
static en_result_t | I2cTxRxData (uint8_t u8DevAddr, uint8_t *pu8TxData, uint32_t u32TxSize, uint8_t *pu8RxData, uint32_t u32RxSize)
| Perform a dummy write and read at the following.
static en_result_t | I2cRxData (uint8_t u8DevAddr, uint8_t *pu8RxData, uint32_t u32RxSize)
| Read I2C data.
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
## Variables
stc_i2c_int_sel_t | stcI2cIntSel
stc_i2c_int_cb_t | stcI2cIntCb
stc_i2c_info_t | stcI2cInfo

## Detailed Description

A detailed description is available at Module description

History:

- 2014-03-17 0.1 Edison Zhang First version.

Definition in file i2c_int_at24cxx.c.

## Typedef Documentation

typedef enum en_i2c_rw_mode en_i2c_rw_mode_t

I2C read and write mode.

typedef enum en_i2c_seq en_i2c_seq_t

I2C transfer sequence.

typedef struct stc_i2c_info stc_i2c_info_t

I2C transfer information structure.

## Enumeration Type Documentation

enum en_i2c_rw_mode

I2C read and write mode.

Enumerator:

  I2cTxMode | I2C TX only.
  I2cRxMode | I2C RX only.
  I2cTxRxMode | I2C TX first and RX at the following.

Definition at line 74 of file i2c_int_at24cxx.c.

enum en_i2c_seq

I2C transfer sequence.

Enumerator:

  I2cSeqStart | I2C Start process.
  I2cSeqWrite | I2C Write process.
  I2cSeqRestart | I2C Restart process.
  I2cSeqRead | I2C Read process.
  I2cSeqStop | I2C Stop process.

Definition at line 86 of file i2c_int_at24cxx.c.

## Function Documentation

static void Delay | ( | uint32_t | u32Cnt | ) | `[static]`

Delay function.

Parameters:

  [in] | u32Cnt | Time count

Definition at line 152 of file i2c_int_at24cxx.c.

Referenced by I2cTxCallback().

Here is the caller graph for this function:

static boolean_t I2cCheckErrorStatus | ( | void |  | ) | `[static]`

Check the error status of I2C.

Return values:

  TRUE | No error
  FALSE | I2C error occurs

Definition at line 130 of file i2c_int_at24cxx.c.

References EE_I2C_CH, FALSE, I2cBusErr, I2cOverrunError, Mfs_I2c_GetStatus(), and TRUE.

Referenced by I2cIntCallback().

Here is the call graph for this function:

Here is the caller graph for this function:

static void I2cIntCallback | ( | void |  | ) | `[static]`

I2C interrupt callback function.

Definition at line 288 of file i2c_int_at24cxx.c.

References stc_i2c_info::bI2cErrorFlag, EE_I2C_CH, stc_i2c_info::enRwMode, stc_i2c_info::enSequence, I2cCheckErrorStatus(), I2cNAck, I2cRxMode, I2cRxTxInt, I2cSeqRead, I2cSeqRestart, I2cSeqStart, I2cSeqWrite, Mfs_I2c_ClrStatus(), Mfs_I2c_ConfigAck(), Mfs_I2c_GetAck(), Mfs_I2c_GetStatus(), TRUE, stc_i2c_info::u32Count, and stc_i2c_info::u32RxSize.

Referenced by I2cRxData(), I2cTxData(), and I2cTxRxData().

Here is the call graph for this function:

Here is the caller graph for this function:

static void I2cRxCallback | ( | void |  | ) | `[static]`

I2C RX callback function.

Definition at line 255 of file i2c_int_at24cxx.c.

References stc_i2c_info::bI2cErrorFlag, EE_I2C_CH, stc_i2c_info::enSequence, I2cNAck, I2cRxTxInt, I2cSeqRead, Mfs_I2c_ClrStatus(), Mfs_I2c_ConfigAck(), Mfs_I2c_GenerateStop(), Mfs_I2c_ReceiveData(), Ok, stc_i2c_info::pu8RxBuf, stc_i2c_info::u32Count, and stc_i2c_info::u32RxSize.

Referenced by I2cRxData(), and I2cTxRxData().

Here is the call graph for this function:

Here is the caller graph for this function:

static en_result_t I2cRxData | ( | uint8_t | u8DevAddr,
|  | uint8_t * | pu8RxData,
|  | uint32_t | u32RxSize
| ) |  | `[static]`

Read I2C data.

Parameters:

  u8DevAddr | 7-bit device address
  pu8RxData | Pointer to data buffer
  u32RxSize | Read buffer size

Return values:

  Ok | Data are read normally
  Error | Data read are ended with error

Definition at line 495 of file i2c_int_at24cxx.c.

References stc_i2c_info::bI2cErrorFlag, stc_i2c_int_sel::bRxInt, stc_i2c_int_sel::bStopDetectInt, stc_i2c_int_sel::bTxInt, stc_i2c_int_sel::bTxRxInt, EE_I2C_CH, stc_i2c_info::enRwMode, stc_i2c_info::enSequence, Error, I2cIntCallback(), I2cRxCallback(), I2cRxMode, I2cSeqStart, I2cSeqStop, I2cStopDetectCallback(), I2cTxCallback(), Mfs_I2c_EnableInt(), Ok, PDL_ZERO_STRUCT, stc_i2c_int_cb::pfnRxIntCb, stc_i2c_int_cb::pfnStopDetectCb, stc_i2c_int_cb::pfnTxIntCb, stc_i2c_int_cb::pfnTxRxCb, stc_i2c_info::pu8RxBuf, TRUE, stc_i2c_info::u32Count, stc_i2c_info::u32RxSize, and stc_i2c_info::u8DevAddr.

Referenced by At24cxx_CurrentAddrRead(), and At24cxx_SequentialRead().

Here is the call graph for this function:

Here is the caller graph for this function:

static void I2cStopDetectCallback | ( | void |  | ) | `[static]`

I2C stop detection callback function.

Definition at line 353 of file i2c_int_at24cxx.c.

References stc_i2c_int_sel::bRxInt, stc_i2c_int_sel::bStopDetectInt, stc_i2c_int_sel::bTxInt, stc_i2c_int_sel::bTxRxInt, EE_I2C_CH, stc_i2c_info::enSequence, I2cRxTxInt, I2cSeqStop, I2cStopDetect, Mfs_I2c_ClrStatus(), Mfs_I2c_DisableInt(), Mfs_I2c_GetStatus(), PDL_ZERO_STRUCT, and TRUE.

Referenced by I2cRxData(), I2cTxData(), and I2cTxRxData().

Here is the call graph for this function:

Here is the caller graph for this function:

static void I2cTxCallback | ( | void |  | ) | `[static]`

I2C TX callback function.

Definition at line 163 of file i2c_int_at24cxx.c.

References stc_i2c_info::bI2cErrorFlag, stc_i2c_int_sel::bTxInt, Delay(), EE_I2C_CH, stc_i2c_info::enRwMode, stc_i2c_info::enSequence, I2cAck, I2cRxTxInt, I2cSeqRestart, I2cSeqStart, I2cSeqWrite, I2cTxMode, I2cTxRxMode, Mfs_I2c_ClrStatus(), Mfs_I2c_ConfigAck(), Mfs_I2c_DisableInt(), Mfs_I2c_GenerateRestart(), Mfs_I2c_GenerateStart(), Mfs_I2c_GenerateStop(), Mfs_I2c_SendData(), Ok, PDL_ZERO_STRUCT, stc_i2c_info::pu8TxBuf, TRUE, stc_i2c_info::u32Count, stc_i2c_info::u32TxRxGap, stc_i2c_info::u32TxSize, and stc_i2c_info::u8DevAddr.

Referenced by I2cRxData(), I2cTxData(), and I2cTxRxData().

Here is the call graph for this function:

Here is the caller graph for this function:

static en_result_t I2cTxData | ( | uint8_t | u8DevAddr,
|  | uint8_t * | pu8Data,
|  | uint32_t | u32Size
| ) |  | `[static]`

Write I2C data.

Parameters:

  u8DevAddr | 7-bit device address
  pu8Data | Pointer to data buffer
  u32Size | Write buffer size

Return values:

  Ok | Data are transferred normally
  Error | Data transferred are ended with error

Definition at line 384 of file i2c_int_at24cxx.c.

References stc_i2c_info::bI2cErrorFlag, stc_i2c_int_sel::bStopDetectInt, stc_i2c_int_sel::bTxInt, stc_i2c_int_sel::bTxRxInt, EE_I2C_CH, stc_i2c_info::enRwMode, stc_i2c_info::enSequence, Error, I2cIntCallback(), I2cSeqStart, I2cSeqStop, I2cStopDetectCallback(), I2cTxCallback(), I2cTxMode, Mfs_I2c_EnableInt(), Ok, PDL_ZERO_STRUCT, stc_i2c_int_cb::pfnStopDetectCb, stc_i2c_int_cb::pfnTxIntCb, stc_i2c_int_cb::pfnTxRxCb, stc_i2c_info::pu8TxBuf, TRUE, stc_i2c_info::u32Count, stc_i2c_info::u32TxSize, and stc_i2c_info::u8DevAddr.

Referenced by At24cxx_ByteWrite(), and At24cxx_PageWrite().

Here is the call graph for this function:

Here is the caller graph for this function:

static en_result_t I2cTxRxData | ( | uint8_t | u8DevAddr,
|  | uint8_t * | pu8TxData,
|  | uint32_t | u32TxSize,
|  | uint8_t * | pu8RxData,
|  | uint32_t | u32RxSize
| ) |  | `[static]`

Perform a dummy write and read at the following.

Parameters:

  u8DevAddr | 7-bit device address
  pu8TxData | Pointer to write data buffer
  u32TxSize | Write buffer size
  pu8RxData | Pointer to read data buffer
  u32RxSize | Read buffer size

Return values:

  Ok | Data are transfer normally
  Error | Data transfer are ended with error

Definition at line 436 of file i2c_int_at24cxx.c.

References stc_i2c_info::bI2cErrorFlag, stc_i2c_int_sel::bRxInt, stc_i2c_int_sel::bStopDetectInt, stc_i2c_int_sel::bTxInt, stc_i2c_int_sel::bTxRxInt, EE_I2C_CH, stc_i2c_info::enRwMode, stc_i2c_info::enSequence, Error, I2cIntCallback(), I2cRxCallback(), I2cSeqStart, I2cSeqStop, I2cStopDetectCallback(), I2cTxCallback(), I2cTxRxMode, Mfs_I2c_EnableInt(), Ok, PDL_ZERO_STRUCT, stc_i2c_int_cb::pfnRxIntCb, stc_i2c_int_cb::pfnStopDetectCb, stc_i2c_int_cb::pfnTxIntCb, stc_i2c_int_cb::pfnTxRxCb, stc_i2c_info::pu8RxBuf, stc_i2c_info::pu8TxBuf, SystemCoreClock, TRUE, stc_i2c_info::u32Count, stc_i2c_info::u32RxSize, stc_i2c_info::u32TxRxGap, stc_i2c_info::u32TxSize, and stc_i2c_info::u8DevAddr.

Referenced by At24cxx_RandomRead().

Here is the call graph for this function:

Here is the caller graph for this function:

## Variable Documentation

stc_i2c_info_t stcI2cInfo

Definition at line 120 of file i2c_int_at24cxx.c.

stc_i2c_int_cb_t stcI2cIntCb

Definition at line 119 of file i2c_int_at24cxx.c.

stc_i2c_int_sel_t stcI2cIntSel

Definition at line 118 of file i2c_int_at24cxx.c.