You don't check the HAL status when you call HAL_UART_Receive_IT
If it returns HAL_BUSY, then you'll never get another interrupt.
Avoid doing any non crucial stuff from inside the interrupt. Just set a flag and exit the interrupt. Then in the main while loop you can check the flag and do what you need to do.
Below is an example for checking HAL status for Rx. I didn't write code for checking the HAL status for the HAL_UART_Transmit_IT as I have a ring buffer that does check it. If you need an example of that, I have a project on Github that you can look at.
#include "main.h"
extern UART_HandleTypeDef hlpuart1;
uint8_t aRxBuffer[10];
bool dataRdyFlag = false;
HAL_StatusTypeDef hal_status;
// call before main while loop
void PollingInit(void)
{
UART_EnableInt();
}
// called from inside main while loop
void PollingRoutine(void)
{
UART_CheckRdyFlag();
UART_CheckRxStatus();
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if(huart == &hlpuart1)
{
dataRdyFlag = true;
UART_EnableInt();
}
}
void UART_CheckRdyFlag(void)
{
if(dataRdyFlag)
{
dataRdyFlag = false;
HAL_UART_Transmit_IT(&hlpuart1, (uint8_t *)aRxBuffer, 10);
}
}
void UART_EnableInt(void)
{
hal_status = HAL_UART_Receive_IT(&hlpuart1, (uint8_t *)aRxBuffer, 10);
}
void UART_CheckRxStatus(void)
{
if(hal_status != HAL_OK)
{
UART_EnableInt();
}
}