Skip to content

Commit a58684d

Browse files
nordic-seglkartben
authored andcommitted
tests: drivers: i2s: Add i2s_additional tests
Extend I2S testing with additional test cases that verify I2S/TDM driver operation at various configurations. Check: - word sizes of 8, 16, 24, 32 and 48 bits; - one, two, four and eight audio channels configuration; - data format I2S, Left Justified, Right Justified, PCM Long, PCM Short; - data order MSB and LSB first; - bit clock and frame clock inversion; - block size of 6 bytes; - bit clock continuous and gated; - internal loopback; - pingpong option. Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
1 parent 736058d commit a58684d

11 files changed

+1199
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(i2s_additional)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
mainmenu "I2S Additional Test"
8+
9+
source "Kconfig.zephyr"
10+
11+
config I2S_TEST_USE_GPIO_LOOPBACK
12+
bool "Use GPIO loopback"
13+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
14+
help
15+
Use wiring between the data-out and data-in pins for looping back
16+
data. This option is intended to be used for devices that do not
17+
provide the internal loopback functionality.
18+
19+
config I2S_TEST_ALLOWED_DATA_OFFSET
20+
int "Allowed offset in received data"
21+
default 2 if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
22+
default 0
23+
help
24+
Maximum allowed offset between sent and received samples. Non-zero
25+
value of this option may be needed when GPIO loopback is used.
26+
27+
config I2S_TEST_WORD_SIZE_8_BIT_UNSUPPORTED
28+
bool "8 bit word size is not supported by the driver"
29+
help
30+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
31+
When set to 'n', test will do the transmission.
32+
33+
config I2S_TEST_WORD_SIZE_16_BIT_UNSUPPORTED
34+
bool "16 bit word size is not supported by the driver"
35+
help
36+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
37+
When set to 'n', test will do the transmission.
38+
39+
config I2S_TEST_WORD_SIZE_24_BIT_UNSUPPORTED
40+
bool "24 bit word size is not supported by the driver"
41+
help
42+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
43+
When set to 'n', test will do the transmission.
44+
45+
config I2S_TEST_WORD_SIZE_32_BIT_UNSUPPORTED
46+
bool "32 bit word size is not supported by the driver"
47+
help
48+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
49+
When set to 'n', test will do the transmission.
50+
51+
config I2S_TEST_WORD_SIZE_48_BIT_UNSUPPORTED
52+
bool "48 bit word size is not supported by the driver"
53+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
54+
help
55+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
56+
When set to 'n', test will do the transmission.
57+
58+
config I2S_TEST_ONE_CHANNEL_UNSUPPORTED
59+
bool "Single audio channel is not supported by the driver"
60+
help
61+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
62+
When set to 'n', test will do the transmission.
63+
64+
config I2S_TEST_FOUR_CHANNELS_UNSUPPORTED
65+
bool "Four audio channels are not supported by the driver"
66+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED
67+
help
68+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
69+
When set to 'n', test will do the transmission.
70+
71+
config I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED
72+
bool "Eight audio channels are not supported by the driver"
73+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED
74+
help
75+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
76+
When set to 'n', test will do the transmission.
77+
78+
config I2S_TEST_DATA_FORMAT_I2S_UNSUPPORTED
79+
bool "I2S_FMT_DATA_FORMAT_I2S is not supported by the driver"
80+
help
81+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
82+
When set to 'n', test will do the transmission.
83+
84+
config I2S_TEST_DATA_FORMAT_LEFT_JUSTIFIED_UNSUPPORTED
85+
bool "I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED is not supported by the driver"
86+
help
87+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
88+
When set to 'n', test will do the transmission.
89+
90+
config I2S_TEST_DATA_FORMAT_RIGHT_JUSTIFIED_UNSUPPORTED
91+
bool "I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED is not supported by the driver"
92+
help
93+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
94+
When set to 'n', test will do the transmission.
95+
96+
config I2S_TEST_DATA_FORMAT_PCM_LONG_UNSUPPORTED
97+
bool "I2S_FMT_DATA_FORMAT_PCM_LONG is not supported by the driver"
98+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED
99+
help
100+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
101+
When set to 'n', test will do the transmission.
102+
103+
config I2S_TEST_DATA_FORMAT_PCM_SHORT_UNSUPPORTED
104+
bool "I2S_FMT_DATA_FORMAT_PCM_SHORT is not supported by the driver"
105+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED
106+
help
107+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
108+
When set to 'n', test will do the transmission.
109+
110+
config I2S_TEST_DATA_ORDER_MSB_UNSUPPORTED
111+
bool "I2S_FMT_DATA_ORDER_MSB is not supported by the driver"
112+
help
113+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
114+
When set to 'n', test will do the transmission.
115+
116+
config I2S_TEST_DATA_ORDER_LSB_UNSUPPORTED
117+
bool "I2S_FMT_DATA_ORDER_LSB is not supported by the driver"
118+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
119+
help
120+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
121+
When set to 'n', test will do the transmission.
122+
123+
config I2S_TEST_BIT_CLK_INV_UNSUPPORTED
124+
bool "I2S_FMT_BIT_CLK_INV is not supported by the driver"
125+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
126+
help
127+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
128+
When set to 'n', test will do the transmission.
129+
130+
config I2S_TEST_FRAME_CLK_INV_UNSUPPORTED
131+
bool "I2S_FMT_FRAME_CLK_INV is not supported by the driver"
132+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
133+
help
134+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
135+
When set to 'n', test will do the transmission.
136+
137+
config I2S_TEST_BLOCK_SIZE_6_UNSUPPORTED
138+
bool "Block_size of 6 is not supported by the driver"
139+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
140+
help
141+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
142+
When set to 'n', test will do the transmission.
143+
144+
config I2S_TEST_OPTIONS_BIT_CLK_CONT_UNSUPPORTED
145+
bool "I2S_OPT_BIT_CLK_CONT is not supported by the driver"
146+
help
147+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
148+
When set to 'n', test will do the transmission.
149+
150+
config I2S_TEST_OPTIONS_BIT_CLK_GATED_UNSUPPORTED
151+
bool "I2S_OPT_BIT_CLK_GATED is not supported by the driver"
152+
help
153+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
154+
When set to 'n', test will do the transmission.
155+
156+
config I2S_TEST_OPTIONS_LOOPBACK_UNSUPPORTED
157+
bool "I2S_OPT_LOOPBACK is not supported by the driver"
158+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
159+
help
160+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
161+
When set to 'n', test will do the transmission.
162+
163+
config I2S_TEST_OPTIONS_PINGPONG_UNSUPPORTED
164+
bool "I2S_OPT_PINGPONG is not supported by the driver"
165+
default y if DT_HAS_NORDIC_NRF_I2S_ENABLED || DT_HAS_NORDIC_NRF_TDM_ENABLED
166+
help
167+
When set to 'y', test will check that i2s_configure() returns -EINVAL.
168+
When set to 'n', test will do the transmission.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_I2S_TEST_WORD_SIZE_32_BIT_UNSUPPORTED=y
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
aliases {
9+
i2s-node0 = &i2s0;
10+
};
11+
};
12+
13+
&pinctrl {
14+
i2s0_default_alt: i2s0_default_alt {
15+
group1 {
16+
psels = <NRF_PSEL(I2S_SCK_M, 1, 5)>,
17+
<NRF_PSEL(I2S_LRCK_M, 1, 6)>,
18+
<NRF_PSEL(I2S_SDOUT, 1, 1)>,
19+
<NRF_PSEL(I2S_SDIN, 1, 2)>;
20+
};
21+
};
22+
};
23+
24+
&i2s0 {
25+
status = "okay";
26+
pinctrl-0 = <&i2s0_default_alt>;
27+
pinctrl-names = "default";
28+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
aliases {
9+
i2s-node0 = &i2s0;
10+
};
11+
};
12+
13+
&pinctrl {
14+
i2s0_default_alt: i2s0_default_alt {
15+
group1 {
16+
psels = <NRF_PSEL(I2S_SCK_M, 1, 6)>,
17+
<NRF_PSEL(I2S_LRCK_M, 1, 7)>,
18+
<NRF_PSEL(I2S_SDOUT, 0, 4)>,
19+
<NRF_PSEL(I2S_SDIN, 0, 5)>;
20+
};
21+
};
22+
};
23+
24+
&uart1 {
25+
status = "disabled";
26+
};
27+
28+
&i2s0 {
29+
status = "okay";
30+
pinctrl-0 = <&i2s0_default_alt>;
31+
pinctrl-names = "default";
32+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* Drive i2s peripheral from ACLK. */
2+
3+
&clock {
4+
hfclkaudio-frequency = <11289600>;
5+
};
6+
7+
&i2s0 {
8+
clock-source = "ACLK";
9+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* i2s-node0 is the transmitter/receiver */
8+
9+
/ {
10+
aliases {
11+
i2s-node0 = &tdm130;
12+
};
13+
};
14+
15+
&pinctrl {
16+
tdm130_default_alt: tdm130_default_alt {
17+
group1 {
18+
psels = <NRF_PSEL(TDM_SCK_M, 1, 3)>,
19+
<NRF_PSEL(TDM_FSYNC_M, 1, 6)>,
20+
<NRF_PSEL(TDM_SDOUT, 1, 4)>,
21+
<NRF_PSEL(TDM_SDIN, 1, 5)>;
22+
};
23+
};
24+
};
25+
26+
&tdm130 {
27+
status = "okay";
28+
pinctrl-0 = <&tdm130_default_alt>;
29+
pinctrl-names = "default";
30+
memory-regions = <&cpuapp_dma_region>;
31+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* i2s-node0 is the transmitter/receiver */
8+
9+
/ {
10+
aliases {
11+
i2s-node0 = &i2s20;
12+
};
13+
};
14+
15+
&pinctrl {
16+
i2s20_default_alt: i2s20_default_alt {
17+
group1 {
18+
psels = <NRF_PSEL(I2S_SCK_M, 1, 11)>,
19+
<NRF_PSEL(I2S_LRCK_M, 1, 12)>,
20+
<NRF_PSEL(I2S_SDOUT, 1, 8)>,
21+
<NRF_PSEL(I2S_SDIN, 1, 9)>;
22+
};
23+
};
24+
};
25+
26+
&i2s20 {
27+
status = "okay";
28+
pinctrl-0 = <&i2s20_default_alt>;
29+
pinctrl-names = "default";
30+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_I2S=y
2+
CONFIG_ZTEST=y

0 commit comments

Comments
 (0)