M480 BSP V3.05.005
The Board Support Package for M480 Series
Macros | Functions

Macros

#define I2C_SET_CONTROL_REG(i2c, u8Ctrl)
 The macro is used to set I2C bus condition at One Time. More...
 
#define I2C_START(i2c)
 The macro is used to set START condition of I2C Bus. More...
 
#define I2C_WAIT_READY(i2c)
 The macro is used to wait I2C bus status get ready. More...
 
#define I2C_GET_DATA(i2c)
 The macro is used to Read I2C Bus Data Register. More...
 
#define I2C_SET_DATA(i2c, u8Data)
 Write a Data to I2C Data Register. More...
 
#define I2C_GET_STATUS(i2c)
 Get I2C Bus status code. More...
 
#define I2C_GET_TIMEOUT_FLAG(i2c)
 Get Time-out flag from I2C Bus. More...
 
#define I2C_GET_WAKEUP_FLAG(i2c)
 To get wake-up flag from I2C Bus. More...
 
#define I2C_CLEAR_WAKEUP_FLAG(i2c)
 To clear wake-up flag. More...
 
#define I2C_SMBUS_GET_STATUS(i2c)
 To get SMBus Status. More...
 
#define I2C_SMBUS_GET_PEC_VALUE(i2c)
 Get SMBus CRC value. More...
 
#define I2C_SMBUS_SET_PACKET_BYTE_COUNT(i2c, u32PktSize)
 Set SMBus Bytes number of Transmission or reception. More...
 
#define I2C_SMBUS_ENABLE_ALERT(i2c)
 Enable SMBus Alert function. More...
 
#define I2C_SMBUS_DISABLE_ALERT(i2c)
 Disable SMBus Alert pin function. More...
 
#define I2C_SMBUS_SET_SUSCON_OUT(i2c)
 Set SMBus SUSCON pin is output mode. More...
 
#define I2C_SMBUS_SET_SUSCON_IN(i2c)
 Set SMBus SUSCON pin is input mode. More...
 
#define I2C_SMBUS_SET_SUSCON_HIGH(i2c)
 Set SMBus SUSCON pin output high state. More...
 
#define I2C_SMBUS_SET_SUSCON_LOW(i2c)
 Set SMBus SUSCON pin output low state. More...
 
#define I2C_SMBUS_ACK_MANUAL(i2c)
 Enable SMBus Acknowledge control by manual. More...
 
#define I2C_SMBUS_ACK_AUTO(i2c)
 Disable SMBus Acknowledge control by manual. More...
 
#define I2C_SMBUS_9THBIT_INT_ENABLE(i2c)
 Enable SMBus Acknowledge manual interrupt. More...
 
#define I2C_SMBUS_9THBIT_INT_DISABLE(i2c)
 Disable SMBus Acknowledge manual interrupt. More...
 
#define I2C_SMBUS_RST_PEC_AT_START_ENABLE(i2c)
 Enable SMBus PEC clear at REPEAT START. More...
 
#define I2C_SMBUS_RST_PEC_AT_START_DISABLE(i2c)
 Disable SMBus PEC clear at Repeat START. More...
 
#define I2C_ENABLE_RX_PDMA(i2c)
 Enable RX PDMA function. More...
 
#define I2C_ENABLE_TX_PDMA(i2c)
 Enable TX PDMA function. More...
 
#define I2C_DISABLE_RX_PDMA(i2c)
 Disable RX PDMA transfer. More...
 
#define I2C_DISABLE_TX_PDMA(i2c)
 Disable TX PDMA transfer. More...
 
#define I2C_ENABLE_PDMA_STRETCH(i2c)
 Enable PDMA stretch function. More...
 
#define I2C_DISABLE_PDMA_STRETCH(i2c)
 Disable PDMA stretch function. More...
 
#define I2C_DISABLE_RST_PDMA(i2c)
 Reset PDMA function. More...
 

Functions

__STATIC_INLINE void I2C_STOP (I2C_T *i2c)
 The macro is used to set STOP condition of I2C Bus. More...
 
void I2C_ClearTimeoutFlag (I2C_T *i2c)
 Clear Time-out Counter flag. More...
 
void I2C_Close (I2C_T *i2c)
 Disable specify I2C Controller. More...
 
void I2C_Trigger (I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack)
 Set Control bit of I2C Controller. More...
 
void I2C_DisableInt (I2C_T *i2c)
 Disable Interrupt of I2C Controller. More...
 
void I2C_EnableInt (I2C_T *i2c)
 Enable Interrupt of I2C Controller. More...
 
uint32_t I2C_GetBusClockFreq (I2C_T *i2c)
 Get I2C Bus Clock. More...
 
uint32_t I2C_GetIntFlag (I2C_T *i2c)
 Get Interrupt Flag. More...
 
uint32_t I2C_GetStatus (I2C_T *i2c)
 Get I2C Bus Status Code. More...
 
