📄 compositeddriverdescriptors.c
字号:
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
AUDD_NUMCHANNELS,
AUDD_BYTESPERSAMPLE,
AUDD_BYTESPERSAMPLE*8,
1 // One discrete frequency supported
},
{
AUDD_SAMPLERATE & 0xFF,
(AUDD_SAMPLERATE >> 8) & 0xFF,
(AUDD_SAMPLERATE >> 16) & 0xFF
}
},
// Audio streaming endpoint standard descriptor
{
sizeof(AUDEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
AUDD_Descriptors_DATAOUT),
USBEndpointDescriptor_ISOCHRONOUS,
BOARD_USB_ENDPOINTS_MAXPACKETSIZE(AUDD_Descriptors_DATAOUT),
1, // Polling interval = 2^(x-1) milliseconds (1 ms)
0, // This is not a synchronization endpoint
0 // No associated synchronization endpoint
},
// Audio streaming endpoint class-specific descriptor
{
sizeof(AUDDataEndpointDescriptor),
AUDGenericDescriptor_ENDPOINT,
AUDDataEndpointDescriptor_SUBTYPE,
0, // No attributes
0, // Endpoint is not synchronized
0 // Endpoint is not synchronized
},
#endif // (AUDIO defined)
#if defined(usb_CDCCDC)
// CDC 1
// IAD for CDC/ACM port 1
{
sizeof(USBInterfaceAssociationDescriptor),
USBGenericDescriptor_INTERFACEASSOCIATION,
CDCD_Descriptors_INTERFACENUM1,
2,
CDCCommunicationInterfaceDescriptor_CLASS,
CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
0 // No string descriptor for this interface
},
// Communication class interface standard descriptor
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
CDCD_Descriptors_INTERFACENUM1, // This is interface #2
0, // This is alternate setting #0 for this interface
1, // This interface uses 1 endpoint
CDCCommunicationInterfaceDescriptor_CLASS,
CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,
CDCCommunicationInterfaceDescriptor_NOPROTOCOL,
0 // No string descriptor for this interface
},
// Class-specific header functional descriptor
{
sizeof(CDCHeaderDescriptor),
CDCGenericDescriptor_INTERFACE,
CDCGenericDescriptor_HEADER,
CDCGenericDescriptor_CDC1_10
},
// Class-specific call management functional descriptor
{
sizeof(CDCCallManagementDescriptor),
CDCGenericDescriptor_INTERFACE,
CDCGenericDescriptor_CALLMANAGEMENT,
CDCCallManagementDescriptor_SELFCALLMANAGEMENT,
CDCD_Descriptors_INTERFACENUM1 + 1 // No associated data interface
},
// Class-specific abstract control management functional descriptor
{
sizeof(CDCAbstractControlManagementDescriptor),
CDCGenericDescriptor_INTERFACE,
CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,
CDCAbstractControlManagementDescriptor_LINE
},
// Class-specific union functional descriptor with one slave interface
{
sizeof(CDCUnionDescriptor),
CDCGenericDescriptor_INTERFACE,
CDCGenericDescriptor_UNION,
CDCD_Descriptors_INTERFACENUM1, // Number of master interface is #2
CDCD_Descriptors_INTERFACENUM1+1 // First slave interface is #3
},
// Notification endpoint standard descriptor
{
sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CDCD_Descriptors_NOTIFICATION1),
USBEndpointDescriptor_INTERRUPT,
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_NOTIFICATION1),
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
10 // Endpoint is polled every 10ms
},
// Data class interface standard descriptor
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
CDCD_Descriptors_INTERFACENUM1 + 1, // This is interface #3
0, // This is alternate setting #0 for this interface
2, // This interface uses 2 endpoints
CDCDataInterfaceDescriptor_CLASS,
CDCDataInterfaceDescriptor_SUBCLASS,
CDCDataInterfaceDescriptor_NOPROTOCOL,
0 // No string descriptor for this interface
},
// Bulk-OUT endpoint standard descriptor
{
sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
CDCD_Descriptors_DATAOUT1),
USBEndpointDescriptor_BULK,
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAOUT1),
USBEndpointDescriptor_MAXBULKSIZE_FS),
0 // Must be 0 for full-speed bulk endpoints
},
// Bulk-IN endpoint descriptor
{
sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CDCD_Descriptors_DATAIN1),
USBEndpointDescriptor_BULK,
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CDCD_Descriptors_DATAIN1),
USBEndpointDescriptor_MAXBULKSIZE_FS),
0 // Must be 0 for full-speed bulk endpoints
},
#endif // (2 CDCs defined)
#if defined(usb_CDCMSD) || defined(usb_HIDMSD)
// Mass Storage interface descriptor.
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
MSDD_Descriptors_INTERFACENUM,
0, // This is alternate setting #0.
2, // Interface uses two endpoints.
MSInterfaceDescriptor_CLASS,
MSInterfaceDescriptor_SCSI,
MSInterfaceDescriptor_BULKONLY,
0 // No string descriptor for interface.
},
// Bulk-OUT endpoint descriptor
{
sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
MSDD_Descriptors_BULKOUT),
USBEndpointDescriptor_BULK,
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKOUT),
USBEndpointDescriptor_MAXBULKSIZE_FS),
0 // No string descriptor for endpoint.
},
// Bulk-IN endpoint descriptor
{
sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
MSDD_Descriptors_BULKIN),
USBEndpointDescriptor_BULK,
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(MSDD_Descriptors_BULKIN),
USBEndpointDescriptor_MAXBULKSIZE_FS),
0 // No string descriptor for endpoint.
},
#endif // (MSD defined)
};
/// String descriptor with the supported languages.
const unsigned char languageIdDescriptor[] = {
USBStringDescriptor_LENGTH(1),
USBGenericDescriptor_STRING,
USBStringDescriptor_ENGLISH_US
};
/// Manufacturer name.
const unsigned char manufacturerDescriptor[] = {
USBStringDescriptor_LENGTH(5),
USBGenericDescriptor_STRING,
USBStringDescriptor_UNICODE('A'),
USBStringDescriptor_UNICODE('t'),
USBStringDescriptor_UNICODE('m'),
USBStringDescriptor_UNICODE('e'),
USBStringDescriptor_UNICODE('l')
};
/// Product name.
const unsigned char productDescriptor[] = {
USBStringDescriptor_LENGTH(14),
USBGenericDescriptor_STRING,
USBStringDescriptor_UNICODE('C'),
USBStringDescriptor_UNICODE('o'),
USBStringDescriptor_UNICODE('m'),
USBStringDescriptor_UNICODE('p'),
USBStringDescriptor_UNICODE('o'),
USBStringDescriptor_UNICODE('s'),
USBStringDescriptor_UNICODE('i'),
USBStringDescriptor_UNICODE('t'),
USBStringDescriptor_UNICODE('e'),
USBStringDescriptor_UNICODE(' '),
USBStringDescriptor_UNICODE('D'),
USBStringDescriptor_UNICODE('e'),
USBStringDescriptor_UNICODE('m'),
USBStringDescriptor_UNICODE('o')
};
/// Product serial number.
const unsigned char serialNumberDescriptor[] = {
USBStringDescriptor_LENGTH(4),
USBGenericDescriptor_STRING,
USBStringDescriptor_UNICODE('0'),
USBStringDescriptor_UNICODE('1'),
USBStringDescriptor_UNICODE('2'),
USBStringDescriptor_UNICODE('3')
};
/// Array of pointers to the four string descriptors.
const unsigned char *stringDescriptors[] = {
languageIdDescriptor,
manufacturerDescriptor,
productDescriptor,
serialNumberDescriptor,
};
//------------------------------------------------------------------------------
// Exported variables
//------------------------------------------------------------------------------
/// List of descriptors required by an USB audio speaker device driver.
const USBDDriverDescriptors compositedDriverDescriptors = {
&deviceDescriptor,
(const USBConfigurationDescriptor *) &configurationDescriptors,
#ifdef BOARD_USB_UDPHS
&qualifierDescriptor,
(const USBConfigurationDescriptor *) &configurationDescriptors,
&deviceDescriptor,
(const USBConfigurationDescriptor *) &configurationDescriptors,
&qualifierDescriptor,
(const USBConfigurationDescriptor *) &configurationDescriptors,
#else
0, 0, 0, 0, 0, 0,
#endif
stringDescriptors,
4 // Number of string descriptors
};
#if defined(usb_CDCHID) || defined(usb_HIDAUDIO) || defined(usb_HIDMSD)
/// Report descriptor used by the driver.
const unsigned char hiddReportDescriptor[] = {
HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID,
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_KEYBOARD,
HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION,
// Input report: modifier keys
HIDReport_GLOBAL_REPORTSIZE + 1, 1,
HIDReport_GLOBAL_REPORTCOUNT + 1, 8,
HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID,
HIDReport_LOCAL_USAGEMINIMUM + 1,
HIDD_Descriptors_FIRSTMODIFIERKEY,
HIDReport_LOCAL_USAGEMAXIMUM + 1,
HIDD_Descriptors_LASTMODIFIERKEY,
HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0,
HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1,
HIDReport_INPUT + 1, HIDReport_VARIABLE,
// Input report: standard keys
HIDReport_GLOBAL_REPORTCOUNT + 1, 3,
HIDReport_GLOBAL_REPORTSIZE + 1, 8,
HIDReport_GLOBAL_LOGICALMINIMUM + 1,
HIDD_Descriptors_FIRSTSTANDARDKEY,
HIDReport_GLOBAL_LOGICALMAXIMUM + 1,
HIDD_Descriptors_LASTSTANDARDKEY,
HIDReport_GLOBAL_USAGEPAGE + 1, HIDKeypad_PAGEID,
HIDReport_LOCAL_USAGEMINIMUM + 1,
HIDD_Descriptors_FIRSTSTANDARDKEY,
HIDReport_LOCAL_USAGEMAXIMUM + 1,
HIDD_Descriptors_LASTSTANDARDKEY,
HIDReport_INPUT + 1, 0 /* Data array */,
// Output report: LEDs
HIDReport_GLOBAL_REPORTCOUNT + 1, 3,
HIDReport_GLOBAL_REPORTSIZE + 1, 1,
HIDReport_GLOBAL_USAGEPAGE + 1, HIDLeds_PAGEID,
HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0,
HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1,
HIDReport_LOCAL_USAGEMINIMUM + 1, HIDLeds_NUMLOCK,
HIDReport_LOCAL_USAGEMAXIMUM + 1, HIDLeds_SCROLLLOCK,
HIDReport_OUTPUT + 1, HIDReport_VARIABLE,
// Output report: padding
HIDReport_GLOBAL_REPORTCOUNT + 1, 1,
HIDReport_GLOBAL_REPORTSIZE + 1, 5,
HIDReport_OUTPUT + 1, HIDReport_CONSTANT,
HIDReport_ENDCOLLECTION
};
#endif // (HID defined)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -