RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches

Overview

Function definitions for I2C driver.

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_getInterruptEnable (i2c_instance_t *inst)
 Get Interrupt Enable.
u32 i2c_getFilteringStatus (i2c_instance_t *inst)
 Get Filtering Status.
u32 i2c_getSlaveOverride (i2c_instance_t *inst)
 Get Slave Override.

I2C (Master Functions)

Functions for controlling the I2C master.

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_sendTxByte (i2c_instance_t *inst, u8 byte)
 Transmits a byte of data over I2C.
void i2c_sendTxAck (i2c_instance_t *inst)
 Transmits an ACK signal over I2C.
void i2c_sendTxNack (i2c_instance_t *inst)
 Transmits an NACK signal over I2C.
void i2c_waitTxAck (i2c_instance_t *inst)
 Waits until the transmission of an ACK signal is complete over the I2C bus.
void i2c_waitRxAck (i2c_instance_t *inst)
 Waits until the reception of an ACK signal is complete over the I2C bus.
void i2c_sendAckBlocking (i2c_instance_t *inst)
 Sends an ACK signal over the I2C bus and waits until the transmission is complete.
void i2c_sendNackBlocking (i2c_instance_t *inst)
 Sends an NACK signal over the I2C bus and waits until the transmission is complete.
u32 i2c_getRxData (i2c_instance_t *inst)
 Reads data from I2C receive data register.
u32 i2c_getRxAck (i2c_instance_t *inst)
 Reads Acknowledge signal from I2C receive data register.
u32 i2c_getRxNack (i2c_instance_t *inst)
 Checks if the received ACK signal is detected.
void i2c_sendTxByteRepeat (i2c_instance_t *inst, u8 byte)
 Sends a byte over I2C bus with repeat mode enabled.
