Dataflow Runtime API  3.1.1.0
Enumerations | Functions
SystemPeripherals_I2C.h File Reference
#include <Imt.Base.Core.Platform/Platform.h>
#include "SystemMemoryMap.h"
#include "RegisterDefinitions/hw_hsi2c.h"

Enumerations

enum  I2CModuleAddress { I2CModuleAddress_I2C0 = SOC_I2C_0_REGS , I2CModuleAddress_I2C1 = SOC_I2C_1_REGS , I2CModuleAddress_I2C2 = SOC_I2C_2_REGS }
 I2C module. More...
 
enum  I2COperatingMode { I2COperatingMode_SlaveReceiver , I2COperatingMode_SlaveTransmitter , I2COperatingMode_MasterReceiver , I2COperatingMode_MasterTransmitter }
 Enumeration of the available I2C operating modes. More...
 
enum  I2CClockRate { I2CClockRate_50kHz = 50000 , I2CClockRate_100kHz = 100000 , I2CClockRate_400KHz = 400000 }
 Enumeration of the supported I2C clock rates. More...
 
enum  I2CInterruptEvent {
  I2CInterruptEvent_AddressedAsSlave = I2C_IRQSTATUS_AAS , I2CInterruptEvent_BusFree = I2C_IRQSTATUS_BF , I2CInterruptEvent_StartCondition = I2C_IRQSTATUS_STC , I2CInterruptEvent_AccessError = I2C_IRQSTATUS_AERR ,
  I2CInterruptEvent_ArbitrationLost = I2C_IRQSTATUS_AL , I2CInterruptEvent_NoAcknowledge = I2C_IRQSTATUS_NACK , I2CInterruptEvent_GeneralCall = I2C_IRQSTATUS_GC , I2CInterruptEvent_RegisterReadyForAccess = I2C_IRQSTATUS_ARDY ,
  I2CInterruptEvent_ReceiveStatus = I2C_IRQSTATUS_RRDY , I2CInterruptEvent_TransmitStatus = I2C_IRQSTATUS_XRDY , I2CInterruptEvent_ReceiveDraining = I2C_IRQSTATUS_RDR , I2CInterruptEvent_TransmitDraining = I2C_IRQSTATUS_XDR
}
 Enumeration of the interrupt events. More...
 

Functions

void I2C_Init (const I2CModuleAddress moduleBaseAddress, const I2CClockRate clockRateHz, const uint8_t deviceAddress)
 Initialize the I2C module with FIFO buffers. More...
 
void I2C_Reset (const I2CModuleAddress moduleBaseAddress)
 Reset the I2C module. More...
 
I2COperatingMode I2C_GetOperatingMode (const I2CModuleAddress moduleBaseAddress)
 
void I2C_GenerateStart (const I2CModuleAddress moduleBaseAddress, const uint8_t slaveAddress, const bool writeEnabled, const uint16_t bytesToTransfer)
 Generate START signal (I2C-protocol specific signal timing). More...
 
void I2C_GenerateStop (const I2CModuleAddress moduleBaseAddress)
 Generate STOP signal (I2C-protocol specific signal timing). More...
 
bool I2C_IsInterruptEventPending (const I2CModuleAddress moduleBaseAddress, const I2CInterruptEvent eventFlag)
 Check if the given interrupt event is pending. More...
 
void I2C_ClearInterruptEvent (const I2CModuleAddress moduleBaseAddress, const I2CInterruptEvent eventFlag)
 Clear the given interrupt event. More...
 
void I2C_ClearFIFOBuffers (const I2CModuleAddress moduleBaseAddress)
 Clear the RX and TX FIFO buffer. More...
 
uint8_t I2C_GetRxBufferStatus (const I2CModuleAddress moduleBaseAddress)
 RX buffer status. More...
 
uint16_t I2C_GetRxBufferThreshold (const I2CModuleAddress moduleBaseAddress)
 Threshold value for FIFO buffer in RX mode. More...
 
uint8_t I2C_GetTxBufferStatus (const I2CModuleAddress moduleBaseAddress)
 TX buffer status. More...
 
uint16_t I2C_GetTxBufferThreshold (const I2CModuleAddress moduleBaseAddress)
 Threshold value for FIFO buffer in TX mode. More...
 
uint8_t I2C_ReceiveData (const I2CModuleAddress moduleBaseAddress)
 Receive next byte (use I2C_GetRxBufferStatus to determinate the amount of bytes which can be read) More...
 
void I2C_SendData (const I2CModuleAddress moduleBaseAddress, const uint8_t data)
 Send the byte. More...
 

Enumeration Type Documentation

◆ I2CClockRate

Enumeration of the supported I2C clock rates.

Enumerator
I2CClockRate_50kHz 
I2CClockRate_100kHz 
I2CClockRate_400KHz 

◆ I2CInterruptEvent

Enumeration of the interrupt events.

Note
The I2C module generates 12 types of interrupt
See also
TRM Chapter 21.3.11 I2C Interrupts
Enumerator
I2CInterruptEvent_AddressedAsSlave 
I2CInterruptEvent_BusFree 
I2CInterruptEvent_StartCondition 
I2CInterruptEvent_AccessError 
I2CInterruptEvent_ArbitrationLost 
I2CInterruptEvent_NoAcknowledge 
I2CInterruptEvent_GeneralCall 
I2CInterruptEvent_RegisterReadyForAccess 
I2CInterruptEvent_ReceiveStatus 
I2CInterruptEvent_TransmitStatus 
I2CInterruptEvent_ReceiveDraining 
I2CInterruptEvent_TransmitDraining 