uint32_t I2C_Open (I2C_T *i2c, uint32_t u32BusClock)
 Enable specify I2C Controller and set Clock Divider. More...
 
uint8_t I2C_GetData (I2C_T *i2c)
 Read a Byte from I2C Bus. More...
 
void I2C_SetSlaveAddr (I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddr, uint8_t u8GCMode)
 Set 7-bit Slave Address and GC Mode. More...
 
void I2C_SetSlaveAddrMask (I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask)
 Configure the mask bits of 7-bit Slave Address. More...
 
uint32_t I2C_SetBusClockFreq (I2C_T *i2c, uint32_t u32BusClock)
 Set I2C Bus Clock. More...
 
void I2C_EnableTimeout (I2C_T *i2c, uint8_t u8LongTimeout)
 Enable Time-out Counter Function and support Long Time-out. More...
 
void I2C_DisableTimeout (I2C_T *i2c)
 Disable Time-out Counter Function. More...
 
void I2C_EnableWakeup (I2C_T *i2c)
 Enable I2C Wake-up Function. More...
 
void I2C_DisableWakeup (I2C_T *i2c)
 Disable I2C Wake-up Function. More...
 
void I2C_SetData (I2C_T *i2c, uint8_t u8Data)
 Send a byte to I2C Bus. More...
 
void I2C_SMBusClearInterruptFlag (I2C_T *i2c, uint8_t u8SMBusIntFlag)
 Clear SMBus Interrupt Flag. More...
 
uint8_t I2C_WriteByte (I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t data)
 Write a byte to Slave. More...
 
uint32_t I2C_WriteMultiBytes (I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t data[], uint32_t u32wLen)
 Write multi bytes to Slave. More...
 
uint8_t I2C_WriteByteOneReg (I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t data)
 Specify a byte register address and write a byte to Slave. More...
 
uint32_t I2C_WriteMultiBytesOneReg (I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t data[], uint32_t u32wLen)
 Specify a byte register address and write multi bytes to Slave. More...
 
uint8_t I2C_WriteByteTwoRegs (I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t data)
 Specify two bytes register address and Write a byte to Slave. More...
 
uint32_t I2C_WriteMultiBytesTwoRegs (I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t data[], uint32_t u32wLen)
 Specify two bytes register address and write multi bytes to Slave. More...
 
uint8_t I2C_ReadByte (I2C_T *i2c, uint8_t u8SlaveAddr)
 Read a byte from Slave. More...
 
uint32_t I2C_ReadMultiBytes (I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t rdata[], uint32_t u32rLen)
 Read multi bytes from Slave. More...
 
uint8_t I2C_ReadByteOneReg (I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr)
 Specify a byte register address and read a byte from Slave. More...
 
uint32_t I2C_ReadMultiBytesOneReg (I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t rdata[], uint32_t u32rLen)
 Specify a byte register address and read multi bytes from Slave. More...
 
uint8_t I2C_ReadByteTwoRegs (I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr)
 Specify two bytes register address and read a byte from Slave. More...
 
uint32_t I2C_ReadMultiBytesTwoRegs (I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t rdata[], uint32_t u32rLen)
 Specify two bytes register address and read multi bytes from Slave. More...
 
uint32_t I2C_SMBusGetStatus (I2C_T *i2c)
 To get SMBus Status. More...
 
void I2C_SMBusSetPacketByteCount (I2C_T *i2c, uint32_t u32PktSize)
 Set SMBus Bytes Counts of Transmission or Reception. More...
 
void I2C_SMBusOpen (I2C_T *i2c, uint8_t u8HostDevice)
 Init SMBus Host/Device Mode. More...
 
void I2C_SMBusClose (I2C_T *i2c)
 Disable SMBus function. More...
 
void I2C_SMBusPECTxEnable (I2C_T *i2c, uint8_t u8PECTxEn)
 Enable SMBus PEC Transmit Function. More...
 
uint8_t I2C_SMBusGetPECValue (I2C_T *i2c)
 Get SMBus CRC value. More...
 
void I2C_SMBusIdleTimeout (I2C_T *i2c, uint32_t us, uint32_t u32Hclk)
 Calculate Time-out of SMBus idle period. More...
 
void I2C_SMBusTimeout (I2C_T *i2c, uint32_t ms, uint32_t u32Pclk)
 Calculate Time-out of SMBus active period. More...
 
void I2C_SMBusClockLoTimeout (I2C_T *i2c, uint32_t ms, uint32_t u32Pclk)
 Calculate Cumulative Clock low Time-out of SMBus active period. More...
 

Detailed Description

Macro Definition Documentation

◆ I2C_CLEAR_WAKEUP_FLAG

#define I2C_CLEAR_WAKEUP_FLAG (   i2c)

To clear wake-up flag.

Parameters
[in]i2cSpecify I2C port
Returns
None

