mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 13:01:10 +02:00
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:
@@ -64,10 +64,13 @@ def irq(u):
|
|||||||
print("IRQ_RXIDLE:", bool(u.irq().flags() & u.IRQ_RXIDLE), "data:", u.read())
|
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.
|
# Test that the IRQ is called for each set of byte received.
|
||||||
for bits_per_s in (2400, 9600, 115200):
|
for bits_per_s in (2400, 9600, 115200):
|
||||||
|
print("========")
|
||||||
|
print("bits_per_s:", bits_per_s)
|
||||||
|
|
||||||
if tx_pin is None:
|
if tx_pin is None:
|
||||||
uart = UART(uart_id, bits_per_s)
|
uart = UART(uart_id, bits_per_s)
|
||||||
else:
|
else:
|
||||||
@@ -81,10 +84,11 @@ for bits_per_s in (2400, 9600, 115200):
|
|||||||
# Configure desired IRQ.
|
# Configure desired IRQ.
|
||||||
uart.irq(irq, uart.IRQ_RXIDLE)
|
uart.irq(irq, uart.IRQ_RXIDLE)
|
||||||
|
|
||||||
# Write data and wait for IRQ.
|
for i in range(2):
|
||||||
print("write", bits_per_s)
|
# Write data and wait for IRQ.
|
||||||
uart.write(text)
|
print("write")
|
||||||
uart.flush()
|
uart.write(text[i])
|
||||||
print("ready")
|
uart.flush()
|
||||||
time.sleep_ms(100)
|
print("ready")
|
||||||
print("done")
|
time.sleep_ms(100)
|
||||||
|
print("done")
|
||||||
|
@@ -1,12 +1,30 @@
|
|||||||
write 2400
|
========
|
||||||
|
bits_per_s: 2400
|
||||||
|
write
|
||||||
ready
|
ready
|
||||||
IRQ_RXIDLE: True data: b'12345678'
|
IRQ_RXIDLE: True data: b'12345678'
|
||||||
done
|
done
|
||||||
write 9600
|
write
|
||||||
|
ready
|
||||||
|
IRQ_RXIDLE: True data: b'abcdefgh'
|
||||||
|
done
|
||||||
|
========
|
||||||
|
bits_per_s: 9600
|
||||||
|
write
|
||||||
ready
|
ready
|
||||||
IRQ_RXIDLE: True data: b'12345678'
|
IRQ_RXIDLE: True data: b'12345678'
|
||||||
done
|
done
|
||||||
write 115200
|
write
|
||||||
|
ready
|
||||||
|
IRQ_RXIDLE: True data: b'abcdefgh'
|
||||||
|
done
|
||||||
|
========
|
||||||
|
bits_per_s: 115200
|
||||||
|
write
|
||||||
ready
|
ready
|
||||||
IRQ_RXIDLE: True data: b'12345678'
|
IRQ_RXIDLE: True data: b'12345678'
|
||||||
done
|
done
|
||||||
|
write
|
||||||
|
ready
|
||||||
|
IRQ_RXIDLE: True data: b'abcdefgh'
|
||||||
|
done
|
||||||
|
Reference in New Issue
Block a user