tests/extmod_hardware/machine_pwm.py: Convert test to use target_wiring. · sofarocean/micropython@8f24c86 · GitHub
Skip to content

Commit 8f24c86

Browse files
committed
tests/extmod_hardware/machine_pwm.py: Convert test to use target_wiring.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 47871a4 commit 8f24c86

12 files changed

Lines changed: 63 additions & 34 deletions

File tree

tests/extmod_hardware/machine_pwm.py

Lines changed: 17 additions & 34 deletions

tests/run-tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@
291291
"extmod/machine_uart_tx.py",
292292
"extmod_hardware/machine_can_timings.py",
293293
"extmod_hardware/machine_encoder.py",
294+
"extmod_hardware/machine_pwm.py",
294295
"extmod_hardware/machine_uart_irq_break.py",
295296
"extmod_hardware/machine_uart_irq_rx.py",
296297
"extmod_hardware/machine_uart_irq_rxidle.py",

tests/target_wiring/NUCLEO_WB55.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
uart_loopback_kwargs = {}
99

1010
spi_standalone_args_list = [(1,), (2,)]
11+
12+
pwm_loopback_pins = [("D1", "D0")]

tests/target_wiring/PYBx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
# CAN args assume no connection for single device tests
1313
can_args = (1,)
1414
can_kwargs = {}
15+
16+
pwm_loopback_pins = [("X1", "X2")]

tests/target_wiring/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ SPI instances will be created using:
4848
for spi_args in spi_standalone_args_list:
4949
machine.SPI(*spi_args)
5050

51+
### PWM tests
52+
53+
PWM tests require a PWM output to be connected in loopback mode to another GPIO pin
54+
that will use `machine.time_pulse_us()` to time the PWM output signal. The variables
55+
are:
56+
57+
pwm_loopback_pins: list[tuple[Any, Any]]
58+
59+
The PWM and input Pin instances will be created using:
60+
61+
for pwm_pin, pulse_pin in pwm_loopback_pins:
62+
machine.PWM(pwm_pin)
63+
machine.Pin(pulse_pin, Pin.IN)
64+
5165
### Encoder tests
5266

5367
Encoder tests require one encoder to be connected in loopback mode to two other GPIO

tests/target_wiring/alif.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
uart_loopback_kwargs = {}
88

99
spi_standalone_args_list = [(0,)]
10+
11+
pwm_loopback_pins = [("P0_4", "P0_5")]

tests/target_wiring/esp32.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
else:
1515
spi_standalone_args_list = [(1,), (2,)]
1616

17+
pwm_loopback_pins = [(4, 5)]
18+
1719
encoder_loopback_id = 0
1820
encoder_loopback_out_pins = (4, 12)
1921
encoder_loopback_in_pins = (5, 13)

tests/target_wiring/esp8266.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
uart_loopback_kwargs = {}
88

99
spi_standalone_args_list = [(1,)]
10+
11+
pwm_loopback_pins = [(4, 5)]

tests/target_wiring/mimxrt.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@
33
# Connect:
44
# - UART1 TX and RX, usually D0 and D1
55

6+
import sys
7+
68
uart_loopback_args = (1,)
79
uart_loopback_kwargs = {}
810

911
spi_standalone_args_list = [()]
1012

13+
if "Teensy" in sys.implementation._machine:
14+
# Teensy 4.x
15+
pwm_loopback_pins = [
16+
("D0", "D1"), # FLEXPWM X and UART 1
17+
("D2", "D3"), # FLEXPWM A/B
18+
("D11", "D12"), # QTMR and MOSI/MISO of SPI 0
19+
]
20+
else:
21+
pwm_loopback_pins = [("D0", "D1")]
22+
1123
encoder_loopback_id = 0
1224
encoder_loopback_out_pins = ("D0", "D2")
1325
encoder_loopback_in_pins = ("D1", "D3")

tests/target_wiring/rp2.py

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)