Skip to content

Commit 957cea2

Browse files
sfe-SparkFrodpgeorge
authored andcommitted
rp2/machine_uart: Allow new TX/RX pins on RP2350.
Signed-off-by: Damien George <[email protected]>
1 parent 7a78e5a commit 957cea2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ports/rp2/machine_uart.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@
6969
#define MAX_BUFFER_SIZE (32766)
7070

7171
#define IS_VALID_PERIPH(uart, pin) (((((pin) + 4) & 8) >> 3) == (uart))
72+
#if PICO_RP2350
73+
#define IS_VALID_TX(uart, pin) (((pin) & 1) == 0 && IS_VALID_PERIPH(uart, pin))
74+
#define IS_VALID_RX(uart, pin) (((pin) & 1) == 1 && IS_VALID_PERIPH(uart, pin))
75+
#else
7276
#define IS_VALID_TX(uart, pin) (((pin) & 3) == 0 && IS_VALID_PERIPH(uart, pin))
7377
#define IS_VALID_RX(uart, pin) (((pin) & 3) == 1 && IS_VALID_PERIPH(uart, pin))
78+
#endif
7479
#define IS_VALID_CTS(uart, pin) (((pin) & 3) == 2 && IS_VALID_PERIPH(uart, pin))
7580
#define IS_VALID_RTS(uart, pin) (((pin) & 3) == 3 && IS_VALID_PERIPH(uart, pin))
7681

@@ -398,8 +403,8 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args,
398403
__dsb(); // make sure UARTLCR_H register is written to
399404
uart_set_fifo_enabled(self->uart, true);
400405
__dsb(); // make sure UARTLCR_H register is written to
401-
gpio_set_function(self->tx, GPIO_FUNC_UART);
402-
gpio_set_function(self->rx, GPIO_FUNC_UART);
406+
gpio_set_function(self->tx, UART_FUNCSEL_NUM(self->uart, self->tx));
407+
gpio_set_function(self->rx, UART_FUNCSEL_NUM(self->uart, self->rx));
403408
if (self->invert & UART_INVERT_RX) {
404409
gpio_set_inover(self->rx, GPIO_OVERRIDE_INVERT);
405410
}

0 commit comments

Comments
 (0)