From 6e658868e05e6e59e81743d6a8575acbf581b372 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 28 Nov 2020 10:30:33 +0100 Subject: [PATCH] cpu/cc2538: enable UART IRQ only if cb is not NULL --- cpu/cc2538/periph/uart.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cpu/cc2538/periph/uart.c b/cpu/cc2538/periph/uart.c index c4e894b0dd..03260dbe76 100644 --- a/cpu/cc2538/periph/uart.c +++ b/cpu/cc2538/periph/uart.c @@ -145,15 +145,13 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) /* Configure line control for 8-bit, no parity, 1 stop bit and enable */ u->cc2538_uart_lcrh.LCRH = (WLEN_8_BITS << 5) | FEN; - /* register callbacks */ + /* register callbacks and enable UART irq */ if (rx_cb) { uart_ctx[uart].rx_cb = rx_cb; uart_ctx[uart].arg = arg; + NVIC_EnableIRQ(UART_IRQ(uart_num)); } - /* enable UART interrupt */ - NVIC_EnableIRQ(UART_IRQ(uart_num)); - /* UART Enable */ u->cc2538_uart_ctl.CTLbits.UARTEN = 1;