Skip to content

Commit 54536a3

Browse files
authored
Merge pull request adafruit#9500 from tannewt/2350_uart11
Support UART_AUX pin function
2 parents 2991c48 + a2e0e2e commit 54536a3

File tree

1 file changed

+20
-2
lines changed
  • ports/raspberrypi/common-hal/busio

1 file changed

+20
-2
lines changed

ports/raspberrypi/common-hal/busio/UART.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,17 @@ static void pin_check(const uint8_t uart, const mcu_pin_obj_t *pin, const uint8_
4646
if (pin == NULL) {
4747
return;
4848
}
49-
if (!(((pin->number % 4) == pin_type) && ((((pin->number + 4) / 8) % NUM_UARTS) == uart))) {
49+
uint8_t pins_uart = (pin->number + 4) / 8 % NUM_UARTS;
50+
if (pins_uart != uart) {
51+
raise_ValueError_invalid_pins();
52+
}
53+
#ifdef PICO_RP2350
54+
if ((pin_type == 0 && pin->number % 4 == 2) ||
55+
(pin_type == 1 && pin->number % 4 == 3)) {
56+
return;
57+
}
58+
#endif
59+
if ((pin->number % 4) != pin_type) {
5060
raise_ValueError_invalid_pins();
5161
}
5262
}
@@ -56,7 +66,15 @@ static uint8_t pin_init(const uint8_t uart, const mcu_pin_obj_t *pin, const uint
5666
return NO_PIN;
5767
}
5868
claim_pin(pin);
59-
gpio_set_function(pin->number, GPIO_FUNC_UART);
69+
gpio_function_t function = GPIO_FUNC_UART;
70+
#ifdef PICO_RP2350
71+
if ((pin_type == 0 && pin->number % 4 == 2) ||
72+
(pin_type == 1 && pin->number % 4 == 3)) {
73+
function = GPIO_FUNC_UART_AUX;
74+
}
75+
#endif
76+
77+
gpio_set_function(pin->number, function);
6078
return pin->number;
6179
}
6280

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy