I am trying to run UART1 interrupt on ESP32 WROVER but in process of compilation I get:
../main/scan.c: In function 'uart_intr_handle': ../main/scan.c:195:12: error: 'UART1' undeclared (first use in this function) status = UART1.int_st.val; // read UART interrupt Status
^~~~~ ../main/scan.c:195:12: note: each undeclared identifier is reported only once for each function it appears in ../main/scan.c:205:37: error: 'UART_RXFIFO_FULL_INT_CLR' undeclared (first use in this function); did you mean 'UART_FIFO_LEN'? uart_clear_intr_status(UART_NUM_1, UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
^~~~~~~~~~~~~~~~~~~~~~~~
UART_FIFO_LEN ../main/scan.c:205:62: error: 'UART_RXFIFO_TOUT_INT_CLR' undeclared (first use in this function); did you mean 'SPI_IN_DONE_INT_CLR'? uart_clear_intr_status(UART_NUM_1, UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
^~~~~~~~~~~~~~~~~~~~~~~~
SPI_IN_DONE_INT_CLR
Code that is generating this is:
/*
* Define UART interrupt subroutine to ackowledge interrupt
*/
static void IRAM_ATTR uart_intr_handle(void *arg)
{
uint16_t rx_fifo_len, status;
uint16_t i;
BaseType_t xHigherPriorityTaskWoken;
status = UART1.int_st.val; // read UART interrupt Status
rx_fifo_len = UART1.status.rxfifo_cnt; // read number of bytes in UART buffer
while(rx_fifo_len){
rxbuf[i++] = UART1.fifo.rw_byte; // read all bytes
rx_fifo_len--;
}
// after reading bytes from buffer clear UART interrupt status
uart_clear_intr_status(UART_NUM_1, UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
// a test code or debug code to indicate UART receives successfully,
// you can redirect received byte as echo also
//uart_write_bytes(EX_UART_NUM, (const char*) "RX Done", 7);
}
Example comes from: https://github.com/theElementZero/ESP32-UART-interrupt-handling/blob/master/uart_interrupt.c
What should I do to get UART1 variable?
Tnx for helping out!