How to use ESP32 S2 UART RX interrupt?

wangxy
Posts: 7
Joined: Thu Jan 06, 2022 6:01 am

How to use ESP32 S2 UART RX interrupt?

Postby wangxy » Thu Jan 06, 2022 6:33 am

Hello everybody!
May i ask how to use the esp32s2 UART RX interrupt. IDF 4.2
Hope to get your help.

Code: Select all

static void IRAM_ATTR uart0_irq_handler(void *arg) 
{
	//how to write a program?
}
void IUsart::uart_config(void)
{
    uart_config_t uart0_cfg;
    uart0_cfg.baud_rate = 921600;
    uart0_cfg.data_bits = UART_DATA_8_BITS;
    uart0_cfg.parity = UART_PARITY_DISABLE;
    uart0_cfg.stop_bits = UART_STOP_BITS_1;
    uart0_cfg.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
    uart_param_config(UART_NUM_0, &uart0_cfg);
    uart_set_pin(UART_NUM_0, ECHO_TX0, ECHO_RX0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
    uart_driver_install(UART_NUM_0, RX0_BUF, TX0_BUF, 0, NULL, 0);//
    uart_isr_free(UART_NUM_0);//    
    uart_isr_register(UART_NUM_0, uart0_irq_handler, NULL, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM,NULL);//
    uart_enable_rx_intr(UART_NUM_0);//
}

Who is online

Users browsing this forum: No registered users and 171 guests