I am updating an old project that was built on the "STM32 FWLib", so I am porting everything over to the new Stm32Cube HAL. The real motivation is to get the proper I2C driver in the HAL, but I am unsure how to handle one detail of the UART for use of either the interrupt or DMA drivers: what to choose for the size argument to HAL_UART_Receive_IT() for the case of receiving burst transmissions with large variations in length?
Presently, the code uses the UART interrupt to take incoming characters and immediately enqueue them into an RTOS queue, where they are consumed and run through the processing state machine at a non-interrupt priority in a dedicated thread.
In the application, the data coming over the UART line is mostly unstructured, and of variable length and frequency, so there is no prescribed size to any given transmission. Thus I am unsure how to match up that need to the way the HAL is implemented, without changing code in the HAL code in HAL_UART_IRQHandler().
One possible solution that comes to mind is that I believe could call HAL_UART_Receive_IT() with size =1, and then use HAL_UART_RxCpltCallback to do the enqueue, and then reload the driver with another size=1 call to HAL_UART_Receive_IT.
Not optimal for throughput, but it should handle the general length case that I need.
That seems a bit round-about, so I am curious if there is something that already handles this case in the HAL that I am missing?