Module i2c

Module i2c 

Source
Expand description

The bus half of CMD_I2C_TRANSFER and CMD_I2C_SCAN, over any embedded-hal-async bus.

transfer_with and scan_with are the part that is the same on every board: turning the staged operation list into HAL operations that read straight into the result buffer, walking a scan range, and naming what went wrong in the protocol’s terms. guarded_transfer and guarded_scan add what a board with a shared bus needs around them—a bounded wait for the bus mutex, a deadline on the transaction, and a Reservation through which the board’s own multi-transaction procedures keep a host out of a peripheral mid-procedure. A board with an exclusively owned bus can call the bare functions instead.

Structs§

Held
A Reservation in force; dropping it releases the peripheral.
Reservation
The peripheral one of the board’s own multi-transaction procedures currently holds, if any.

Traits§

Reservations
Independent board procedures may reserve different devices concurrently.

Functions§

deadline_for
How long a transaction moving octets on a bus clocked at speed_khz may take before it is declared stuck.
guarded_scan
The scan counterpart of guarded_transfer: a range that covers a held address is refused whole rather than silently skipping it, so the host learns to try again instead of drawing a wrong inventory.
guarded_transfer
Acquire bus within lock_timeout, refuse the transfer if reserved holds its address, and perform it within deadline.
scan_deadline
The deadline for a whole scan: an address and a probe octet per address in the range.
scan_with
Probe every address in request’s range with a one-octet read, writing the addresses that acknowledged into out in ascending order and returning how many.
status_for
The status a HAL error kind answers with.
transfer_deadline
The deadline for a transfer of shape: its data plus one address octet per operation.
transfer_with
Perform request on bus, writing the concatenated read data into out and returning its length.