In this use case, the I2C will used and set up as follows:
- Slave mode
- 100KHz operation speed
- Not operational in standby
- 10000 packet timeout value
Prerequisites
The device must be connected to an I2C master.
Setup
Code
The following must be added to the user application:
A sample buffer to write from, a sample buffer to read to and length of buffers:
Address to respond to:
Globally accessible module structure:
Function for setting up the module:
Add to user application main()
:
Workflow
- Configure and enable module.
- Create and initialize configuration structure.
- Change address and address mode settings in the configuration.
- Initialize the module with the set configurations.
- Enable the module.
- Create variable to hold transfer direction.
- Create packet variable to transfer.
Implementation
Code
Add to user application main()
:
Workflow
- Wait for start condition from master and get transfer direction.
- Depending on transfer direction, set up buffer to read to or write from, and write or read from master.