Skip to content
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
4 changes: 4 additions & 0 deletions tests/drivers/spi/spi_loopback/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ config SPI_LARGE_BUFFER_SIZE
int "Large buffer size"
default 8192

config SPI_IDEAL_TRANSFER_DURATION_SCALING
int "Scaling factor to compare ideal and measured SPI transfer duration"
default 8

if SOC_SERIES_STM32H7X

config SPI_LOOPBACK_16BITS_FRAMES
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING=12
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING=12
6 changes: 4 additions & 2 deletions tests/drivers/spi/spi_loopback/src/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ ZTEST(spi_loopback, test_spi_complete_multiple_timed)

/* Fail if transfer is faster than theoretically possible */
zassert_true(time_spent_us >= minimum_transfer_time_us,
"Transfer faster than theoretically possible");
"Transfer faster than theoretically possible");

/* handle overflow for print statement */
latency_measurement = time_spent_us - expected_transfer_time_us;
Expand All @@ -337,7 +337,9 @@ ZTEST(spi_loopback, test_spi_complete_multiple_timed)
TC_PRINT("Latency measurement: %llu us\n", latency_measurement);

/* Allow some overhead, but not too much */
zassert_true(time_spent_us <= expected_transfer_time_us * 8, "Very high latency");
zassert_true(time_spent_us <=
expected_transfer_time_us * CONFIG_SPI_IDEAL_TRANSFER_DURATION_SCALING,
"Very high latency");

spi_loopback_compare_bufs(buffer_tx, buffer_rx, BUF_SIZE,
buffer_print_tx, buffer_print_rx);
Expand Down