Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
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_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.

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 59 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 84 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 214 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 204 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 111 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 199 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 209 of file i2c.c.

◆ i2c_getFilteringHit()

u32 i2c_getFilteringHit ( i2c_instance_t * inst)

#include <i2c.h>

Get Filtering Hit.

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

Definition at line 33 of file i2c.c.

◆ i2c_getFilteringStatus()

u32 i2c_getFilteringStatus ( i2c_instance_t * inst)

#include <i2c.h>

Get Filtering Status.

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

Definition at line 38 of file i2c.c.

◆ i2c_getInterruptFlag()

u32 i2c_getInterruptFlag ( i2c_instance_t * inst)

#include <i2c.h>

Get Interrupt Flag.

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.

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

Definition at line 28 of file i2c.c.

◆ i2c_getSlaveOverride()

u32 i2c_getSlaveOverride ( i2c_instance_t * inst)

#include <i2c.h>

Get Slave Override.

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

Definition at line 48 of file i2c.c.

◆ i2c_getSlaveStatus()

u32 i2c_getSlaveStatus ( i2c_instance_t * inst)

#include <i2c.h>

Get Slave Status.

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

Definition at line 43 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 127 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 253 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 280 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 79 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 116 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 74 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 95 of file i2c.c.

◆ i2c_rxAck()

u32 i2c_rxAck ( i2c_instance_t * inst)

#include <i2c.h>

Reads data from I2C receive data register.

Parameters
instPointer to I2C instance.

Definition at line 179 of file i2c.c.

◆ i2c_rxAckWait()

void i2c_rxAckWait ( 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 152 of file i2c.c.

◆ i2c_rxData()

u32 i2c_rxData ( i2c_instance_t * inst)

#include <i2c.h>

Reads data from I2C receive data register.

Parameters
instPointer to I2C instance.

Definition at line 169 of file i2c.c.

◆ i2c_rxNack()

u32 i2c_rxNack ( i2c_instance_t * inst)

#include <i2c.h>

Checks if the received ACK signal is detected.

Parameters
instPointer to I2C instance.

Definition at line 174 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 194 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 307 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 54 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 69 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 89 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 100 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 105 of file i2c.c.

◆ i2c_txAck()

void i2c_txAck ( i2c_instance_t * inst)

#include <i2c.h>

Transmits an ACK signal over I2C.

Parameters
instPointer to I2C instance.

Definition at line 137 of file i2c.c.

◆ i2c_txAckBlocking()

void i2c_txAckBlocking ( 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 157 of file i2c.c.

◆ i2c_txAckWait()

void i2c_txAckWait ( 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 147 of file i2c.c.

◆ i2c_txByte()

void i2c_txByte ( 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 132 of file i2c.c.

◆ i2c_txByteRepeat()

void i2c_txByteRepeat ( 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 184 of file i2c.c.

◆ i2c_txNack()

void i2c_txNack ( i2c_instance_t * inst)

#include <i2c.h>

Transmits an NACK signal over I2C.

Parameters
instPointer to I2C instance.

Definition at line 142 of file i2c.c.

◆ i2c_txNackBlocking()

void i2c_txNackBlocking ( 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 163 of file i2c.c.

◆ i2c_txNackRepeat()

void i2c_txNackRepeat ( 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 189 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 219 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 236 of file i2c.c.