MPLAB Harmony USB Stack
|
The USB Device Library features a modular and layered architecture, as illustrated in the following figure.
USB Device Library Architecture
As seen in the figure, the USB Device Library consists of the following three major components.
The USBCD manages the state of the USB peripheral and provides the Device Layer with structured data access methods to the USB. It also provides the Device_layer with USB events. The USBCD is a MPLAB Harmony driver and uses the MPLAB Harmony framework services for its operation. It supports only one client per instance of the USB Peripheral. This client would typically be the Device Layer. In case of multiple USB peripherals, the USBCD can manage multiple USB peripherals, each being accessed by one client. The driver is accessed exclusively by the Device Layer in the USB Device Layer Architecture. The USBCD provides functions to:
The Device Layer responds to the enumeration requests issued by the USB Host. It has exclusive access to an instance of the USBCD and the control endpoint (Endpoint 0). When the Host issues a class specific control transfer request, the Device Layer will analyze the setup packet of the control transfer and will route the control transfer to the appropriate function driver. The Device Layer must be initialized with the following data:
The Device Layer initializes all function drivers that are registered with it when it receives a Set Configuration (for a supported configuration) from the Host. It deinitializes the function drivers when a USB reset event occurs. It opens the USBCD and registers an event handler to receive USB events. The Device Layer can also be opened by the application (the application becomes a client to the Device Layer). The application can then receive bus and device events and respond to control transfer requests. The Device Layer provides events to the application such as device configured or device reset. Some of these events are notification-only events, while other events require the application to take action.
The Function Drivers implements various USB device classes as per the class specification. The USB Device Library architecture can support multiple instances of a function driver. An example would be a USB CDC device that emulates two serial ports. Function drivers provide an abstracted and an easy to use interface to the application. The application must register an event handler with the function driver to receive function driver events and must respond to some of these events with control transfer read/write functions. Function drivers access the bus through the Device Layer.
MPLAB Harmony USB Stack
|