CoX Peripheral Interface(M051 Implement) V2.1.1.0
API Reference
M051 I2C API
Collaboration diagram for M051 I2C API:

Functions

void I2CMasterInit (unsigned long ulBase, unsigned long ulI2CClk)
 Set the clock rate of the specified I2C port.
xtBoolean I2CMasterTransfer (unsigned long ulBase, tI2CMasterTransferCfg *tCfg, unsigned long ulOption)
 Transmit and Receive data in master mode of the specified I2C port.
xtBoolean I2CSlaveTransfer (unsigned long ulBase, tI2CSlaveTransferCfg *tCfg, unsigned long ulOption)
 Transmit and Receive data in slave mode of the specified I2C port.
xtBoolean I2CMasterTransferComplete (unsigned long ulBase)
 Check Transfer of Master is complete or not.
xtBoolean I2CSlaveTransferComplete (unsigned long ulBase)
 Check Slave of Master is complete or not.
void I2CMasterHandler (unsigned long ulBase)
 General Master Interrupt handler for I2C peripheral.
void I2CSlaveHandler (unsigned long ulBase)
 General slave Interrupt handler for I2C peripheral.
void I2CIntCallbackInit (unsigned long ulBase, xtEventCallback xtI2CCallback)
 initialize interrupts callback for the specified Port.
void I2CDisable (unsigned long ulBase)
 Disable I2C module of the specified I2C port.
void I2CEnable (unsigned long ulBase)
 Enable I2C module of the specified I2C port.
unsigned long I2CStatusGet (unsigned long ulBase)
 Get I2C status of the specified I2C port.
void I2CSlaveInit (unsigned long ulBase, unsigned char ucSlaveAddr, unsigned long ulGeneralCall)
 Set the clock rate of the specified I2C port.
void I2CSlaveOwnAddressSet (unsigned long ulBase, unsigned char ucSlaveNum, unsigned char ucSlaveAddr, unsigned long ulGeneralCall)
 Set the slave address of the specified I2C port.
void I2CSlaveOwnAddressMaskSet (unsigned long ulBase, unsigned char ucSlaveNum, unsigned char ucSlaveAddrMask)
 Set 4 7-bit slave address mask of the specified I2C port.
void I2CIntFlagClear (unsigned long ulBase)
 Clear the I2C interrupt flag of the specified I2C port.
void I2CTimeoutFlagClear (unsigned long ulBase)
 Clear the I2C time out flag of the specified I2C port.
void I2CTimeoutCounterSet (unsigned long ulBase, unsigned long ulEnable, unsigned long ulDiv4)
 Enable/Disable I2C 14-bit timeout counter of the specified I2C port.
xtBoolean I2CIntFlagGet (unsigned long ulBase)
 Get the I2C interrupt flag of the specified I2C port.
xtBoolean I2CTimeoutFlagGet (unsigned long ulBase)
 Get the I2C time out flag of the specified I2C port.
void I2CIntDisable (unsigned long ulBase)
 Disable I2C interrupt of the specified I2C port.
void I2CIntEnable (unsigned long ulBase)
 Enable I2C interrupt of the specified I2C port.

Function Documentation

void I2CMasterInit ( unsigned long  ulBase,
unsigned long  ulI2CClk 
)

Set the clock rate of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.
ulI2CClkspecifies the I2C clock rate.

This function is to initialize and set the clock rate specified I2C port.

The ulBase must be:I2C0_BASE.

The ulI2CClk is the I2C clock rate.

Note:
This is only for master
Returns:
None.

Definition at line 924 of file xi2c.c.

References I2C0_BASE, I2C_CON_ENS1, I2C_O_CLK, I2C_O_CON, SYSCTL_PERIPH_I2C0, SysCtlHClockGet(), SysCtlPeripheralReset(), xASSERT, and xHWREG.

Here is the call graph for this function:

xtBoolean I2CMasterTransfer ( unsigned long  ulBase,
tI2CMasterTransferCfg tCfg,
unsigned long  ulOption 
)

Transmit and Receive data in master mode of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.
tCfgspecifies Pointer to a I2C_M_SETUP_Type structure that contains specified information about the configuration for master transfer.
ulOptionspecifies interrupt or polling mode.

This function is to Transmit and Receive data in master mode of specified I2C port.

The ulBase must be: I2C0_BASE.

The tCfg is the I2C Master transfer setup data structure

Note:
This is only for master In case of using I2C to receive data only, either transmit length set to 0 or transmit data pointer set to NULL. In case of using I2C to transmit data only, either receive length set to 0 or receive data pointer set to NULL. In case of using I2C to transmit followed by receive data, transmit length, transmit data pointer, receive length and receive data pointer should be set corresponding.
Returns:
Master transfer , could be:xtrue master transfer successfully xfalse master transfer not transfer successfully

