[riot-notifications] [RIOT-OS/RIOT] cpu/efm32/uart: fix handling of RX when no RX callback is configured (#12278)

Bas Stottelaar notifications at github.com
Sat Sep 21 17:25:51 CEST 2019


basilfx requested changes on this pull request.



> @@ -131,15 +129,16 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
 
         /* enable receive interrupt */
         LEUART_IntEnable(leuart, LEUART_IEN_RXDATAV);

I guess this also needs to be wrapped inside an if-statement

>      }
 #endif
 
     /* enable the interrupt */
-    NVIC_ClearPendingIRQ(uart_config[dev].irq);
-    NVIC_EnableIRQ(uart_config[dev].irq);
+    if (isr_ctx[dev].rx_cb) {

Use `rx_cb` instead.

> @@ -164,10 +163,62 @@ void uart_write(uart_t dev, const uint8_t *data, size_t len)
 void uart_poweron(uart_t dev)
 {
     CMU_ClockEnable(uart_config[dev].cmu, true);
+
+    if (_is_usart(dev)) {
+        USART_TypeDef *usart = uart_config[dev].dev;
+
+        /* enable tx */
+        usart->CMD = USART_CMD_TXEN;

Please use `USART_Enable` (and `LEUART_Enable`). There is [more happening](http://devtools.silabs.com/dl/documentation/doxygen/5.7/efr32mg12/html/em__usart_8c_source.html#l00663) in these methods to have compatibility with other EFM32 families.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/12278#pullrequestreview-291469193
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190921/43a221dd/attachment.htm>


More information about the notifications mailing list