8000 Apply review feeedback · esp8266/Arduino@ae7903d · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ae7903d

Browse files
committed
Apply review feeedback
1 parent 5bc2ea5 commit ae7903d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

cores/esp8266/uart.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ struct uartIsrContext_t
8080

8181
// NOTE: GCC will generated an invalid warning for the following line
8282
// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
83+
#pragma GCC diagnostic push
84+
#pragma GCC diagnostic ignored "-Wmissing-braces"
8385
static volatile struct uartIsrContext_t s_uartInterruptContext[2] = { 0 };
86+
#pragma GCC diagnostic pop
8487

8588
/*
8689
In the context of the naming conventions in this file, "_unsafe" means two things:
@@ -343,11 +346,13 @@ uart_isrDefault(void * arg)
343346
}
344347

345348
void
346-
uart_subscribeInterrupt(int uart_nr, uartInterruptHandler callback, void* param)
349+
uart_subscribeInterrupt_unsafe(int uart_nr, uartInterruptHandler callback, void* param)
347350
{
348351
s_uartInterruptContext[uart_nr].callback = callback;
349352
s_uartInterruptContext[uart_nr].arg = param;
350353

354+
// check if we are already attached to the interrupt for
355+
// the other uart and only attach if not
351356
int other_nr = (uart_nr + 1) % 2;
352357
if (s_uartInterruptContext[other_nr].callback == NULL)
353358
{
@@ -356,7 +361,7 @@ uart_subscribeInterrupt(int uart_nr, uartInterruptHandler callback, void* param)
356361
}
357362

358363
bool
359-
uart_unsubscribeInterrupt(int uart_nr, uartInterruptHandler callback)
364+
uart_unsubscribeInterrupt_unsafe(int uart_nr, uartInterruptHandler callback)
360365
{
361366
if (s_uartInterruptContext[uart_nr].callback == callback)
362367
{
@@ -368,6 +373,8 @@ uart_unsubscribeInterrupt(int uart_nr, uartInterruptHandler callback)
368373
s_uartInterruptContext[uart_nr].callback = NULL;
369374
s_uartInterruptContext[uart_nr].arg = NULL;
370375

376+
// check if we are also attached to the interrupt for
377+
// the other uart and only deattach if not
371378
int other_nr = (uart_nr + 1) % 2;
372379
if (s_uartInterruptContext[other_nr].callback == NULL)
373380
{
@@ -410,7 +417,7 @@ uart_start_isr(uart_t* uart)
410417
// UIPE: parity error
411418
// UITO: rx fifo timeout
412419
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);
414421

415422
}
416423

@@ -651,7 +658,7 @@ uart_uninit(uart_t* uart)
651658
if (uart->rx_enabled)
652659
{
653660
ETS_UART_INTR_DISABLE();
654-
if (uart_unsubscribeInterrupt(uart->uart_nr, uart_isrDefault))
661+
if (uart_unsubscribeInterrupt_unsafe(uart->uart_nr, uart_isrDefault))
655662
{
656663
ETS_UART_INTR_ENABLE();
657664
}

cores/esp8266/uart.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ extern "C" {
152152
// uart_subscribeInterrupt & uart_unsubscribeInterrupt are not safe and must
153153
// be called within ETS_UART_INTR_DISABLE()/ETS_UART_INTR_ENABLE() protection
154154
//
155-
void uart_subscribeInterrupt(int uart_nr, uartInterruptHandler callback, void* param);
155+
void uart_subscribeInterrupt_unsafe(int uart_nr, uartInterruptHandler callback, void* param);
156156
// if uart_unsubscribeInterrupt returns false, then ETS_UART_INTR_ENABLE() doesn't
157157
// need to be called after it
158-
bool uart_unsubscribeInterrupt(int uart_nr, uartInterruptHandler callback);
158+
bool uart_unsubscribeInterrupt_unsafe(int uart_nr, uartInterruptHandler callback);
159159

160160
#if defined (__cplusplus)
161161
} // extern "C"

0 commit comments

Comments
 (0)
0