◆ I2CModuleAddress

I2C module.

The multi-master I2C peripheral provides an interface between a CPU and any I2C-bus-compatible device that connects via the I2C serial bus. External components attached to the I2C bus can serially transmit/receive up to 8-bit data to/from the CPU device through the two-wire I2C interface. This device includes three instantiations of the I2C module: I2C0, I2C1 and I2C2. Enumeration of the available I2C modules

Enumerator
I2CModuleAddress_I2C0 
I2CModuleAddress_I2C1 
I2CModuleAddress_I2C2 

◆ I2COperatingMode

Enumeration of the available I2C operating modes.

Enumerator
I2COperatingMode_SlaveReceiver 
I2COperatingMode_SlaveTransmitter 
I2COperatingMode_MasterReceiver 
I2COperatingMode_MasterTransmitter 

Function Documentation

◆ I2C_ClearFIFOBuffers()

void I2C_ClearFIFOBuffers ( const I2CModuleAddress  moduleBaseAddress)

Clear the RX and TX FIFO buffer.

Parameters
moduleBaseAddressThe module base address

◆ I2C_ClearInterruptEvent()

void I2C_ClearInterruptEvent ( const I2CModuleAddress  moduleBaseAddress,
const I2CInterruptEvent  eventFlag 
)

Clear the given interrupt event.

Parameters
moduleBaseAddressThe module base address
eventFlag

◆ I2C_GenerateStart()

void I2C_GenerateStart ( const I2CModuleAddress  moduleBaseAddress,
const uint8_t  slaveAddress,
const bool  writeEnabled,
const uint16_t  bytesToTransfer 
)

Generate START signal (I2C-protocol specific signal timing).

Parameters
moduleBaseAddressThe module base address
slaveAddress
writeEnabled
bytesToTransfer

◆ I2C_GenerateStop()

void I2C_GenerateStop ( const I2CModuleAddress  moduleBaseAddress)

Generate STOP signal (I2C-protocol specific signal timing).

Parameters
moduleBaseAddressThe module base address

◆ I2C_GetOperatingMode()

I2COperatingMode I2C_GetOperatingMode ( const I2CModuleAddress  moduleBaseAddress)
Parameters
moduleBaseAddressThe module base address
Returns
the I2C operating mode

◆ I2C_GetRxBufferStatus()

uint8_t I2C_GetRxBufferStatus ( const I2CModuleAddress  moduleBaseAddress)

RX buffer status.

This read-only field indicates the number of bytes to be transferred from the FIFO at the end of the I2C transfer (when RDR is asserted). It corresponds to the level indication of the RX FIFO (number of written locations).

Parameters
moduleBaseAddressThe module base address
Returns
uint8_t

◆ I2C_GetRxBufferThreshold()

uint16_t I2C_GetRxBufferThreshold ( const I2CModuleAddress  moduleBaseAddress)

Threshold value for FIFO buffer in RX mode.

Parameters
moduleBaseAddressThe module base address
Returns
uint16_t

◆ I2C_GetTxBufferStatus()

uint8_t I2C_GetTxBufferStatus ( const I2CModuleAddress  moduleBaseAddress)

TX buffer status.

This read-only field indicates the number of data bytes still left to be written in the TX FIFO. It is equal with the initial value of I2C_CNT.DCOUNT minus the number of data bytes already written in the TX FIFO through the OCP Interface

Parameters
moduleBaseAddressThe module base address
Returns
uint8_t

◆ I2C_GetTxBufferThreshold()

uint16_t I2C_GetTxBufferThreshold ( const I2CModuleAddress  moduleBaseAddress)

Threshold value for FIFO buffer in TX mode.

Parameters
moduleBaseAddressThe module base address
Returns
uint16_t

◆ I2C_Init()

void I2C_Init ( const I2CModuleAddress  moduleBaseAddress,
const I2CClockRate  clockRateHz,
const uint8_t  deviceAddress 
)

Initialize the I2C module with FIFO buffers.

Parameters
moduleBaseAddressThe module base address
clockRateHzthe clock rate in Hz
deviceAddressOwn I2C address of the I2C module

◆ I2C_IsInterruptEventPending()

bool I2C_IsInterruptEventPending ( const I2CModuleAddress  moduleBaseAddress,
const I2CInterruptEvent  eventFlag 
)

Check if the given interrupt event is pending.

Parameters
moduleBaseAddressThe module base address
eventFlag

◆ I2C_ReceiveData()

uint8_t I2C_ReceiveData ( const I2CModuleAddress  moduleBaseAddress)

Receive next byte (use I2C_GetRxBufferStatus to determinate the amount of bytes which can be read)

Parameters
moduleBaseAddressThe module base address
Returns
uint8_t

◆ I2C_Reset()

void I2C_Reset ( const I2CModuleAddress  moduleBaseAddress)

Reset the I2C module.

Receive and transmit FIFOs are cleared and all status bits are set to their default values. All configuration registers are not reset, they keep their initial values

Parameters
moduleBaseAddressThe module base address

◆ I2C_SendData()

void I2C_SendData ( const I2CModuleAddress  moduleBaseAddress,
const uint8_t  data 
)

Send the byte.

Parameters
moduleBaseAddressThe module base address
data