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)
103
103
ret = spi_transceive (spi_conf , tx_bufs , rx_bufs );
104
104
if (ret ) {
105
105
SYS_LOG_ERR ("Code %d" , ret );
106
- return -1 ;
106
+ return ret ;
107
107
}
108
108
109
109
if (memcmp (buffer_tx , buffer_rx , BUF_SIZE )) {
@@ -286,6 +286,27 @@ static int spi_async_call(struct spi_config *spi_conf)
286
286
return 0 ;
287
287
}
288
288
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
+
289
310
void main (void )
290
311
{
291
312
struct k_thread async_thread ;
@@ -327,6 +348,10 @@ void main(void)
327
348
goto end ;
328
349
}
329
350
351
+ if (spi_ressource_lock_test (& spi_slow , & spi_fast )) {
352
+ goto end ;
353
+ }
354
+
330
355
SYS_LOG_INF ("All tx/rx passed" );
331
356
end :
332
357
k_thread_cancel (async_thread_id );
You can’t perform that action at this time.
0 commit comments