If wake-up flag is set, use this macro to clear it.

Definition at line 176 of file i2c.h.

◆ I2C_DISABLE_PDMA_STRETCH

#define I2C_DISABLE_PDMA_STRETCH (   i2c)

Disable PDMA stretch function.

Parameters
[in]i2cThe pointer of the specified I2C module.
Returns
None.

I2C will send STOP after PDMA transfers done automatically.

Definition at line 417 of file i2c.h.

◆ I2C_DISABLE_RST_PDMA

#define I2C_DISABLE_RST_PDMA (   i2c)

Reset PDMA function.

Parameters
[in]i2cThe pointer of the specified I2C module.
Returns
None.

I2C PDMA engine will be reset after this function is called.

Definition at line 426 of file i2c.h.

◆ I2C_DISABLE_RX_PDMA

#define I2C_DISABLE_RX_PDMA (   i2c)

Disable RX PDMA transfer.

Parameters
[in]i2cThe pointer of the specified I2C module.
Returns
None.

Clear RXPDMAEN bit of I2C_CTL1 register to disable RX PDMA transfer function.

Definition at line 390 of file i2c.h.

◆ I2C_DISABLE_TX_PDMA

#define I2C_DISABLE_TX_PDMA (   i2c)

Disable TX PDMA transfer.

Parameters
[in]i2cThe pointer of the specified I2C module.
Returns
None.

Clear TXPDMAEN bit of I2C_CTL1 register to disable TX PDMA transfer function.

Definition at line 399 of file i2c.h.

◆ I2C_ENABLE_PDMA_STRETCH

#define I2C_ENABLE_PDMA_STRETCH (   i2c)

Enable PDMA stretch function.

Parameters
[in]i2cThe pointer of the specified I2C module.
Returns
None.

Enable this function is to stretch bus by hardware after PDMA transfer is done if SI is not cleared.

Definition at line 408 of file i2c.h.

◆ I2C_ENABLE_RX_PDMA

#define I2C_ENABLE_RX_PDMA (   i2c)

Enable RX PDMA function.

Parameters
[in]i2cThe pointer of the specified I2C module.
Returns
None.

Set RXPDMAEN bit of I2C_CTL1 register to enable RX PDMA transfer function.

Definition at line 372 of file i2c.h.

◆ I2C_ENABLE_TX_PDMA

#define I2C_ENABLE_TX_PDMA (   i2c)

Enable TX PDMA function.

Parameters
[in]i2cThe pointer of the specified I2C module.
Returns
None.

Set TXPDMAEN bit of I2C_CTL1 register to enable TX PDMA transfer function.

Definition at line 381 of file i2c.h.

◆ I2C_GET_DATA

#define I2C_GET_DATA (   i2c)

The macro is used to Read I2C Bus Data Register.

Parameters
[in]i2cSpecify I2C port
Returns
A byte of I2C data register

I2C controller read data from bus and save it in I2CDAT register.

Definition at line 113 of file i2c.h.

◆ I2C_GET_STATUS

#define I2C_GET_STATUS (   i2c)

Get I2C Bus status code.

Parameters
[in]i2cSpecify I2C port
Returns
I2C status code

To get this status code to monitor I2C bus event.

Definition at line 138 of file i2c.h.

◆ I2C_GET_TIMEOUT_FLAG

#define I2C_GET_TIMEOUT_FLAG (   i2c)

Get Time-out flag from I2C Bus.

Parameters
[in]i2cSpecify I2C port
Return values
0I2C Bus time-out is not happened
1I2C Bus time-out is happened

When I2C bus occurs time-out event, the time-out flag will be set.

Definition at line 151 of file i2c.h.

◆ I2C_GET_WAKEUP_FLAG

#define I2C_GET_WAKEUP_FLAG (   i2c)

To get wake-up flag from I2C Bus.

Parameters
[in]i2cSpecify I2C port
Return values
0Chip is not woken-up from power-down mode
1Chip is woken-up from power-down mode

I2C bus occurs wake-up event, wake-up flag will be set.

Definition at line 164 of file i2c.h.

◆ I2C_SET_CONTROL_REG

#define I2C_SET_CONTROL_REG (   i2c,
  u8Ctrl 
)

The macro is used to set I2C bus condition at One Time.

Parameters
[in]i2cSpecify I2C port
[in]u8CtrlA byte writes to I2C control register
Returns
None

Set I2C_CTL register to control I2C bus conditions of START, STOP, SI, ACK.

Definition at line 77 of file i2c.h.

◆ I2C_SET_DATA

#define I2C_SET_DATA (   i2c,
  u8Data 
)

Write a Data to I2C Data Register.

Parameters
[in]i2cSpecify I2C port
[in]u8DataA byte that writes to data register
Returns
None

When write a data to I2C_DAT register, the I2C controller will shift it to I2C bus.