void i2c_sendTxNackRepeat (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.

Function Documentation

◆ i2c_applyConfig()

void i2c_applyConfig ( i2c_instance_t * inst)

#include <i2c.h>

Apply the software configuration to the hardware.

Writes all values stored in the i2c_instance to the corresponding I2C hardware registers.

Parameters
instPointer to I2C instance.

Definition at line 83 of file i2c.c.

◆ i2c_checkMasterBusy()

u32 i2c_checkMasterBusy ( i2c_instance_t * inst)

#include <i2c.h>

Checks if the I2C master is busy.

Parameters
instPointer to I2C instance.
Returns
Non-zero if the master is busy, zero otherwise.

Definition at line 108 of file i2c.c.

◆ i2c_clearInterruptFlag()

void i2c_clearInterruptFlag ( i2c_instance_t * inst,
i2c_interrupt_t value )

#include <i2c.h>

Clears specific I2C interrupt flags.

Parameters
instPointer to I2C instance.
valueThe interrupt flag(s) to clear.

Definition at line 219 of file i2c.c.

◆ i2c_disableInterrupt()

void i2c_disableInterrupt ( i2c_instance_t * inst,
i2c_interrupt_t value )

#include <i2c.h>

Disables specific I2C interrupts.

Parameters
instPointer to I2C instance.
valueThe interrupt(s) to disable.

Definition at line 209 of file i2c.c.

◆ i2c_dropMaster()

void i2c_dropMaster ( i2c_instance_t * inst)

#include <i2c.h>

Drops the current I2C master operation.

Parameters
instPointer to I2C instance.

Definition at line 135 of file i2c.c.

◆ i2c_enableFilter()

void i2c_enableFilter ( i2c_instance_t * inst,
u32 filterId,
u32 config )

#include <i2c.h>

Enables and configures an I2C hardware filter.

Parameters
instPointer to I2C instance.
filterIdThe ID of the filter to enable.
configThe configuration value for the filter.

Definition at line 204 of file i2c.c.

◆ i2c_enableInterrupt()

void i2c_enableInterrupt ( i2c_instance_t * inst,
i2c_interrupt_t value )

#include <i2c.h>

Enables specific I2C interrupts.

Parameters
instPointer to I2C instance.
valueThe interrupt(s) to enable.

Definition at line 214 of file i2c.c.

◆ i2c_getFilteringHit()

u32 i2c_getFilteringHit ( i2c_instance_t * inst)

#include <i2c.h>

Get Filtering Hit.

Retrieve value from i2c_hwreg_t::HIT_CONTEXT.

Parameters
instPointer to I2C instance.
Returns
Filtering Hit Register Value.

Definition at line 38 of file i2c.c.

◆ i2c_getFilteringStatus()

u32 i2c_getFilteringStatus ( i2c_instance_t * inst)

#include <i2c.h>

Get Filtering Status.

Retrieve value from i2c_hwreg_t::FILTER_STATUS.

Parameters
instPointer to I2C instance.
Returns
Filtering Status Register Value.

Definition at line 43 of file i2c.c.

◆ i2c_getInterruptEnable()

u32 i2c_getInterruptEnable ( i2c_instance_t * inst)

#include <i2c.h>

Get Interrupt Enable.

Retrieve value from i2c_hwreg_t::INTERRUPT.

Parameters
instPointer to I2C instance.
Returns
Interrupt Enable Register Value.

Definition at line 28 of file i2c.c.

◆ i2c_getInterruptFlag()

u32 i2c_getInterruptFlag ( i2c_instance_t * inst)

#include <i2c.h>

Get Interrupt Flag.

Retrieve value from i2c_hwreg_t::INTERRUPT_CLEAR.

Parameters
instPointer to I2C instance.
Returns
Interrupt Flag Register Value.

Definition at line 23 of file i2c.c.

◆ i2c_getMasterStatus()

u32 i2c_getMasterStatus ( i2c_instance_t * inst)

#include <i2c.h>

Get Master Status.

Retrieve value from i2c_hwreg_t::MASTER_STATUS Register.

Parameters
instPointer to I2C instance.
Returns
Master Status Register Value.

Definition at line 33 of file i2c.c.

◆ i2c_getRxAck()

u32 i2c_getRxAck ( i2c_instance_t * inst)

#include <i2c.h>

Reads Acknowledge signal from I2C receive data register.

Parameters
instPointer to I2C instance.

Definition at line 68 of file i2c.c.

◆ i2c_getRxData()

u32 i2c_getRxData ( i2c_instance_t * inst)

#include <i2c.h>

Reads data from I2C receive data register.

Parameters
instPointer to I2C instance.

Definition at line 58 of file i2c.c.

◆ i2c_getRxNack()

u32 i2c_getRxNack ( i2c_instance_t * inst)

#include <i2c.h>

Checks if the received ACK signal is detected.

Parameters
instPointer to I2C instance.

Definition at line 63 of file i2c.c.

◆ i2c_getSlaveOverride()

u32 i2c_getSlaveOverride ( i2c_instance_t * inst)

#include <i2c.h>

Get Slave Override.

Retrieve value from i2c_hwreg_t::SLAVE_OVERRIDE.

Parameters
instPointer to I2C instance.
Returns
Slave Override Register Value.

Definition at line 53 of file i2c.c.

◆ i2c_getSlaveStatus()

u32 i2c_getSlaveStatus ( i2c_instance_t * inst)

#include <i2c.h>

Get Slave Status.

Retrieve value from i2c_hwreg_t::SLAVE_STATUS Register.

Parameters
instPointer to I2C instance.
Returns
Slave Status Register Value.

Definition at line 48 of file i2c.c.

◆ i2c_listenAck()

void i2c_listenAck ( i2c_instance_t * inst)

#include <i2c.h>

Configures the I2C controller to listen for ACK signals on the receiver (RX) line.

Parameters
instPointer to I2C instance.

Definition at line 151 of file i2c.c.

◆ i2c_readData_b()

void i2c_readData_b ( i2c_instance_t * inst,
u8 regAddr,
u8 * data,
u32 length )

#include <i2c.h>

Read data with an 8-bit register address over I2C.

Parameters
instPointer to I2C instance.
regAddr8-bit register address to read from.
dataPointer to data buffer to store read data.
lengthNumber of bytes to read.
Note
This function performs a read operation over the I2C bus using an 8-bit register address.
  • It begins by sending the start condition, followed by the slave address with the write bit.
  • Next, it transmits the target register address within the slave.
  • Then, it sends a repeated start condition followed by the slave address with the read bit.
  • Finally, it reads the specified number of bytes from the slave into the provided data buffer.

Definition at line 258 of file i2c.c.

◆ i2c_readData_w()

void i2c_readData_w ( i2c_instance_t * inst,
u16 regAddr,
u8 * data,
u32 length )

#include <i2c.h>

Read data with a 16-bit register address over I2C.

Parameters
instPointer to I2C instance.
regAddr16-bit register address to read from.
dataPointer to data buffer to store read data.
lengthNumber of bytes to read.
Note
This function performs a read operation over the I2C bus using a 16-bit register address.
  • It begins by sending the start condition, followed by the slave address with the write bit.
  • Next, it transmits the target register address within the slave.
  • Then, it sends a repeated start condition followed by the slave address with the read bit.
  • Finally, it reads the specified number of bytes from the slave into the provided data buffer.

Definition at line 285 of file i2c.c.

◆ i2c_recoverMaster()

void i2c_recoverMaster ( i2c_instance_t * inst)

#include <i2c.h>

Initiate recover condition for I2C master mode and sets the dropped status if necessary.

Parameters
instPointer to I2C instance.

Definition at line 103 of file i2c.c.

◆ i2c_recoverMasterBlocking()

void i2c_recoverMasterBlocking ( i2c_instance_t * inst)

#include <i2c.h>

Initiate recover condition for I2C master mode and waits until the operation is complete.

Parameters
instPointer to I2C instance.

Definition at line 140 of file i2c.c.

◆ i2c_restartMaster()

void i2c_restartMaster ( i2c_instance_t * inst)

#include <i2c.h>

Initiate restart condition for I2C master mode and sets the dropped status if necessary.

Parameters
instPointer to I2C instance.

Definition at line 98 of file i2c.c.

◆ i2c_restartMasterBlocking()

void i2c_restartMasterBlocking ( i2c_instance_t * inst)

#include <i2c.h>

Initiate restart condition for I2C master mode and waits until the operation is complete.

Parameters
instPointer to I2C instance.

Definition at line 119 of file i2c.c.

◆ i2c_sendAckBlocking()

void i2c_sendAckBlocking ( i2c_instance_t * inst)

#include <i2c.h>

Sends an ACK signal over the I2C bus and waits until the transmission is complete.

Parameters
instPointer to I2C instance.

Definition at line 162 of file i2c.c.

◆ i2c_sendNackBlocking()

void i2c_sendNackBlocking ( i2c_instance_t * inst)

#include <i2c.h>

Sends an NACK signal over the I2C bus and waits until the transmission is complete.

Parameters
instPointer to I2C instance.

Definition at line 156 of file i2c.c.

◆ i2c_sendTxAck()

void i2c_sendTxAck ( i2c_instance_t * inst)

#include <i2c.h>

Transmits an ACK signal over I2C.

Parameters
instPointer to I2C instance.

Definition at line 183 of file i2c.c.

◆ i2c_sendTxByte()

void i2c_sendTxByte ( i2c_instance_t * inst,
u8 byte )

#include <i2c.h>

Transmits a byte of data over I2C.

Parameters
instPointer to I2C instance.
byteThe byte of data to transmit.

Definition at line 178 of file i2c.c.

◆ i2c_sendTxByteRepeat()

void i2c_sendTxByteRepeat ( i2c_instance_t * inst,
u8 byte )

#include <i2c.h>

Sends a byte over I2C bus with repeat mode enabled.

Parameters
instPointer to I2C instance.
byteThe byte of data to transmit.

Definition at line 168 of file i2c.c.

◆ i2c_sendTxNack()

void i2c_sendTxNack ( i2c_instance_t * inst)

#include <i2c.h>

Transmits an NACK signal over I2C.

Parameters
instPointer to I2C instance.

Definition at line 188 of file i2c.c.

◆ i2c_sendTxNackRepeat()

void i2c_sendTxNackRepeat ( i2c_instance_t * inst)

#include <i2c.h>

Sends a NACK signal over I2C bus with repeat mode enabled.

Parameters
instPointer to I2C instance.

Definition at line 173 of file i2c.c.

◆ i2c_setFilterConfig()

void i2c_setFilterConfig ( i2c_instance_t * inst,
u32 filterId,
u32 value )

#include <i2c.h>

Sets the configuration for an I2C hardware filter.

Parameters
instPointer to I2C instance.
filterIdThe ID of the filter to configure.
valueThe configuration value to set for the filter.

Definition at line 78 of file i2c.c.

◆ i2c_setMux()

void i2c_setMux ( i2c_instance_t * inst,
const uint8_t cr )

#include <i2c.h>

Set I2C MUX control register.

Parameters
instPointer to I2C instance.
crMUX control register value.
Note
This function hardcdeds the I2C address of the multiplexer to 0x71.

Definition at line 314 of file i2c.c.

◆ i2c_setSlaveOverride()

void i2c_setSlaveOverride ( i2c_instance_t * inst,
u32 value )

#include <i2c.h>

Write values to I2C hardware registers.

Parameters
instPointer to I2C instance.
valueValue to write to Slave Override register.

Definition at line 73 of file i2c.c.

◆ i2c_startMaster()

void i2c_startMaster ( i2c_instance_t * inst)

#include <i2c.h>

Initiate start condition for I2C master mode and sets the dropped status if necessary.

Parameters
instPointer to I2C instance.

Definition at line 93 of file i2c.c.

◆ i2c_startMasterBlocking()

void i2c_startMasterBlocking ( i2c_instance_t * inst)

#include <i2c.h>

Initiate start condition for I2C master mode and waits until the operation is complete.

Parameters
instPointer to I2C instance.

Definition at line 113 of file i2c.c.

◆ i2c_stopMaster()

void i2c_stopMaster ( i2c_instance_t * inst)

#include <i2c.h>

Initiate stop condition for I2C master mode and sets the dropped status if necessary.

Parameters
instPointer to I2C instance.

Definition at line 124 of file i2c.c.

◆ i2c_stopMasterBlocking()

void i2c_stopMasterBlocking ( i2c_instance_t * inst)

#include <i2c.h>

Initiate stop condition for I2C master mode and waits until the operation is complete.

Parameters
instPointer to I2C instance.

Definition at line 129 of file i2c.c.

◆ i2c_waitRxAck()

void i2c_waitRxAck ( i2c_instance_t * inst)

#include <i2c.h>

Waits until the reception of an ACK signal is complete over the I2C bus.

Parameters
instPointer to I2C instance.

Definition at line 198 of file i2c.c.

◆ i2c_waitTxAck()

void i2c_waitTxAck ( i2c_instance_t * inst)

#include <i2c.h>

Waits until the transmission of an ACK signal is complete over the I2C bus.

Parameters
instPointer to I2C instance.

Definition at line 193 of file i2c.c.

◆ i2c_writeData_b()

void i2c_writeData_b ( i2c_instance_t * inst,
u8 regAddr,
u8 * data,
u32 length )

#include <i2c.h>

Write data with an 8-bit register address over I2C and check rx ack for each transaction.

Parameters
instPointer to I2C instance.
regAddr8-bit register address to write to.
dataPointer to data buffer to write.
lengthNumber of bytes to write.
Note
This function performs a write operation over the I2C bus using a 16-bit register address.
  • It begins by sending the start condition, followed by the slave address with the write bit.
  • Next, it transmits the target register address within the slave.
  • Then, it iterates through the provided data buffer, transmitting each byte individually.
  • After sending each byte, the function waits for an acknowledgment (ACK) from the slave , device to confirm reception using the TX_AND_CHECK() macro.
  • If at any point the slave does not acknowledge (ACK), the macro ensures that the function will block until an ACK is received. Finally, a stop condition is sent to complete the transaction.

Definition at line 224 of file i2c.c.

◆ i2c_writeData_w()

void i2c_writeData_w ( i2c_instance_t * inst,
u16 regAddr,
u8 * data,
u32 length )

#include <i2c.h>

Write data with a 16-bit register address over I2C and check rx ack for each transaction.

Parameters
instPointer to I2C instance.
regAddr16-bit register address to write to.
dataPointer to data buffer to write.
lengthNumber of bytes to write.
Note
This function performs a write operation over the I2C bus using a 16-bit register address.
  • It begins by sending the start condition, followed by the slave address with the write bit.
  • Next, it transmits the target register address within the slave.
  • Then, it iterates through the provided data buffer, transmitting each byte individually.
  • After sending each byte, the function waits for an acknowledgment (ACK) from the slave , device to confirm reception using the TX_AND_CHECK() macro.
  • If at any point the slave does not acknowledge (ACK), the macro ensures that the function will block until an ACK is received. Finally, a stop condition is sent to complete the transaction.

Definition at line 241 of file i2c.c.