![Adafruit Feather M4 Express Скачать руководство пользователя страница 145](http://html1.mh-extra.com/html/adafruit/feather-m4-express/feather-m4-express_manual_2845857145.webp)
Trinket M0: Create UART before I2C
On the Trinket M0 (only), if you are using both
busio.UART
and
busio.I2C
, you must create the UART object first, e.g.:
>>> import board,busio
>>> uart = busio.UART(board.TX, board.RX)
>>> i2c = busio.I2C(board.SCL, board.SDA)
Creating
busio.I2C
first does not work:
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
© Adafruit Industries
https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51
Page 150 of 183
Содержание Feather M4 Express
Страница 1: ...Adafruit Feather M4 Express Created by lady ada Last updated on 2019 03 04 10 41 14 PM UTC...
Страница 5: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 10 of 183...
Страница 58: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 63 of 183...
Страница 164: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 169 of 183...
Страница 168: ...Adafruit Industries https learn adafruit com adafruit feather m4 express atsamd51 Page 173 of 183...