Update UART.c

Incorporating feedback: https://github.com/adafruit/circuitpython/pull/4772#discussion_r634112839
This commit is contained in:
EmergReanimator 2021-05-19 20:19:16 +02:00 committed by GitHub
parent 2b64b1d335
commit 7805392b9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -255,21 +255,18 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
}
void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) {
#if (1)
never_reset_sercom(self->usart_desc.device.hw);
never_reset_pin_number(self->rx_pin);
never_reset_pin_number(self->tx_pin);
return;
#else
for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) {
if (mcu_uart_banks[i] == self->handle.Instance) {
never_reset_uart[i] = true;
never_reset_pin_number(self->tx->pin->port, self->tx->pin->number);
never_reset_pin_number(self->rx->pin->port, self->rx->pin->number);
break;
for (size_t i = 0; i < MP_ARRAY_SIZE(sercom_insts); i++) {
const Sercom *sercom = sercom_insts[i];
Sercom *hw = (Sercom *)(self->usart_desc.device.hw);
// Reserve pins for active UART only
if (sercom == hw) {
never_reset_sercom(hw);
never_reset_pin_number(self->rx_pin);
never_reset_pin_number(self->tx_pin);
}
}
#endif
return;
}
bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {