Go to the source code of this file.
I2C driver API definitions.
This file provides data structures and APIs for controlling the I2C peripheral on the EfxSapphireSoC platform.
Definition in file i2c.h.
Data Structures | |
| struct | i2c_filter_hwreg_t |
| I2C hardware filter configuration map. More... | |
| struct | i2c_hwreg_t |
| I2C hardware register map. More... | |
| struct | i2c_instance_t |
| I2C instance. Holds the software registers and hardware pointer. More... | |
Macros | |
I2C Mode Control Register Bitmasks | |
| #define | I2C_MODE_CPOL (1 << 0) |
| I2C Clock Polarity Mask */. | |
| #define | I2C_MODE_CPHA (1 << 1) |
| I2C Clock Phase Mask */. | |
I2C TX/RX and Status Register Bitmasks | |
| #define | I2C_TX_VALUE (0xFF) |
| Mask for TX value */. | |
| #define | I2C_TX_VALID (1 << 8) |
| Mask for TX valid bit */. | |
| #define | I2C_TX_ENABLE (1 << 9) |
| Mask for Enable TX */. | |
| #define | I2C_TX_REPEAT (1 << 10) |
| Mask for Repeat TX */. | |
| #define | I2C_TX_DISABLE_ON_DATA_CONFLICT (1 << 11) |
| Mask for Disable TX on data conflict */. | |
| #define | I2C_RX_VALUE (0xFF) |
| Mask for RX value */. | |
| #define | I2C_RX_VALID (1 << 8) |
| Mask for RX valid bit */. | |
| #define | I2C_RX_LISTEN (1 << 9) |
| Mask for RX listen mode */. | |
I2C Master/Slave Status Register Bitmasks | |
| #define | I2C_MASTER_BUSY (1 << 0) |
| Mask for Master Busy */. | |
| #define | I2C_MASTER_START (1 << 4) |
| Mask for Master Start */. | |
| #define | I2C_MASTER_STOP (1 << 5) |
| Mask for Master Stop */. | |
| #define | I2C_MASTER_DROP (1 << 6) |
| Mask for Master Drop */. | |
| #define | I2C_MASTER_RECOVER (1 << 7) |
| Mask for Master Recover */. | |
| #define | I2C_MASTER_START_DROPPED (1 << 9) |
| Mask for Master Start Dropped */. | |
| #define | I2C_MASTER_STOP_DROPPED (1 << 10) |
| Mask for Master Stop Dropped */. | |
| #define | I2C_MASTER_RECOVER_DROPPED (1 << 11) |
| Mask for Master Recover Dropped */. | |
| #define | I2C_SLAVE_STATUS_IN_FRAME (1 << 0) |
| Mask for the transaction is in progress */. | |
| #define | I2C_SLAVE_STATUS_SDA (1 << 1) |
| Mask for Slave's current state of SDA Line*/. | |
| #define | I2C_SLAVE_STATUS_SCL (1 << 2) |
| Mask for Slave's current state of SCL Line*/. | |
| #define | I2C_SLAVE_OVERRIDE_SDA (1 << 1) |
| Mask for Force Slave SDA line */. | |
| #define | I2C_SLAVE_OVERRIDE_SCL (1 << 2) |
| Mask for Force Slave SCL line*/. | |
I2C Filter Configuration Bitmasks | |
| #define | I2C_FILTER_7_BITS (0) |
| Filter setting for 7 bits */. | |
| #define | I2C_FILTER_10_BITS (1 << 14) |
| Filter setting for 10 bits */. | |
| #define | I2C_FILTER_ENABLE (1 << 15) |
| Filter Enable */. | |
I2C Read/Write Definitions | |
| #define | I2C_READ 0x01 |
| Indicate Read Transcation */. | |
| #define | I2C_WRITE 0x00 |
| Indicate Write Transcation */. | |
I2C TX and Check Macro | |
| #define | TX_AND_CHECK(inst, byte) |
| Transmits a single byte over the I2C bus and waits for an ACK response. | |
Enumerations | |
Interrupt Enums | |
Enums used for driver interrupt handling. | |
| enum | i2c_interrupt_t { I2C_INTERRUPT_RX_DATA = (1 << 0) , I2C_INTERRUPT_RX_ACK = (1 << 1) , I2C_INTERRUPT_TX_DATA = (1 << 2) , I2C_INTERRUPT_TX_ACK = (1 << 3) , I2C_INTERRUPT_START = (1 << 4) , I2C_INTERRUPT_RESTART = (1 << 5) , I2C_INTERRUPT_END = (1 << 6) , I2C_INTERRUPT_DROP = (1 << 7) , I2C_INTERRUPT_CLOCK_GEN_EXIT = (1 << 15) , I2C_INTERRUPT_CLOCK_GEN_ENTER = (1 << 16) , I2C_INTERRUPT_FILTER = (1 << 17) } |
| I2C Enable Interrupt List. More... | |
Functions | |
| void | i2c_applyConfig (i2c_instance_t *inst) |
| Apply the software configuration to the hardware. | |
| void | i2c_setSlaveOverride (i2c_instance_t *inst, u32 value) |
| Write values to I2C hardware registers. | |
I2C (Get Functions) | |
Read value from I2C hardware registers. | |
| u32 | i2c_getSlaveStatus (i2c_instance_t *inst) |
| Get Slave Status. | |
| u32 | i2c_getMasterStatus (i2c_instance_t *inst) |
| Get Master Status. | |
| u32 | i2c_getFilteringHit (i2c_instance_t *inst) |
| Get Filtering Hit. | |
| u32 | i2c_getInterruptFlag (i2c_instance_t *inst) |
| Get Interrupt Flag. | |
| u32 | i2c_getFilteringStatus (i2c_instance_t *inst) |
| Get Filtering Status. | |
| u32 | i2c_getSlaveOverride (i2c_instance_t *inst) |
| Get Slave Override. | |
I2C (Master Functions) | |
Read value from I2C hardware registers. | |
| void | i2c_startMaster (i2c_instance_t *inst) |
| Initiate start condition for I2C master mode and sets the dropped status if necessary. | |
| void | i2c_restartMaster (i2c_instance_t *inst) |
| Initiate restart condition for I2C master mode and sets the dropped status if necessary. | |
| void | i2c_recoverMaster (i2c_instance_t *inst) |
| Initiate recover condition for I2C master mode and sets the dropped status if necessary. | |
| void | i2c_startMasterBlocking (i2c_instance_t *inst) |
| Initiate start condition for I2C master mode and waits until the operation is complete. | |
| void | i2c_restartMasterBlocking (i2c_instance_t *inst) |
| Initiate restart condition for I2C master mode and waits until the operation is complete. | |
| void | i2c_stopMaster (i2c_instance_t *inst) |
| Initiate stop condition for I2C master mode and sets the dropped status if necessary. | |
| void | i2c_stopMasterBlocking (i2c_instance_t *inst) |
| Initiate stop condition for I2C master mode and waits until the operation is complete. | |
| void | i2c_recoverMasterBlocking (i2c_instance_t *inst) |
| Initiate recover condition for I2C master mode and waits until the operation is complete. | |
| void | i2c_dropMaster (i2c_instance_t *inst) |
| Drops the current I2C master operation. | |
| u32 | i2c_checkMasterBusy (i2c_instance_t *inst) |
| Checks if the I2C master is busy. | |
I2C (Transmit/Receive Functions) | |
Transmit data over I2C or receive data over I2C. | |
| void | i2c_listenAck (i2c_instance_t *inst) |
| configures the I2C controller to listen for ACK signals on the receiver (RX) line. | |
| void | i2c_txByte (i2c_instance_t *inst, u8 byte) |
| Transmits a byte of data over I2C. | |
| void | i2c_txAck (i2c_instance_t *inst) |
| Transmits an ACK signal over I2C. | |
| void | i2c_txNack (i2c_instance_t *inst) |
| Transmits an NACK signal over I2C. | |
| void | i2c_txAckWait (i2c_instance_t *inst) |
| Waits until the transmission of an ACK signal is complete over the I2C bus. | |
| void | i2c_rxAckWait (i2c_instance_t *inst) |
| Waits until the reception of an ACK signal is complete over the I2C bus. | |
| void | i2c_txAckBlocking (i2c_instance_t *inst) |
| Sends an ACK signal over the I2C bus and waits until the transmission is complete. | |
| void | i2c_txNackBlocking (i2c_instance_t *inst) |
| Sends an NACK signal over the I2C bus and waits until the transmission is complete. | |
| u32 | i2c_rxData (i2c_instance_t *inst) |
| Reads data from I2C receive data register. | |
| u32 | i2c_rxAck (i2c_instance_t *inst) |
| Reads data from I2C receive data register. | |
| u32 | i2c_rxNack (i2c_instance_t *inst) |
| Checks if the received ACK signal is detected. | |
| void | i2c_txByteRepeat (i2c_instance_t *inst, u8 byte) |
| Sends a byte over I2C bus with repeat mode enabled. | |
| void | i2c_txNackRepeat (i2c_instance_t *inst) |
| Sends a NACK signal over I2C bus with repeat mode enabled. | |
I2C (Control Functions) | |
Configure I2C filters and interrupts. | |
| void | i2c_enableFilter (i2c_instance_t *inst, u32 filterId, u32 config) |
| Enables and configures an I2C hardware filter. | |
| void | i2c_setFilterConfig (i2c_instance_t *inst, u32 filterId, u32 value) |
| Sets the configuration for an I2C hardware filter. | |
| void | i2c_enableInterrupt (i2c_instance_t *inst, i2c_interrupt_t value) |
| Enables specific I2C interrupts. | |
| void | i2c_disableInterrupt (i2c_instance_t *inst, i2c_interrupt_t value) |
| Disables specific I2C interrupts. | |
| void | i2c_clearInterruptFlag (i2c_instance_t *inst, i2c_interrupt_t value) |
| Clears specific I2C interrupt flags. | |
I2C (Read/Write Functions) | |
Read and write data over I2C bus. | |
| void | i2c_writeData_b (i2c_instance_t *inst, u8 regAddr, u8 *data, u32 length) |
| Write data with an 8-bit register address over I2C and check rx ack for each transaction. | |
| void | i2c_writeData_w (i2c_instance_t *inst, u16 regAddr, u8 *data, u32 length) |
| Write data with a 16-bit register address over I2C and check rx ack for each transaction. | |
| void | i2c_readData_b (i2c_instance_t *inst, u8 regAddr, u8 *data, u32 length) |
| Read data with an 8-bit register address over I2C. | |
| void | i2c_readData_w (i2c_instance_t *inst, u16 regAddr, u8 *data, u32 length) |
| Read data with a 16-bit register address over I2C. | |
| void | i2c_setMux (i2c_instance_t *inst, const uint8_t cr) |
| Set I2C MUX control register. | |