I2CDriverBase#

class I2CDriverBase[source]#

Bases: ABC

Vendor I2C-adapter driver contract. Concrete drivers own their transport and lifecycle.

address arguments are 7-bit device addresses (the adapter SDK handles the R/W bit). Drivers translate this contract to the vendor SDK’s master primitives.

Methods

close

Close the adapter handle.

open

Open the adapter (typically a USB host adapter) and prepare it for transactions.

read

Read length bytes from the 7-bit address (master read transaction).

set_bitrate

Set the master clock rate in kHz.

set_power_enable

Enable or disable target-power output on the adapter (where supported).

set_pullups

Enable or disable the adapter's internal bus pull-ups (typical: ~10 kΩ to VCC).

write

Write data to the 7-bit address (master write transaction).

write_read

Write data then immediately read read_len bytes from address using a repeated START.

abstractmethod open() → None[source]#

Open the adapter (typically a USB host adapter) and prepare it for transactions.

abstractmethod close() → None[source]#

Close the adapter handle. Idempotent.

abstractmethod read(address: int, length: int) → bytes[source]#

Read length bytes from the 7-bit address (master read transaction).

abstractmethod write(address: int, data: bytes) → None[source]#

Write data to the 7-bit address (master write transaction).

abstractmethod write_read(
address: int,
data: bytes,
read_len: int,
) → bytes[source]#

Write data then immediately read read_len bytes from address using a repeated START.

Used for register reads: write the register address, then read its contents without releasing the bus. No STOP is issued between the write and the read.

abstractmethod set_bitrate(bitrate: int) → None[source]#

Set the master clock rate in kHz. Drivers may snap to the nearest supported rate.

abstractmethod set_pullups(enable: bool) → None[source]#

Enable or disable the adapter’s internal bus pull-ups (typical: ~10 kΩ to VCC).

abstractmethod set_power_enable(enable: bool) → None[source]#

Enable or disable target-power output on the adapter (where supported).