简体   繁体   中英

ESP32 UART interrupt every character

Is there a way to generate an uart interrupt on an ESP32 as soon as a single character has been received?

I know you can generate an interrupt when the whole message has been received, or on a specific pattern, buffer overflows, errors, etc., but I am looking for a (simple) way to this on a per character basis.

Assuming you're working with ESP IDF, you can configure the UART interrupts to trigger from a RX threshold of a single byte quite easily. Omitting all error handling:

uart_intr_config_t uintr_cfg = {.rxfifo_full_thresh = 1};
uart_intr_config(UART_NUM_x, &uintr_cfg);
uart_enable_rx_intr(UART_NUM_x);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM