File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ static int spi_complete_loop(struct spi_config *spi_conf)
103103 ret = spi_transceive (spi_conf , tx_bufs , rx_bufs );
104104 if (ret ) {
105105 SYS_LOG_ERR ("Code %d" , ret );
106- return -1 ;
106+ return ret ;
107107 }
108108
109109 if (memcmp (buffer_tx , buffer_rx , BUF_SIZE )) {
@@ -286,6 +286,27 @@ static int spi_async_call(struct spi_config *spi_conf)
286286 return 0 ;
287287}
288288
289+ static int spi_ressource_lock_test (struct spi_config * spi_conf_lock ,
290+ struct spi_config * spi_conf_try )
291+ {
292+ spi_conf_lock -> operation |= SPI_LOCK_ON ;
293+
294+ if (spi_complete_loop (spi_conf_lock )) {
295+ return -1 ;
296+ }
297+
298+ if (spi_release (spi_conf_lock )) {
299+ SYS_LOG_ERR ("Deadlock now?" );
300+ return -1 ;
301+ }
302+
303+ if (spi_complete_loop (spi_conf_try )) {
304+ return -1 ;
305+ }
306+
307+ return 0 ;
308+ }
309+
289310void main (void )
290311{
291312 struct k_thread async_thread ;
@@ -327,6 +348,10 @@ void main(void)
327348 goto end ;
328349 }
329350
351+ if (spi_ressource_lock_test (& spi_slow , & spi_fast )) {
352+ goto end ;
353+ }
354+
330355 SYS_LOG_INF ("All tx/rx passed" );
331356end :
332357 k_thread_cancel (async_thread_id );
You can’t perform that action at this time.
0 commit comments