Trinket M0: Create Uart Before I2C - Adafruit Feather M4 Express Manual

Table of Contents

Advertisement

import board
import busio
from microcontroller import Pin
def is_hardware_uart(tx, rx):
try:
p = busio.UART(tx, rx)
p.deinit()
return True
except ValueError:
return False
def get_unique_pins():
exclude = ['NEOPIXEL', 'APA102_MOSI', 'APA102_SCK']
pins = [pin for pin in [
getattr(board, p) for p in dir(board) if p not in exclude]
if isinstance(pin, Pin)]
unique = []
for p in pins:
if p not in unique:
unique.append(p)
return unique
for tx_pin in get_unique_pins():
for rx_pin in get_unique_pins():
if rx_pin is tx_pin:
continue
else:
if is_hardware_uart(tx_pin, rx_pin):
print("RX pin:", rx_pin, "\t TX pin:", tx_pin)
else:
pass

Trinket M0: Create UART before I2C

On the Trinket M0 (only), if you are using both
>>> import board,busio
>>> uart = busio.UART(board.TX, board.RX)
>>> i2c = busio.I2C(board.SCL, board.SDA)
Creating
first does not work:
busio.I2C
© Adafruit Industries
busio.UART
https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51
and
, you must create the UART object first, e.g.:
busio.I2C
Page 150 of 183

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Feather M4 Express and is the answer not in the manual?

Subscribe to Our Youtube Channel

Related Products for Adafruit Feather M4 Express

Table of Contents

Save PDF