简体   繁体   English

ESP32 UART 中断每个字符

[英]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?有没有办法在收到单个字符后立即在 ESP32 上生成 uart 中断?

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.假设您正在使用 ESP IDF,您可以很容易地将UART 中断配置为从单字节的RX 阈值触发。 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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