Merge pull request #5388 from microDev1/serial-over-uart
Fix espressif serial over uart
This commit is contained in:
commit
bd997dd67e
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue