CC35xxDriverLibrary
i2c.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "../inc/hw_types.h"
#include "../inc/hw_ints.h"
#include "../inc/hw_memmap.h"
#include "../inc/hw_i2c.h"
#include "debug.h"
#include "interrupt.h"
#include "cpu.h"
Include dependency graph for i2c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

I2C Controller Commands

For usage details see description of I2CControllerSetCommand()

#define I2C_CONTROLLER_CMD_SINGLE_SEND   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_STOP_EN_STOP)
 
#define I2C_CONTROLLER_CMD_SINGLE_RECEIVE   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_STOP_EN_STOP)
 
#define I2C_CONTROLLER_CMD_BURST_SEND_START   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START)
 
#define I2C_CONTROLLER_CMD_BURST_SEND_CONT   (I2C_CCTR_BURSTRUN_EN)
 
#define I2C_CONTROLLER_CMD_BURST_SEND_FINISH   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP)
 
#define I2C_CONTROLLER_CMD_BURST_RECEIVE_START   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_ACK_EN_ACK | I2C_CCTR_CACKOEN_EN)
 
#define I2C_CONTROLLER_CMD_BURST_RECEIVE_CONT   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_ACK_EN_ACK | I2C_CCTR_CACKOEN_EN)
 
#define I2C_CONTROLLER_CMD_BURST_RECEIVE_FINISH   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP)
 
#define I2C_CONTROLLER_CMD_BURST_FINISH   (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP)
 
I2C Controller Transaction Length

For usage details see description of I2CControllerSetCommand()

#define I2C_CONTROLLER_TRANSACTION_LENGTH_MAX   0xFFF
 The maximum length of a burst transaction. More...
 
#define I2C_CONTROLLER_TRANSACTION_LENGTH_SINGLE   0x001
 The length of a single byte transaction. More...
 
#define I2C_CONTROLLER_TRANSACTION_LENGTH_NONE   0x000
 The length to be used together with some commands that does not have any data associated with it. More...
 
I2C Controller Configurations
#define I2C_CONTROLLER_CONFIG_DEFAULT   0
 Default configuration. More...
 
#define I2C_CONTROLLER_CONFIG_CLOCK_STRETCHING_DETECTION   I2C_CCR_CLKSTRETCH_EN
 Enables the clock stretching detection. More...
 
#define I2C_CONTROLLER_CONFIG_MULTI_CONTROLLER_MODE   I2C_CCR_MCST_EN
 Enable Multicontroller mode. More...
 
#define I2C_CONTROLLER_CONFIG_LOOPBACK   I2C_CCR_LPBK_EN
 The controller is in a test mode loopback configuration. More...
 
I2C Controller Transaction Direction
#define I2C_CONTROLLER_DIR_RECEIVE   I2C_CSA_DIR_RECEIVE
 I2C Controller is initiating a read from the target. More...
 
#define I2C_CONTROLLER_DIR_TRANSMIT   I2C_CSA_DIR_TRANSMIT
 I2C Controller is initiating a write to the target. More...
 
I2C Controller Error Status
#define I2C_CONTROLLER_ERR_NONE   0
 No error. More...
 
#define I2C_CONTROLLER_ERR_ADDR_ACK   I2C_CSR_ADRACK_SET
 The transmitted address was not acknowledged. More...
 
#define I2C_CONTROLLER_ERR_DATA_ACK   I2C_CSR_DATACK_SET
 The transmitted data was not acknowledged. More...
 
#define I2C_CONTROLLER_ERR_ARB_LOST   I2C_CSR_ARBLST_SET
 The controller lost arbitration. More...
 
I2C Interrupts
#define I2C_INT_ALL   0xFFFFFFFF
 The collection of all interrupt sources for the I2C module. More...
 
I2C Controller Interrupts
#define I2C_CONTROLLER_INT_RX_DONE   I2C_EVENT0_IMASK_CRXDONE
 
#define I2C_CONTROLLER_INT_TX_DONE   I2C_EVENT0_IMASK_CTXDONE
 
