Skip to content

Commit

Permalink
tests/machine_uart_irq_txidle.py: Simplify the test script.
Browse files Browse the repository at this point in the history
Now that no minimal delay time is required for SAMD devices.

Signed-off-by: robert-hh <robert@hammelrath.com>
  • Loading branch information
robert-hh committed Aug 29, 2024
1 parent 21b3843 commit 0e41092
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions tests/extmod/machine_uart_irq_txidle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,20 @@
uart_id = 0
tx_pin = "GPIO0"
rx_pin = "GPIO1"
min_window = 1
elif "samd" in sys.platform and "ItsyBitsy M0" in sys.implementation._machine:
uart_id = 0
tx_pin = "D1"
rx_pin = "D0"
# For SAMD delay_ms has to be used for the trailing window, and the
# mininmal time is 11 ms to allow for scheduling.
min_window = 11
elif "samd" in sys.platform and "ItsyBitsy M4" in sys.implementation._machine:
uart_id = 3
tx_pin = "D1"
rx_pin = "D0"
min_window = 11
elif "mimxrt" in sys.platform:
uart_id = 1
tx_pin = None
min_window = 0
elif "nrf" in sys.platform:
uart_id = 0
tx_pin = None
min_window = 0
else:
print("Please add support for this test on this platform.")
raise SystemExit
Expand All @@ -61,12 +54,11 @@ def irq(u):
# the test marks a time window close to the expected of the sending
# and the time at which the IRQ should have been fired.
# It is just a rough estimation of 10 characters before and
# 20 characters after the data's end, unless there is a need to
# wait a minimal time, like for SAMD devices.
# 20 characters after the data's end.

bits_per_char = 10 # 1(startbit) + 8(bits) + 1(stopbit) + 0(parity)
start_time_us = (len(text) - 10) * bits_per_char * 1_000_000 // bits_per_s
window_ms = max(min_window, 20 * bits_per_char * 1_000 // bits_per_s + 1)
window_ms = 20 * bits_per_char * 1_000 // bits_per_s + 1

print("write", bits_per_s)
uart.write(text)
Expand Down

0 comments on commit 0e41092

Please sign in to comment.