XCORE SDK
XCORE Software Development Kit
Enumerations | Functions
hil_i2c_register

Enumerations

enum  i2c_regop_res_t { I2C_REGOP_SUCCESS , I2C_REGOP_DEVICE_NACK , I2C_REGOP_INCOMPLETE }
 

Functions

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)
 

Detailed Description

The public API for using the RTOS I2C slave driver.

Enumeration Type Documentation

◆ 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.

Function Documentation

◆ read_reg()

uint8_t read_reg ( i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  reg,
i2c_regop_res_t result 
)
inline

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
ctxA pointer to the I2C master context to use.
device_addrThe address of the device to read from.
regThe address of the register to read from.
resultIndicates 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()

uint16_t read_reg16 ( i2c_master_t ctx,
uint8_t  device_addr,
uint16_t  reg,
i2c_regop_res_t result 
)
inline

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
ctxA pointer to the I2C master context to use.
device_addrThe address of the device to read from.
regThe address of the register to read from.
resultIndicates 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()

uint16_t read_reg16_addr8 ( i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  reg,
i2c_regop_res_t result 
)
inline

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
ctxA pointer to the I2C master context to use.
device_addrThe address of the device to read from.
regThe address of the register to read from.
resultIndicates 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()

uint8_t read_reg8_addr16 ( i2c_master_t ctx,
uint8_t  device_addr,
uint16_t  reg,
i2c_regop_res_t result 
)
inline

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
ctxA pointer to the I2C master context to use.
device_addrThe address of the device to read from.
regThe address of the register to read from.
resultIndicates 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()

i2c_regop_res_t write_reg ( i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  reg,
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 context to use.
device_addrThe address of the device to write to.
regThe address of the register to write to.
dataThe 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()

i2c_regop_res_t write_reg16 ( i2c_master_t ctx,
uint8_t  device_addr,
uint16_t  reg,
uint16_t  data 
)
inline

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
ctxA pointer to the I2C master context to use.
device_addrThe address of the device to write to.
regThe address of the register to write to.
dataThe 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()

i2c_regop_res_t write_reg16_addr8 ( i2c_master_t ctx,
uint8_t  device_addr,
uint8_t  reg,
uint16_t  data 
)
inline

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
ctxA pointer to the I2C master context to use.
device_addrThe address of the device to write to.
regThe address of the register to write to.
dataThe 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()

i2c_regop_res_t write_reg8_addr16 ( i2c_master_t ctx,
uint8_t  device_addr,
uint16_t  reg,
uint8_t  data 
)
inline

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
ctxA pointer to the I2C master context to use.
device_addrThe address of the device to write to.
regThe address of the register to write to.
dataThe 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.