I am trying to program a kind of cli with uart receive interrupts for an embedded system. I want my code to stay in uart function till i press the enter as '\r' then go on till it gets to the next uart function and wait for enter again. like some kind of scanf.
int main(void)
{
while (1)
{
uart_interrupt_receive();
//something else
uart_interrupt_receive();
//something else
}
I dont want to use scanf or getchar if possible. I got here so far. I cant decide which flags to use to make it work the way i want or how else i can change it?
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)(){
if (USART2->ISR & USART_ISR_RXNE) //is rx flag active
{
char rx = (char)(USART2->RDR & 0xFF); //received char rx
if ((rx == '\r') || (rx == '\n')) //if rx enter
{
//go on
}//if
else
{
//wait
}//else
}//if
}//uart_rxcplt_callback