#define I2C_CONTROLLER_INT_RX_FIFO_TRIGGER   I2C_EVENT0_IMASK_RXFIFOTRGC
 
#define I2C_CONTROLLER_INT_TX_FIFO_TRIGGER   I2C_EVENT0_IMASK_TXFIFOTRGC
 
#define I2C_CONTROLLER_INT_RX_FIFO_FULL   I2C_EVENT0_IMASK_RXFIFOFULLC
 
#define I2C_CONTROLLER_INT_TX_FIFO_FULL   I2C_EVENT0_IMASK_TXFIFOFULLC
 
#define I2C_CONTROLLER_INT_TX_FIFO_EMPTY   I2C_EVENT0_IMASK_TXEMPTYC
 
#define I2C_CONTROLLER_INT_NACK   I2C_EVENT0_IMASK_CNACK
 
#define I2C_CONTROLLER_INT_START   I2C_EVENT0_IMASK_CSTART
 
#define I2C_CONTROLLER_INT_STOP   I2C_EVENT0_IMASK_CSTOP
 
#define I2C_CONTROLLER_INT_ARB_LOST   I2C_EVENT0_IMASK_CARBLOST
 
I2C Target Interrupts
#define I2C_TARGET_INT_RX_DONE   I2C_EVENT0_IMASK_TRXDONE
 
#define I2C_TARGET_INT_TX_DONE   I2C_EVENT0_IMASK_TTXDONE
 
#define I2C_TARGET_INT_RX_FIFO_TRIGGER   I2C_EVENT0_IMASK_RXFIFOTRGT
 
#define I2C_TARGET_INT_TX_FIFO_TRIGGER   I2C_EVENT0_IMASK_TXFIFOTRGT
 
#define I2C_TARGET_INT_RX_FIFO_FULL   I2C_EVENT0_IMASK_RXFIFOFULLT
 
#define I2C_TARGET_INT_TX_FIFO_FULL   I2C_EVENT0_IMASK_TXFIFOFULLT
 
#define I2C_TARGET_INT_TX_FIFO_EMPTY   I2C_EVENT0_IMASK_TXEMPTYT
 
#define I2C_TARGET_INT_START   I2C_EVENT0_IMASK_TSTART
 
#define I2C_TARGET_INT_STOP   I2C_EVENT0_IMASK_TSTOP
 
#define I2C_TARGET_INT_GEN_CALL   I2C_EVENT0_IMASK_TGENCALL
 
#define I2C_TARGET_INT_TX_FIFO_UNDERFLOW   I2C_EVENT0_IMASK_TX_UNFL_T
 
#define I2C_TARGET_INT_ARB_LOST   I2C_EVENT0_IMASK_CARBLOST
 
I2C Modes
#define I2C_MODE_STANDARD   0
 Standard-mode (100kbit/s) More...
 
#define I2C_MODE_FAST   1
 Fast-mode (400kbit/s) More...
 
#define I2C_MODE_FAST_PLUS   2
 Fast-mode Plus (1Mbit/s) More...
 
I2C Controller Address modes
#define I2C_CONTROLLER_ADDR_MODE_7_BIT   I2C_CSA_CMODE_SEVEN_BIT
 7-bit addressing More...
 
#define I2C_CONTROLLER_ADDR_MODE_10_BIT   I2C_CSA_CMODE_TEN_BIT
 10-bit addressing More...
 
I2C Target Address modes
#define I2C_TARGET_ADDR_MODE_7_BIT   I2C_TOAR_MODE_SEVEN_BIT
 7-bit addressing More...
 
#define I2C_TARGET_ADDR_MODE_10_BIT   I2C_TOAR_MODE_TEN_BIT
 10-bit addressing More...
 
I2C FIFO Macros
#define I2C_RX_FIFO_SIZE   (I2C_FIFOSR_RXFIFOCNT_MAXIMUM >> I2C_FIFOSR_RXFIFOCNT_S)
 
#define I2C_TX_FIFO_SIZE   (I2C_FIFOSR_TXFIFOCNT_MAXIMUM >> I2C_FIFOSR_TXFIFOCNT_S)
 

