Skip to content

Commit 19f2df8

Browse files
committed
[nrf noup] drivers: i2c_nrfx_twim: twister testing
This commit provides a set of tests for the i2c_nrfx_twim driver extension. Signed-off-by: Andrzej Kuros <[email protected]>
1 parent 40c71df commit 19f2df8

File tree

7 files changed

+595
-0
lines changed

7 files changed

+595
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(i2c_api)
6+
7+
FILE(GLOB app_sources src/*.c)
8+
target_sources(app PRIVATE ${app_sources})
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*
8+
* SDA = P0.26 and P1.2
9+
* SCL = P0.25 and P1.3
10+
*/
11+
12+
/ {
13+
aliases {
14+
i2c-controller = &i2c1;
15+
i2c-controller-target = &i2c2;
16+
};
17+
};
18+
19+
&pinctrl {
20+
i2c2_default: i2c2_default {
21+
group1 {
22+
psels = <NRF_PSEL(TWIS_SDA, 0, 26)>,
23+
<NRF_PSEL(TWIS_SCL, 0, 25)>;
24+
bias-pull-up;
25+
};
26+
};
27+
28+
i2c2_sleep: i2c2_sleep {
29+
group1 {
30+
psels = <NRF_PSEL(TWIS_SDA, 0, 26)>,
31+
<NRF_PSEL(TWIS_SCL, 0, 25)>;
32+
low-power-enable;
33+
};
34+
};
35+
};
36+
37+
&i2c2 {
38+
compatible = "nordic,nrf-twis";
39+
pinctrl-0 = <&i2c2_default>;
40+
pinctrl-1 = <&i2c2_sleep>;
41+
pinctrl-names = "default", "sleep";
42+
status = "okay";
43+
};
44+
45+
&i2c1 {
46+
compatible = "nordic,nrf-twim";
47+
zephyr,concat-buf-size = <256>;
48+
status = "okay";
49+
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*
8+
* SDA = P2.8 and P2.9
9+
* SCL = P1.2 and P1.3
10+
*/
11+
12+
/ {
13+
aliases {
14+
i2c-controller = &i2c130;
15+
i2c-controller-target = &i2c131;
16+
};
17+
};
18+
19+
&pinctrl {
20+
i2c130_default: i2c130_default {
21+
group1 {
22+
psels = <NRF_PSEL(TWIM_SDA, 2, 8)>,
23+
<NRF_PSEL(TWIM_SCL, 1, 2)>;
24+
bias-pull-up;
25+
};
26+
};
27+
28+
i2c130_sleep: i2c130_sleep {
29+
group1 {
30+
psels = <NRF_PSEL(TWIM_SDA, 2, 8)>,
31+
<NRF_PSEL(TWIM_SCL, 1, 2)>;
32+
low-power-enable;
33+
};
34+
};
35+
36+
i2c131_default: i2c131_default {
37+
group1 {
38+
psels = <NRF_PSEL(TWIM_SDA, 2, 9)>,
39+
<NRF_PSEL(TWIM_SCL, 1, 3)>;
40+
bias-pull-up;
41+
};
42+
};
43+
44+
i2c131_sleep: i2c131_sleep {
45+
group1 {
46+
psels = <NRF_PSEL(TWIM_SDA, 2, 9)>,
47+
<NRF_PSEL(TWIM_SCL, 1, 3)>;
48+
low-power-enable;
49+
};
50+
};
51+
};
52+
53+
&i2c130 {
54+
compatible = "nordic,nrf-twim";
55+
clock-frequency = <I2C_BITRATE_STANDARD>;
56+
pinctrl-0 = <&i2c130_default>;
57+
pinctrl-1 = <&i2c130_sleep>;
58+
pinctrl-names = "default", "sleep";
59+
zephyr,concat-buf-size = <256>;
60+
memory-regions = <&cpuapp_dma_region>;
61+
status = "okay";
62+
};
63+
64+
&i2c131 {
65+
compatible = "nordic,nrf-twis";
66+
clock-frequency = <I2C_BITRATE_STANDARD>;
67+
pinctrl-0 = <&i2c131_default>;
68+
pinctrl-1 = <&i2c131_sleep>;
69+
pinctrl-names = "default", "sleep";
70+
memory-regions = <&cpuapp_dma_region>;
71+
status = "okay";
72+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*
8+
* SDA = P1.8 and P1.9
9+
* SCL = P1.10 and P1.11
10+
*/
11+
12+
/ {
13+
aliases {
14+
i2c-controller = &i2c21;
15+
i2c-controller-target = &i2c22;
16+
};
17+
};
18+
19+
&pinctrl {
20+
i2c21_default: i2c21_default {
21+
group1 {
22+
psels = <NRF_PSEL(TWIS_SDA, 1, 8)>,
23+
<NRF_PSEL(TWIS_SCL, 1, 10)>;
24+
bias-pull-up;
25+
};
26+
};
27+
28+
i2c21_sleep: i2c21_sleep {
29+
group1 {
30+
psels = <NRF_PSEL(TWIS_SDA, 1, 8)>,
31+
<NRF_PSEL(TWIS_SCL, 1, 10)>;
32+
low-power-enable;
33+
};
34+
};
35+
36+
i2c22_default: i2c22_default {
37+
group1 {
38+
psels = <NRF_PSEL(TWIS_SDA, 1, 9)>,
39+
<NRF_PSEL(TWIS_SCL, 1, 11)>;
40+
bias-pull-up;
41+
};
42+
};
43+
44+
i2c22_sleep: i2c22_sleep {
45+
group1 {
46+
psels = <NRF_PSEL(TWIS_SDA, 1, 9)>,
47+
<NRF_PSEL(TWIS_SCL, 1, 11)>;
48+
low-power-enable;
49+
};
50+
};
51+
};
52+
53+
&i2c21 {
54+
compatible = "nordic,nrf-twim";
55+
pinctrl-0 = <&i2c21_default>;
56+
pinctrl-1 = <&i2c21_sleep>;
57+
pinctrl-names = "default", "sleep";
58+
zephyr,concat-buf-size = <256>;
59+
status = "okay";
60+
};
61+
62+
&i2c22 {
63+
compatible = "nordic,nrf-twis";
64+
pinctrl-0 = <&i2c22_default>;
65+
pinctrl-1 = <&i2c22_sleep>;
66+
pinctrl-names = "default", "sleep";
67+
status = "okay";
68+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_BOOT_BANNER=n
3+
4+
CONFIG_LOG=y
5+
CONFIG_I2C_LOG_LEVEL_INF=y
6+
CONFIG_I2C=y
7+
CONFIG_I2C_TARGET=y
8+
CONFIG_I2C_TARGET_BUFFER_MODE=y
9+
CONFIG_I2C_NRFX_TWIS_BUF_SIZE=256
10+
11+
CONFIG_ZERO_LATENCY_IRQS=y

0 commit comments

Comments
 (0)