17.8.2.2.2 Workflow
- Configure and enable module.
configure_i2c();- 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 = 65535; - Initialize the module with the set configurations.
while(i2c_master_init(&i2c_master_instance, CONF_I2C_MASTER_MODULE, &config_i2c_master) \!= STATUS_OK); - Enable the module.
i2c_master_enable(&i2c_master_instance);
- Configure callback functionality.
configure_i2c_callbacks();- Register write complete callback.
i2c_master_register_callback(&i2c_master_instance, i2c_write_complete_callback,I2C_MASTER_CALLBACK_WRITE_COMPLETE); - Enable write complete callback.
i2c_master_enable_callback(&i2c_master_instance,I2C_MASTER_CALLBACK_WRITE_COMPLETE);
- Create a packet to send to slave.
wr_packet.address = SLAVE_ADDRESS;wr_packet.data_length = DATA_LENGTH;wr_packet.data = wr_buffer;
