generic UART example for STM32 using CubeMX HAL

Hello: I am self-teaching myself STM32 and FreeRTOS, and I am having difficulty finding examples for this stuff compared to the plethora of examples I was able to gather when learning AVR’s and arduino-land. I am trying to make a base for myself to use whenever I start a new project, and I am getting stumped on how to effectively use a UART with the CubeMX HAL and FreeRTOS. In 2009, someone asked this very question, and the founder of FreeRTOS made a suggestion: https://www.freertos.org/FreeRTOSSupportForumArchive/July2009/freertosBestwaytoimplementgenericUARTdrivers3321054.html “..an efficient way would be to have a DMA pass data to and from the UART and a circular buffer. Then have the DMA interrupt use a semaphore to unblock tasks when there is enough data to make it worth processing.” So my question: does someone have an example of this working, ideally with the CubeMX HAL? I have been reading about task notifications (which I can use, since CubeMX uses FreeRTOS v9.0), is there an example that does this with those instead of semaphores? My base code that I am trying to port from arduino land, uses a command parser that can accept messages of varying length, and I need to keep that functionality. I apolgize in advance for the n00b question… it is hard for me to take everything I’ve learned thus far and start from a blank page, and example to learn from would help me greatly. Thank you in advance 🙂

generic UART example for STM32 using CubeMX HAL

Specifics of FIFOs and DMAs are chip specific as the hardware moves the data, so outside of the scope of FreeRTOS support. The following file provides a heavily commented example of how to use a stream buffer to send data from an ISR to a task using software https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Demo/Common/Minimal/StreamBufferInterrupt.c You can look at the source code on the direct to task notification documentation pages to see how to signal a task from an interrupt using a notification. If you were using a DMA to move data then the ISR would be the DMA end interrupt: https://www.freertos.org/RTOSTaskNotificationAsCounting_Semaphore.html

generic UART example for STM32 using CubeMX HAL

THANK YOU.. that example is more or less exactly what I was looking for.