Skip to content

Commit 21224c8

Browse files
author
Andrei-Edward Popa
committed
drivers: serial: rpi_pico: replaced high level API functions
replaced high level API functions with register access Signed-off-by: Andrei-Edward Popa <[email protected]>
1 parent b74c946 commit 21224c8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

drivers/serial/uart_rpi_pico.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,26 @@ struct uart_rpi_data {
3333
static int uart_rpi_poll_in(const struct device *dev, unsigned char *c)
3434
{
3535
const struct uart_rpi_config *config = dev->config;
36+
uart_hw_t * const uart_hw = config->uart_regs;
3637

37-
if (!uart_is_readable(config->uart_dev)) {
38+
if (uart_hw->fr & UART_UARTFR_RXFE_BITS) {
3839
return -1;
3940
}
4041

41-
*c = (unsigned char)uart_get_hw(config->uart_dev)->dr;
42+
*c = (unsigned char)uart_hw->dr;
4243
return 0;
4344
}
4445

4546
static void uart_rpi_poll_out(const struct device *dev, unsigned char c)
4647
{
4748
const struct uart_rpi_config *config = dev->config;
49+
uart_hw_t * const uart_hw = config->uart_regs;
50+
51+
while (uart_hw->fr & UART_UARTFR_TXFF_BITS) {
52+
/* Wait */
53+
}
4854

49-
uart_putc_raw(config->uart_dev, c);
55+
uart_hw->dr = c;
5056
}
5157

5258
static int uart_rpi_init(const struct device *dev)
@@ -62,6 +68,10 @@ static int uart_rpi_init(const struct device *dev)
6268
return ret;
6369
}
6470

71+
/*
72+
* uart_init() may be replaced by register based API once rpi-pico platform
73+
* has a clock controller driver and a reset controller driver
74+
*/
6575
baudrate = uart_init(uart_inst, data->baudrate);
6676
/* Check if baudrate adjustment returned by 'uart_init' function is a positive value */
6777
if (baudrate <= 0) {

0 commit comments

Comments
 (0)