8000 tests/extmod: Add esp32 support to the machine_i2s_rate test. · micropython/micropython@6d05424 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d05424

Browse files
projectgusdpgeorge
authored andcommitted
tests/extmod: Add esp32 support to the machine_i2s_rate test.
This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 0d00d72 commit 6d05424

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/extmod/machine_i2s_rate.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
import time, sys
1010

11+
MAX_DELTA_MS = 4
12+
1113
# Configure pins based on the board.
14+
# Tuples of (i2s_id, sck_pin, ws_pin, sd_tx_pin, sd_rx_pin)
1215
# A board must have at least one instance to test, both TX and RX mode.
1316
if "pyboard" in sys.platform:
1417
i2s_instances = ((2, Pin("Y6"), Pin("Y5"), Pin("Y8"), Pin("Y8")),)
@@ -22,6 +25,10 @@
2225
(1, Pin("D26"), Pin("D27"), Pin("D7"), Pin("D8")),
2326
(2, Pin("D4"), Pin("D3"), Pin("D2"), None),
2427
)
28+
elif "esp32" in sys.platform:
29+
i2s_instances = ((0, Pin(18), Pin(19), Pin(21), Pin(14)),)
30+
# Allow for small additional RTOS overhead
31+
MAX_DELTA_MS = 8
2532

2633
TEST_BYTES = b"01234567"
2734
RATE = 11025 # frames/sec
@@ -73,11 +80,12 @@ def test(i2s_id, sck_pin, ws_pin, sd_pin, mode, bits_per_sample, frame_format):
7380
i2s.deinit()
7481

7582
# Time should be in range of 400ms.
76-
time_in_range = abs(dt - 400) <= 4
83+
time_delta = abs(dt - 400)
84+
time_in_range = time_delta <= MAX_DELTA_MS
7785

7886
# Print out test result if requested, or if time not in range.
7987
if print_results or not time_in_range:
80-
print(mode_str, bits_per_sample, channels, time_in_range)
88+
print(mode_str, bits_per_sample, channels, time_in_range or time_delta)
8189

8290

8391
print_results = True

0 commit comments

Comments
 (0)
0