Skip to content

Commit ee43b9a

Browse files
nika-nordiccvinayak
authored andcommitted
[nrf fromtree] tests: boards: nrf: add i2c driver test with TWIS slave
Test defines a lopback between i2c driver master and nrfx TWIS slave to verify their functional correctness. Signed-off-by: Nikodem Kastelik <[email protected]> (cherry picked from commit 01ea0f2)
1 parent 28e2f57 commit ee43b9a

12 files changed

+413
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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(i2c_slave)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
10+
target_sources(app PRIVATE ${app_sources})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_NRFX_TWIS1=y
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/ {
2+
aliases {
3+
i2c-slave = &i2c1;
4+
};
5+
};
6+
7+
&pinctrl {
8+
i2c0_default_alt: i2c0_default_alt {
9+
group1 {
10+
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
11+
<NRF_PSEL(TWIM_SCL, 0, 3)>;
12+
};
13+
};
14+
15+
i2c0_sleep_alt: i2c0_sleep_alt {
16+
group1 {
17+
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
18+
<NRF_PSEL(TWIM_SCL, 0, 3)>;
19+
low-power-enable;
20+
};
21+
};
22+
23+
i2c1_default_alt: i2c1_default_alt {
24+
group1 {
25+
/* Temporary workaround as it is currently not possible
26+
* to configure pins for TWIS with pinctrl. */
27+
psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
28+
<NRF_PSEL(TWIM_SCL, 0, 31)>;
29+
bias-pull-up;
30+
};
31+
};
32+
33+
i2c1_sleep_alt: i2c1_sleep_alt {
34+
group1 {
35+
psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
36+
<NRF_PSEL(TWIM_SCL, 0, 31)>;
37+
low-power-enable;
38+
};
39+
};
40+
};
41+
42+
&i2c0 {
43+
compatible = "nordic,nrf-twim";
44+
status = "okay";
45+
pinctrl-0 = <&i2c0_default_alt>;
46+
pinctrl-1 = <&i2c0_sleep_alt>;
47+
pinctrl-names = "default", "sleep";
48+
sensor: sensor@54 {
49+
reg = <0x54>;
50+
};
51+
};
52+
53+
54+
&i2c1 {
55+
compatible = "nordic,nrf-twis";
56+
status = "okay";
57+
pinctrl-0 = <&i2c1_default_alt>;
58+
pinctrl-1 = <&i2c1_sleep_alt>;
59+
pinctrl-names = "default", "sleep";
60+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_NRFX_TWIS2=y
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/ {
2+
aliases {
3+
i2c-slave = &i2c2;
4+
};
5+
};
6+
7+
&pinctrl {
8+
i2c1_default_alt: i2c1_default_alt {
9+
group1 {
10+
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
11+
<NRF_PSEL(TWIM_SCL, 0, 5)>;
12+
};
13+
};
14+
15+
i2c1_sleep_alt: i2c1_sleep_alt {
16+
group1 {
17+
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
18+
<NRF_PSEL(TWIM_SCL, 0, 5)>;
19+
low-power-enable;
20+
};
21+
};
22+
23+
i2c2_default_alt: i2c2_default_alt {
24+
group1 {
25+
/* Temporary workaround as it is currently not possible
26+
* to configure pins for TWIS with pinctrl. */
27+
psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
28+
<NRF_PSEL(TWIM_SCL, 0, 25)>;
29+
bias-pull-up;
30+
};
31+
};
32+
33+
i2c2_sleep_alt: i2c2_sleep_alt {
34+
group1 {
35+
psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
36+
<NRF_PSEL(TWIM_SCL, 0, 25)>;
37+
low-power-enable;
38+
};
39+
};
40+
};
41+
42+
&i2c1 {
43+
compatible = "nordic,nrf-twim";
44+
status = "okay";
45+
pinctrl-0 = <&i2c1_default_alt>;
46+
pinctrl-1 = <&i2c1_sleep_alt>;
47+
pinctrl-names = "default", "sleep";
48+
sensor: sensor@54 {
49+
reg = <0x54>;
50+
};
51+
};
52+
53+
&i2c2 {
54+
compatible = "nordic,nrf-twis";
55+
pinctrl-0 = <&i2c2_default_alt>;
56+
pinctrl-1 = <&i2c2_sleep_alt>;
57+
pinctrl-names = "default", "sleep";
58+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_NRFX_TWIS131=y
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/ {
2+
aliases {
3+
i2c-slave = &i2c131;
4+
};
5+
};
6+
7+
&pinctrl {
8+
i2c130_default_alt: i2c130_default_alt {
9+
group1 {
10+
psels = <NRF_PSEL(TWIM_SDA, 2, 8)>,
11+
<NRF_PSEL(TWIM_SCL, 1, 2)>;
12+
};
13+
};
14+
15+
i2c130_sleep_alt: i2c130_sleep_alt {
16+
group1 {
17+
psels = <NRF_PSEL(TWIM_SDA, 2, 8)>,
18+
<NRF_PSEL(TWIM_SCL, 1, 2)>;
19+
low-power-enable;
20+
};
21+
};
22+
23+
i2c131_default_alt: i2c131_default_alt {
24+
group1 {
25+
/* Temporary workaround as it is currently not possible
26+
* to configure pins for TWIS with pinctrl. */
27+
psels = <NRF_PSEL(TWIM_SDA, 2, 9)>,
28+
<NRF_PSEL(TWIM_SCL, 1, 3)>;
29+
bias-pull-up;
30+
};
31+
};
32+
33+
i2c131_sleep_alt: i2c131_sleep_alt {
34+
group1 {
35+
psels = <NRF_PSEL(TWIM_SDA, 2, 9)>,
36+
<NRF_PSEL(TWIM_SCL, 1, 3)>;
37+
low-power-enable;
38+
};
39+
};
40+
};
41+
42+
&i2c130 {
43+
compatible = "nordic,nrf-twim";
44+
status = "okay";
45+
clock-frequency = <I2C_BITRATE_STANDARD>;
46+
pinctrl-0 = <&i2c130_default_alt>;
47+
pinctrl-1 = <&i2c130_sleep_alt>;
48+
pinctrl-names = "default", "sleep";
49+
memory-regions = <&cpuapp_dma_region>;
50+
sensor: sensor@54 {
51+
reg = <0x54>;
52+
};
53+
};
54+
55+
&i2c131 {
56+
compatible = "nordic,nrf-twis";
57+
status = "okay";
58+
clock-frequency = <I2C_BITRATE_STANDARD>;
59+
pinctrl-0 = <&i2c131_default_alt>;
60+
pinctrl-1 = <&i2c131_sleep_alt>;
61+
pinctrl-names = "default", "sleep";
62+
memory-regions = <&cpuapp_dma_region>;
63+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_NRFX_TWIS22=y
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/ {
2+
aliases {
3+
i2c-slave = &i2c22;
4+
};
5+
};
6+
7+
&pinctrl {
8+
i2c21_default_alt: i2c21_default_alt {
9+
group1 {
10+
psels = <NRF_PSEL(TWIM_SDA, 1, 8)>,
11+
<NRF_PSEL(TWIM_SCL, 1, 12)>;
12+
};
13+
};
14+
15+
i2c21_sleep_alt: i2c21_sleep_alt {
16+
group1 {
17+
psels = <NRF_PSEL(TWIM_SDA, 1, 8)>,
18+
<NRF_PSEL(TWIM_SCL, 1, 12)>;
19+
low-power-enable;
20+
};
21+
};
22+
23+
i2c22_default_alt: i2c22_default_alt {
24+
group1 {
25+
/* Temporary workaround as it is currently not possible
26+
* to configure pins for TWIS with pinctrl. */
27+
psels = <NRF_PSEL(TWIM_SDA, 1, 9)>,
28+
<NRF_PSEL(TWIM_SCL, 1, 13)>;
29+
bias-pull-up;
30+
};
31+
};
32+
33+
i2c22_sleep_alt: i2c22_sleep_alt {
34+
group1 {
35+
psels = <NRF_PSEL(TWIM_SDA, 1, 9)>,
36+
<NRF_PSEL(TWIM_SCL, 1, 13)>;
37+
low-power-enable;
38+
};
39+
};
40+
};
41+
42+
&i2c21 {
43+
compatible = "nordic,nrf-twim";
44+
status = "okay";
45+
pinctrl-0 = <&i2c21_default_alt>;
46+
pinctrl-1 = <&i2c21_sleep_alt>;
47+
pinctrl-names = "default", "sleep";
48+
sensor: sensor@54 {
49+
reg = <0x54>;
50+
};
51+
};
52+
53+
&i2c22 {
54+
compatible = "nordic,nrf-twis";
55+
status = "okay";
56+
pinctrl-0 = <&i2c22_default_alt>;
57+
pinctrl-1 = <&i2c22_sleep_alt>;
58+
pinctrl-names = "default", "sleep";
59+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_I2C=y
2+
CONFIG_ZTEST=y

0 commit comments

Comments
 (0)