18.8.1.2.2 Workflow

  1. Configure and enable module.
    configure_i2c_slave();
    
    1. Create and initialize configuration structure.
      struct i2c_slave_config config_i2c_slave;
      i2c_slave_get_config_defaults(&config_i2c_slave);
      
    2. 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;
      
    3. Initialize the module with the set configurations.
      i2c_slave_init(&i2c_slave_instance, CONF_I2C_SLAVE_MODULE, &config_i2c_slave);
      
    4. Enable the module.
      i2c_slave_enable(&i2c_slave_instance);
      
  2. Create variable to hold transfer direction.
    enum i2c_slave_direction dir;
    
  3. Create packet variable to transfer.
    struct i2c_slave_packet packet = {
        .data_length = DATA_LENGTH,
        .data        = write_buffer,
    };