i2c_link i2c_master_v2
API Reference Manual  /  4 Model-to-Model Interfaces  / 

i2c_master

Description
SIM_INTERFACE(i2c_master) {
        void (*bus_freed)(conf_object_t *device);
        void (*read_response)(conf_object_t *device, uint8 value);
        void (*ack_read_response)(conf_object_t *device);
        void (*write_response)(conf_object_t *device, i2c_status_t status);
        void (*start_response)(conf_object_t *device, i2c_status_t status);
};

#define I2C_MASTER_INTERFACE "i2c_master"

The i2c_master interface should be implemented by devices that intend to act as a master on an I2C link.

The functions start_response, read_response, ack_read_response and write_response are called as a response to the corresponding request_* calls to the I2C link.

The status parameter to the start_response function can have three values:

I2C_status_success
The transfer was successfully started
I2C_status_noack
No I2C slave device accepted the transfer, likely because there was no I2C slave device listening to the given address
I2C_status_bus_busy
An existing transfer blocks the I2C link. When the existing transfer is completed (i.e., on the next STOP condition), the link will call the bus_freed function in the master device, if it's implemented. This makes it possible to avoid periodical polling of a busy link.

The status parameter to the write_response function can have two values, I2C_status_success for success, or I2C_status_noack if the slave device did not ack the written byte.

Execution Context
Cell Context for all methods.

i2c_link i2c_master_v2