cpu/cc2538: enable UART IRQ only if cb is not NULL

This commit is contained in:
Alexandre Abadie 2020-11-28 10:30:33 +01:00
parent 7237e38436
commit 6e658868e0
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405

View File

@ -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;