pytest_i2s_tdm.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import pytest
  4. from pytest_embedded import Dut
  5. @pytest.mark.esp32s3
  6. @pytest.mark.esp32c3
  7. @pytest.mark.esp32c6
  8. @pytest.mark.esp32h2
  9. @pytest.mark.generic
  10. def test_i2s_tdm_example(dut: Dut) -> None:
  11. dut.expect(r'D \(([0-9]+)\) i2s_common: tx channel is registered on I2S0 successfully', timeout=5)
  12. dut.expect(r'D \(([0-9]+)\) i2s_common: rx channel is registered on I2S0 successfully', timeout=5)
  13. dut.expect(r'D \(([0-9]+)\) i2s_common: DMA malloc info: dma_desc_num = ([0-9]+), '
  14. r'dma_desc_buf_size = dma_frame_num \* slot_num \* data_bit_width = ([0-9]+)', timeout=5)
  15. dut.expect(r'D \(([0-9]+)\) i2s_tdm: Clock division info: \[sclk\] ([0-9]+) Hz '
  16. r'\[mdiv\] ([0-9]+) \[mclk\] ([0-9]+) Hz \[bdiv\] ([0-9]+) \[bclk\] ([0-9]+) Hz', timeout=5)
  17. dut.expect(r'D \(([0-9]+)\) i2s_tdm: The tx channel on I2S0 has been initialized to TDM mode successfully', timeout=5)
  18. dut.expect(r'D \(([0-9]+)\) i2s_common: DMA malloc info: dma_desc_num = ([0-9]+), '
  19. r'dma_desc_buf_size = dma_frame_num \* slot_num \* data_bit_width = ([0-9]+)', timeout=5)
  20. dut.expect(r'D \(([0-9]+)\) i2s_tdm: Clock division info: \[sclk\] ([0-9]+) Hz '
  21. r'\[mdiv\] ([0-9]+) \[mclk\] ([0-9]+) Hz \[bdiv\] ([0-9]+) \[bclk\] ([0-9]+) Hz', timeout=5)
  22. dut.expect(r'D \(([0-9]+)\) i2s_tdm: The rx channel on I2S0 has been initialized to TDM mode successfully', timeout=5)
  23. chan_enable_pattern = [
  24. r'D \(([0-9]+)\) i2s_common: i2s tx channel enabled',
  25. r'D \(([0-9]+)\) i2s_common: i2s rx channel enabled'
  26. ]
  27. dut.expect(chan_enable_pattern, timeout=5)
  28. dut.expect(chan_enable_pattern, timeout=5)
  29. dut.expect(r'Write Task: i2s write ([0-9]+) bytes', timeout=5)
  30. dut.expect(r'Read Task: i2s read ([0-9]+) bytes', timeout=5)
  31. dut.expect(r'-----------------------------------', timeout=5)
  32. dut.expect(r'\[0\] 12 \[1\] 34 \[2\] 56 \[3\] 78', timeout=10)
  33. dut.expect(r'\[4\] 9a \[5\] bc \[6\] de \[7\] f0', timeout=10)