adafruit_bitbangio
¶
A library for adding bitbang I2C and SPI to CircuitPython without the built-in bitbangio module. The interface is intended to be the same as bitbangio and therefore there is no bit order or chip select functionality. If your board supports bitbangio, it is recommended to use that instead as the timing should be more reliable.
- Author(s): Melissa LeBlanc-Williams
Implementation Notes¶
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
-
class
adafruit_bitbangio.
I2C
(scl, sda, *, frequency=400000, timeout=1)¶ Software-based implementation of the I2C protocol over GPIO pins.
-
deinit
()¶ Free any hardware used by the object.
-
readfrom_into
(address, buffer, *, start=0, end=None)¶ Read data from an address and into the buffer
-
scan
()¶ Perform an I2C Device Scan
-
writeto
(address, buffer, *, start=0, end=None)¶ Write data from the buffer to an address
-
writeto_then_readfrom
(address, buffer_out, buffer_in, *, out_start=0, out_end=None, in_start=0, in_end=None)¶ Write data from buffer_out to an address and then read data from an address and into buffer_in
-
-
class
adafruit_bitbangio.
SPI
(clock, MOSI=None, MISO=None)¶ Software-based implementation of the SPI protocol over GPIO pins.
-
configure
(*, baudrate=100000, polarity=0, phase=0, bits=8)¶ Configures the SPI bus. Only valid when locked.
-
deinit
()¶ Free any hardware used by the object.
-
frequency
¶ Return the currently configured baud rate
-
readinto
(buffer, start=0, end=None, write_value=0)¶ Read into the buffer specified by buf while writing zeroes. Requires the SPI being locked. If the number of bytes to read is 0, nothing happens.
-
write
(buffer, start=0, end=None)¶ Write the data contained in buf. Requires the SPI being locked. If the buffer is empty, nothing happens.
-
write_readinto
(buffer_out, buffer_in, *, out_start=0, out_end=None, in_start=0, in_end=None)¶ Write out the data in buffer_out while simultaneously reading data into buffer_in. The lengths of the slices defined by buffer_out[out_start:out_end] and buffer_in[in_start:in_end] must be equal. If buffer slice lengths are both 0, nothing happens.
-