Skip to content

Commit 989cde8

Browse files
mstasiaknordicrlubos
authored andcommitted
tests: drivers: audio: Add tests for PDM
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]>
1 parent bb0ce75 commit 989cde8

File tree

8 files changed

+478
-0
lines changed

8 files changed

+478
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@
786786
/tests/bluetooth/bsim/nrf_auraconfig/ @nrfconnect/ncs-audio
787787
/tests/bluetooth/tester/ @carlescufi @nrfconnect/ncs-paladin
788788
/tests/crypto/ @stephen-nordic @magnev
789+
/tests/drivers/audio/pdm_loopback/ @nrfconnect/ncs-low-level-test
789790
/tests/drivers/gpio/ @nrfconnect/ncs-low-level-test @nrfconnect/ncs-ll-ursus
790791
/tests/drivers/flash/flash_rpc/ @nrfconnect/ncs-pluto
791792
/tests/drivers/flash_patch/ @nrfconnect/ncs-pluto
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(pdm_loopback)
11+
12+
target_sources(app PRIVATE src/main.c)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
source "Kconfig.zephyr"
8+
9+
config TEST_PDM_SAMPLING_RATE
10+
int "PDM sample rate in Hz"
11+
default 10000
12+
help
13+
The test will use it to define frequency of PDM sampling and
14+
calculate the size of the buffer.
15+
16+
config TEST_PDM_EXPECTED_FREQUENCY
17+
int "Expected PDM_CLK frequency in Hz"
18+
default 1000000
19+
help
20+
The test will use it to confirm that the captured PDM_CLK
21+
frequency in correct.
22+
23+
config TEST_PDM_SAMPLING_TIME
24+
int "PDM sampling time for one block in ms"
25+
default 100
26+
help
27+
The test will use it to calculate the size of data block and
28+
determine the period of capturing timer.
29+
30+
config TEST_USE_DMM
31+
bool "Use of DMM prealocation"
32+
default n
33+
help
34+
The test will use it to determine whether to prealocate DMM
35+
buffer or use regular mem slab and allocate dmm buffer inside
36+
PDM driver.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
gpio_test {
9+
compatible = "gpio-leds";
10+
pulse_counter: pulse_counter {
11+
gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
12+
};
13+
};
14+
};
15+
16+
&pinctrl {
17+
pdm0_default_alt: pdm0_default_alt {
18+
group1 {
19+
psels = <NRF_PSEL(PDM_CLK, 1, 2)>,
20+
<NRF_PSEL(PDM_DIN, 1, 4)>;
21+
};
22+
};
23+
};
24+
25+
pdm_dev: &pdm0 {
26+
status = "okay";
27+
pinctrl-0 = <&pdm0_default_alt>;
28+
pinctrl-names = "default";
29+
clock-source = "PCLK32M";
30+
memory-regions = <&cpuapp_dma_region>;
31+
};
32+
33+
&gpio1 {
34+
status = "okay";
35+
};
36+
37+
&gpiote130 {
38+
owned-channels = <0>;
39+
status = "okay";
40+
};
41+
42+
&timer130 {
43+
status = "okay";
44+
};
45+
46+
&dppic130 {
47+
owned-channels = <0>;
48+
source-channels = <0>;
49+
status = "okay";
50+
};
51+
52+
&dppic133 {
53+
owned-channels = <0>;
54+
sink-channels = <0>;
55+
status = "okay";
56+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
gpio_test {
9+
compatible = "gpio-leds";
10+
pulse_counter: pulse_counter {
11+
gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
12+
};
13+
};
14+
};
15+
16+
&pinctrl {
17+
pdm20_default_alt: pdm20_default_alt {
18+
group1 {
19+
psels = <NRF_PSEL(PDM_CLK, 1, 10)>,
20+
<NRF_PSEL(PDM_DIN, 1, 12)>;
21+
};
22+
};
23+
};
24+
25+
pdm_dev: &pdm20 {
26+
status = "okay";
27+
pinctrl-0 = <&pdm20_default_alt>;
28+
pinctrl-names = "default";
29+
clock-source = "PCLK32M";
30+
};
31+
32+
&gpio1 {
33+
status = "okay";
34+
};
35+
36+
&timer00 {
37+
status = "okay";
38+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_ZTEST=y
8+
CONFIG_TEST_USERSPACE=y
9+
10+
CONFIG_AUDIO=y
11+
CONFIG_AUDIO_DMIC=y
12+
CONFIG_GPIO=y
13+
CONFIG_NRFX_GPPI=y

0 commit comments

Comments
 (0)