Skip to content

Commit e4574fa

Browse files
committed
Clean UART on reset
1 parent 3ad13e1 commit e4574fa

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,12 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {
187187
ioctl(busio_uart_dev[self->number].fd, TCFLSH, (long unsigned int)NULL);
188188
return true;
189189
}
190+
191+
void busio_uart_reset(void) {
192+
for (int i = 0; i < MP_ARRAY_SIZE(busio_uart_dev); i++) {
193+
if (busio_uart_dev[i].fd >= 0) {
194+
close(busio_uart_dev[i].fd);
195+
busio_uart_dev[i].fd = -1;
196+
}
197+
}
198+
}

ports/cxd56/common-hal/busio/UART.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ typedef struct {
4040
uint32_t timeout;
4141
} busio_uart_obj_t;
4242

43+
void busio_uart_reset(void);
44+
4345
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_UART_H

ports/cxd56/supervisor/port.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "common-hal/analogio/AnalogIn.h"
3636
#include "common-hal/pulseio/PulseOut.h"
3737
#include "common-hal/pulseio/PWMOut.h"
38+
#include "common-hal/busio/UART.h"
3839

3940
safe_mode_t port_init(void) {
4041
boardctl(BOARDIOC_INIT, 0);
@@ -60,6 +61,9 @@ void reset_port(void) {
6061
pulseout_reset();
6162
pwmout_reset();
6263
#endif
64+
#if CIRCUITPY_BUSIO
65+
busio_uart_reset();
66+
#endif
6367

6468
reset_all_pins();
6569
}

0 commit comments

Comments
 (0)