Definition at line 126 of file i2c.h.

◆ I2C_SMBUS_9THBIT_INT_DISABLE

#define I2C_SMBUS_9THBIT_INT_DISABLE (   i2c)

Disable SMBus Acknowledge manual interrupt.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function is used to disable SMBUS acknowledge manual interrupt on the 9th clock cycle when SMBUS=1 and ACKMEN=1

Definition at line 339 of file i2c.h.

◆ I2C_SMBUS_9THBIT_INT_ENABLE

#define I2C_SMBUS_9THBIT_INT_ENABLE (   i2c)

Enable SMBus Acknowledge manual interrupt.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function is used to enable SMBUS acknowledge manual interrupt on the 9th clock cycle when SMBUS=1 and ACKMEN=1

Definition at line 327 of file i2c.h.

◆ I2C_SMBUS_ACK_AUTO

#define I2C_SMBUS_ACK_AUTO (   i2c)

Disable SMBus Acknowledge control by manual.

Parameters
[in]i2cSpecify I2C port
Returns
None

Disable acknowledge response control by user.

Definition at line 315 of file i2c.h.

◆ I2C_SMBUS_ACK_MANUAL

#define I2C_SMBUS_ACK_MANUAL (   i2c)

Enable SMBus Acknowledge control by manual.

Parameters
[in]i2cSpecify I2C port
Returns
None

The 9th bit can response the ACK or NACK according the received data by user. When the byte is received, SCLK line stretching to low between the 8th and 9th SCLK pulse.

Definition at line 303 of file i2c.h.

◆ I2C_SMBUS_DISABLE_ALERT

#define I2C_SMBUS_DISABLE_ALERT (   i2c)

Disable SMBus Alert pin function.

Parameters
[in]i2cSpecify I2C port
Returns
None

Device Mode(BMHEN=0): If ALERTEN(I2C_BUSCTL[4]) is clear, the Alert pin will pull hi, and reply NACK when get ARP from host Host Mode(BMHEN=1): If ALERTEN(I2C_BUSCTL[4]) is clear, the Alert pin is not supported to receive alert state(Lo trigger)

Definition at line 240 of file i2c.h.

◆ I2C_SMBUS_ENABLE_ALERT

#define I2C_SMBUS_ENABLE_ALERT (   i2c)

Enable SMBus Alert function.

Parameters
[in]i2cSpecify I2C port
Returns
None

Device Mode(BMHEN=0): If ALERTEN(I2C_BUSCTL[4]) is set, the Alert pin will pull lo, and reply ACK when get ARP from host Host Mode(BMHEN=1): If ALERTEN(I2C_BUSCTL[4]) is set, the Alert pin is supported to receive alert state(Lo trigger)

Definition at line 227 of file i2c.h.

◆ I2C_SMBUS_GET_PEC_VALUE

#define I2C_SMBUS_GET_PEC_VALUE (   i2c)

Get SMBus CRC value.

Parameters
[in]i2cSpecify I2C port
Returns
Packet error check byte value

The CRC check value after a transmission or a reception by count by using CRC8

Definition at line 201 of file i2c.h.

◆ I2C_SMBUS_GET_STATUS

#define I2C_SMBUS_GET_STATUS (   i2c)

To get SMBus Status.

Parameters
[in]i2cSpecify I2C port
Returns
SMBus status

To get the Bus Management status of I2C_BUSSTS register

Definition at line 189 of file i2c.h.

◆ I2C_SMBUS_RST_PEC_AT_START_DISABLE

#define I2C_SMBUS_RST_PEC_AT_START_DISABLE (   i2c)

Disable SMBus PEC clear at Repeat START.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function is used to disable the condition of Repeat START can clear the PEC calculation.

Definition at line 363 of file i2c.h.

◆ I2C_SMBUS_RST_PEC_AT_START_ENABLE

#define I2C_SMBUS_RST_PEC_AT_START_ENABLE (   i2c)

Enable SMBus PEC clear at REPEAT START.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function is used to enable the condition of REAEAT START can clear the PEC calculation.

Definition at line 351 of file i2c.h.

◆ I2C_SMBUS_SET_PACKET_BYTE_COUNT

#define I2C_SMBUS_SET_PACKET_BYTE_COUNT (   i2c,
  u32PktSize 
)

Set SMBus Bytes number of Transmission or reception.

Parameters
[in]i2cSpecify I2C port
[in]u32PktSizeTransmit / Receive bytes
Returns
None

The transmission or receive byte number in one transaction when PECEN is set. The maximum is 255 bytes.

Definition at line 214 of file i2c.h.

◆ I2C_SMBUS_SET_SUSCON_HIGH

#define I2C_SMBUS_SET_SUSCON_HIGH (   i2c)

Set SMBus SUSCON pin output high state.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function to set SUSCON(I2C_BUSCTL[6]) pin is output hi state.

Definition at line 278 of file i2c.h.

