Data Sheet

AS7265x
Design Considerations
ams Application Note Page 14
[v1-5] 2018-May-23 Document Feedback
Figure 17. Sample Code of Writing a Virtual Register
void i2cm_AS72xx_write(uint8_t virtualReg, uint8_t d)
{
volatile uint8_t status;
while (1)
{
// Read slave I2C status to see if we can write the reg address.
status = i2cm_read(I2C_AS72XX_SLAVE_STATUS_REG);
if ((status & I2C_AS72XX_SLAVE_TX_VALID) == 0)
// No inbound TX pending at slave. Okay to write now.
break ;
}
// Send the virtual register address
// (setting bit 7 to indicate a pending write).
i2cm_write(I2C_AS72XX_SLAVE_WRITE_REG, (virtualReg | 0x80)) ;
while (1)
{
// Read the slave I2C status to see if we can write the data byte.
status = i2cm_read(I2C_AS72XX_SLAVE_STATUS_REG) ;
if ((status & I2C_AS72XX_SLAVE_TX_VALID) == 0)
// No inbound TX pending at slave. Okay to write data now.
break ;
}
// Send the data to complete the operation.
i2cm_write(I2C_AS72XX_SLAVE_WRITE_REG, d) ;
}