File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
ports/raspberrypi/common-hal/busio Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -118,16 +118,16 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
118
118
119
119
uint8_t uart_id = ((((tx != NULL ) ? tx -> number : rx -> number ) + 4 ) / 8 ) % NUM_UARTS ;
120
120
121
+ if (uart_status [uart_id ] != STATUS_FREE ) {
122
+ mp_raise_RuntimeError (translate ("All UART peripherals are in use" ));
123
+ }
124
+ // These may raise exceptions if pins are already in use.
121
125
self -> tx_pin = pin_init (uart_id , tx , 0 );
122
126
self -> rx_pin = pin_init (uart_id , rx , 1 );
123
127
self -> cts_pin = pin_init (uart_id , cts , 2 );
124
128
self -> rts_pin = pin_init (uart_id , rts , 3 );
129
+ uart_status [uart_id ] = STATUS_BUSY ;
125
130
126
- if (uart_status [uart_id ] != STATUS_FREE ) {
127
- mp_raise_RuntimeError (translate ("All UART peripherals are in use" ));
128
- } else {
129
- uart_status [uart_id ] = STATUS_BUSY ;
130
- }
131
131
132
132
self -> uart = UART_INST (uart_id );
133
133
self -> uart_id = uart_id ;
You can’t perform that action at this time.
0 commit comments