◆ I2C_SMBUS_SET_SUSCON_IN

#define I2C_SMBUS_SET_SUSCON_IN (   i2c)

Set SMBus SUSCON pin is input mode.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function to set SUSCON(I2C_BUSCTL[6]) pin is input mode.

Definition at line 266 of file i2c.h.

◆ I2C_SMBUS_SET_SUSCON_LOW

#define I2C_SMBUS_SET_SUSCON_LOW (   i2c)

Set SMBus SUSCON pin output low state.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function to set SUSCON(I2C_BUSCTL[6]) pin is output lo state.

Definition at line 291 of file i2c.h.

◆ I2C_SMBUS_SET_SUSCON_OUT

#define I2C_SMBUS_SET_SUSCON_OUT (   i2c)

Set SMBus SUSCON pin is output mode.

Parameters
[in]i2cSpecify I2C port
Returns
None

This function to set SUSCON(I2C_BUSCTL[6]) pin is output mode.

Definition at line 253 of file i2c.h.

◆ I2C_START

#define I2C_START (   i2c)

The macro is used to set START condition of I2C Bus.

Parameters
[in]i2cSpecify I2C port
Returns
None

Set the I2C bus START condition in I2C_CTL register.

Definition at line 89 of file i2c.h.

◆ I2C_WAIT_READY

#define I2C_WAIT_READY (   i2c)

The macro is used to wait I2C bus status get ready.

Parameters
[in]i2cSpecify I2C port
Returns
None

When a new status is presented of I2C bus, the SI flag will be set in I2C_CTL register.

Definition at line 101 of file i2c.h.

Function Documentation

◆ I2C_ClearTimeoutFlag()

void I2C_ClearTimeoutFlag ( I2C_T i2c)

Clear Time-out Counter flag.

Parameters
[in]i2cSpecify I2C port
Returns
None

When Time-out flag will be set, use this function to clear I2C Bus Time-out counter flag .

Definition at line 105 of file i2c.c.

◆ I2C_Close()

void I2C_Close ( I2C_T i2c)

Disable specify I2C Controller.

Parameters
[in]i2cSpecify I2C port
Returns
None

Reset I2C Controller and disable specify I2C port.

Definition at line 72 of file i2c.c.

◆ I2C_DisableInt()

void I2C_DisableInt ( I2C_T i2c)

Disable Interrupt of I2C Controller.

Parameters
[in]i2cSpecify I2C port
Returns
None

The function is used for disable I2C interrupt

Definition at line 161 of file i2c.c.

◆ I2C_DisableTimeout()

void I2C_DisableTimeout ( I2C_T i2c)

Disable Time-out Counter Function.

Parameters
[in]i2cSpecify I2C port
Returns
None

To disable Time-out Counter function in I2CTOC register.

Definition at line 407 of file i2c.c.

◆ I2C_DisableWakeup()

void I2C_DisableWakeup ( I2C_T i2c)

Disable I2C Wake-up Function.

Parameters
[in]i2cSpecify I2C port
Returns
None

To disable Wake-up function of I2C Wake-up control register.

Definition at line 437 of file i2c.c.

◆ I2C_EnableInt()

void I2C_EnableInt ( I2C_T i2c)

Enable Interrupt of I2C Controller.

Parameters
[in]i2cSpecify I2C port
Returns
None

The function is used for enable I2C interrupt

Definition at line 176 of file i2c.c.

◆ I2C_EnableTimeout()

void I2C_EnableTimeout ( I2C_T i2c,
uint8_t  u8LongTimeout 
)

Enable Time-out Counter Function and support Long Time-out.

Parameters
[in]i2cSpecify I2C port
[in]u8LongTimeoutConfigure DIV4 to enable Long Time-out (0/1)
Returns
None

This function enable Time-out Counter function and configure DIV4 to support Long Time-out.

Definition at line 383 of file i2c.c.

◆ I2C_EnableWakeup()

void I2C_EnableWakeup ( I2C_T i2c)

Enable I2C Wake-up Function.

Parameters
[in]i2cSpecify I2C port
Returns
None

To enable Wake-up function of I2C Wake-up control register.

Definition at line 422 of file i2c.c.

◆ I2C_GetBusClockFreq()

uint32_t I2C_GetBusClockFreq ( I2C_T i2c)

Get I2C Bus Clock.

Parameters
[in]i2cSpecify I2C port
Returns
The actual I2C Bus clock in Hz

To get the actual I2C Bus Clock frequency.

Definition at line 190 of file i2c.c.

◆ I2C_GetData()

uint8_t I2C_GetData ( I2C_T i2c)

Read a Byte from I2C Bus.

Parameters
[in]i2cSpecify I2C port
Returns
I2C Data

To read a bytes data from specify I2C port.

Definition at line 285 of file i2c.c.

◆ I2C_GetIntFlag()

