Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromtree] tests: drivers: spi: Add negative test cases #1637

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/drivers/spi/spi_error_cases/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(spi_error_cases)

FILE(GLOB app_sources src/*.c)

target_sources(app PRIVATE ${app_sources})
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
spi3_default_alt: spi3_default_alt {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
<NRF_PSEL(SPIM_MISO, 1, 3)>,
<NRF_PSEL(SPIM_MOSI, 1, 5)>;
};
};

spi3_sleep_alt: spi3_sleep_alt {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
<NRF_PSEL(SPIM_MISO, 1, 3)>,
<NRF_PSEL(SPIM_MOSI, 1, 5)>;
low-power-enable;
};
};

spi1_default_alt: spi1_default_alt {
group1 {
psels = <NRF_PSEL(SPIS_SCK, 1, 2)>,
<NRF_PSEL(SPIS_MISO, 1, 4)>,
<NRF_PSEL(SPIS_MOSI, 1, 6)>,
<NRF_PSEL(SPIS_CSN, 1, 8)>;
};
};

spi1_sleep_alt: spi1_sleep_alt {
group1 {
psels = <NRF_PSEL(SPIS_SCK, 1, 2)>,
<NRF_PSEL(SPIS_MISO, 1, 4)>,
<NRF_PSEL(SPIS_MOSI, 1, 6)>,
<NRF_PSEL(SPIS_CSN, 1, 8)>;
low-power-enable;
};
};

};

dut_spi: &spi3 {
status = "okay";
pinctrl-0 = <&spi3_default_alt>;
pinctrl-1 = <&spi3_sleep_alt>;
pinctrl-names = "default", "sleep";
overrun-character = <0x00>;
cs-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
dut_spi_dt: test-spi-dev@0 {
compatible = "vnd,spi-device";
reg = <0>;
spi-max-frequency = <200000>;
};
};

dut_spis: &spi1 {
compatible = "nordic,nrf-spis";
status = "okay";
def-char = <0x00>;
pinctrl-0 = <&spi1_default_alt>;
pinctrl-1 = <&spi1_sleep_alt>;
pinctrl-names = "default", "sleep";
dut_spis_dt: test-spis-dev@0 {
compatible = "vnd,spi-device";
reg = <0>;
spi-max-frequency = <200000>;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
spi22_default_alt: spi22_default_alt {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
<NRF_PSEL(SPIM_MISO, 1, 11)>,
<NRF_PSEL(SPIM_MOSI, 1, 9)>;
};
};

spi22_sleep_alt: spi22_sleep_alt {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
<NRF_PSEL(SPIM_MISO, 1, 11)>,
<NRF_PSEL(SPIM_MOSI, 1, 9)>;
low-power-enable;
};
};

spi21_default_alt: spi21_default_alt {
group1 {
psels = <NRF_PSEL(SPIS_SCK, 1, 12)>,
<NRF_PSEL(SPIS_MISO, 1, 10)>,
<NRF_PSEL(SPIS_MOSI, 1, 8)>,
<NRF_PSEL(SPIS_CSN, 1, 14)>;
};
};

spi21_sleep_alt: spi21_sleep_alt {
group1 {
psels = <NRF_PSEL(SPIS_SCK, 1, 12)>,
<NRF_PSEL(SPIS_MISO, 1, 10)>,
<NRF_PSEL(SPIS_MOSI, 1, 8)>,
<NRF_PSEL(SPIS_CSN, 1, 14)>;
low-power-enable;
};
};

};

&gpio2 {
status = "okay";
};

dut_spi: &spi22 {
status = "okay";
pinctrl-0 = <&spi22_default_alt>;
pinctrl-1 = <&spi22_sleep_alt>;
pinctrl-names = "default", "sleep";
overrun-character = <0x00>;
cs-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
dut_spi_dt: test-spi-dev@0 {
compatible = "vnd,spi-device";
reg = <0>;
spi-max-frequency = <200000>;
};
};

dut_spis: &spi21 {
compatible = "nordic,nrf-spis";
status = "okay";
def-char = <0x00>;
pinctrl-0 = <&spi21_default_alt>;
pinctrl-1 = <&spi21_sleep_alt>;
pinctrl-names = "default", "sleep";
dut_spis_dt: test-spis-dev@0 {
compatible = "vnd,spi-device";
reg = <0>;
spi-max-frequency = <200000>;
};
/delete-property/rx-delay-supported;
/delete-property/rx-delay;
};
7 changes: 7 additions & 0 deletions tests/drivers/spi/spi_error_cases/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_SPI=y
CONFIG_SPI_SLAVE=y
CONFIG_GPIO=y
CONFIG_POLL=y
CONFIG_SPI_ASYNC=y
CONFIG_SPI_EXTENDED_MODES=y
CONFIG_ZTEST=y
Loading
Loading