nRF5 SDK  v12.2.0
Choose documentation:
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Experimental: USB device library
This information applies to the nRF52840 SoC only.

This chapter explains the details of the USB device (USBD) library implementation in this SDK.

Class brick concept

usb_low_level.svg
USB device architecture overview

The library allows to compose the whole USB device using class bricks:

  • Every class creates an instance.
  • Multiple instances of the same class may exist.
  • Every class instance contains a pointer to the event processing function.
  • In every instance, the location of the event processing function pointer is the same.
  • You can configure a USB device by adding the selected class instances to the controller.
  • The controller has arrays that connect the endpoint and the interface to the selected class instance.
  • Classes create a linked list that makes it easier to enumerate them.

Controller module

The main task of the controller is to distribute events to the correct blocks. You can also use it to access a class instance, if you know the interface or endpoint number.

The design of this module assumes that it is easy for a higher level module to know the endpoint number for read/write operations. However, for the information that comes from bottom to top, an additional module is required that will direct all the events to the right higher level module.

Every class instance needs a pointer to the data processing function. No matter what type of class it is, this pointer must be in a constant position.

Core module

The main task of the core module is to process all system events and manage the current USB bus state. It also manages the enumeration process gathering all the descriptors from a class instance.

Driver

For detailed driver documentation, refer to Experimental: USBD driver.

Strings

This is a highly customizable string description module. For detailed documentation, refer to USBD library configurable string descriptor module.

Predefined classes

This library provides a number of standard predefined classes that are ready to just instantiate them into the code. For more documentation on these classes, see USB Device library classes implemementation.

USBD library configurable string descriptor module

USB Device library classes implemementation