This example illustrates how to utilize the Sapphire SoC as an I2C slave, offering the functionality of an 8-bit by 256-bit memory module. The provided i2cMasterDemo application can control the i2cSlaveDemo application as described in this section. Upon running the program, you will have the information on the I2C configurations, including the slave address, timeout settings, and various timing configurations. The UART console acts as an interactive terminal, facilitating the monitoring of current memory values by simply pressing the I key. By default, the slave is configured for 1-byte register addresses. For 2-byte register addresses, you need to modify the definition of WORD_REG_ADDR to 1.
For more detail of the driver, refer to I2C Driver
Newlib
By default, newlib-nano is used for this demo.
- See also
- User Debug Configuration - To learn more about User Debug Configuration.
Execution Sequence:
The design displays these messages in a UART terminal:
Welcome to I2C Slave Demo !
I2C 0 init done
This device will asct as I2C Slave with 8 bit x 256 bit memory
Configurations:
Slave Address = 0x67
Timeout setting = 0xc350
Tsu = 166
tLow = 250
tHigh = 250
tBuf = 500
0 1 2 3 4 5 6 7 8 9 a b c d e f
0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
40: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
90: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff
press i to show the memory content of I2C slave
>>