The functions in the Inter-Integrated Circuit (I2C) Slave synchronous driver provides an interface to read/write the data from/to the master device. The functions will be blocked until the operation is done.
I2C Modes (standard mode/fastmode+/highspeed mode) can only be selected in START.
Initialize and deinitialize the driver and associated hardware
Register the I/O descriptor
Set the address of the slave device
Enable or disable the I2C slave
Read/Write message to/from the master
Set the I2C slave device address
Which clock source is used
After the I2C hardware initialization, the i2c_s_sync_get_io_descriptor function is needed to register an I/O descriptor. Then use the i2c_s_sync_set_addr function to set the slave address and enable the I2C hardware. At the end, start the read/write operation.
System Management Bus (SMBus) is not supported
Power Management Bus (PMBus) is not supported
The following shows a simple example of using the I2C slave. The I2C slave must have been initialized by i2c_s_sync_init. This initialization will configure the operation of the I2C slave.
void I2C_0_example(void)
{
struct io_descriptor *io;
uint8_t c;
i2c_s_sync_get_io_descriptor(&I2C_0, &io);
i2c_s_sync_set_addr(&I2C_0, 1);
i2c_s_sync_enable(&I2C_0);
io_read(io, &c, 1);
}
The I2C slave peripheral and its related I/O lines and clocks