Skip to content

Commit a34af0d

Browse files
committed
[nrf fromtree] tests: drivers: spi: Add negative test cases
Extend test coverage by adding tests that check invalid use of the SPI API. Signed-off-by: Sebastian Głąb <[email protected]> (cherry picked from commit 5e4bbd5)
1 parent 94a7ff9 commit a34af0d

File tree

6 files changed

+442
-0
lines changed

6 files changed

+442
-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(spi_error_cases)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
10+
target_sources(app PRIVATE ${app_sources})
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&pinctrl {
8+
spi3_default_alt: spi3_default_alt {
9+
group1 {
10+
psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
11+
<NRF_PSEL(SPIM_MISO, 1, 3)>,
12+
<NRF_PSEL(SPIM_MOSI, 1, 5)>;
13+
};
14+
};
15+
16+
spi3_sleep_alt: spi3_sleep_alt {
17+
group1 {
18+
psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
19+
<NRF_PSEL(SPIM_MISO, 1, 3)>,
20+
<NRF_PSEL(SPIM_MOSI, 1, 5)>;
21+
low-power-enable;
22+
};
23+
};
24+
25+
spi1_default_alt: spi1_default_alt {
26+
group1 {
27+
psels = <NRF_PSEL(SPIS_SCK, 1, 2)>,
28+
<NRF_PSEL(SPIS_MISO, 1, 4)>,
29+
<NRF_PSEL(SPIS_MOSI, 1, 6)>,
30+
<NRF_PSEL(SPIS_CSN, 1, 8)>;
31+
};
32+
};
33+
34+
spi1_sleep_alt: spi1_sleep_alt {
35+
group1 {
36+
psels = <NRF_PSEL(SPIS_SCK, 1, 2)>,
37+
<NRF_PSEL(SPIS_MISO, 1, 4)>,
38+
<NRF_PSEL(SPIS_MOSI, 1, 6)>,
39+
<NRF_PSEL(SPIS_CSN, 1, 8)>;
40+
low-power-enable;
41+
};
42+
};
43+
44+
};
45+
46+
dut_spi: &spi3 {
47+
status = "okay";
48+
pinctrl-0 = <&spi3_default_alt>;
49+
pinctrl-1 = <&spi3_sleep_alt>;
50+
pinctrl-names = "default", "sleep";
51+
overrun-character = <0x00>;
52+
cs-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
53+
dut_spi_dt: test-spi-dev@0 {
54+
compatible = "vnd,spi-device";
55+
reg = <0>;
56+
spi-max-frequency = <200000>;
57+
};
58+
};
59+
60+
dut_spis: &spi1 {
61+
compatible = "nordic,nrf-spis";
62+
status = "okay";
63+
def-char = <0x00>;
64+
pinctrl-0 = <&spi1_default_alt>;
65+
pinctrl-1 = <&spi1_sleep_alt>;
66+
pinctrl-names = "default", "sleep";
67+
dut_spis_dt: test-spis-dev@0 {
68+
compatible = "vnd,spi-device";
69+
reg = <0>;
70+
spi-max-frequency = <200000>;
71+
};
72+
};
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&pinctrl {
8+
spi22_default_alt: spi22_default_alt {
9+
group1 {
10+
psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
11+
<NRF_PSEL(SPIM_MISO, 1, 11)>,
12+
<NRF_PSEL(SPIM_MOSI, 1, 9)>;
13+
};
14+
};
15+
16+
spi22_sleep_alt: spi22_sleep_alt {
17+
group1 {
18+
psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
19+
<NRF_PSEL(SPIM_MISO, 1, 11)>,
20+
<NRF_PSEL(SPIM_MOSI, 1, 9)>;
21+
low-power-enable;
22+
};
23+
};
24+
25+
spi21_default_alt: spi21_default_alt {
26+
group1 {
27+
psels = <NRF_PSEL(SPIS_SCK, 1, 12)>,
28+
<NRF_PSEL(SPIS_MISO, 1, 10)>,
29+
<NRF_PSEL(SPIS_MOSI, 1, 8)>,
30+
<NRF_PSEL(SPIS_CSN, 1, 14)>;
31+
};
32+
};
33+
34+
spi21_sleep_alt: spi21_sleep_alt {
35+
group1 {
36+
psels = <NRF_PSEL(SPIS_SCK, 1, 12)>,
37+
<NRF_PSEL(SPIS_MISO, 1, 10)>,
38+
<NRF_PSEL(SPIS_MOSI, 1, 8)>,
39+
<NRF_PSEL(SPIS_CSN, 1, 14)>;
40+
low-power-enable;
41+
};
42+
};
43+
44+
};
45+
46+
&gpio2 {
47+
status = "okay";
48+
};
49+
50+
dut_spi: &spi22 {
51+
status = "okay";
52+
pinctrl-0 = <&spi22_default_alt>;
53+
pinctrl-1 = <&spi22_sleep_alt>;
54+
pinctrl-names = "default", "sleep";
55+
overrun-character = <0x00>;
56+
cs-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
57+
dut_spi_dt: test-spi-dev@0 {
58+
compatible = "vnd,spi-device";
59+
reg = <0>;
60+
spi-max-frequency = <200000>;
61+
};
62+
};
63+
64+
dut_spis: &spi21 {
65+
compatible = "nordic,nrf-spis";
66+
status = "okay";
67+
def-char = <0x00>;
68+
pinctrl-0 = <&spi21_default_alt>;
69+
pinctrl-1 = <&spi21_sleep_alt>;
70+
pinctrl-names = "default", "sleep";
71+
dut_spis_dt: test-spis-dev@0 {
72+
compatible = "vnd,spi-device";
73+
reg = <0>;
74+
spi-max-frequency = <200000>;
75+
};
76+
/delete-property/rx-delay-supported;
77+
/delete-property/rx-delay;
78+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_SPI=y
2+
CONFIG_SPI_SLAVE=y
3+
CONFIG_GPIO=y
4+
CONFIG_POLL=y
5+
CONFIG_SPI_ASYNC=y
6+
CONFIG_SPI_EXTENDED_MODES=y
7+
CONFIG_ZTEST=y

0 commit comments

Comments
 (0)