[riot-notifications] [RIOT-OS/RIOT] cpu/rpx0xx: port RIOT to the Raspberry Pi RP2040 MCU (#16609)

fabian18 notifications at github.com
Thu Jul 8 11:37:14 CEST 2021


@fabian18 commented on this pull request.



> +    uint32_t baud_ibrd = baud_rate_div >> 7;
+    uint32_t baud_fbrd;
+
+    if (baud_ibrd == 0) {
+        baud_ibrd = 1;
+        baud_fbrd = 0;
+    }
+    else if (baud_ibrd >= 65535) {
+        baud_ibrd = 65535;
+        baud_fbrd = 0;
+    }
+    else {
+        baud_fbrd = ((baud_rate_div & 0x7f) + 1) / 2;
+    }
+
+    io_reg_atomic_set(&(dev->UARTIBRD.reg), baud_ibrd & UART0_UARTIBRD_BAUD_DIVINT_Msk);

```suggestion
dev->UARTIBRD.reg = baud_ibrd;
```

> +    uint32_t baud_fbrd;
+
+    if (baud_ibrd == 0) {
+        baud_ibrd = 1;
+        baud_fbrd = 0;
+    }
+    else if (baud_ibrd >= 65535) {
+        baud_ibrd = 65535;
+        baud_fbrd = 0;
+    }
+    else {
+        baud_fbrd = ((baud_rate_div & 0x7f) + 1) / 2;
+    }
+
+    io_reg_atomic_set(&(dev->UARTIBRD.reg), baud_ibrd & UART0_UARTIBRD_BAUD_DIVINT_Msk);
+    io_reg_atomic_set(&(dev->UARTFBRD.reg), baud_fbrd & UART0_UARTFBRD_BAUD_DIVFRAC_Msk);

```suggestion
dev->UARTFBRD.reg = baud_fbrd;
```

> +    }
+    io_reg_atomic_set(&dev->UARTCR.reg, enable_mask);
+    uart_init_pins(uart);
+
+    _irq_enable(uart);
+
+    return UART_OK;
+}
+
+void uart_write(uart_t uart, const uint8_t *data, size_t len)
+{
+    UART0_Type *dev = uart_config[uart].dev;
+
+    for (size_t i = 0; i < len; i++) {
+        dev->UARTDR.reg = data[i];
+        mutex_lock(&tx_locks[uart]);

The mutex lock leads to a deadlock for me if I try to `printf()` within an interrupt routine.
For example we could instead block if the UART Tx FIFO is full:
```C
while (dev->UARTFR.bit.TXFF) {}
```

-- 
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/16609#pullrequestreview-701836896
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210708/8ea6a990/attachment.htm>


More information about the notifications mailing list