diff options
| author | Lucian Copeland <hierophect@gmail.com> | 2020-05-20 12:48:01 -0400 |
|---|---|---|
| committer | Lucian Copeland <hierophect@gmail.com> | 2020-05-20 12:48:01 -0400 |
| commit | 66c09efae287de5cf099dea09288809b922c191d (patch) | |
| tree | 88fdce1fd220f07e30c3a550fff4d17a12162635 /ports/stm | |
| parent | 916ca9f8a635d20c299326a955d4ca51dae055e1 (diff) | |
Add UART one-way instance search, fix bugs in stm32 implementation
Diffstat (limited to 'ports/stm')
| -rw-r--r-- | ports/stm/common-hal/busio/UART.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index c83479126..0dc10c4e4 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -259,7 +259,7 @@ void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { - return self->tx->pin == NULL; + return (self->tx->pin == NULL && self->rx->pin == NULL); } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { @@ -272,10 +272,15 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { } } - reset_pin_number(self->tx->pin->port,self->tx->pin->number); - reset_pin_number(self->rx->pin->port,self->rx->pin->number); - self->tx = NULL; - self->rx = NULL; + if (self->tx) { + reset_pin_number(self->tx->pin->port,self->tx->pin->number); + self->tx = NULL; + } + if (self->rx) { + reset_pin_number(self->rx->pin->port,self->rx->pin->number); + self->rx = NULL; + } + ringbuf_free(&self->ringbuf); } |
