1313
1414import time , sys
1515
16- byte_by_byte = False
17- # Configure pins based on the target.
18- if "alif" in sys .platform :
19- uart_id = 1
20- tx_pin = None
21- rx_pin = None
22- elif "esp32" in sys .platform :
23- uart_id = 1
24- tx_pin = 4
25- rx_pin = 5
26- elif "pyboard" in sys .platform :
27- if "STM32WB" in sys .implementation ._machine :
28- # LPUART(1) is on PA2/PA3
29- uart_id = "LP1"
30- else :
31- # UART(4) is on PA0/PA1
32- uart_id = 4
33- tx_pin = None
34- rx_pin = None
35- elif "samd" in sys .platform and "ItsyBitsy M0" in sys .implementation ._machine :
36- uart_id = 0
37- tx_pin = "D1"
38- rx_pin = "D0"
39- byte_by_byte = True
40- elif "samd" in sys .platform and "ItsyBitsy M4" in sys .implementation ._machine :
41- uart_id = 3
42- tx_pin = "D1"
43- rx_pin = "D0"
44- elif "nrf" in sys .platform :
45- uart_id = 0
46- tx_pin = None
47- rx_pin = None
48- elif "renesas-ra" in sys .platform :
49- uart_id = 9
50- tx_pin = None # P602 @ RA6M2
51- rx_pin = None # P601 @ RA6M2
52- elif "CC3200" in sys .implementation ._machine :
16+ if "CC3200" in sys .implementation ._machine :
5317 # CC3200 doesn't work because it's too slow and has an allocation error in the handler.
5418 print ("SKIP" )
5519 raise SystemExit
56- else :
57- print ("Please add support for this test on this platform." )
58- raise SystemExit
20+
21+ from target_wiring import uart_loopback_args , uart_loopback_kwargs
22+
23+ byte_by_byte = "ItsyBitsy M0" in sys .implementation ._machine
5924
6025
6126def irq (u ):
@@ -67,11 +32,7 @@ def irq(u):
6732# Test that the IRQ is called for each byte received.
6833# Use slow baudrates so that the IRQ has time to run.
6934for bits_per_s in (2400 , 9600 ):
70- if tx_pin is None :
71- uart = UART (uart_id , bits_per_s )
72- else :
73- uart = UART (uart_id , bits_per_s , tx = tx_pin , rx = rx_pin )
74-
35+ uart = UART (* uart_loopback_args , baudrate = bits_per_s , ** uart_loopback_kwargs )
7536 uart .irq (irq , uart .IRQ_RX )
7637
7738 print ("write" , bits_per_s )
0 commit comments