I2CDriverBase#
- class I2CDriverBase[source]#
Bases:
ABCVendor I2C-adapter driver contract. Concrete drivers own their transport and lifecycle.
addressarguments 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 the adapter handle.
Open the adapter (typically a USB host adapter) and prepare it for transactions.
Read
lengthbytes from the 7-bitaddress(master read transaction).Set the master clock rate in kHz.
Enable or disable target-power output on the adapter (where supported).
Enable or disable the adapter's internal bus pull-ups (typical: ~10 kΩ to VCC).
Write
datato the 7-bitaddress(master write transaction).Write
datathen immediately readread_lenbytes fromaddressusing a repeated START.- abstractmethod open() None[source]#
Open the adapter (typically a USB host adapter) and prepare it for transactions.
- abstractmethod read(address: int, length: int) bytes[source]#
Read
lengthbytes from the 7-bitaddress(master read transaction).
- abstractmethod write(address: int, data: bytes) None[source]#
Write
datato the 7-bitaddress(master write transaction).
- abstractmethod write_read( ) bytes[source]#
Write
datathen immediately readread_lenbytes fromaddressusing 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.