60 #include "../inc/hw_types.h" 61 #include "../inc/hw_ints.h" 62 #include "../inc/hw_memmap.h" 63 #include "../inc/hw_i2c.h" 76 #define I2C_CONTROLLER_CMD_SINGLE_SEND (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_STOP_EN_STOP) 77 #define I2C_CONTROLLER_CMD_SINGLE_RECEIVE (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_STOP_EN_STOP) 78 #define I2C_CONTROLLER_CMD_BURST_SEND_START (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START) 79 #define I2C_CONTROLLER_CMD_BURST_SEND_CONT (I2C_CCTR_BURSTRUN_EN) 80 #define I2C_CONTROLLER_CMD_BURST_SEND_FINISH (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP) 81 #define I2C_CONTROLLER_CMD_BURST_RECEIVE_START \ 82 (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_START_EN_START | I2C_CCTR_ACK_EN_ACK | I2C_CCTR_CACKOEN_EN) 83 #define I2C_CONTROLLER_CMD_BURST_RECEIVE_CONT (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_ACK_EN_ACK | I2C_CCTR_CACKOEN_EN) 84 #define I2C_CONTROLLER_CMD_BURST_RECEIVE_FINISH (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP) 85 #define I2C_CONTROLLER_CMD_BURST_FINISH (I2C_CCTR_BURSTRUN_EN | I2C_CCTR_STOP_EN_STOP) 97 #define I2C_CONTROLLER_TRANSACTION_LENGTH_MAX 0xFFF 98 #define I2C_CONTROLLER_TRANSACTION_LENGTH_SINGLE 0x001 100 #define I2C_CONTROLLER_TRANSACTION_LENGTH_NONE 0x000 112 #define I2C_CONTROLLER_CONFIG_DEFAULT 0 113 #define I2C_CONTROLLER_CONFIG_CLOCK_STRETCHING_DETECTION I2C_CCR_CLKSTRETCH_EN 115 #define I2C_CONTROLLER_CONFIG_MULTI_CONTROLLER_MODE I2C_CCR_MCST_EN 117 #define I2C_CONTROLLER_CONFIG_LOOPBACK I2C_CCR_LPBK_EN 128 #define I2C_CONTROLLER_DIR_RECEIVE I2C_CSA_DIR_RECEIVE 129 #define I2C_CONTROLLER_DIR_TRANSMIT I2C_CSA_DIR_TRANSMIT 140 #define I2C_CONTROLLER_ERR_NONE 0 141 #define I2C_CONTROLLER_ERR_ADDR_ACK I2C_CSR_ADRACK_SET 143 #define I2C_CONTROLLER_ERR_DATA_ACK I2C_CSR_DATACK_SET 145 #define I2C_CONTROLLER_ERR_ARB_LOST I2C_CSR_ARBLST_SET 159 #define I2C_INT_ALL 0xFFFFFFFF 168 #define I2C_CONTROLLER_INT_RX_DONE I2C_EVENT0_IMASK_CRXDONE 169 #define I2C_CONTROLLER_INT_TX_DONE I2C_EVENT0_IMASK_CTXDONE 170 #define I2C_CONTROLLER_INT_RX_FIFO_TRIGGER I2C_EVENT0_IMASK_RXFIFOTRGC 171 #define I2C_CONTROLLER_INT_TX_FIFO_TRIGGER I2C_EVENT0_IMASK_TXFIFOTRGC 172 #define I2C_CONTROLLER_INT_RX_FIFO_FULL I2C_EVENT0_IMASK_RXFIFOFULLC 173 #define I2C_CONTROLLER_INT_TX_FIFO_FULL I2C_EVENT0_IMASK_TXFIFOFULLC 174 #define I2C_CONTROLLER_INT_TX_FIFO_EMPTY I2C_EVENT0_IMASK_TXEMPTYC 175 #define I2C_CONTROLLER_INT_NACK I2C_EVENT0_IMASK_CNACK 176 #define I2C_CONTROLLER_INT_START I2C_EVENT0_IMASK_CSTART 177 #define I2C_CONTROLLER_INT_STOP I2C_EVENT0_IMASK_CSTOP 178 #define I2C_CONTROLLER_INT_ARB_LOST I2C_EVENT0_IMASK_CARBLOST 187 #define I2C_TARGET_INT_RX_DONE I2C_EVENT0_IMASK_TRXDONE 188 #define I2C_TARGET_INT_TX_DONE I2C_EVENT0_IMASK_TTXDONE 189 #define I2C_TARGET_INT_RX_FIFO_TRIGGER I2C_EVENT0_IMASK_RXFIFOTRGT 190 #define I2C_TARGET_INT_TX_FIFO_TRIGGER I2C_EVENT0_IMASK_TXFIFOTRGT 191 #define I2C_TARGET_INT_RX_FIFO_FULL I2C_EVENT0_IMASK_RXFIFOFULLT 192 #define I2C_TARGET_INT_TX_FIFO_FULL I2C_EVENT0_IMASK_TXFIFOFULLT 193 #define I2C_TARGET_INT_TX_FIFO_EMPTY I2C_EVENT0_IMASK_TXEMPTYT 194 #define I2C_TARGET_INT_START I2C_EVENT0_IMASK_TSTART 195 #define I2C_TARGET_INT_STOP I2C_EVENT0_IMASK_TSTOP 196 #define I2C_TARGET_INT_GEN_CALL I2C_EVENT0_IMASK_TGENCALL 197 #define I2C_TARGET_INT_TX_FIFO_UNDERFLOW I2C_EVENT0_IMASK_TX_UNFL_T 198 #define I2C_TARGET_INT_ARB_LOST I2C_EVENT0_IMASK_CARBLOST 208 #define I2C_MODE_STANDARD 0 209 #define I2C_MODE_FAST 1 211 #define I2C_MODE_FAST_PLUS 2 222 #define I2C_CONTROLLER_ADDR_MODE_7_BIT I2C_CSA_CMODE_SEVEN_BIT 223 #define I2C_CONTROLLER_ADDR_MODE_10_BIT I2C_CSA_CMODE_TEN_BIT 234 #define I2C_TARGET_ADDR_MODE_7_BIT I2C_TOAR_MODE_SEVEN_BIT 235 #define I2C_TARGET_ADDR_MODE_10_BIT I2C_TOAR_MODE_TEN_BIT 245 #define I2C_RX_FIFO_SIZE (I2C_FIFOSR_RXFIFOCNT_MAXIMUM >> I2C_FIFOSR_RXFIFOCNT_S) 246 #define I2C_TX_FIFO_SIZE (I2C_FIFOSR_TXFIFOCNT_MAXIMUM >> I2C_FIFOSR_TXFIFOCNT_S) 255 #ifdef DRIVERLIB_DEBUG 270 static bool I2CIsBaseValid(uint32_t base)
396 ASSERT(I2CIsBaseValid(base));
405 ASSERT(transactionLength <= 0xFFF);
430 uint32_t addressMode,
435 ASSERT(I2CIsBaseValid(base));
438 ASSERT(!(targetAddr & 0xFC00));
466 ASSERT(I2CIsBaseValid(base));
486 ASSERT(I2CIsBaseValid(base));
509 ASSERT(I2CIsBaseValid(base));
540 ASSERT(I2CIsBaseValid(base));
583 ASSERT(I2CIsBaseValid(base));
604 ASSERT(I2CIsBaseValid(base));
623 ASSERT(I2CIsBaseValid(base));
642 ASSERT(I2CIsBaseValid(base));
660 ASSERT(I2CIsBaseValid(base));
678 ASSERT(I2CIsBaseValid(base));
699 ASSERT(I2CIsBaseValid(base));
729 ASSERT(I2CIsBaseValid(base));
730 ASSERT(1 <= level && level <= 8);
772 ASSERT(I2CIsBaseValid(base));
815 ASSERT(I2CIsBaseValid(base));
860 ASSERT(I2CIsBaseValid(base));
893 ASSERT(I2CIsBaseValid(base));
920 ASSERT(I2CIsBaseValid(base));
952 ASSERT(I2CIsBaseValid(base));
978 ASSERT(I2CIsBaseValid(base));
1034 ASSERT(I2CIsBaseValid(base));
1082 ASSERT(I2CIsBaseValid(base));
1147 ASSERT(I2CIsBaseValid(base));
1195 ASSERT(I2CIsBaseValid(base));
#define I2C_CSA_TADDR_S
Definition: hw_i2c.h:221
#define I2C_FIFOSR_RXFIFOCNT_S
Definition: hw_i2c.h:1354
#define I2C_FIFOCTL_TXTRIG_M
Definition: hw_i2c.h:1252
#define I2C_O_CSR
Definition: hw_i2c.h:54
#define I2C_FIFOSR_RXFIFOCNT_MAXIMUM
Definition: hw_i2c.h:1356
__STATIC_INLINE void I2CPutData(uint32_t base, uint8_t data)
Puts a data element into the I2C TX FIFO.
Definition: i2c.h:949
#define I2C_FIFOSR_TXFIFOCNT_MAXIMUM
Definition: hw_i2c.h:1391
#define I2C_CSR_BUSY_M
Definition: hw_i2c.h:391
#define I2C_CONTROLLER_DIR_RECEIVE
I2C Controller is initiating a read from the target.
Definition: i2c.h:128
__STATIC_INLINE bool I2CIsRxFifoFull(uint32_t base)
Check if RX FIFO is full.
Definition: i2c.h:675
#define I2C_CONTROLLER_CMD_BURST_SEND_CONT
Definition: i2c.h:79
#define HWREG(x)
Definition: hw_types.h:78
#define I2C_CONTROLLER_CMD_BURST_SEND_FINISH
Definition: i2c.h:80
#define __STATIC_INLINE
Definition: hw_types.h:57
__STATIC_INLINE uint32_t I2CGetRxFifoCount(uint32_t base)
Get the number of bytes in the RX FIFO.
Definition: i2c.h:601
__STATIC_INLINE uint32_t I2CIntStatus(uint32_t base, bool masked)
Gets the current I2C interrupt status.
Definition: i2c.h:1192
#define I2C_CONTROLLER_DIR_TRANSMIT
I2C Controller is initiating a write to the target.
Definition: i2c.h:130
#define I2C_FIFOSR_RXFIFOCNT_MINIMUM
Definition: hw_i2c.h:1355
#define I2C_O_CCR
Definition: hw_i2c.h:60
#define I2C_FIFOSR_RXFIFOCNT_M
Definition: hw_i2c.h:1353
__STATIC_INLINE void I2CFlushTxFifo(uint32_t base)
Flush the I2C TX FIFO.
Definition: i2c.h:769
void I2CControllerInit(uint32_t base, uint32_t config, uint32_t mode)
Initializes the I2C Controller module.
Definition: i2c.c:43
#define I2C_O_EVENT0_RIS
Definition: hw_i2c.h:102
#define I2C_O_CSA
Definition: hw_i2c.h:48
__STATIC_INLINE void I2CSetRxFifoTrigger(uint32_t base, uint8_t level)
Set RX FIFO trigger level.
Definition: i2c.h:726
#define I2C_FIFOSR_TXFIFOCNT_MINIMUM
Definition: hw_i2c.h:1390
__STATIC_INLINE void I2CControllerSetCommand(uint32_t base, uint32_t cmd, uint16_t transactionLength)
Controls the state of the I2C Controller module.
Definition: i2c.h:393
#define I2C_CSR_BUSBSY_M
Definition: hw_i2c.h:498
#define I2C_CCTR_MBLEN_M
Definition: hw_i2c.h:365
#define I2C_FIFOCTL_RXTRIG_M
Definition: hw_i2c.h:1303
__STATIC_INLINE bool I2CIsTxFifoEmpty(uint32_t base)
Check if TX FIFO is empty.
Definition: i2c.h:620
#define I2C_O_CCTR
Definition: hw_i2c.h:51
__STATIC_INLINE void I2CDisableInt(uint32_t base, uint32_t intFlags)
Disables individual I2C interrupt sources.
Definition: i2c.h:1079
#define I2C_CONTROLLER_CMD_BURST_RECEIVE_START
Definition: i2c.h:81
#define I2C1_BASE
Definition: hw_memmap.h:89
#define I2C_FIFOSR_TXFIFOCNT_M
Definition: hw_i2c.h:1388
__STATIC_INLINE bool I2CControllerIsBusBusy(uint32_t base)
Indicates whether or not the I2C bus is busy.
Definition: i2c.h:537
#define I2C_O_EVENT0_IMEN
Definition: hw_i2c.h:114
#define I2C_FIFOCTL_RXFLUSH_EN
Definition: hw_i2c.h:1331
__STATIC_INLINE void I2CControllerDisable(uint32_t base)
Disables the I2C controller module.
Definition: i2c.h:483
__STATIC_INLINE void I2CSetTxFifoTrigger(uint32_t base, uint8_t level)
Set TX FIFO trigger level.
Definition: i2c.h:696
__STATIC_INLINE bool I2CIsRxFifoEmpty(uint32_t base)
Check if RX FIFO is empty.
Definition: i2c.h:639
#define I2C_O_FIFOCTL
Definition: hw_i2c.h:87
#define I2C_O_FIFOSR
Definition: hw_i2c.h:90
#define I2C_CONTROLLER_CMD_BURST_SEND_START
Definition: i2c.h:78
#define I2C_CSR_BUSY_SET
Definition: hw_i2c.h:394
#define I2C_FIFOCTL_TXFLUSH_EN
Definition: hw_i2c.h:1280
__STATIC_INLINE bool I2CIsTxFifoFull(uint32_t base)
Check if TX FIFO is full.
Definition: i2c.h:657
__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.
Definition: i2c.h:429
#define ASSERT(expr)
Definition: debug.h:81
#define I2C_O_TXDATA
Definition: hw_i2c.h:81
#define I2C_CCR_ACTIVE_EN
Definition: hw_i2c.h:584
#define I2C_O_EVENT0_IDIS
Definition: hw_i2c.h:111
__STATIC_INLINE void I2CFlushRxFifo(uint32_t base)
Flush the I2C RX FIFO.
Definition: i2c.h:812
__STATIC_INLINE void I2CControllerEnable(uint32_t base)
Enable the I2C Controller module.
Definition: i2c.h:463
__STATIC_INLINE void I2CFlushFifos(uint32_t base)
Flush the I2C TX and RX FIFOs.
Definition: i2c.h:857
#define I2C_FIFOCTL_RXTRIG_S
Definition: hw_i2c.h:1304
#define I2C_O_EVENT0_IMDIS
Definition: hw_i2c.h:117
#define I2C_O_EVENT0_MIS
Definition: hw_i2c.h:105
__STATIC_INLINE void I2CClearInt(uint32_t base, uint32_t intFlags)
Clears I2C interrupt sources.
Definition: i2c.h:1144
__STATIC_INLINE uint32_t I2CGetDataNonBlocking(uint32_t base, uint8_t *data)
Gets a data element from the I2C RX FIFO (non-blocking).
Definition: i2c.h:917
#define I2C0_BASE
Definition: hw_memmap.h:88
#define I2C_CCTR_MBLEN_S
Definition: hw_i2c.h:366
#define I2C_FIFOSR_TXFIFOCNT_S
Definition: hw_i2c.h:1389
uint32_t I2CControllerGetError(uint32_t base)
Gets the error status of the I2C Controller module.
Definition: i2c.c:109
#define I2C_FIFOCTL_TXTRIG_S
Definition: hw_i2c.h:1253
#define I2C_CONTROLLER_ADDR_MODE_7_BIT
7-bit addressing
Definition: i2c.h:222
__STATIC_INLINE uint32_t I2CGetTxFifoCount(uint32_t base)
Get the number of bytes in the TX FIFO.
Definition: i2c.h:580
__STATIC_INLINE void I2CEnableInt(uint32_t base, uint32_t intFlags)
Enables individual I2C interrupt sources.
Definition: i2c.h:1031
#define I2C_CONTROLLER_CMD_BURST_RECEIVE_CONT
Definition: i2c.h:83
__STATIC_INLINE uint32_t I2CPutDataNonBlocking(uint32_t base, uint8_t data)
Puts a data element into the I2C TX FIFO (non-blocking).
Definition: i2c.h:975
#define I2C_CONTROLLER_ADDR_MODE_10_BIT
10-bit addressing
Definition: i2c.h:224
#define I2C_O_RXDATA
Definition: hw_i2c.h:78
#define HWREGB(x)
Definition: hw_types.h:90
#define I2C_CONTROLLER_CMD_SINGLE_SEND
Definition: i2c.h:76
__STATIC_INLINE bool I2CControllerIsBusy(uint32_t base)
Indicates whether or not the I2C Controller is busy.
Definition: i2c.h:506
#define I2C_CSR_BUSBSY_SET
Definition: hw_i2c.h:501
__STATIC_INLINE void I2CGetData(uint32_t base, uint8_t *data)
Gets a data element from the I2C RX FIFO.
Definition: i2c.h:890