fix espressif serial over uart

This commit is contained in:
microDev 2021-09-25 00:00:00 +05:30
parent 10fdc80b9c
commit 1be6c41da4
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
3 changed files with 15 additions and 1 deletions

View File

@ -38,6 +38,8 @@
#include "supervisor/shared/translate.h"
#include "supervisor/shared/tick.h"
uint8_t never_reset_uart_mask = 0;
void uart_reset(void) {
for (uart_port_t num = 0; num < UART_NUM_MAX; num++) {
// Ignore the UART used by the IDF.
@ -46,12 +48,20 @@ void uart_reset(void) {
continue;
}
#endif
if (uart_is_driver_installed(num)) {
if (uart_is_driver_installed(num) && !(never_reset_uart_mask & 1 << num)) {
uart_driver_delete(num);
}
}
}
void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) {
common_hal_never_reset_pin(self->rx_pin);
common_hal_never_reset_pin(self->tx_pin);
common_hal_never_reset_pin(self->rts_pin);
common_hal_never_reset_pin(self->cts_pin);
never_reset_uart_mask |= 1 << self->uart_num;
}
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t *tx, const mcu_pin_obj_t *rx,
const mcu_pin_obj_t *rts, const mcu_pin_obj_t *cts,

View File

@ -58,6 +58,9 @@ void never_reset_pin_number(gpio_num_t pin_number) {
}
void common_hal_never_reset_pin(const mcu_pin_obj_t *pin) {
if (pin == NULL) {
return;
}
never_reset_pin_number(pin->number);
}

View File

@ -36,6 +36,7 @@ void reset_all_pins(void);
// need to store a full pointer.
void reset_pin_number(gpio_num_t pin_number);
void common_hal_reset_pin(const mcu_pin_obj_t *pin);
void common_hal_never_reset_pin(const mcu_pin_obj_t *pin);
void claim_pin(const mcu_pin_obj_t *pin);
void claim_pin_number(gpio_num_t pin_number);
bool pin_number_is_free(gpio_num_t pin_number);