Highly flexible Composite USB Device Library
This project implements a platform-independent, highly flexible USB Device software framework, which allows you to create a full-feature USB 2.0 device firmware with multiple independent interfaces.
The project consists of the followings: * The USB 2.0 device framework is located in the Device folder. * Common USB classes are implemented as part of the project, under the Class folder. * The Templates folder contains
usbd_config.hconfiguration file and various example files. * The Doc folder contains a prepared doxyfile for Doxygen documentation generation.
The interface implementations are completely separated from the USB device control. Each of them should use its class-specific API from
usbd_.h. There are only two steps to mount an interface to a device:
The interfaces are added to the device configuration in the order of the mount calls. It is possible to change the active interfaces during runtime by unmounting all and mounting the new ones. The only requirement is that the device has to be logically disconnected from the host when it is done.
The device control of the library is limited to the global state management using the public API in usbd.h. The bulk of the device operation is servicing the device peripheral events: - USB Reset signal on bus ->
USBD_ResetCallback()- USB control pipe setup request received ->
USBD_SetupCallback()- USB endpoint data transfer completed ->
The USBD handles are used as a shared management structure for both this stack and the peripheral driver. Any additional fields that the peripheral driver requires can be defined in the driver-specific usbdpddef.h header, while the usbd_types.h shall be included by the driver.
A virtual network with a single lwIP server (DNS, DHCP, HTTP) is presented by the device (as a network adapter). Composite USB device demonstrating the CDC-NCM function usage and a reduced DFU interface to enter ROM bootloader.
A generic USB device bootloader firmware for STM32 controllers. USB device with a single DFU interface which is mountable on both the bootloader's and the application's device stack.
A debug serial port with selectable output power and battery charging. Composite USB device with one CDC (serial port), two HID interfaces (onboard sensors and power management) and the bootloader's DFU interface.
A CAN bus gateway which uses a custom protocol over a USB serial port emulation. Composite USB device with CDC-ACM function and the bootloader's DFU interface.
This project is free to use for everyone as long as the license terms are met. Any found defects or suggestions should be reported as a GitHub issue. Improvements in the form of pull requests are also welcome.