Skip to content

Commit 2684aeb

Browse files
committed
don't check for RX and TX both none in ports: now checked in shared-bindings
1 parent 6d51356 commit 2684aeb

File tree

5 files changed

+8
-16
lines changed

5 files changed

+8
-16
lines changed

locale/circuitpython.pot

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,10 +1987,6 @@ msgstr ""
19871987
msgid "Stopping AP is not supported."
19881988
msgstr ""
19891989

1990-
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
1991-
msgid "Supply at least one UART pin"
1992-
msgstr ""
1993-
19941990
#: shared-bindings/alarm/time/TimeAlarm.c
19951991
msgid "Supply one of monotonic_time or epoch_time"
19961992
msgstr ""
@@ -4116,8 +4112,6 @@ msgstr ""
41164112
msgid "twai_start returned esp-idf error #%d"
41174113
msgstr ""
41184114

4119-
#: ports/atmel-samd/common-hal/busio/UART.c
4120-
#: ports/espressif/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
41214115
#: shared-bindings/busio/UART.c shared-bindings/canio/CAN.c
41224116
msgid "tx and rx cannot both be None"
41234117
msgstr ""

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
112112

113113
uart_config_t uart_config = {0};
114114
bool have_rs485_dir = rs485_dir != NULL;
115-
if (!have_tx && !have_rx) {
116-
mp_raise_ValueError(translate("tx and rx cannot both be None"));
117-
}
115+
116+
// shared-bindings checks that TX and RX are not both None, so we don't need to check here.
118117

119118
// Filter for sane settings for RS485
120119
if (have_rs485_dir) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
179179
break;
180180
}
181181
} else {
182-
mp_raise_ValueError(translate("tx and rx cannot both be None"));
182+
// TX and RX are both None. But this is already handled in shared-bindings, so
183+
// we won't get here.
183184
}
184185

185186
if (rx && !rx_config) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
183183
mp_raise_ValueError(translate("All UART peripherals are in use"));
184184
}
185185

186-
if ((tx == NULL) && (rx == NULL)) {
187-
mp_raise_ValueError(translate("tx and rx cannot both be None"));
188-
}
186+
// shared-bindings checks that TX and RX are not both None, so we don't need to check here.
189187

190188
mp_arg_validate_int_min(receiver_buffer_size, 1, MP_QSTR_receiver_buffer_size);
191189

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
8585
bool sigint_enabled) {
8686

8787
// match pins to UART objects
88-
USART_TypeDef *USARTx;
88+
USART_TypeDef *USARTx = NULL;
8989

9090
uint8_t tx_len = MP_ARRAY_SIZE(mcu_uart_tx_list);
9191
uint8_t rx_len = MP_ARRAY_SIZE(mcu_uart_rx_list);
@@ -159,8 +159,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
159159
USARTx = assign_uart_or_throw(self, (self->tx != NULL),
160160
periph_index, uart_taken);
161161
} else {
162-
// both pins cannot be empty
163-
mp_raise_ValueError(translate("tx and rx cannot both be None"));
162+
// TX and RX are both None. But this is already handled in shared-bindings, so
163+
// we won't get here.
164164
}
165165

166166
// Other errors

0 commit comments

Comments
 (0)