Skip to content

Support async in i2c Driver by using new ESP-IDF V5.2 driver impl #388

@teamplayer3

Description

@teamplayer3

i2c Driver Docs

The driver APIs have been clearly divided into master and slave, with all calls now separated into i2c_master_* and i2c_slave_*. This provides a higher-level interface for the i2c driver. To support async operations in master mode, callbacks can be set in transmit, transmit_receive, and receive to signal when the operation is complete. An event callback can also be registered with register_event_callbacks to receive events such as I2C_EVENT_ALIVE, I2C_EVENT_DONE, and I2C_EVENT_NACK. To initiate a receive job call slave_receive while in slave mode and to wait for any receive data a callback can be registered with register_event_callbacks.

Changes to current i2c impl

  • Add AsyncI2cSlaveDriver
  • Add I2cBusDriver: allows adding I2cDevice
  • Add I2cDevice: exposes read, write, read_write
  • Add AsyncI2cBusDriver: allows adding AsyncI2cDevice (adds a guard that only one device can use the bus at once), cannot depend on I2cBusDriver because config of bus requires config of cmd queue depth for async operations
  • Add AsyncI2cDevice: exposes async read, async write, async read_write
  • add cfg guards for current esp calls major == 4 || version == 5.1
  • add cfg guards to new calls major != 4 && version != 5.1

Challenges

  • new i2c API does not expose transactional operations
### Tasks
- [ ] https://github.com/esp-rs/esp-idf-sys/pull/290

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions