📄 usb_descriptors.h
字号:
//! Usb Interface Descriptor
typedef struct {
U8 bLength; //!< size of this descriptor in bytes
U8 bDescriptorType; //!< INTERFACE descriptor type
U8 bInterfaceNumber; //!< Number of interface
U8 bAlternateSetting; //!< value to select alternate setting
U8 bNumEndpoints; //!< Number of EP except EP 0
U8 bInterfaceClass; //!< Class code assigned by the USB
U8 bInterfaceSubClass; //!< Sub-class code assigned by the USB
U8 bInterfaceProtocol; //!< Protocol code assigned by the USB
U8 iInterface; //!< Index of string descriptor
} S_usb_interface_descriptor;
#define CS_INTERFACE 0x24
#define CS_ENDPOINT 0x25
#define GENERAL_SUB_TYPE 0x01
#define FORMAT_SUB_TYPE 0x02
#define HEADER_SUB_TYPE 0x01
#define MIXER_UNIT_SUB_TYPE 0x04
#define FEATURE_UNIT_SUB_TYPE 0x06
#define INPUT_TERMINAL_SUB_TYPE 0x02
#define FEATURE_UNIT_SUB_TYPE 0x06
#define OUTPUT_TERMINAL_SUB_TYPE 0x03
//! A U D I O Specific
//! Audio AC interface descriptor
typedef struct {
U8 bLength; /* Size of this descriptor in bytes */
U8 bDescriptorType; /* CS interface*/
U8 bDescritorSubtype; /* HEADER Subtype */
U16 bcdADC; /* Revision of class spec */
U16 wTotalLength; /* Total size of class specific descriptor */
U8 bInCollection; /* Number of streaming interface */
U8 baInterfaceNr; /* Total length of Report descriptor */
} S_usb_ac_interface_descriptor;
//! USB mic INPUT Terminal Descriptor
typedef struct{
U8 bLenght;
U8 bDescriptorType;
U8 bDescriptorSubType;
U8 bTerminalID;
U16 wTerminalType;
U8 bAssocTerminal;
U8 bNrChannels;
U16 wChannelConfig;
U8 iChannelNames;
U8 iTerminal;
} S_usb_mic_in_ter_descriptor;
//! USB Audio Feature Unit descriptor
typedef struct{
U8 bLenght;
U8 bDescriptorType;
U8 bDescriptorSubType;
U8 bUnitID;
U8 bSourceID;
U8 bControSize;
U16 bmaControls;
} S_usb_feature_unit_descriptor;
//! USB mic OUTPUT Terminal Descriptor
typedef struct{
U8 bLenght;
U8 bDescriptorType;
U8 bDescriptorSubType;
U8 bTerminalID;
U16 wTerminalType;
U8 bAssocTerminal;
U8 bSourceID;
U8 iTerminal;
} S_usb_mic_out_ter_descriptor;
//! USB Standard AS interface Descriptor
typedef struct{
U8 bLenght;
U8 bDescriptorType;
U8 bInterfaceNumber;
U8 bAlternateSetting;
U8 bNumEndpoints;
U8 bInterfaceClass;
U8 bInterfaceSubclass;
U8 bInterfaceProtocol;
U8 iInterface;
} S_usb_as_interface_descriptor;
//! USB AS general interface descriptor
typedef struct{
U8 bLenght;
U8 bDescriptorType;
U8 bDescriptorSubType;
U8 bTerminalLink;
U8 bDelay;
U16 wFormatTag;
} S_usb_as_g_interface_descriptor;
//! Audio Format Type descriptor
typedef struct{
U8 bLenght;
U8 bDescriptorType;
U8 bDescriptorSubType;
U8 bFormatType;
U8 bNrChannels;
U8 bSubFrameSize;
U8 bBitResolution;
U8 bSampleFreqType;
U16 wLsbyteiSamFreq;
U8 bMsbyteiSamFreq;
} S_usb_format_type;
//! Endpoint AUDIO Specific descriptor
typedef struct{
U8 bLenght;
U8 bDescriptorType;
U8 bDescriptorSubType;
U8 bmAttributes;
U8 bLockDelayUnits;
U16 wLockDelay;
}S_usb_endpoint_audio_specific;
//! Usb Audio Endpoint Descriptor
typedef struct {
U8 bLength; //!< Size of this descriptor in bytes
U8 bDescriptorType; //!< ENDPOINT descriptor type
U8 bEndpointAddress; //!< Address of the endpoint
U8 bmAttributes; //!< Endpoint's attributes
U16 wMaxPacketSize; //!< Maximum packet size for this EP
U8 bInterval; //!< Interval for polling EP in ms
U8 bRefresh;
U8 bSynAddress;
} S_usb_endpoint_audio_descriptor;
//! Usb Endpoint Descriptor
typedef struct {
U8 bLength; //!< Size of this descriptor in bytes
U8 bDescriptorType; //!< ENDPOINT descriptor type
U8 bEndpointAddress; //!< Address of the endpoint
U8 bmAttributes; //!< Endpoint's attributes
U16 wMaxPacketSize; //!< Maximum packet size for this EP
U8 bInterval; //!< Interval for polling EP in ms
} S_usb_endpoint_descriptor;
//! Usb Device Qualifier Descriptor
typedef struct {
U8 bLength; //!< Size of this descriptor in bytes
U8 bDescriptorType; //!< Device Qualifier descriptor type
U16 bscUSB; //!< Binay Coded Decimal Spec. release
U8 bDeviceClass; //!< Class code assigned by the USB
U8 bDeviceSubClass; //!< Sub-class code assigned by the USB
U8 bDeviceProtocol; //!< Protocol code assigned by the USB
U8 bMaxPacketSize0; //!< Max packet size for EP0
U8 bNumConfigurations; //!< Number of possible configurations
U8 bReserved; //!< Reserved for future use, must be zero
} S_usb_device_qualifier_descriptor;
//! Usb Language Descriptor
typedef struct {
U8 bLength; //!< size of this descriptor in bytes
U8 bDescriptorType; //!< STRING descriptor type
U16 wlangid; //!< language id
} S_usb_language_id;
//_____ U S B M A N U F A C T U R E R D E S C R I P T O R _______________
//struct usb_st_manufacturer
typedef struct {
U8 bLength; // size of this descriptor in bytes
U8 bDescriptorType; // STRING descriptor type
U16 wstring[USB_MN_LENGTH];// unicode characters
} S_usb_manufacturer_string_descriptor;
//_____ U S B P R O D U C T D E S C R I P T O R _________________________
//struct usb_st_product
typedef struct {
U8 bLength; // size of this descriptor in bytes
U8 bDescriptorType; // STRING descriptor type
U16 wstring[USB_PN_LENGTH];// unicode characters
} S_usb_product_string_descriptor;
//_____ U S B S E R I A L N U M B E R D E S C R I P T O R _____________
//struct usb_st_serial_number
typedef struct {
U8 bLength; // size of this descriptor in bytes
U8 bDescriptorType; // STRING descriptor type
U16 wstring[USB_SN_LENGTH];// unicode characters
} S_usb_serial_number;
/*_____ U S B A U D I O D E S C R I P T O R __________________________________*/
typedef struct
{
S_usb_configuration_descriptor cfg;
S_usb_interface_descriptor ifc;
S_usb_ac_interface_descriptor audioac;
S_usb_mic_in_ter_descriptor mic_in_ter;
S_usb_feature_unit_descriptor mic_fea_unit;
S_usb_mic_out_ter_descriptor mic_out_ter;
S_usb_as_interface_descriptor mic_as_alt0;
S_usb_as_interface_descriptor mic_as_alt1;
S_usb_as_g_interface_descriptor mic_g_as;
S_usb_format_type mic_format_type;
S_usb_endpoint_audio_descriptor ep1;
S_usb_endpoint_audio_specific ep1_s;
} S_usb_user_configuration_descriptor;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -