samples/spi: Add a quick test for spi_release() API function
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
c2913ad025
commit
0938ccbbc1
1 changed files with 26 additions and 1 deletions
|
@ -103,7 +103,7 @@ static int spi_complete_loop(struct spi_config *spi_conf)
|
||||||
ret = spi_transceive(spi_conf, tx_bufs, rx_bufs);
|
ret = spi_transceive(spi_conf, tx_bufs, rx_bufs);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
SYS_LOG_ERR("Code %d", ret);
|
SYS_LOG_ERR("Code %d", ret);
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(buffer_tx, buffer_rx, BUF_SIZE)) {
|
if (memcmp(buffer_tx, buffer_rx, BUF_SIZE)) {
|
||||||
|
@ -286,6 +286,27 @@ static int spi_async_call(struct spi_config *spi_conf)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int spi_ressource_lock_test(struct spi_config *spi_conf_lock,
|
||||||
|
struct spi_config *spi_conf_try)
|
||||||
|
{
|
||||||
|
spi_conf_lock->operation |= SPI_LOCK_ON;
|
||||||
|
|
||||||
|
if (spi_complete_loop(spi_conf_lock)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spi_release(spi_conf_lock)) {
|
||||||
|
SYS_LOG_ERR("Deadlock now?");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spi_complete_loop(spi_conf_try)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
struct k_thread async_thread;
|
struct k_thread async_thread;
|
||||||
|
@ -327,6 +348,10 @@ void main(void)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spi_ressource_lock_test(&spi_slow, &spi_fast)) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
SYS_LOG_INF("All tx/rx passed");
|
SYS_LOG_INF("All tx/rx passed");
|
||||||
end:
|
end:
|
||||||
k_thread_cancel(async_thread_id);
|
k_thread_cancel(async_thread_id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue