tests/extmod_hardware/machine_uart_irq_rxidle.py: Test multiple writes.

This tests that the RXIDLE callback is called correctly after a second lot
of bytes are received.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-06-30 11:27:50 +10:00
parent a4a098ff82
commit 29b5c2207c
2 changed files with 33 additions and 11 deletions

View File

@@ -64,10 +64,13 @@ def irq(u):
print("IRQ_RXIDLE:", bool(u.irq().flags() & u.IRQ_RXIDLE), "data:", u.read())
text = "12345678"
text = ("12345678", "abcdefgh")
# Test that the IRQ is called for each set of byte received.
for bits_per_s in (2400, 9600, 115200):
print("========")
print("bits_per_s:", bits_per_s)
if tx_pin is None:
uart = UART(uart_id, bits_per_s)
else:
@@ -81,9 +84,10 @@ for bits_per_s in (2400, 9600, 115200):
# Configure desired IRQ.
uart.irq(irq, uart.IRQ_RXIDLE)
for i in range(2):
# Write data and wait for IRQ.
print("write", bits_per_s)
uart.write(text)
print("write")
uart.write(text[i])
uart.flush()
print("ready")
time.sleep_ms(100)

View File

@@ -1,12 +1,30 @@
write 2400
========
bits_per_s: 2400
write
ready
IRQ_RXIDLE: True data: b'12345678'
done
write 9600
write
ready
IRQ_RXIDLE: True data: b'abcdefgh'
done
========
bits_per_s: 9600
write
ready
IRQ_RXIDLE: True data: b'12345678'
done
write 115200
write
ready
IRQ_RXIDLE: True data: b'abcdefgh'
done
========
bits_per_s: 115200
write
ready
IRQ_RXIDLE: True data: b'12345678'
done
write
ready
IRQ_RXIDLE: True data: b'abcdefgh'
done