uint32_t I2C_GetIntFlag ( I2C_T i2c)

Get Interrupt Flag.

Parameters
[in]i2cSpecify I2C port
Returns
I2C interrupt flag status

To get I2C Bus interrupt flag.

Definition at line 246 of file i2c.c.

◆ I2C_GetStatus()

uint32_t I2C_GetStatus ( I2C_T i2c)

Get I2C Bus Status Code.

Parameters
[in]i2cSpecify I2C port
Returns
I2C Status Code

To get I2C Bus Status Code.

Definition at line 271 of file i2c.c.

◆ I2C_Open()

uint32_t I2C_Open ( I2C_T i2c,
uint32_t  u32BusClock 
)

Enable specify I2C Controller and set Clock Divider.

Parameters
[in]i2cSpecify I2C port
[in]u32BusClockThe target I2C bus clock in Hz
Returns
Actual I2C bus clock frequency

The function enable the specify I2C Controller and set proper Clock Divider in I2C CLOCK DIVIDED REGISTER (I2CLK) according to the target I2C Bus clock. I2C Bus clock = PCLK / (4*(divider+1).

Definition at line 38 of file i2c.c.

◆ I2C_ReadByte()

uint8_t I2C_ReadByte ( I2C_T i2c,
uint8_t  u8SlaveAddr 
)

Read a byte from Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
Returns
Read a byte data from Slave

The function is used for I2C Master to read a byte data from Slave.

Definition at line 1129 of file i2c.c.

◆ I2C_ReadByteOneReg()

uint8_t I2C_ReadByteOneReg ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint8_t  u8DataAddr 
)

Specify a byte register address and read a byte from Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u8DataAddrSpecify a address(1 byte) of data read from
Returns
Read a byte data from Slave

The function is used for I2C Master specify a byte address that a data byte read from Slave.

Definition at line 1274 of file i2c.c.

◆ I2C_ReadByteTwoRegs()

uint8_t I2C_ReadByteTwoRegs ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint16_t  u16DataAddr 
)

Specify two bytes register address and read a byte from Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u16DataAddrSpecify an address(2 bytes) of data read from
Returns
Read a byte data from Slave

The function is used for I2C Master specify two bytes address that a data byte read from Slave.

Definition at line 1448 of file i2c.c.

◆ I2C_ReadMultiBytes()

uint32_t I2C_ReadMultiBytes ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint8_t  rdata[],
uint32_t  u32rLen 
)

Read multi bytes from Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[out]rdata[]A data array to store data from Slave
[in]u32rLenHow many bytes need to read from Slave
Returns
A length of how many bytes have been received

The function is used for I2C Master to read multi data bytes from Slave.

Definition at line 1198 of file i2c.c.

◆ I2C_ReadMultiBytesOneReg()

uint32_t I2C_ReadMultiBytesOneReg ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint8_t  u8DataAddr,
uint8_t  rdata[],
uint32_t  u32rLen 
)

Specify a byte register address and read multi bytes from Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u8DataAddrSpecify a address (1 bytes) of data read from
[out]rdata[]A data array to store data from Slave
[in]u32rLenHow many bytes need to read from Slave
Returns
A length of how many bytes have been received

The function is used for I2C Master specify a byte address that multi data bytes read from Slave.

Definition at line 1358 of file i2c.c.

◆ I2C_ReadMultiBytesTwoRegs()

uint32_t I2C_ReadMultiBytesTwoRegs ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint16_t  u16DataAddr,
uint8_t  rdata[],
uint32_t  u32rLen 
)

Specify two bytes register address and read multi bytes from Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u16DataAddrSpecify a address (2 bytes) of data read from
[out]rdata[]A data array to store data from Slave
[in]u32rLenHow many bytes need to read from Slave
Returns
A length of how many bytes have been received

The function is used for I2C Master specify two bytes address that multi data bytes read from Slave.

Definition at line 1540 of file i2c.c.

◆ I2C_SetBusClockFreq()

uint32_t I2C_SetBusClockFreq ( I2C_T i2c,
uint32_t  u32BusClock 
)

Set I2C Bus Clock.

Parameters
[in]i2cSpecify I2C port
[in]u32BusClockThe target I2C Bus Clock in Hz
Returns
The actual I2C Bus Clock in Hz

To set the actual I2C Bus Clock frequency.

Definition at line 217 of file i2c.c.

◆ I2C_SetData()

void I2C_SetData ( I2C_T i2c,
uint8_t  u8Data 
)

Send a byte to I2C Bus.

Parameters
[in]i2cSpecify I2C port
[in]u8DataThe data to send to I2C bus
Returns
None

This function is used to write a byte to specified I2C port

Definition at line 300 of file i2c.c.

◆ I2C_SetSlaveAddr()

void I2C_SetSlaveAddr ( I2C_T i2c,
uint8_t  u8SlaveNo,
uint8_t  u8SlaveAddr,
uint8_t  u8GCMode 
)

