Sharing Hardware Peripherals across Tasks

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 (CDC) to provide an interactive Virtual COM Port (VPC). Unlike the previous chapter, which took an extremely low-level approach to driver development, this chapter focuses on writing threadsafe code on top of an existing driver stack.

In a nutshell, we will cover the following topics:

  • Understanding shared peripherals
  • Introducing the STM USB driver stack 
  • Developing a StreamBuffer USB virtual COM port
  • Using mutexes for access control
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.119.241