2022-09-26 03:53 AM
Hello,
I am using the STM32F746-discovery board, along with touchgfx in NoRTOS mode. What I am trying to do is whenever the keyboard key is pressed (USB HID configured), the ASCII of that particular key should be sent to the model, then to the viewpresenter, and finally to the view.
In FreeRTOS, I was using binarsemaphores to activate the model, but I'm unsure how to perform the same functionality without using the OS.
Anyone who knows how to tell the model that there has been something to update.
Thanks.
2022-09-26 12:04 PM
I don't use Touchgfx so I'm not aware if there is any built-in equivalent for RTOS functions.
If there aren't, you will need to implement what's known as a P-V semaphore, the underlying algorithm used by FreeRTOS and most realtime operating system. You can Google "P and V semaphore" to find out the details.
Basically, you have a "P" function which blocks a task until a global counter increments to a specific value. The "V" function, called in the USART interrupt, increments the global counter once for every valid character received. In addition, it performs whatever procedure is necessary to unblock the "P" task and schedule it for execution. When the "P" task unblocks the counter is cleared before returning control to the task body. Note that incrementing and clearing the global counter must be atomic operations (i.e. not interruptable or cacheable).
For single character the max counter value is "1", a binary semaphore. For an entire line of characters of fixed length, you can use a larger max count.
The P-V algorithm has been around for at least 50 years so I'm sure there are code examples out there somewhere.
Jack Peacock