Skip to content

Commit 1ddde35

Browse files
nordic-seglrlubos
authored andcommitted
tests: drivers: i2s: Test different length transmission
Add test that verifies I2S/TDM communication (single instance with GPIO loopback from DOUT to DIN) at different configuration. Verify: - mono / stereo configuration; - 8/16/32 bit word size; - 8/16/24 bytes long data buffer. Signed-off-by: Sebastian Głąb <[email protected]>
1 parent 4f99b6c commit 1ddde35

13 files changed

+1099
-0
lines changed

scripts/ci/license_allow_list.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Apache-2.0: |
4949
^nrf/modules/openthread/
5050
^nrf/samples/net/http_server/src/main.c
5151
^nrf/tests/benchmarks/kernel_freq_change/src/kernel_context.c
52+
^nrf/tests/drivers/i2s/i2s_buffer/src/i2s_buffer.c
5253
^nrf/tests/subsys/suit/common/tls_config/user-tls-conf.h
5354
^nrf/subsys/settings/
5455
^nrf/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2025 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(i2s_buffer)
11+
12+
FILE(GLOB app_sources src/*.c)
13+
target_sources(app PRIVATE ${app_sources})
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
mainmenu "I2S Buffer Test"
8+
9+
config I2S_TEST_ALLOWED_DATA_OFFSET
10+
int "Allowed offset in received data"
11+
default 2 if DT_HAS_NORDIC_NRF_I2S_ENABLED
12+
default 0
13+
help
14+
Maximum allowed offset between sent and received samples.
15+
Value is in "full" audio samples.
16+
Offset of 1 "full" audio sample is:
17+
- 1 byte for mono 8 bit word size.
18+
- 2 bytes for stereo 8 bit word size.
19+
- 2 bytes for mono 16 bit word size.
20+
- 4 bytes for stereo 16 bit word size.
21+
- 4 bytes for mono 32 bit word size.
22+
- 8 bytes for stereo 32 bit word size.
23+
24+
config I2S_TEST_BUFFER_SIZE
25+
int "Number of bytes send in one transaction"
26+
default 16
27+
help
28+
Value has to be a multiple of 8 bytes. Test supports up to 32 bytes.
29+
30+
config I2S_TEST_WORD_SIZE_32_BIT_UNSUPPORTED
31+
bool "32 bit word size is not supported by the driver"
32+
help
33+
When set to 'y' testing 32 bit word size is skipped.
34+
35+
config I2S_TEST_BLOCK_SIZE_8_UNSUPPORTED
36+
bool "Block_size of 8 bytes is not supported by the driver"
37+
default y if DT_HAS_NORDIC_NRF_TDM_ENABLED
38+
help
39+
When set to 'y', test that use 8 bytes of data check if
40+
i2s_configure() returns -EINVAL.
41+
When set to 'n', test will do the I2S transmission.
42+
43+
source "Kconfig.zephyr"
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: 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: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Test requires GPIO loopback:
8+
* P1.01 - P1.02
9+
*/
10+
11+
/ {
12+
aliases {
13+
i2s-node0 = &i2s0;
14+
};
15+
};
16+
17+
&pinctrl {
18+
i2s0_default_alt: i2s0_default_alt {
19+
group1 {
20+
psels = <NRF_PSEL(I2S_SCK_M, 1, 5)>,
21+
<NRF_PSEL(I2S_LRCK_M, 1, 6)>,
22+
<NRF_PSEL(I2S_SDOUT, 1, 1)>,
23+
<NRF_PSEL(I2S_SDIN, 1, 2)>;
24+
};
25+
};
26+
};
27+
28+
&i2s0 {
29+
status = "okay";
30+
pinctrl-0 = <&i2s0_default_alt>;
31+
pinctrl-names = "default";
32+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Test requires GPIO loopback:
8+
* P0.04 - P0.05
9+
*/
10+
11+
/ {
12+
aliases {
13+
i2s-node0 = &i2s0;
14+
};
15+
};
16+
17+
&pinctrl {
18+
i2s0_default_alt: i2s0_default_alt {
19+
group1 {
20+
psels = <NRF_PSEL(I2S_SCK_M, 1, 6)>,
21+
<NRF_PSEL(I2S_LRCK_M, 1, 7)>,
22+
<NRF_PSEL(I2S_SDOUT, 0, 4)>,
23+
<NRF_PSEL(I2S_SDIN, 0, 5)>;
24+
};
25+
};
26+
};
27+
28+
&uart1 {
29+
status = "disabled";
30+
};
31+
32+
&i2s0 {
33+
status = "okay";
34+
pinctrl-0 = <&i2s0_default_alt>;
35+
pinctrl-names = "default";
36+
};
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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Test requires GPIO loopback:
8+
* P1.04 - P1.05
9+
*/
10+
11+
/ {
12+
aliases {
13+
i2s-node0 = &tdm130;
14+
};
15+
};
16+
17+
&pinctrl {
18+
tdm130_default_alt: tdm130_default_alt {
19+
group1 {
20+
psels = <NRF_PSEL(TDM_SCK_M, 1, 3)>,
21+
<NRF_PSEL(TDM_FSYNC_M, 1, 6)>,
22+
<NRF_PSEL(TDM_SDOUT, 1, 4)>,
23+
<NRF_PSEL(TDM_SDIN, 1, 5)>;
24+
};
25+
};
26+
};
27+
28+
&tdm130 {
29+
status = "okay";
30+
pinctrl-0 = <&tdm130_default_alt>;
31+
pinctrl-names = "default";
32+
memory-regions = <&cpuapp_dma_region>;
33+
};
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: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Test requires GPIO loopback:
8+
* P1.08 - P1.09
9+
*/
10+
11+
/ {
12+
aliases {
13+
i2s-node0 = &i2s20;
14+
};
15+
};
16+
17+
&pinctrl {
18+
i2s20_default_alt: i2s20_default_alt {
19+
group1 {
20+
psels = <NRF_PSEL(I2S_SCK_M, 1, 11)>,
21+
<NRF_PSEL(I2S_LRCK_M, 1, 12)>,
22+
<NRF_PSEL(I2S_SDOUT, 1, 8)>,
23+
<NRF_PSEL(I2S_SDIN, 1, 9)>;
24+
};
25+
};
26+
};
27+
28+
&i2s20 {
29+
status = "okay";
30+
pinctrl-0 = <&i2s20_default_alt>;
31+
pinctrl-names = "default";
32+
};
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: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Test requires GPIO loopback:
8+
* P1.30 - P1.31
9+
*/
10+
11+
/ {
12+
aliases {
13+
i2s-node0 = &tdm;
14+
};
15+
};
16+
17+
&pinctrl {
18+
tdm_default_alt: tdm_default_alt {
19+
group1 {
20+
psels = <NRF_PSEL(TDM_SCK_M, 1, 23)>,
21+
<NRF_PSEL(TDM_FSYNC_M, 1, 14)>,
22+
<NRF_PSEL(TDM_SDOUT, 1, 30)>,
23+
<NRF_PSEL(TDM_SDIN, 1, 31)>;
24+
};
25+
};
26+
};
27+
28+
&tdm {
29+
status = "okay";
30+
pinctrl-0 = <&tdm_default_alt>;
31+
pinctrl-names = "default";
32+
};

0 commit comments

Comments
 (0)