Clean UART on reset

This commit is contained in:
Kamil Tomaszewski 2019-10-21 13:17:51 +02:00
parent 3ad13e14d8
commit e4574fa3bf
3 changed files with 15 additions and 0 deletions

View File

@ -187,3 +187,12 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {
ioctl(busio_uart_dev[self->number].fd, TCFLSH, (long unsigned int)NULL);
return true;
}
void busio_uart_reset(void) {
for (int i = 0; i < MP_ARRAY_SIZE(busio_uart_dev); i++) {
if (busio_uart_dev[i].fd >= 0) {
close(busio_uart_dev[i].fd);
busio_uart_dev[i].fd = -1;
}
}
}

View File

@ -40,4 +40,6 @@ typedef struct {
uint32_t timeout;
} busio_uart_obj_t;
void busio_uart_reset(void);
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_UART_H

View File

@ -35,6 +35,7 @@
#include "common-hal/analogio/AnalogIn.h"
#include "common-hal/pulseio/PulseOut.h"
#include "common-hal/pulseio/PWMOut.h"
#include "common-hal/busio/UART.h"
safe_mode_t port_init(void) {
boardctl(BOARDIOC_INIT, 0);
@ -60,6 +61,9 @@ void reset_port(void) {
pulseout_reset();
pwmout_reset();
#endif
#if CIRCUITPY_BUSIO
busio_uart_reset();
#endif
reset_all_pins();
}