summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2022-11-24 11:51:09 +0100
committerDamien George <damien@micropython.org>2022-12-14 12:45:51 +1100
commitf78dd25a2cb729cc5b59f5df8cda1b57535c4244 (patch)
tree3ef32a71945be24c9930b6e427e5a37c745a6f3f
parent5b1fd8802a14bb59ca1ecc30df317e5994b2a327 (diff)
samd/machine_uart: Check the UART TX pin assignment.
Check, if TX is at Pad 0 (SAMD51), or Pad 0 or 2 (SAMD21).
-rw-r--r--ports/samd/machine_uart.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ports/samd/machine_uart.c b/ports/samd/machine_uart.c
index c8f25d985..28261c2fc 100644
--- a/ports/samd/machine_uart.c
+++ b/ports/samd/machine_uart.c
@@ -263,8 +263,11 @@ STATIC mp_obj_t machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args
#if defined(MCU_SAMD21)
if (self->tx_pad_config.pad_nr == 2) { // Map pad 2 to TXPO = 1
txpo = 1;
- }
+ } else
#endif
+ if (self->tx_pad_config.pad_nr != 0) {
+ mp_raise_ValueError(MP_ERROR_TEXT("invalid tx pin"));
+ }
uart->USART.CTRLA.reg =
SERCOM_USART_CTRLA_DORD // Data order