|
8 | 8 |
|
9 | 9 | import time, sys |
10 | 10 |
|
| 11 | +MAX_DELTA_MS = 4 |
| 12 | + |
11 | 13 | # Configure pins based on the board. |
| 14 | +# Tuples of (i2s_id, sck_pin, ws_pin, sd_tx_pin, sd_rx_pin) |
12 | 15 | # A board must have at least one instance to test, both TX and RX mode. |
13 | 16 | if "pyboard" in sys.platform: |
14 | 17 | i2s_instances = ((2, Pin("Y6"), Pin("Y5"), Pin("Y8"), Pin("Y8")),) |
|
22 | 25 | (1, Pin("D26"), Pin("D27"), Pin("D7"), Pin("D8")), |
23 | 26 | (2, Pin("D4"), Pin("D3"), Pin("D2"), None), |
24 | 27 | ) |
| 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 |
25 | 32 |
|
26 | 33 | TEST_BYTES = b"01234567" |
27 | 34 | RATE = 11025 # frames/sec |
@@ -73,11 +80,12 @@ def test(i2s_id, sck_pin, ws_pin, sd_pin, mode, bits_per_sample, frame_format): |
73 | 80 | i2s.deinit() |
74 | 81 |
|
75 | 82 | # 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 |
77 | 85 |
|
78 | 86 | # Print out test result if requested, or if time not in range. |
79 | 87 | 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) |
81 | 89 |
|
82 | 90 |
|
83 | 91 | print_results = True |
|
0 commit comments