Definition at line 980 of file xi2c.c.

References I2C0_BASE, I2C_CON_SI, I2C_CON_STA, I2C_I2STAT_M_RX_DAT_ACK, I2C_I2STAT_M_RX_DAT_NACK, I2C_I2STAT_M_RX_SLAR_ACK, I2C_I2STAT_M_TX_DAT_ACK, I2C_I2STAT_M_TX_RESTART, I2C_I2STAT_M_TX_SLAW_ACK, I2C_I2STAT_M_TX_START, I2C_O_CON, I2C_TRANSFER_INTERRUPT, I2C_TRANSFER_POLLING, I2CIntEnable(), tI2CMasterTransferCfg::pvRBuf, tI2CMasterTransferCfg::pvWBuf, tI2CConfig::ulDir, tI2CMasterTransferCfg::ulRCount, tI2CMasterTransferCfg::ulRLen, tI2CConfig::ulSetup, tI2CMasterTransferCfg::ulSlave, tI2CMasterTransferCfg::ulWCount, tI2CMasterTransferCfg::ulWLen, xASSERT, xfalse, xHWREG, and xtrue.

Here is the call graph for this function:

xtBoolean I2CSlaveTransfer ( unsigned long  ulBase,
tI2CSlaveTransferCfg tCfg,
unsigned long  ulOption 
)

Transmit and Receive data in slave mode of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.
tCfgspecifies Pointer to a I2C_M_SETUP_Type structure that contains specified information about the configuration for slave transfer.
ulOptionspecifies interrupt or polling mode.

This function is to Transmit and Receive data in slave mode of specified I2C port.

The ulBase must be:I2C0_BASE.

The tCfg is the I2C slave transfer setup data structure definitions.

Note:
this is only for slave In case of using I2C to receive data only, either transmit length set to 0 or transmit data pointer set to NULL. In case of using I2C to transmit data only, either receive length set to 0 or receive data pointer set to NULL. In case of using I2C to transmit followed by receive data, transmit length, transmit data pointer, receive length and receive data pointer should be set corresponding.
Returns:
Slave transfer, could be:xtrue Slave transfer successfully xfalse Slave transfer not transfer successfully

Definition at line 1307 of file xi2c.c.

References I2C0_BASE, I2C_CON_AA, I2C_CON_SI, I2C_I2STAT_NO_INF, I2C_I2STAT_S_RX_GENCALL_ACK, I2C_I2STAT_S_RX_PRE_GENCALL_DAT_ACK, I2C_I2STAT_S_RX_PRE_GENCALL_DAT_NACK, I2C_I2STAT_S_RX_PRE_SLA_DAT_ACK, I2C_I2STAT_S_RX_PRE_SLA_DAT_NACK, I2C_I2STAT_S_RX_SLAW_ACK, I2C_I2STAT_S_RX_STA_STO_SLVREC_SLVTRX, I2C_I2STAT_S_TX_DAT_ACK, I2C_I2STAT_S_TX_DAT_NACK, I2C_I2STAT_S_TX_SLAR_ACK, I2C_O_CON, I2C_O_DAT, I2C_O_STATUS, I2C_STATUS_M, I2C_TRANSFER_INTERRUPT, I2C_TRANSFER_POLLING, I2CIntEnable(), tI2CSlaveTransferCfg::pvRBuf, tI2CSlaveTransferCfg::pvWBuf, tI2CConfig::ulDir, tI2CSlaveTransferCfg::ulRCount, tI2CSlaveTransferCfg::ulRLen, tI2CConfig::ulSetup, tI2CSlaveTransferCfg::ulWCount, tI2CSlaveTransferCfg::ulWLen, xASSERT, xfalse, xHWREG, and xtrue.

Here is the call graph for this function:

xtBoolean I2CMasterTransferComplete ( unsigned long  ulBase)

Check Transfer of Master is complete or not.

Parameters:
ulBasespecifies the I2C module base address.

This function is to get status of Master Transfer

The ulBase must be:I2C0_BASE.

Note:
This is only for master.
Returns:
Master transfer status, could be:xtrue master transfer completed, xfalse master transfer have not completed yet

Definition at line 1192 of file xi2c.c.

References xfalse.

xtBoolean I2CSlaveTransferComplete ( unsigned long  ulBase)

Check Slave of Master is complete or not.

Parameters:
ulBasespecifies the I2C module base address.

