|
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) |
|
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.
◆ rtos_i2c_master_read()
Reads data from an I2C bus as a master.
- Parameters
-
ctx | A pointer to the I2C master driver instance to use. |
device_addr | The address of the device to read from. |
buf | The buffer to fill with data. |
n | The number of bytes to read. |
send_stop_bit | If 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()
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
-
ctx | A pointer to the I2C master driver instance to use. |
device_addr | The address of the device to read from. |
reg_addr | The address of the register to read from. |
data | A 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()
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
-
ctx | A pointer to the I2C master driver instance to use. |
device_addr | The address of the device to write to. |
reg_addr | The address of the register to write to. |
data | The 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()
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
-
ctx | A 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
-
ctx | A pointer to the I2C master driver instance to use. |
device_addr | The address of the device to write to. |
buf | The buffer containing data to write. |
n | The number of bytes to write. |
num_bytes_sent | The 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_bit | If 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. | |