nativeio — Hardware accelerated behavior

The nativeio module contains classes to provide access to IO typically accelerated by hardware on the onboard microcontroller. The classes are meant to align with commonly hardware accelerated IO and not necessarily match up with microcontroller structure (because it varies).

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 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 nativeio
from board import *

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

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

Here is blinky:

import nativeio
from board import *
import time

with nativeio.DigitalInOut(D13) as led:
  led.switch_to_output()
  while True:
    led.value = True
    time.sleep(0.1)
    led.value = False
    time.sleep(0.1)