mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 04:30:24 +01:00
Some checks failed
JavaScript code lint and formatting with Biome / eslint (push) Has been cancelled
Check code formatting / code-formatting (push) Has been cancelled
Check spelling with codespell / codespell (push) Has been cancelled
Build docs / build (push) Has been cancelled
Check examples / embedding (push) Has been cancelled
Package mpremote / build (push) Has been cancelled
.mpy file format and tools / test (push) Has been cancelled
Build ports metadata / build (push) Has been cancelled
alif port / build_alif (alif_ae3_build) (push) Has been cancelled
cc3200 port / build (push) Has been cancelled
esp32 port / build_idf (esp32_build_c2_c5_c6) (push) Has been cancelled
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Has been cancelled
esp32 port / build_idf (esp32_build_s3_c3) (push) Has been cancelled
esp8266 port / build (push) Has been cancelled
mimxrt port / build (push) Has been cancelled
nrf port / build (push) Has been cancelled
powerpc port / build (push) Has been cancelled
qemu port / build_and_test_arm (bigendian) (push) Has been cancelled
qemu port / build_and_test_arm (sabrelite) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_hardfp) (push) Has been cancelled
qemu port / build_and_test_arm (thumb_softfp) (push) Has been cancelled
qemu port / build_and_test_rv32 (push) Has been cancelled
qemu port / build_and_test_rv64 (push) Has been cancelled
renesas-ra port / build_renesas_ra_board (push) Has been cancelled
rp2 port / build (push) Has been cancelled
samd port / build (push) Has been cancelled
stm32 port / build_stm32 (stm32_misc_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_nucleo_build) (push) Has been cancelled
stm32 port / build_stm32 (stm32_pyb_build) (push) Has been cancelled
unix port / minimal (push) Has been cancelled
unix port / reproducible (push) Has been cancelled
unix port / standard (push) Has been cancelled
unix port / standard_v2 (push) Has been cancelled
unix port / coverage (push) Has been cancelled
unix port / coverage_32bit (push) Has been cancelled
unix port / nanbox (push) Has been cancelled
unix port / longlong (push) Has been cancelled
unix port / float (push) Has been cancelled
unix port / gil_enabled (push) Has been cancelled
unix port / stackless_clang (push) Has been cancelled
unix port / float_clang (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / repr_b (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
unix port / sanitize_address (push) Has been cancelled
unix port / sanitize_undefined (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x64, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, true, x86, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
Changed the pin numbers used for the I2S rate testing as the pin numbers used were incompatible with the limited GPIO pins availalbe on the ESP32-C3, causing the tests to fail. Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
111 lines
3.3 KiB
Python
111 lines
3.3 KiB
Python
# Test machine.I2S data transfer rate, for both TX and RX.
|
|
|
|
try:
|
|
from machine import Pin, I2S
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
import time, sys
|
|
|
|
MAX_DELTA_MS = 4
|
|
|
|
# Configure pins based on the board.
|
|
# Tuples of (i2s_id, sck_pin, ws_pin, sd_tx_pin, sd_rx_pin)
|
|
# A board must have at least one instance to test, both TX and RX mode.
|
|
if "pyboard" in sys.platform:
|
|
i2s_instances = ((2, Pin("Y6"), Pin("Y5"), Pin("Y8"), Pin("Y8")),)
|
|
elif "rp2" in sys.platform:
|
|
i2s_instances = (
|
|
(0, Pin(0), Pin(1), Pin(2), Pin(2)),
|
|
(1, Pin(0), Pin(1), Pin(2), Pin(2)),
|
|
)
|
|
elif "mimxrt" in sys.platform:
|
|
i2s_instances = (
|
|
(1, Pin("D26"), Pin("D27"), Pin("D7"), Pin("D8")),
|
|
(2, Pin("D4"), Pin("D3"), Pin("D2"), None),
|
|
)
|
|
elif "esp32" in sys.platform:
|
|
try:
|
|
i2s_instances = ((0, Pin(18), Pin(19), Pin(21), Pin(14)),)
|
|
except ValueError:
|
|
# fallback to lower pin number for ESP32-C3
|
|
i2s_instances = ((0, Pin(6), Pin(7), Pin(10), Pin(11)),)
|
|
# Allow for small additional RTOS overhead
|
|
MAX_DELTA_MS = 8
|
|
|
|
TEST_BYTES = b"01234567"
|
|
RATE = 11025 # frames/sec
|
|
|
|
|
|
def test(i2s_id, sck_pin, ws_pin, sd_pin, mode, bits_per_sample, frame_format):
|
|
if sd_pin is None:
|
|
return
|
|
|
|
i2s = I2S(
|
|
i2s_id,
|
|
sck=sck_pin,
|
|
ws=ws_pin,
|
|
sd=sd_pin,
|
|
mode=mode,
|
|
bits=bits_per_sample,
|
|
format=frame_format,
|
|
rate=RATE,
|
|
ibuf=200,
|
|
)
|
|
|
|
if frame_format == I2S.MONO:
|
|
channels = 1
|
|
else:
|
|
channels = 2
|
|
bits_per_frame = bits_per_sample * channels
|
|
buf_len_200ms = bits_per_frame // 8 * RATE // 5
|
|
|
|
# Create test data and preload I2S buffers.
|
|
if mode == I2S.TX:
|
|
mode_str = "TX"
|
|
data = TEST_BYTES * (buf_len_200ms // len(TEST_BYTES))
|
|
i2s.write(data)
|
|
else:
|
|
mode_str = "RX"
|
|
data = bytearray(len(TEST_BYTES) * (buf_len_200ms // len(TEST_BYTES)))
|
|
i2s.readinto(data)
|
|
|
|
# Time how long it takes to read/write 2 lots of data.
|
|
t0 = time.ticks_ms()
|
|
for i in range(2):
|
|
if mode == I2S.TX:
|
|
i2s.write(data)
|
|
else:
|
|
i2s.readinto(data)
|
|
t1 = time.ticks_ms()
|
|
dt = time.ticks_diff(t1, t0)
|
|
|
|
i2s.deinit()
|
|
|
|
# Time should be in range of 400ms.
|
|
time_delta = abs(dt - 400)
|
|
time_in_range = time_delta <= MAX_DELTA_MS
|
|
|
|
# Print out test result if requested, or if time not in range.
|
|
if print_results or not time_in_range:
|
|
print(mode_str, bits_per_sample, channels, time_in_range or time_delta)
|
|
|
|
|
|
print_results = True
|
|
|
|
for i2s_id, sck_pin, ws_pin, sd_tx_pin, sd_rx_pin in i2s_instances:
|
|
test(i2s_id, sck_pin, ws_pin, sd_tx_pin, I2S.TX, 16, I2S.MONO)
|
|
test(i2s_id, sck_pin, ws_pin, sd_tx_pin, I2S.TX, 16, I2S.STEREO)
|
|
test(i2s_id, sck_pin, ws_pin, sd_tx_pin, I2S.TX, 32, I2S.MONO)
|
|
test(i2s_id, sck_pin, ws_pin, sd_tx_pin, I2S.TX, 32, I2S.STEREO)
|
|
test(i2s_id, sck_pin, ws_pin, sd_rx_pin, I2S.RX, 16, I2S.MONO)
|
|
test(i2s_id, sck_pin, ws_pin, sd_rx_pin, I2S.RX, 16, I2S.STEREO)
|
|
test(i2s_id, sck_pin, ws_pin, sd_rx_pin, I2S.RX, 32, I2S.MONO)
|
|
test(i2s_id, sck_pin, ws_pin, sd_rx_pin, I2S.RX, 32, I2S.STEREO)
|
|
|
|
# For any remaining tests, don't print the results if they pass.
|
|
# This is to have the same output on all boards regardless of
|
|
# how many I2S instances they test.
|
|
print_results = False
|