To see how a queue can be used to keep an architecture loosely coupled, we'll take a look at an application that accepts commands over USB and lights LEDs. While the example application itself is very simple, the concepts presented here scale extremely well. So, regardless of whether there are only a few commands or hundreds, the same approach can be used to keep the architecture flexible.
This application also shows another example of how to keep higher-level code loosely coupled to the underlying hardware. It ensures the LED command code only uses a defined interface to access a Pulse Width Modulation (PWM) implementation, rather than directly interacting with the MCU registers/HAL. The architecture consists of the following major components:
- A USB driver: This is the same USB stack that has been used in previous examples. VirtualCommDriverMultiTask...