From 64507207da5a5b0a32cf0f8d51d6ca324b7dec21 Mon Sep 17 00:00:00 2001 From: Carl Elkins Date: Mon, 8 Jul 2019 02:08:39 +0100 Subject: [PATCH] Added conditional compilation around selection of TX pad candidates Original code was correct for SAMD21 New code for SAMD51 only permits pad-0 for TX --- ports/atmel-samd/common-hal/busio/UART.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 10618d1cec..c32919365c 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -88,11 +88,19 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, continue; } potential_sercom = sercom_insts[sercom_index]; - if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 || +#ifdef SAMD21 + if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 || !(tx->sercom[i].pad == 0 || tx->sercom[i].pad == 2)) { continue; } +#endif +#ifdef SAMD51 + if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 || + !(tx->sercom[i].pad == 0)) { + continue; + } +#endif tx_pinmux = PINMUX(tx->number, (i == 0) ? MUX_C : MUX_D); tx_pad = tx->sercom[i].pad; if (rx == mp_const_none) {