|
uint8_t | read_reg (i2c_master_t *ctx, uint8_t device_addr, uint8_t reg, i2c_regop_res_t *result) |
|
uint8_t | read_reg8_addr16 (i2c_master_t *ctx, uint8_t device_addr, uint16_t reg, i2c_regop_res_t *result) |
|
uint16_t | read_reg16_addr8 (i2c_master_t *ctx, uint8_t device_addr, uint8_t reg, i2c_regop_res_t *result) |
|
uint16_t | read_reg16 (i2c_master_t *ctx, uint8_t device_addr, uint16_t reg, i2c_regop_res_t *result) |
|
i2c_regop_res_t | write_reg (i2c_master_t *ctx, uint8_t device_addr, uint8_t reg, uint8_t data) |
|
i2c_regop_res_t | write_reg8_addr16 (i2c_master_t *ctx, uint8_t device_addr, uint16_t reg, uint8_t data) |
|
i2c_regop_res_t | write_reg16_addr8 (i2c_master_t *ctx, uint8_t device_addr, uint8_t reg, uint16_t data) |
|
i2c_regop_res_t | write_reg16 (i2c_master_t *ctx, uint8_t device_addr, uint16_t reg, uint16_t data) |
|
The public API for using the RTOS I2C slave driver.
◆ i2c_regop_res_t
This type is used by the supplementary I2C register read/write functions to report back on whether the operation was a success or not.
Enumerator |
---|
I2C_REGOP_SUCCESS | The operation was successful.
|
I2C_REGOP_DEVICE_NACK | The operation was NACKed when sending the device address, so either the device is missing or busy.
|
I2C_REGOP_INCOMPLETE | The operation was NACKed halfway through by the slave.
|
◆ read_reg()
Read an 8-bit register on a slave 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
- 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 context to use. |
device_addr | The address of the device to read from. |
reg | The address of the register to read from. |
result | Indicates whether the read completed successfully. Will be set to I2C_REGOP_DEVICE_NACK if the slave NACKed, and I2C_REGOP_SUCCESS on successful completion of the read. |
- Returns
- The value of the register.
◆ read_reg16()
Read an 16-bit register on a slave device.
This function reads from an 16-bit addressed, 16-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
- 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 context to use. |
device_addr | The address of the device to read from. |
reg | The address of the register to read from. |
result | Indicates whether the read completed successfully. Will be set to I2C_REGOP_DEVICE_NACK if the slave NACKed, and I2C_REGOP_SUCCESS on successful completion of the read. |
- Returns
- The value of the register.
◆ read_reg16_addr8()
Read an 16-bit register on a slave device.
This function reads from an 8-bit addressed, 16-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
- 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 context to use. |
device_addr | The address of the device to read from. |
reg | The address of the register to read from. |
result | Indicates whether the read completed successfully. Will be set to I2C_REGOP_DEVICE_NACK if the slave NACKed, and I2C_REGOP_SUCCESS on successful completion of the read. |
- Returns
- The value of the register.
◆ read_reg8_addr16()
Read an 8-bit register on a slave device.
This function reads from an 16-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
- 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 context to use. |
device_addr | The address of the device to read from. |
reg | The address of the register to read from. |
result | Indicates whether the read completed successfully. Will be set to I2C_REGOP_DEVICE_NACK if the slave NACKed, and I2C_REGOP_SUCCESS on successful completion of the read. |
- Returns
- The value of the register.
◆ write_reg()
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 context to use. |
device_addr | The address of the device to write to. |
reg | The address of the register to write to. |
data | The 8-bit value to write. |
- Returns
- I2C_REGOP_DEVICE_NACK if the address is NACKed.
-
I2C_REGOP_INCOMPLETE if not all data was ACKed.
-
I2C_REGOP_SUCCESS on successful completion of the write.
◆ write_reg16()
Write to a 16-bit register on an I2C device.
This function writes to a 16-bit addressed, 16-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 context to use. |
device_addr | The address of the device to write to. |
reg | The address of the register to write to. |
data | The 16-bit value to write. |
- Returns
- I2C_REGOP_DEVICE_NACK if the address is NACKed.
-
I2C_REGOP_INCOMPLETE if not all data was ACKed.
-
I2C_REGOP_SUCCESS on successful completion of the write.
◆ write_reg16_addr8()
Write to a 16-bit register on an I2C device.
This function writes to an 8-bit addressed, 16-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 context to use. |
device_addr | The address of the device to write to. |
reg | The address of the register to write to. |
data | The 16-bit value to write. |
- Returns
- I2C_REGOP_DEVICE_NACK if the address is NACKed.
-
I2C_REGOP_INCOMPLETE if not all data was ACKed.
-
I2C_REGOP_SUCCESS on successful completion of the write.
◆ write_reg8_addr16()
Write to an 8-bit register on an I2C device.
This function writes to a 16-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 context to use. |
device_addr | The address of the device to write to. |
reg | The address of the register to write to. |
data | The 8-bit value to write. |
- Returns
- I2C_REGOP_DEVICE_NACK if the address is NACKed.
-
I2C_REGOP_INCOMPLETE if not all data was ACKed.
-
I2C_REGOP_SUCCESS on successful completion of the write.