Best way to implement UART polling packet receiver.
Hi, I'm doing a firmware for a micro STM32F4.
The micro is always in an infinite loop in the main(), at the end of each cycle it should check if there are any data on UART buffer, in case there are read all data and continue with the normal infinite loop.
Something like that:
while (1) {
do things;
do things;
.....
if (is there data on the UART buffer?)
read data;
}
}I have read on forum and docuimentation that there are many ways to do it (USART_GetFlagStatus, USART_FLAG_RXNE, HAL_UART_Receive) but since it is the first time that I do such a thing, can someone give me some example code or some indication?
Thanks in advance
PS: the package to receive is of variable length, but I can know when it is finished analyzing the received data.