forked from nrfconnect/sdk-zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: drivers: spi: Add test for SPI master and slave
Add test which is using one SPI master and one SPI slave instance. There is already a loopback test for SPI master so this test is focusing on SPI slave API. Test requires 4 pairs of GPIO pins shortened together. One set of pins is used by SPI master and one for SPI slave. Signed-off-by: Krzysztof Chruściński <[email protected]>
- Loading branch information
1 parent
289c7e1
commit 1cd7f51
Showing
6 changed files
with
618 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_slave) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
|
||
target_sources(app PRIVATE ${app_sources}) |
67 changes: 67 additions & 0 deletions
67
tests/drivers/spi/spi_slave/boards/nrf52840dk_nrf52840.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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, 7)>; | ||
}; | ||
}; | ||
|
||
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, 7)>; | ||
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, 8)>, | ||
<NRF_PSEL(SPIS_CSN, 1, 10)>; | ||
}; | ||
}; | ||
|
||
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, 8)>, | ||
<NRF_PSEL(SPIS_CSN, 1, 10)>; | ||
low-power-enable; | ||
}; | ||
}; | ||
|
||
}; | ||
|
||
&spi3 { | ||
status = "okay"; | ||
pinctrl-0 = <&spi3_default_alt>; | ||
pinctrl-1 = <&spi3_sleep_alt>; | ||
pinctrl-names = "default", "sleep"; | ||
overrun-character = <0x00>; | ||
cs-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>; | ||
dut_spi_dt: test-spi-dev@0 { | ||
compatible = "vnd,spi-device"; | ||
reg = <0>; | ||
spi-max-frequency = <4000000>; | ||
}; | ||
}; | ||
|
||
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"; | ||
}; |
73 changes: 73 additions & 0 deletions
73
tests/drivers/spi/spi_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* 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"; | ||
}; | ||
|
||
&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 = <4000000>; | ||
}; | ||
}; | ||
|
||
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"; | ||
/delete-property/rx-delay-supported; | ||
/delete-property/rx-delay; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CONFIG_SPI=y | ||
CONFIG_SPI_SLAVE=y | ||
CONFIG_GPIO=y | ||
CONFIG_POLL=y | ||
CONFIG_SPI_ASYNC=y | ||
CONFIG_ZTEST=y |
Oops, something went wrong.