18.8.1.2.2 Workflow
- Configure and enable module.
configure_i2c_slave();
- Create and initialize configuration structure.
struct
i2c_slave_config config_i2c_slave;
i2c_slave_get_config_defaults(&config_i2c_slave);
- Change address and address mode settings in the configuration.
config_i2c_slave.address = SLAVE_ADDRESS;
config_i2c_slave.address_mode = I2C_SLAVE_ADDRESS_MODE_MASK;
config_i2c_slave.buffer_timeout = 1000;
- Initialize the module with the set configurations.
i2c_slave_init(&i2c_slave_instance, CONF_I2C_SLAVE_MODULE, &config_i2c_slave);
- Enable the module.
i2c_slave_enable(&i2c_slave_instance);
- Create variable to hold transfer direction.
enum
i2c_slave_direction dir;
- Create packet variable to transfer.
struct
i2c_slave_packet packet = {
.data_length = DATA_LENGTH,
.data = write_buffer,
};