USB Component
Version 6.17.0
MDK Middleware for USB Device and Host Communication
|
Implement application specific behavior of a Custom Class USB Device. More...
Content | |
User API | |
User API reference of the Custom Device Class. | |
Configuration | |
Configuration of the USB Device Custom Class in µVision. | |
Implement application specific behavior of a Custom Class USB Device.
The Custom Class in the USB Component may be used to implement any type of USB Device class.
Refer to:
The USB Component allows multiple instances of the Custom class. This feature may be used to create USB Composite Devices. Each Custom Class instance has separate files and interface functions:
This documentation uses n as a placeholder for the instance number 0 - 3. Most applications require only one instance of a Custom Class. For the first Custom Class instance the instance number is 0:
The handling of the Custom Class endpoint events is implemented in an USBD_CustomClassn_Endpointx_Event for every endpoint. Each endpoint (or pair of IN/OUT endpoints with the same endpoint number) uses an own thread in order to allow a parallel functionality of every interface.
Setup packets sent to Control Endpoint 0 are received by the USB Device Core. The USB Device Core will call the USBD_Devicen_Endpoint0_SetupPacketReceived function and pass the setup packet to it. Depending on the return code of USBD_Devicen_Endpoint0_SetupPacketReceived, the USB Device Core either passes the processing to the Custom Class function if custom class is used and if message is addressed to a custom class by calling USBD_CustomClassn_Endpoint0_SetupPacketReceived function or continues to process the received setup packet itself. Depending on the return code of USBD_CustomClassn_Endpoint0_SetupPacketReceived, processing of the setup packet is either done or continues to be processed by USB Device Core.
USB Device Core will call USBD_Devicen_Endpoint0_SetupPacketProcessed and depending on return code it will call USBD_CustomClassn_Endpoint0_SetupPacketProcessed to inform the application that setup packet has been processed by USB Device Core.
If custom handling of request was used and request contains data stage, USB Device Core will call USBD_Devicen_Endpoint0_OutDataReceived and depending on return code it will call USBD_CustomClassn_Endpoint0_OutDataReceived after data expected by request was received, it will call USBD_Devicen_Endpoint0_InDataSent and depending on return code it will call USBD_CustomClassn_Endpoint0_InDataSent after data expected by request was sent.
To create an USB Device with a Custom Class:
Two files are available to implement the application-specific behavior:
Both user code templates contain example code that can be used to demonstrate the features of the templates. Uncomment this code to see how it works on your target hardware.