Skip to content

Commit

Permalink
tests: drivers: audio: Add tests for PDM
Browse files Browse the repository at this point in the history
Added tests for PDM that check PDM_CLK output frequency
and ensure that dmic API works as expected.

Signed-off-by: Michał Stasiak <[email protected]>
  • Loading branch information
mstasiaknordic authored and rlubos committed Dec 11, 2024
1 parent bb0ce75 commit 989cde8
Show file tree
Hide file tree
Showing 8 changed files with 478 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@
/tests/bluetooth/bsim/nrf_auraconfig/ @nrfconnect/ncs-audio
/tests/bluetooth/tester/ @carlescufi @nrfconnect/ncs-paladin
/tests/crypto/ @stephen-nordic @magnev
/tests/drivers/audio/pdm_loopback/ @nrfconnect/ncs-low-level-test
/tests/drivers/gpio/ @nrfconnect/ncs-low-level-test @nrfconnect/ncs-ll-ursus
/tests/drivers/flash/flash_rpc/ @nrfconnect/ncs-pluto
/tests/drivers/flash_patch/ @nrfconnect/ncs-pluto
Expand Down
12 changes: 12 additions & 0 deletions tests/drivers/audio/pdm_loopback/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(pdm_loopback)

target_sources(app PRIVATE src/main.c)
36 changes: 36 additions & 0 deletions tests/drivers/audio/pdm_loopback/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "Kconfig.zephyr"

config TEST_PDM_SAMPLING_RATE
int "PDM sample rate in Hz"
default 10000
help
The test will use it to define frequency of PDM sampling and
calculate the size of the buffer.

config TEST_PDM_EXPECTED_FREQUENCY
int "Expected PDM_CLK frequency in Hz"
default 1000000
help
The test will use it to confirm that the captured PDM_CLK
frequency in correct.

config TEST_PDM_SAMPLING_TIME
int "PDM sampling time for one block in ms"
default 100
help
The test will use it to calculate the size of data block and
determine the period of capturing timer.

config TEST_USE_DMM
bool "Use of DMM prealocation"
default n
help
The test will use it to determine whether to prealocate DMM
buffer or use regular mem slab and allocate dmm buffer inside
PDM driver.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
gpio_test {
compatible = "gpio-leds";
pulse_counter: pulse_counter {
gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
};
};
};

&pinctrl {
pdm0_default_alt: pdm0_default_alt {
group1 {
psels = <NRF_PSEL(PDM_CLK, 1, 2)>,
<NRF_PSEL(PDM_DIN, 1, 4)>;
};
};
};

pdm_dev: &pdm0 {
status = "okay";
pinctrl-0 = <&pdm0_default_alt>;
pinctrl-names = "default";
clock-source = "PCLK32M";
memory-regions = <&cpuapp_dma_region>;
};

&gpio1 {
status = "okay";
};

&gpiote130 {
owned-channels = <0>;
status = "okay";
};

&timer130 {
status = "okay";
};

&dppic130 {
owned-channels = <0>;
source-channels = <0>;
status = "okay";
};

&dppic133 {
owned-channels = <0>;
sink-channels = <0>;
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
gpio_test {
compatible = "gpio-leds";
pulse_counter: pulse_counter {
gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
};
};
};

&pinctrl {
pdm20_default_alt: pdm20_default_alt {
group1 {
psels = <NRF_PSEL(PDM_CLK, 1, 10)>,
<NRF_PSEL(PDM_DIN, 1, 12)>;
};
};
};

pdm_dev: &pdm20 {
status = "okay";
pinctrl-0 = <&pdm20_default_alt>;
pinctrl-names = "default";
clock-source = "PCLK32M";
};

&gpio1 {
status = "okay";
};

&timer00 {
status = "okay";
};
13 changes: 13 additions & 0 deletions tests/drivers/audio/pdm_loopback/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_ZTEST=y
CONFIG_TEST_USERSPACE=y

CONFIG_AUDIO=y
CONFIG_AUDIO_DMIC=y
CONFIG_GPIO=y
CONFIG_NRFX_GPPI=y
Loading

0 comments on commit 989cde8

Please sign in to comment.