busio — Hardware accelerated behavior

The busio module contains classes to support a variety of serial protocols.

When the microcontroller does not support the behavior in a hardware accelerated fashion it may internally use a bitbang routine. However, if hardware support is available on a subset of pins but not those provided, then a RuntimeError will be raised. Use the bitbangio module to explicitly bitbang a serial protocol on any general purpose pins.

Libraries

All libraries change hardware state and should be deinitialized when they are no longer needed. To do so, either call deinit() or use a context manager.

For example:

import busio
from board import *

with busio.I2C(SCL, SDA) as i2c:
  i2c.scan()

This example will initialize the the device, run scan() and then deinit() the hardware.