diff options
| author | Kamil Tomaszewski <kamil.tomaszewski@sony.com> | 2019-10-21 13:17:51 +0200 |
|---|---|---|
| committer | Kamil Tomaszewski <kamil.tomaszewski@sony.com> | 2019-10-21 13:17:51 +0200 |
| commit | e4574fa3bfb1a80218292b5f3b76778bf76cae84 (patch) | |
| tree | 442802ce5d2320787d21dd2581998080a2d95df8 | |
| parent | 3ad13e14d8c4e4b8376c697d1e02c768954e32ca (diff) | |
Clean UART on reset
| -rw-r--r-- | ports/cxd56/common-hal/busio/UART.c | 9 | ||||
| -rw-r--r-- | ports/cxd56/common-hal/busio/UART.h | 2 | ||||
| -rw-r--r-- | ports/cxd56/supervisor/port.c | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c index 6c59c8f28..4a1376f19 100644 --- a/ports/cxd56/common-hal/busio/UART.c +++ b/ports/cxd56/common-hal/busio/UART.c @@ -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; + } + } +} diff --git a/ports/cxd56/common-hal/busio/UART.h b/ports/cxd56/common-hal/busio/UART.h index c1f6fff53..e1d816149 100644 --- a/ports/cxd56/common-hal/busio/UART.h +++ b/ports/cxd56/common-hal/busio/UART.h @@ -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 diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c index 3fddfe52c..c7ed4b232 100644 --- a/ports/cxd56/supervisor/port.c +++ b/ports/cxd56/supervisor/port.c @@ -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(); } |
