I2C Slave Synchronous Driver

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.

Summary of the API's Functional Features

The API provides functions to:
  • 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

Summary of Configuration Options

Below is a list of the main I2C slave parameters that can be configured in START. Many of these parameters are used by the i2c_s_sync_init function when initializing the driver and underlying hardware. Most of the initial values can be overridden.
  • Set the I2C slave device address

  • Which clock source is used

Driver Implementation Description

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.

Limitations

  • System Management Bus (SMBus) is not supported

  • Power Management Bus (PMBus) is not supported

Example of Usage

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.

The example enables the I2C slave, and finally starts a reading operation to the master.
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);}

Dependencies

  • The I2C slave peripheral and its related I/O lines and clocks