XCORE SDK
XCORE Software Development Kit
Functions
rtos_i2c_master_driver_core

Functions

i2c_res_t rtos_i2c_master_write (rtos_i2c_master_t *ctx, uint8_t device_addr, uint8_t buf[], size_t n, size_t *num_bytes_sent, int send_stop_bit)
 
i2c_res_t rtos_i2c_master_read (rtos_i2c_master_t *ctx, uint8_t device_addr, uint8_t buf[], size_t n, int send_stop_bit)
 
void rtos_i2c_master_stop_bit_send (rtos_i2c_master_t *ctx)
 
i2c_regop_res_t rtos_i2c_master_reg_write (rtos_i2c_master_t *ctx, uint8_t device_addr, uint8_t reg_addr, uint8_t data)
 
i2c_regop_res_t rtos_i2c_master_reg_read (rtos_i2c_master_t *ctx, uint8_t device_addr, uint8_t reg_addr, uint8_t *data)
 

Detailed Description

The core functions for using an RTOS I2C master driver instance after it has been initialized and started. These functions may be used by both the host and any client tiles that RPC has been enabled for.

Function Documentation

◆ rtos_i2c_master_read()

i2c_res_t rtos_i2c_master_read ( rtos_i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  buf[],
size_t  n,
int  send_stop_bit 
)
inline

Reads data from an I2C bus as a master.

Parameters
ctxA pointer to the I2C master driver instance to use.
device_addrThe address of the device to read from.
bufThe buffer to fill with data.
nThe number of bytes to read.
send_stop_bitIf this is non-zero then a stop bit. will be sent on the bus after the transaction. This is usually required for normal operation. If this parameter is zero then no stop bit will be omitted. In this case, no other task can use the component until a stop bit has been sent.
Return values
<tt>I2C_ACK</tt>if the read was acknowledged by the device.
<tt>I2C_NACK</tt>otherwise.

◆ rtos_i2c_master_reg_read()

i2c_regop_res_t rtos_i2c_master_reg_read ( rtos_i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  reg_addr,
uint8_t *  data 
)
inline

Reads from an 8-bit register on an I2C device.

This function reads from an 8-bit addressed, 8-bit register in an I2C device. The function reads the data by sending the register address followed reading the register data from the device at the specified device address.

Note that no stop bit is transmitted between the write and the read. The operation is performed as one transaction using a repeated start.

Parameters
ctxA pointer to the I2C master driver instance to use.
device_addrThe address of the device to read from.
reg_addrThe address of the register to read from.
dataA pointer to the byte to fill with data read from the register.
Return values
<tt>I2C_REGOP_DEVICE_NACK</tt>if the device NACKed.
<tt>I2C_REGOP_SUCCESS</tt>on successful completion of the read.

◆ rtos_i2c_master_reg_write()

i2c_regop_res_t rtos_i2c_master_reg_write ( rtos_i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  reg_addr,
uint8_t  data 
)
inline

Write to an 8-bit register on an I2C device.

This function writes to an 8-bit addressed, 8-bit register in an I2C device. The function writes the data by sending the register address followed by the register data to the device at the specified device address.

Parameters
ctxA pointer to the I2C master driver instance to use.
device_addrThe address of the device to write to.
reg_addrThe address of the register to write to.
dataThe 8-bit value to write.
Return values
<tt>I2C_REGOP_DEVICE_NACK</tt>if the address is NACKed.
<tt>I2C_REGOP_INCOMPLETE</tt>if not all data was ACKed.
<tt>I2C_REGOP_SUCCESS</tt>on successful completion of the write.

◆ rtos_i2c_master_stop_bit_send()

void rtos_i2c_master_stop_bit_send ( rtos_i2c_master_t ctx)
inline

Send a stop bit to an I2C bus as a master.

This function will cause a stop bit to be sent on the bus. It should be used to complete/abort a transaction if the send_stop_bit argument was not set when calling the rtos_i2c_master_read() or rtos_i2c_master_write() functions.

Parameters
ctxA pointer to the I2C master driver instance to use.

◆ rtos_i2c_master_write()

i2c_res_t rtos_i2c_master_write ( rtos_i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  buf[],
size_t  n,
size_t *  num_bytes_sent,
int  send_stop_bit 
)
inline

Writes data to an I2C bus as a master.

Parameters
ctxA pointer to the I2C master driver instance to use.
device_addrThe address of the device to write to.
bufThe buffer containing data to write.
nThe number of bytes to write.
num_bytes_sentThe function will set this value to the number of bytes actually sent. On success, this will be equal to n but it will be less if the slave sends an early NACK on the bus and the transaction fails.
send_stop_bitIf this is non-zero then a stop bit will be sent on the bus after the transaction. This is usually required for normal operation. If this parameter is zero then no stop bit will be omitted. In this case, no other task can use the component until a stop bit has been sent.
Return values
<tt>I2C_ACK</tt>if the write was acknowledged by the device.
<tt>I2C_NACK</tt>otherwise.