Expand description
Raw I2C bus access: CMD_I2C_TRANSFER, CMD_I2C_SCAN, their common
reply CMD_I2C_RESULT, and the two tables that describe what a host
may address (PROP_I2C_BUSES, PROP_I2C_DEVICES).
A transfer is one bus transaction with the semantics of embedded-hal
1.0’s I2c::transaction: a START, the address, the operations in
order with a repeated START on each change of direction and no
restart between consecutive operations of the same direction, and one
STOP at the end. The wire form is
BUS (UINT8) | ADDR (UINT8) | OP | OP | ...
OP = KIND (UINT8: 0 write, 1 read) | LEN (PUI) | [LEN data octets, write only]This module validates structure and the protocol’s own rules (a 7-bit address, a known kind, no empty operations, at least one operation). The per-bus limits a device advertises—how much data and how many operations one transfer may carry—are the device’s to enforce, since only it knows which bus is meant.
Structs§
- BusInfo
- One
PROP_I2C_BUSESitem. - Device
Info - One
PROP_I2C_DEVICESitem. - Ops
- The operations of a transfer, decoded one at a time from their wire form. Yields an error and then ends when the list is malformed, so a device validates the whole list before touching the bus.
- Scan
Request - A
CMD_I2C_SCANrequest with an absent range resolved to the default. - Transfer
Request - A
CMD_I2C_TRANSFERrequest whose structure has been validated. - Transfer
Shape - What a transfer amounts to, summed over its operations.
Enums§
- I2cError
- Why a request could not be honored, before any bus was touched.
- Op
- One operation of a transfer.
- OpKind
- The direction of one operation.
Constants§
- ADDRESS_
MAX - Largest 7-bit address.
- NAME_
MAX_ LEN - Longest bus or device name this crate encodes.
- RESULT_
OVERHEAD - Octets a
CMD_I2C_RESULTframe occupies beyond its payload: the header and the command identifier. - SCAN_
DEFAULT_ FIRST - First address a scan probes when the request names no range: the addresses below are reserved (general call, START byte, CBUS, and the high-speed master codes).
- SCAN_
DEFAULT_ LAST - Last address a scan probes when the request names no range: the addresses above are reserved for 10-bit addressing and future use.
Functions§
- buses
- Decode a whole
PROP_I2C_BUSESvalue. - devices
- Decode a whole
PROP_I2C_DEVICESvalue. - encode_
result - Encode a
CMD_I2C_RESULTframe carryingdata: the octets a transfer read, or the addresses a scan found. - encode_
scan - Encode a
CMD_I2C_SCANframe;rangeisNonefor the default. - encode_
transfer - Encode a
CMD_I2C_TRANSFERframe.