17.8.1.2.2 Workflow
- Configure and enable module.
voidconfigure_i2c_master(void){/* Initialize config structure and software module. */structi2c_master_config config_i2c_master;i2c_master_get_config_defaults(&config_i2c_master);/* Change buffer timeout to something longer. */config_i2c_master.buffer_timeout = 10000;/* Initialize and enable device with config. */i2c_master_init(&i2c_master_instance, CONF_I2C_MASTER_MODULE, &config_i2c_master);i2c_master_enable(&i2c_master_instance);}- Create and initialize configuration structure.
structi2c_master_config config_i2c_master;i2c_master_get_config_defaults(&config_i2c_master); - Change settings in the configuration.
config_i2c_master.buffer_timeout = 10000; - Initialize the module with the set configurations.
i2c_master_init(&i2c_master_instance, CONF_I2C_MASTER_MODULE, &config_i2c_master); - Enable the module.
i2c_master_enable(&i2c_master_instance);
- Create a variable to see when we should stop trying to send packet.
uint16_t timeout = 0; - Create a packet to send.
structi2c_master_packet packet = {.address = SLAVE_ADDRESS,.data_length = DATA_LENGTH,.data = write_buffer,.ten_bit_address =false,.high_speed =false,.hs_master_code = 0x0,};
