pytest_i2s_pdm.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.esp32
  6. @pytest.mark.esp32s3
  7. @pytest.mark.esp32c3
  8. @pytest.mark.esp32c6
  9. @pytest.mark.esp32h2
  10. @pytest.mark.generic
  11. @pytest.mark.parametrize(
  12. 'config',
  13. ['pdm_tx'],
  14. indirect=True
  15. )
  16. def test_i2s_pdm_tx_example(dut: Dut) -> None:
  17. dut.expect(r'I2S PDM TX example start', timeout=5)
  18. dut.expect(r'---------------------------', timeout=5)
  19. dut.expect(r'D \(([0-9]+)\) i2s_common: tx channel is registered on I2S0 successfully', timeout=5)
  20. dut.expect(r'D \(([0-9]+)\) i2s_common: DMA malloc info: dma_desc_num = ([0-9]+), '
  21. r'dma_desc_buf_size = dma_frame_num \* slot_num \* data_bit_width = ([0-9]+)', timeout=5)
  22. dut.expect(r'D \(([0-9]+)\) i2s_pdm: Clock division info: \[sclk\] ([0-9]+) Hz '
  23. r'\[mdiv\] ([0-9]+) \[mclk\] ([0-9]+) Hz \[bdiv\] ([0-9]+) \[bclk\] ([0-9]+) Hz', timeout=5)
  24. dut.expect(r'D \(([0-9]+)\) i2s_pdm: The tx channel on I2S0 has been initialized to PDM TX mode successfully', timeout=5)
  25. dut.expect(r'D \(([0-9]+)\) i2s_common: i2s tx channel enabled', timeout=5)
  26. dut.expect(r'Playing bass `twinkle twinkle little star`', timeout=5)
  27. @pytest.mark.esp32
  28. @pytest.mark.esp32s3
  29. @pytest.mark.generic
  30. @pytest.mark.parametrize(
  31. 'config',
  32. ['pdm_rx'],
  33. indirect=True
  34. )
  35. def test_i2s_pdm_rx_example(dut: Dut) -> None:
  36. dut.expect(r'I2S PDM RX example start', timeout=5)
  37. dut.expect(r'---------------------------', timeout=5)
  38. dut.expect(r'D \(([0-9]+)\) i2s_common: rx channel is registered on I2S0 successfully', timeout=5)
  39. dut.expect(r'D \(([0-9]+)\) i2s_common: DMA malloc info: dma_desc_num = ([0-9]+), '
  40. r'dma_desc_buf_size = dma_frame_num \* slot_num \* data_bit_width = ([0-9]+)', timeout=5)
  41. dut.expect(r'D \(([0-9]+)\) i2s_common: i2s rx channel enabled', timeout=5)
  42. dut.expect(r'Read Task: i2s read ([0-9]+) bytes', timeout=5)
  43. dut.expect(r'-----------------------------------', timeout=5)
  44. dut.expect(r'\[0\] ([-]?[0-9]+) \[1\] ([-]?[0-9]+) \[2\] ([-]?[0-9]+) \[3\] ([-]?[0-9]+)', timeout=5)
  45. dut.expect(r'\[4\] ([-]?[0-9]+) \[5\] ([-]?[0-9]+) \[6\] ([-]?[0-9]+) \[7\] ([-]?[0-9]+)', timeout=5)