@@ -80,7 +80,10 @@ struct uartIsrContext_t
80
80
81
81
// NOTE: GCC will generated an invalid warning for the following line
82
82
// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
83
+ #pragma GCC diagnostic push
84
+ #pragma GCC diagnostic ignored "-Wmissing-braces"
83
85
static volatile struct uartIsrContext_t s_uartInterruptContext [2 ] = { 0 };
86
+ #pragma GCC diagnostic pop
84
87
85
88
/*
86
89
In the context of the naming conventions in this file, "_unsafe" means two things:
@@ -343,11 +346,13 @@ uart_isrDefault(void * arg)
343
346
}
344
347
345
348
void
346
- uart_subscribeInterrupt (int uart_nr , uartInterruptHandler callback , void * param )
349
+ uart_subscribeInterrupt_unsafe (int uart_nr , uartInterruptHandler callback , void * param )
347
350
{
348
351
s_uartInterruptContext [uart_nr ].callback = callback ;
349
352
s_uartInterruptContext [uart_nr ].arg = param ;
350
353
354
+ // check if we are already attached to the interrupt for
355
+ // the other uart and only attach if not
351
356
int other_nr = (uart_nr + 1 ) % 2 ;
352
357
if (s_uartInterruptContext [other_nr ].callback == NULL )
353
358
{
@@ -356,7 +361,7 @@ uart_subscribeInterrupt(int uart_nr, uartInterruptHandler callback, void* param)
356
361
}
357
362
358
363
bool
359
- uart_unsubscribeInterrupt (int uart_nr , uartInterruptHandler callback )
364
+ uart_unsubscribeInterrupt_unsafe (int uart_nr , uartInterruptHandler callback )
360
365
{
361
366
if (s_uartInterruptContext [uart_nr ].callback == callback )
362
367
{
@@ -368,6 +373,8 @@ uart_unsubscribeInterrupt(int uart_nr, uartInterruptHandler callback)
368
373
s_uartInterruptContext [uart_nr ].callback = NULL ;
369
374
s_uartInterruptContext [uart_nr ].arg = NULL ;
370
375
376
+ // check if we are also attached to the interrupt for
377
+ // the other uart and only deattach if not
371
378
int other_nr = (uart_nr + 1 ) % 2 ;
372
379
if (s_uartInterruptContext [other_nr ].callback == NULL )
373
380
{
@@ -410,7 +417,7 @@ uart_start_isr(uart_t* uart)
410
417
// UIPE: parity error
411
418
// UITO: rx fifo timeout
412
419
USIE (uart -> uart_nr ) = (1 << UIFF ) | (1 << UIOF ) | (1 << UIFR ) | (1 << UIPE ) | (1 << UITO );
413
- uart_subscribeInterrupt (uart -> uart_nr , uart_isrDefault , (void * )uart );
420
+ uart_subscribeInterrupt_unsafe (uart -> uart_nr , uart_isrDefault , (void * )uart );
414
421
415
422
}
416
423
@@ -651,7 +658,7 @@ uart_uninit(uart_t* uart)
651
658
if (uart -> rx_enabled )
652
659
{
653
660
ETS_UART_INTR_DISABLE ();
654
- if (uart_unsubscribeInterrupt (uart -> uart_nr , uart_isrDefault ))
661
+ if (uart_unsubscribeInterrupt_unsafe (uart -> uart_nr , uart_isrDefault ))
655
662
{
656
663
ETS_UART_INTR_ENABLE ();
657
664
}
0 commit comments