Skip to content

Commit 06aa17f

Browse files
teburdcarlescufi
authored andcommitted
tests: SPI loopback with RTIO
Adds the equivalent spi loopback tests using RTIO and a testplan that uses it. Adds a tdk robokit1 overlay to enable the NOCACHE option so that DMA transfers correctly work. Signed-off-by: Tom Burdick <[email protected]>
1 parent dcd9322 commit 06aa17f

File tree

5 files changed

+453
-13
lines changed

5 files changed

+453
-13
lines changed

tests/drivers/spi/spi_loopback/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ cmake_minimum_required(VERSION 3.20.0)
55
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
66
project(spi_loopback)
77

8-
FILE(GLOB app_sources src/*.c)
9-
target_sources(app PRIVATE ${app_sources})
8+
target_sources(app PRIVATE src/spi.c)
9+
target_sources_ifdef(CONFIG_SPI_RTIO app PRIVATE src/spi_rtio.c)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_SPI_ASYNC=n
2+
CONFIG_NOCACHE_MEMORY=y

tests/drivers/spi/spi_loopback/src/spi.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
88
#include <zephyr/logging/log.h>
9-
LOG_MODULE_REGISTER(main);
9+
LOG_MODULE_REGISTER(spi_loopback);
1010

1111
#include <zephyr/kernel.h>
1212
#include <zephyr/sys/printk.h>
@@ -29,8 +29,8 @@ LOG_MODULE_REGISTER(main);
2929
SPI_MODE_CPHA | SPI_WORD_SET(8) | SPI_LINES_SINGLE
3030

3131

32-
struct spi_dt_spec spi_fast = SPI_DT_SPEC_GET(SPI_FAST_DEV, SPI_OP, 0);
33-
struct spi_dt_spec spi_slow = SPI_DT_SPEC_GET(SPI_SLOW_DEV, SPI_OP, 0);
32+
static struct spi_dt_spec spi_fast = SPI_DT_SPEC_GET(SPI_FAST_DEV, SPI_OP, 0);
33+
static struct spi_dt_spec spi_slow = SPI_DT_SPEC_GET(SPI_SLOW_DEV, SPI_OP, 0);
3434

3535
/* to run this test, connect MOSI pin to the MISO of the SPI */
3636

@@ -47,22 +47,22 @@ static __aligned(32) char buffer2_tx[BUF2_SIZE] __used __attribute__((__section_
4747
static __aligned(32) char buffer2_rx[BUF2_SIZE] __used __attribute__((__section__(".nocache")));
4848
#else
4949
/* this src memory shall be in RAM to support using as a DMA source pointer.*/
50-
uint8_t buffer_tx[] = "0123456789abcdef\0";
51-
uint8_t buffer_rx[BUF_SIZE] = {};
50+
static uint8_t buffer_tx[] = "0123456789abcdef\0";
51+
static uint8_t buffer_rx[BUF_SIZE] = {};
5252

53-
uint8_t buffer2_tx[] = "Thequickbrownfoxjumpsoverthelazydog\0";
54-
uint8_t buffer2_rx[BUF2_SIZE] = {};
53+
static uint8_t buffer2_tx[] = "Thequickbrownfoxjumpsoverthelazydog\0";
54+
static uint8_t buffer2_rx[BUF2_SIZE] = {};
5555
#endif
5656

5757
/*
5858
* We need 5x(buffer size) + 1 to print a comma-separated list of each
5959
* byte in hex, plus a null.
6060
*/
61-
uint8_t buffer_print_tx[BUF_SIZE * 5 + 1];
62-
uint8_t buffer_print_rx[BUF_SIZE * 5 + 1];
61+
static uint8_t buffer_print_tx[BUF_SIZE * 5 + 1];
62+
static uint8_t buffer_print_rx[BUF_SIZE * 5 + 1];
6363

64-
uint8_t buffer_print_tx2[BUF2_SIZE * 5 + 1];
65-
uint8_t buffer_print_rx2[BUF2_SIZE * 5 + 1];
64+
static uint8_t buffer_print_tx2[BUF2_SIZE * 5 + 1];
65+
static uint8_t buffer_print_rx2[BUF2_SIZE * 5 + 1];
6666

6767
static void to_display_format(const uint8_t *src, size_t size, char *dst)
6868
{

0 commit comments

Comments
 (0)