Skip to content

Commit a4a098f

Browse files
committed
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>
1 parent a2e3055 commit a4a098f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/extmod_hardware/machine_uart_irq_rxidle.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
import time, sys
1515

16+
# Target tuning options.
17+
tune_wait_initial_rxidle = False
18+
1619
# Configure pins based on the target.
1720
if "alif" in sys.platform:
1821
uart_id = 1
@@ -26,6 +29,7 @@
2629
uart_id = 1
2730
tx_pin = None
2831
elif "pyboard" in sys.platform:
32+
tune_wait_initial_rxidle = True
2933
if "STM32WB" in sys.implementation._machine:
3034
# LPUART(1) is on PA2/PA3
3135
uart_id = "LP1"
@@ -69,8 +73,15 @@ def irq(u):
6973
else:
7074
uart = UART(uart_id, bits_per_s, tx=tx_pin, rx=rx_pin)
7175

76+
# Ignore a possible initial RXIDLE condition after creating UART.
77+
if tune_wait_initial_rxidle:
78+
uart.irq(lambda _: None, uart.IRQ_RXIDLE)
79+
time.sleep_ms(10)
80+
81+
# Configure desired IRQ.
7282
uart.irq(irq, uart.IRQ_RXIDLE)
7383

84+
# Write data and wait for IRQ.
7485
print("write", bits_per_s)
7586
uart.write(text)
7687
uart.flush()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy