diff options
| author | Damien George <damien@micropython.org> | 2025-06-26 00:29:22 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-07-08 13:18:09 +1000 |
| commit | a4a098ff8210a086d947b53771ed747a8998cef0 (patch) | |
| tree | bf74df08c6f19068da437fcdbcc42049ba6b603b /tests | |
| parent | a2e3055d2d4d84577d4c9c95b2dc740a705d1bfd (diff) | |
tests/extmod_hardware/machine_uart_irq_rxidle.py: Ignore inital IRQ.
On stm32, the hardware generates an RXIDLE IRQ after enabling the UART,
because the RX line is technically idle.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/extmod_hardware/machine_uart_irq_rxidle.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/extmod_hardware/machine_uart_irq_rxidle.py b/tests/extmod_hardware/machine_uart_irq_rxidle.py index 634369150..ced24dca6 100644 --- a/tests/extmod_hardware/machine_uart_irq_rxidle.py +++ b/tests/extmod_hardware/machine_uart_irq_rxidle.py @@ -13,6 +13,9 @@ except (ImportError, AttributeError): import time, sys +# Target tuning options. +tune_wait_initial_rxidle = False + # Configure pins based on the target. if "alif" in sys.platform: uart_id = 1 @@ -26,6 +29,7 @@ elif "mimxrt" in sys.platform: uart_id = 1 tx_pin = None elif "pyboard" in sys.platform: + tune_wait_initial_rxidle = True if "STM32WB" in sys.implementation._machine: # LPUART(1) is on PA2/PA3 uart_id = "LP1" @@ -69,8 +73,15 @@ for bits_per_s in (2400, 9600, 115200): else: uart = UART(uart_id, bits_per_s, tx=tx_pin, rx=rx_pin) + # Ignore a possible initial RXIDLE condition after creating UART. + if tune_wait_initial_rxidle: + uart.irq(lambda _: None, uart.IRQ_RXIDLE) + time.sleep_ms(10) + + # Configure desired IRQ. uart.irq(irq, uart.IRQ_RXIDLE) + # Write data and wait for IRQ. print("write", bits_per_s) uart.write(text) uart.flush() |
