Skip to content

Commit 46c0436

Browse files
authored
Merge pull request #5834 from adafruit/rpi-uart-claim-later
raspberrypi: Claim UART after checking pins
2 parents 6346b9b + 9b82586 commit 46c0436

File tree

1 file changed

+3
-3
lines changed
  • ports/raspberrypi/common-hal/busio

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
120120

121121
if (uart_status[uart_id] != STATUS_FREE) {
122122
mp_raise_RuntimeError(translate("All UART peripherals are in use"));
123-
} else {
124-
uart_status[uart_id] = STATUS_BUSY;
125123
}
126-
124+
// These may raise exceptions if pins are already in use.
127125
self->tx_pin = pin_init(uart_id, tx, 0);
128126
self->rx_pin = pin_init(uart_id, rx, 1);
129127
self->cts_pin = pin_init(uart_id, cts, 2);
130128
self->rts_pin = pin_init(uart_id, rts, 3);
129+
uart_status[uart_id] = STATUS_BUSY;
130+
131131

132132
self->uart = UART_INST(uart_id);
133133
self->uart_id = uart_id;

0 commit comments

Comments
 (0)