Using UART0 on ESP32-S2
Posted: Sun Jun 26, 2022 5:46 am
Hi have a device that has 4 UART peripherals, sometimes I need to use 2 peripherals at the same time. At the moment I can only use UART1 and keep switching it between the devices. It does work but it's hard to debug and prone to errors.
I'm not that strong on C but it seems like the code below prevents changing the pins for UART0.
Does anyone know the background to this, is there an underlying reason why UART0 can't be used on the esp32 family?
Thanks
machine_uart.c
I'm not that strong on C but it seems like the code below prevents changing the pins for UART0.
Does anyone know the background to this, is there an underlying reason why UART0 can't be used on the esp32 family?
Thanks
machine_uart.c
Code: Select all
STATIC mp_obj_t machine_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
switch (uart_num) {
case UART_NUM_0:
self->rx = UART_PIN_NO_CHANGE; // GPIO 3
self->tx = UART_PIN_NO_CHANGE; // GPIO 1
break;
case UART_NUM_1:
self->rx = 9;
self->tx = 10;
break;
#if SOC_UART_NUM > 2
case UART_NUM_2:
self->rx = 16;
self->tx = 17;
break;
#endif
}
// Only reset the driver if it's not the REPL UART.
if (uart_num != MICROPY_HW_UART_REPL) {
// Remove any existing configuration
uart_driver_delete(self->uart_num);
// init the peripheral
// Setup
uart_param_config(self->uart_num, &uartcfg);
uart_driver_install(uart_num, self->rxbuf, self->txbuf, 0, NULL, 0);
}