This function is to get status of slave Transfer

The ulBase must be:I2C0_BASE.

Note:
this is only for slave
Returns:
Slave transfer status, could be:xtrue slave transfer completed, xfalse slave transfer have not completed yet

Definition at line 1219 of file xi2c.c.

References xfalse.

void I2CMasterHandler ( unsigned long  ulBase)
void I2CSlaveHandler ( unsigned long  ulBase)
void I2CIntCallbackInit ( unsigned long  ulBase,
xtEventCallback  xtI2CCallback 
)

initialize interrupts callback for the specified Port.

Parameters:
ulPortis the base address of the I2C port.
xtI2CCallbackis callback for the specified Port.

Initialize interrupts callback for the specified Port.

Returns:
None.

Definition at line 1779 of file xi2c.c.

References I2C0_BASE, and xASSERT.

void I2CDisable ( unsigned long  ulBase)

Disable I2C module of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to disable I2C module of the specified I2C port.

The ulBase must be:I2C0_BASE.

Returns:
None.

Definition at line 1853 of file xi2c.c.

References I2C0_BASE, I2C_CON_ENS1, I2C_O_CON, xASSERT, and xHWREG.

Referenced by I2CMasterHandler().

void I2CEnable ( unsigned long  ulBase)

Enable I2C module of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to enable I2C module of the specified I2C port.

The ulBase must be:I2C0_BASE.

Returns:
None.

Definition at line 1829 of file xi2c.c.

References I2C0_BASE, I2C_CON_ENS1, I2C_O_CON, xASSERT, and xHWREG.

unsigned long I2CStatusGet ( unsigned long  ulBase)

Get I2C status of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to get I2C status of the specified I2C port. There are 26 status codes. Please refer to xi2c.h M051_I2C_STATUS_Type in detail.

The ulBase must be:I2C0_BASE.

Returns:
I2C status.

Definition at line 1685 of file xi2c.c.

References I2C0_BASE, I2C_O_STATUS, I2C_STATUS_M, xASSERT, and xHWREG.

void I2CSlaveInit ( unsigned long  ulBase,
unsigned char  ucSlaveAddr,
unsigned long  ulGeneralCall 
)

Set the clock rate of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.
ucSlaveAddrspecifies the slave address.
ulGeneralCallspecifies enable General Call function or not.

This function is to Set 4 7-bit slave addresses and enable General Call function of specified I2C port.

The ulBase must be:I2C0_BASE.

The ucSlaveAddr is the I2C slave address,There are 4 slave addrss. The ucSlaveAddr can be a 7-bit value.

The ulGeneralCall is to enable the General Call function or not. The ulGeneralCall can be one of the following values: I2C_GENERAL_CALL_EN,I2C_GENERAL_CALL_DIS.

Note:
this is only for slave
Returns:
None.

Definition at line 1254 of file xi2c.c.

References I2C0_BASE, I2C_CON_AA, I2C_CON_ENS1, I2C_O_ADDR0, I2C_O_CON, SYSCTL_PERIPH_I2C0, SysCtlPeripheralReset(), xASSERT, and xHWREG.

Here is the call graph for this function:

void I2CSlaveOwnAddressSet ( unsigned long  ulBase,
unsigned char  ucSlaveNum,
unsigned char  ucSlaveAddr,
unsigned long  ulGeneralCall 
)

Set the slave address of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.
ucSlaveNumspecifies the salve address number.
ucSlaveAddrspecifies the slave address.
ulGeneralCallspecifies enable General Call function or not.

This function is to Set 4 7-bit slave addresses and enable General Call function of specified I2C port.

The ulBase must be:I2C0_BASE.

The ucSlaveNum is the I2C slave address number,There are 4 slave addrss,so The ucSlaveNum can be: 0, 1, 2, 3.

The ucSlaveAddr is the I2C slave address,There are 4 slave addrss. The ucSlaveAddr can be a 7-bit value.

The ulGeneralCall is to enable the General Call function or not. The ulGeneralCall can be one of the following values: I2C_GENERAL_CALL_EN,I2C_GENERAL_CALL_DIS.

Note:
this is only for slave
Returns:
None.

Definition at line 1597 of file xi2c.c.

References I2C0_BASE, I2C_GENERAL_CALL_DIS, I2C_GENERAL_CALL_EN, xASSERT, and xHWREG.

void I2CSlaveOwnAddressMaskSet ( unsigned long  ulBase,
unsigned char  ucSlaveNum,
unsigned char  ucSlaveAddrMask 
)

Set 4 7-bit slave address mask of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.
ucSlaveNumspecifies the salve address number.
ucSlaveAddrMaskspecifies the slave address mask.

