In the previous chapter, we went through several examples of creating drivers, but they were only used by a single task. Since we're creating a multi-tasking asynchronous system, a few additional considerations need to be made to ensure that the peripherals exposed by our drivers can safely be used by multiple tasks. Preparing a driver for use by multiple tasks requires a number of additional considerations.
Accordingly, this chapter first illustrates the pitfalls of a shared peripheral in a multi-tasking, real-time environment. After understanding the problem we're trying to solve, we'll investigate potential solutions for wrapping a driver in a way that provides an easy-to-use abstraction layer that is safe to use across multiple tasks. We'll be using the STM32 USB stack to implement a Communication Device Class ...