@web-font-path: "roboto-debian.css";
Functions providing an interrupt driven I2C slave interface. More...
Typedefs | |
typedef enum i2c_slave_event_t | i2c_slave_event_t |
I2C slave event types. | |
typedef void(* | i2c_slave_handler_t) (i2c_inst_t *i2c, i2c_slave_event_t event) |
I2C slave event handler. | |
Enumerations | |
enum | i2c_slave_event_t { I2C_SLAVE_RECEIVE , I2C_SLAVE_REQUEST , I2C_SLAVE_FINISH } |
I2C slave event types. More... | |
Functions | |
void | i2c_slave_init (i2c_inst_t *i2c, uint8_t address, i2c_slave_handler_t handler) |
Configure an I2C instance for slave mode. | |
void | i2c_slave_deinit (i2c_inst_t *i2c) |
Restore an I2C instance to master mode. | |
Functions providing an interrupt driven I2C slave interface.
This I2C slave helper library configures slave mode and hooks the relevant I2C IRQ so that a user supplied handler is called with enumerated I2C events.
An example application slave_mem_i2c
, which makes use of this library, can be found in pico_examples.
typedef void(* i2c_slave_handler_t) (i2c_inst_t *i2c, i2c_slave_event_t event) |
I2C slave event handler.
The event handler will run from the I2C ISR, so it should return quickly (under 25 us at 400 kb/s). Avoid blocking inside the handler and split large data transfers across multiple calls for best results. When sending data to master, up to i2c_get_write_available() bytes can be written without blocking. When receiving data from master, up to i2c_get_read_available() bytes can be read without blocking.
enum i2c_slave_event_t |
void i2c_slave_deinit | ( | i2c_inst_t * | i2c | ) |
void i2c_slave_init | ( | i2c_inst_t * | i2c, |
uint8_t | address, | ||
i2c_slave_handler_t | handler ) |
Configure an I2C instance for slave mode.
i2c | I2C instance. |
address | 7-bit slave address. |
handler | Callback for events from I2C master. It will run from the I2C ISR, on the CPU core where the slave was initialised. |