Set 7-bit Slave Address and GC Mode.

Parameters
[in]i2cSpecify I2C port
[in]u8SlaveNoSet the number of I2C address register (0~3)
[in]u8SlaveAddr7-bit slave address
[in]u8GCModeEnable/Disable GC mode (I2C_GCMODE_ENABLE / I2C_GCMODE_DISABLE)
Returns
None

This function is used to set 7-bit slave addresses in I2C SLAVE ADDRESS REGISTER (I2CADDR0~3) and enable GC Mode.

Definition at line 319 of file i2c.c.

◆ I2C_SetSlaveAddrMask()

void I2C_SetSlaveAddrMask ( I2C_T i2c,
uint8_t  u8SlaveNo,
uint8_t  u8SlaveAddrMask 
)

Configure the mask bits of 7-bit Slave Address.

Parameters
[in]i2cSpecify I2C port
[in]u8SlaveNoSet the number of I2C address mask register (0~3)
[in]u8SlaveAddrMaskA byte for slave address mask
Returns
None

This function is used to set 7-bit slave addresses.

Definition at line 351 of file i2c.c.

◆ I2C_SMBusClearInterruptFlag()

void I2C_SMBusClearInterruptFlag ( I2C_T i2c,
uint8_t  u8SMBusIntFlag 
)

Clear SMBus Interrupt Flag.

Parameters
[in]i2cSpecify I2C port
[in]u8SMBusIntFlagSpecify SMBus interrupt flag
Returns
None

To clear flags of I2C_BUSSTS status register if interrupt set.

Definition at line 468 of file i2c.c.

◆ I2C_SMBusClockLoTimeout()

void I2C_SMBusClockLoTimeout ( I2C_T i2c,
uint32_t  ms,
uint32_t  u32Pclk 
)

Calculate Cumulative Clock low Time-out of SMBus active period.

Parameters
[in]i2cSpecify I2C port
[in]msTime-out length(ms)
[in]u32Pclkperipheral clock frequency
Returns
None

This function is used to set SMBus Time-out length when bus is in Active state. Time-out length is calculate the SCL line "clocks" low cumulative timing.

Definition at line 653 of file i2c.c.

◆ I2C_SMBusClose()

void I2C_SMBusClose ( I2C_T i2c)

Disable SMBus function.

Parameters
[in]i2cSpecify I2C port
Returns
None

Disable all SMBus function include Bus disable, CRC check, Acknowledge by manual, Host/Device Mode.

Definition at line 526 of file i2c.c.

◆ I2C_SMBusGetPECValue()

uint8_t I2C_SMBusGetPECValue ( I2C_T i2c)

Get SMBus CRC value.

Parameters
[in]i2cSpecify I2C port
Returns
A byte is packet error check value

The CRC check value after a transmission or a reception by count by using CRC8

Definition at line 567 of file i2c.c.

◆ I2C_SMBusGetStatus()

uint32_t I2C_SMBusGetStatus ( I2C_T i2c)

To get SMBus Status.

Parameters
[in]i2cSpecify I2C port
Returns
SMBus status

To get the Bus Management status of I2C_BUSSTS register

Definition at line 452 of file i2c.c.

◆ I2C_SMBusIdleTimeout()

void I2C_SMBusIdleTimeout ( I2C_T i2c,
uint32_t  us,
uint32_t  u32Hclk 
)

Calculate Time-out of SMBus idle period.

Parameters
[in]i2cSpecify I2C port
[in]usTime-out length(us)
[in]u32HclkI2C peripheral clock frequency
Returns
None

This function is used to set SMBus Time-out length when bus is in Idle state.

Definition at line 585 of file i2c.c.

◆ I2C_SMBusOpen()

void I2C_SMBusOpen ( I2C_T i2c,
uint8_t  u8HostDevice 
)

Init SMBus Host/Device Mode.

Parameters
[in]i2cSpecify I2C port
[in]u8HostDeviceInit SMBus port mode(I2C_SMBH_ENABLE(1)/I2C_SMBD_ENABLE(0))
Returns
None

Using SMBus communication must specify the port is a Host or a Device.

Definition at line 500 of file i2c.c.

◆ I2C_SMBusPECTxEnable()

void I2C_SMBusPECTxEnable ( I2C_T i2c,
uint8_t  u8PECTxEn 
)

Enable SMBus PEC Transmit Function.

Parameters
[in]i2cSpecify I2C port
[in]u8PECTxEnCRC transmit enable(PECTX_ENABLE) or disable(PECTX_DISABLE)
Returns
None

When enable CRC check function, the Host or Device needs to transmit CRC byte.

Definition at line 543 of file i2c.c.

◆ I2C_SMBusSetPacketByteCount()

void I2C_SMBusSetPacketByteCount ( I2C_T i2c,
uint32_t  u32PktSize 
)