Functions

void I2CControllerInit (uint32_t base, uint32_t config, uint32_t mode)
 Initializes the I2C Controller module. More...
 
__STATIC_INLINE void I2CControllerSetCommand (uint32_t base, uint32_t cmd, uint16_t transactionLength)
 Controls the state of the I2C Controller module. More...
 
__STATIC_INLINE void I2CControllerSetTargetAddr (uint32_t base, uint32_t addressMode, uint16_t targetAddr, uint32_t direction)
 Sets the address that the I2C Controller will place on the bus. More...
 
__STATIC_INLINE void I2CControllerEnable (uint32_t base)
 Enable the I2C Controller module. More...
 
__STATIC_INLINE void I2CControllerDisable (uint32_t base)
 Disables the I2C controller module. More...
 
__STATIC_INLINE bool I2CControllerIsBusy (uint32_t base)
 Indicates whether or not the I2C Controller is busy. More...
 
__STATIC_INLINE bool I2CControllerIsBusBusy (uint32_t base)
 Indicates whether or not the I2C bus is busy. More...
 
uint32_t I2CControllerGetError (uint32_t base)
 Gets the error status of the I2C Controller module. More...
 
__STATIC_INLINE uint32_t I2CGetTxFifoCount (uint32_t base)
 Get the number of bytes in the TX FIFO. More...
 
__STATIC_INLINE uint32_t I2CGetRxFifoCount (uint32_t base)
 Get the number of bytes in the RX FIFO. More...
 
__STATIC_INLINE bool I2CIsTxFifoEmpty (uint32_t base)
 Check if TX FIFO is empty. More...
 
__STATIC_INLINE bool I2CIsRxFifoEmpty (uint32_t base)
 Check if RX FIFO is empty. More...
 
__STATIC_INLINE bool I2CIsTxFifoFull (uint32_t base)
 Check if TX FIFO is full. More...
 
__STATIC_INLINE bool I2CIsRxFifoFull (uint32_t base)
 Check if RX FIFO is full. More...
 
__STATIC_INLINE void I2CSetTxFifoTrigger (uint32_t base, uint8_t level)
 Set TX FIFO trigger level. More...
 
__STATIC_INLINE void I2CSetRxFifoTrigger (uint32_t base, uint8_t level)
 Set RX FIFO trigger level. More...
 
__STATIC_INLINE void I2CFlushTxFifo (uint32_t base)
 Flush the I2C TX FIFO. More...
 
__STATIC_INLINE void I2CFlushRxFifo (uint32_t base)
 Flush the I2C RX FIFO. More...
 
__STATIC_INLINE void I2CFlushFifos (uint32_t base)
 Flush the I2C TX and RX FIFOs. More...
 
__STATIC_INLINE void I2CGetData (uint32_t base, uint8_t *data)
 Gets a data element from the I2C RX FIFO. More...
 
__STATIC_INLINE uint32_t I2CGetDataNonBlocking (uint32_t base, uint8_t *data)
 Gets a data element from the I2C RX FIFO (non-blocking). More...
 
__STATIC_INLINE void I2CPutData (uint32_t base, uint8_t data)
 Puts a data element into the I2C TX FIFO. More...
 
__STATIC_INLINE uint32_t I2CPutDataNonBlocking (uint32_t base, uint8_t data)
 Puts a data element into the I2C TX FIFO (non-blocking). More...
 
__STATIC_INLINE void I2CEnableInt (uint32_t base, uint32_t intFlags)
 Enables individual I2C interrupt sources. More...
 
__STATIC_INLINE void I2CDisableInt (uint32_t base, uint32_t intFlags)
 Disables individual I2C interrupt sources. More...
 
__STATIC_INLINE void I2CClearInt (uint32_t base, uint32_t intFlags)
 Clears I2C interrupt sources. More...
 
__STATIC_INLINE uint32_t I2CIntStatus (uint32_t base, bool masked)
 Gets the current I2C interrupt status. More...