Core Layer RTOS Model

The core layer of μC/USB-Device needs an RTOS for three purposes:

  • Signal the completion of synchronous transfers.
  • Manage core events.
  • Manage debug events (optional).

Core Events Management

For proper operation, the core layer needs an OS task that will manage the core events. For more information on the purpose of this task or on what a core event is, refer to the Task Model page. The core events must be queued in a data structure and be processed by the core. This allows the core to process the events in a task context instead of in an ISR context, as most of the events will be raised by the device driver’s ISR. The core task also needs to be informed when a new event is queued. Figure - Core events management within RTOS port describes the core events management within the RTOS port.

Figure - Core events management within RTOS port

Core events management within RTOS port

(1) A core event is added to the queue.

(2) The core task of the core layer pends on the queue. Whenever an event is added, the core task is resumed to process it.


Debug Events Management

The core layer of μC/USB-Device offers an optional feature to do tracing and debugging. For more information on this feature, see the Debug and Trace page. This feature requires an OS task. For more information on the purpose of this task or on debug events, refer to the Task Model page. The behavior of this task is similar to the core task described in the Core Events Management section. The difference is that the RTOS port does not need to manage the queue, as it is handled within the core layer. The RTOS port only needs to provide a signal that will inform of a debug event insertion.

Synchronous Transfer Completion Signals

The core layer needs a way to signal the application about the synchronous transfer completion. The core will need one signal per endpoint. The RTOS resources usually used for this signal is a semaphore. Figure - Synchronous transfer completion notification describes a synchronous transfer completion notification.

Figure - Synchronous transfer completion notification

Synchronous transfer completion notification

(1) Application task calls a synchronous transfer function.

(2) While the transfer is in progress, the application task pends on the transfer completion signal.

(3) Once the transfer is completed, the core will post the transfer completion signal which will resume the application task.