Set SMBus Bytes Counts of Transmission or Reception.

Parameters
[in]i2cSpecify I2C port
[in]u32PktSizeTransmit / Receive bytes
Returns
None

The transmission or receive byte number in one transaction when PECEN is set. The maximum is 255 bytes.

Definition at line 484 of file i2c.c.

◆ I2C_SMBusTimeout()

void I2C_SMBusTimeout ( I2C_T i2c,
uint32_t  ms,
uint32_t  u32Pclk 
)

Calculate Time-out of SMBus active period.

Parameters
[in]i2cSpecify I2C port
[in]msTime-out length(ms)
[in]u32Pclkperipheral clock frequency
Returns
None

This function is used to set SMBus Time-out length when bus is in active state. Time-out length is calculate the SCL line "one clock" pull low timing.

Definition at line 617 of file i2c.c.

◆ I2C_STOP()

__STATIC_INLINE void I2C_STOP ( I2C_T i2c)

The macro is used to set STOP condition of I2C Bus.

Parameters
[in]i2cSpecify I2C port
Returns
None

Set the I2C bus STOP condition in I2C_CTL register.

Definition at line 444 of file i2c.h.

◆ I2C_Trigger()

void I2C_Trigger ( I2C_T i2c,
uint8_t  u8Start,
uint8_t  u8Stop,
uint8_t  u8Si,
uint8_t  u8Ack 
)

Set Control bit of I2C Controller.

Parameters
[in]i2cSpecify I2C port
[in]u8StartSet I2C START condition
[in]u8StopSet I2C STOP condition
[in]u8SiClear SI flag
[in]u8AckSet I2C ACK bit
Returns
None

The function set I2C Control bit of I2C Bus protocol.

Definition at line 124 of file i2c.c.

◆ I2C_WriteByte()

uint8_t I2C_WriteByte ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint8_t  data 
)

Write a byte to Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]dataWrite a byte data to Slave
Return values
0Write data success
1Write data fail, or bus occurs error events, or write timeout

The function is used for I2C Master write a byte data to Slave.

Definition at line 690 of file i2c.c.

◆ I2C_WriteByteOneReg()

uint8_t I2C_WriteByteOneReg ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint8_t  u8DataAddr,
uint8_t  data 
)

Specify a byte register address and write a byte to Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u8DataAddrSpecify a address (1 byte) of data write to
[in]dataA byte data to write it to Slave
Return values
0Write data success
1Write data fail, or bus occurs error events

The function is used for I2C Master specify a address that data write to in Slave.

Definition at line 826 of file i2c.c.

◆ I2C_WriteByteTwoRegs()

uint8_t I2C_WriteByteTwoRegs ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint16_t  u16DataAddr,
uint8_t  data 
)

Specify two bytes register address and Write a byte to Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u16DataAddrSpecify a address (2 byte) of data write to
[in]dataWrite a byte data to Slave
Return values
0Write data success
1Write data fail, or bus occurs error events

The function is used for I2C Master specify two bytes address that data write to in Slave.

Definition at line 975 of file i2c.c.

◆ I2C_WriteMultiBytes()

uint32_t I2C_WriteMultiBytes ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint8_t  data[],
uint32_t  u32wLen 
)

Write multi bytes to Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]*dataPointer to array to write data to Slave
[in]u32wLenHow many bytes need to write to Slave
Returns
A length of how many bytes have been transmitted.

The function is used for I2C Master write multi bytes data to Slave.

Definition at line 755 of file i2c.c.

◆ I2C_WriteMultiBytesOneReg()

uint32_t I2C_WriteMultiBytesOneReg ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint8_t  u8DataAddr,
uint8_t  data[],
uint32_t  u32wLen 
)

Specify a byte register address and write multi bytes to Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u8DataAddrSpecify a address (1 byte) of data write to
[in]*dataPointer to array to write data to Slave
[in]u32wLenHow many bytes need to write to Slave
Returns
A length of how many bytes have been transmitted.

The function is used for I2C Master specify a byte address that multi data bytes write to in Slave.

Definition at line 901 of file i2c.c.

◆ I2C_WriteMultiBytesTwoRegs()

uint32_t I2C_WriteMultiBytesTwoRegs ( I2C_T i2c,
uint8_t  u8SlaveAddr,
uint16_t  u16DataAddr,
uint8_t  data[],
uint32_t  u32wLen 
)

Specify two bytes register address and write multi bytes to Slave.

Parameters
[in]*i2cPoint to I2C peripheral
[in]u8SlaveAddrAccess Slave address(7-bit)
[in]u16DataAddrSpecify a address (2 bytes) of data write to
[in]data[]A data array for write data to Slave
[in]u32wLenHow many bytes need to write to Slave
Returns
A length of how many bytes have been transmitted.

The function is used for I2C Master specify a byte address that multi data write to in Slave.

Definition at line 1055 of file i2c.c.