This function is to Set 4 7-bit slave address mask of specified I2C port.The corresponding address bit is "Don't Care"

The ulBase must be:I2C0_BASE.

The ucSlaveNum is the I2C slave address number,There are 4 slave addrss,so The ucSlaveNum can be: 0, 1, 2, 3.

The ucSlaveAddrMask is the I2C slave address mask,There are 4 slave addrss. The ucSlaveAddrMask can be a 7-bit value.

Note:
this is only for slave
Returns:
None.

Definition at line 1649 of file xi2c.c.

References I2C0_BASE, xASSERT, and xHWREG.

void I2CIntFlagClear ( unsigned long  ulBase)

Clear the I2C interrupt flag of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to clear the I2C interrupt flag of the specified I2C port.

The ulBase must be:I2C0_BASE.

Returns:
None.

Definition at line 1926 of file xi2c.c.

References I2C0_BASE, I2C_CON_SI, I2C_O_CON, xASSERT, and xHWREG.

void I2CTimeoutFlagClear ( unsigned long  ulBase)

Clear the I2C time out flag of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to clear the I2C time out flag of the specified I2C port.

The ulBase must be:I2C0_BASE.

Returns:
None.

Definition at line 1950 of file xi2c.c.

References I2C0_BASE, I2C_O_TOC, I2C_TOC_TIF, xASSERT, and xHWREG.

void I2CTimeoutCounterSet ( unsigned long  ulBase,
unsigned long  ulEnable,
unsigned long  ulDiv4 
)

Enable/Disable I2C 14-bit timeout counter of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.
ulEnablespecifies Enable/Disable 14-bit timeout counter.
ulDiv4specifies 4 time the 14-bit timeout counter or not.

This function is to Enable/Disable I2C 14-bit timeout counter and set div4 bit of timeout counter of the specified I2C port.

The ulBase must be:I2C0_BASE.

The ulEnable can be one of the following values: I2C_TIMEOUT_EN, I2C_TIMEOUT_DIS.

The ulDiv4 can be one of the following values: I2C_TIMEOUT_DIV4, I2C_TIMEOUT_DIV_NO.

Returns:
None.

Definition at line 1983 of file xi2c.c.

References I2C0_BASE, I2C_O_TOC, I2C_TIMEOUT_DIS, I2C_TIMEOUT_DIV4, I2C_TIMEOUT_DIV_NO, I2C_TIMEOUT_EN, xASSERT, and xHWREG.

xtBoolean I2CIntFlagGet ( unsigned long  ulBase)

Get the I2C interrupt flag of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to get the I2C interrupt flag of the specified I2C port.

The ulBase must be: I2C0_BASE.

Returns:
could be:xtrue the interrupt has been triggered. xfalse the interrupt has not been triggered.

Definition at line 1878 of file xi2c.c.

References I2C0_BASE, I2C_O_CON, xASSERT, xfalse, xHWREG, and xtrue.

xtBoolean I2CTimeoutFlagGet ( unsigned long  ulBase)

Get the I2C time out flag of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to get the I2C time out flag of the specified I2C port.

The ulBase must be:I2C0_BASE.

Returns:
could be:xtrue the Time out has been occur. xfalse the Time out has not been occur.

Definition at line 1902 of file xi2c.c.

References I2C0_BASE, I2C_O_TOC, I2C_TOC_TIF, xASSERT, xfalse, xHWREG, and xtrue.

void I2CIntDisable ( unsigned long  ulBase)

Disable I2C interrupt of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to disable I2C interrupt of the specified I2C port.

The ulBase must be:I2C0_BASE.

Returns:
None.

Definition at line 1803 of file xi2c.c.

References I2C0_BASE, I2C_CON_EI, I2C_O_CON, INT_I2C0, xASSERT, xHWREG, and xIntDisable().

Referenced by I2C0IntHandler(), and I2CSlaveHandler().

Here is the call graph for this function:

void I2CIntEnable ( unsigned long  ulBase)

Enable I2C interrupt of the specified I2C port.

Parameters:
ulBasespecifies the I2C module base address.

This function is to enable I2C interrupt of the specified I2C port.

The ulBase must be:I2C0_BASE.

Returns:
None.

Definition at line 1755 of file xi2c.c.

References I2C0_BASE, I2C_CON_EI, I2C_O_CON, INT_I2C0, xASSERT, xHWREG, and xIntEnable().

Referenced by I2C0IntHandler(), I2CMasterTransfer(), I2CSlaveHandler(), and I2CSlaveTransfer().

Here is the call graph for this function: