QUERY · ISSUE
ESP32 Port - Using UART0
enhancementport-esp32
Any particular reason the UART0 is blocked for user code?
What are the implication of using it? What are the fun errors?
This can drive the hardware design choices.
Thank you
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);
// get uart id
mp_int_t uart_num = mp_obj_get_int(args[0]);
if (uart_num < 0 || uart_num >= UART_NUM_MAX) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART(%d) does not exist"), uart_num);
}
// Attempts to use UART0 from Python has resulted in all sorts of fun errors.
// FIXME: UART0 is disabled for now.
if (uart_num == UART_NUM_0) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART(%d) is disabled (dedicated to REPL)"), uart_num);
}
CANDIDATE · PULL REQUEST
esp32/uart: Allow limited configuration of (repl) uart0.
port-esp32
For many applications the hardcoded 115200 repl buadrate on esp32 is painfully slow. This function allows this to be adjusted dynamically.
UART0 is blocked from access via the existing machine.UART interface, presumable for good reason: https://github.com/micropython/micropython/blob/a3675294ae39a724aec6959238c45af0dea92f21/ports/esp32/machine_uart.c#L297
So this just provides a direct function via the esp32 module to set just the baudrate.
Hey @UnexpectedMaker this should tick that box you were talking about :-)