Skip to content

Commit 2a60277

Browse files
committed
tests: benchmarks: power_consumption: spi: improve stability
Thread suspend can happen only when transaction is not happening. Similar like for flash and i2s testing. Signed-off-by: Piotr Kosycarz <[email protected]>
1 parent 2791fbf commit 2a60277

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/benchmarks/power_consumption/spi/src/driver_test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
#define SPIOP SPI_WORD_SET(8) | SPI_TRANSFER_MSB
1111

12+
static bool suspend_req;
13+
14+
bool self_suspend_req(void)
15+
{
16+
suspend_req = true;
17+
return true;
18+
}
19+
1220
void thread_definition(void)
1321
{
1422
int ret;
@@ -22,6 +30,11 @@ void thread_definition(void)
2230
struct spi_buf_set rx_spi_buf_set = {.buffers = &rx_spi_bufs, .count = 1};
2331

2432
while (1) {
33+
if (suspend_req) {
34+
suspend_req = false;
35+
k_thread_suspend(k_current_get());
36+
}
37+
2538
ret = spi_transceive_dt(&spispec, &tx_spi_buf_set, &rx_spi_buf_set);
2639
if (ret < 0) {
2740
printk("Error during SPI transfer");

0 commit comments

Comments
 (0)