esp32/uart: Use high-level function to install UART0 RX ISR handler.
Using xt_set_interrupt_handler is too low-level for the ESP IDF, since it
may have multiple handlers registered at the same IRQ level (eg both BT and
UART are on number 5).
#include <stdio.h>
-#include "esp_intr.h"
-#include "soc/uart_struct.h"
+#include "driver/uart.h"
#include "py/mpstate.h"
#include "py/mphal.h"
STATIC void uart_irq_handler(void *arg);
void uart_init(void) {
- xt_set_interrupt_handler(ETS_UART0_INUM, uart_irq_handler, NULL);
- ESP_INTR_ENABLE(ETS_UART0_INUM);
+ uart_isr_handle_t handle;
+ uart_isr_register(UART_NUM_0, uart_irq_handler, NULL, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM, &handle);
+ uart_enable_rx_intr(UART_NUM_0);
}
// all code executed in ISR must be in IRAM, and any const data must be in DRAM
