📄 usb_dsc.h
字号:
typedef struct
{
U16 bogus_interrupts; // number of bogus interrupts
usb_dev_class_state_type bogus_state; // state during bogus interrupt
U16 bogus_status; // bogus interrupt status
} usb_dev_class_error_type;
/*---------------------------------------------------------------------------
USB Setup
----------------------------------------------------------------------------*/
typedef __packed struct
{
U8 bmRequestType;
U8 bRequest;
__packed union
{
U16 value;
__packed struct
{
U8 index;
U8 type;
} descriptor;
} wValue;
U16 wIndex;
U16 wLength;
} usb_dev_class_setup_type;
typedef enum
{
USB_RX_IDLE = 0,
USB_RX_RECEIVE
} usb_dev_class_rx_state_type;
typedef struct
{
usb_dev_class_setup_type setup;
U16 wLength;
U16 wCount;
U8 *pData;
} usb_dev_class_control_tx_type;
typedef struct
{
usb_dev_class_control_tx_type sControl;
} USB_Control_Block;
/*---------------------------------------------------------------------------
The USB Device Notification Info
---------------------------------------------------------------------------*/
typedef __packed struct
{
U8 bmRequestType;
U8 bNotification;
U16 wValue;
U16 wIndex;
U16 wLength;
U16 wSerialState;
U8 Data[USBDC_MAX_NOTIFICATION_DATA_SIZE - 2];
} usb_cdc_acm_notification_type;
/*---------------------------------------------------------------------------
Set/Get Line Coding CDC Request
---------------------------------------------------------------------------*/
typedef __packed struct
{
U32 data_rate; // interface data rate
U8 stop_bits; // number stop bits
U8 parity; // parity
U8 data_bits; // number of data bits/unsigned char
} usb_dev_class_iface_line_coding_type;
/*---------------------------------------------------------------------------
The USB Device Serial Interface Info
---------------------------------------------------------------------------*/
typedef __packed struct
{
usb_dev_class_iface_line_coding_type sLineCoding;
U8 cd; // carrier detect
U8 ri; // ring indicator
U8 dsr; // data set ready
U8 break_state; // state of break detection
U8 flow_control; // Flow Control
U8 dtr; // data terminal ready
U8 rts; // request to send
void (*dtr_callback_fn)(void); // dtr callback function
} usb_dev_class_serial_iface_info_type;
/*---------------------------------------------------------------------------
The USB Device Stream Control Info
---------------------------------------------------------------------------*/
typedef struct
{
unsigned char dtr; // data terminal ready
void (*dtr_callback_fn)(void); // dtr callback function
} usb_dev_class_stream_control_type;
typedef struct
{
usb_dev_class_rx_state_type bRxState;
U8 bConfigured;
U8 bClassType;
U8 bPowered;
U8 bAddress;
U8 bNotiUpdated;
usb_dev_class_control_tx_type sControl;
usb_dev_class_serial_iface_info_type Interface[MAX_NUMBER_OF_INTERFACE];
usb_cdc_acm_notification_type NotiMsg;
void (*EventCallBack[MAX_USB_EVENT])(/*U8 *pData, U16 wLen*/);
void (*ClearFeatureCallback)(void);
} usb_dev_class_control_block;
/*---------------------------------------------------------------------------
The Device Descriptor. See the USB Spec for the format.
---------------------------------------------------------------------------*/
typedef __packed struct
{
U8 bLength;
U8 bDescriptorType;
U16 bcdUSB;
U8 bDeviceClass;
U8 bDeviceSubClass;
U8 bDeviceProtocol;
U8 bMaxPacketSize0;
U16 idVendor;
U16 idProduct;
U16 bcdDevice;
U8 iManufacturer;
U8 iProduct;
U8 iSerialNumber;
U8 bNumConfigurations;
} usb_dev_descriptor_type;
/*---------------------------------------------------------------------------
The Configuration Descriptor. See the USB Spec for the format.
---------------------------------------------------------------------------*/
typedef __packed struct
{
U8 bLength;
U8 bDescriptorType;
U16 wTotalLength;
U8 bNumInterfaces;
U8 bConfigurationValue;
U8 iConfiguration;
U8 bmAttributes;
U8 MaxPower;
} usb_dev_configuration_descriptor_type;
/*---------------------------------------------------------------------------
The Interface Descriptor. See the USB Spec for the format.
---------------------------------------------------------------------------*/
typedef __packed struct
{
U8 bLength;
U8 bDescriptorType;
U8 bInterfaceNumber;
U8 bAlternateSetting;
U8 bNumEndpoints;
U8 bInterfaceClass;
U8 bInterfaceSubClass;
U8 bInterfaceProtocol;
U8 iInterface;
} usb_dev_interface_descriptor_type;
/*---------------------------------------------------------------------------
The Endpoint Descriptor. See the USB Spec for the format.
---------------------------------------------------------------------------*/
typedef __packed struct
{
U8 bLength;
U8 bDescriptorType;
U8 bEndpointAddress;
U8 bmAttributes;
U16 wMaxPacketSize;
U8 bInterval;
} usb_dev_endpoint_descriptor_type;
typedef __packed struct
{
U8 bLength;
U8 bDescriptorType;
U8 bDescriptorSubtype;
U8 bFuntionSpecificData;
} usb_func_descriptor_type1;
typedef __packed struct
{
U8 bLength;
U8 bDescriptorType;
U8 bDescriptorSubtype;
U8 bData[2];
} usb_func_descriptor_type2;
/* This is the language descriptor. Only English is supported.
* This descriptor is defined in Table 9-11 of the USB spec.
*/
#define USBDC_NUM_LANGUAGES 1
/*typedef __packed struct
{
U8 bLength; // length of languages supported in this device
U8 bDescriptorType;// STRING descriptor type
U16 wLANGUID[USBDC_NUM_LANGUAGES];
} usb_dev_lang_support_string_type;
*/
typedef __packed struct
{
U8 bLength;
U8 bDescriptorType;// STRING descriptor type
U16 wString[100];
} usb_dev_string_type;
typedef __packed struct
{
usb_dev_configuration_descriptor_type config_des;
usb_dev_interface_descriptor_type cdc_inf_des;
usb_func_descriptor_type2 cdc_header;
usb_func_descriptor_type2 cdc_call_mng;
usb_func_descriptor_type1 cdc_abs_ctrl;
usb_func_descriptor_type2 cdc_union;
usb_dev_endpoint_descriptor_type cdc_ep_des;
usb_dev_interface_descriptor_type acm_inf_des;
usb_dev_endpoint_descriptor_type acm_ep_in_des;
usb_dev_endpoint_descriptor_type acm_ep_out_des;
} usb_config_des_modem_type;
typedef __packed struct
{
usb_dev_configuration_descriptor_type config_des;
usb_dev_interface_descriptor_type cdc_inf_des;
// usb_func_descriptor_type2 cdc_header;
// usb_func_descriptor_type2 cdc_call_mng;
// usb_func_descriptor_type1 cdc_abs_ctrl;
// usb_func_descriptor_type2 cdc_union;
usb_dev_endpoint_descriptor_type cdc_ep_des;
// usb_dev_interface_descriptor_type acm_inf_des;
usb_dev_endpoint_descriptor_type acm_ep_in_des;
// usb_dev_endpoint_descriptor_type acm_ep_out_des;
} usb_config_des_bulk_type;
typedef __packed struct
{
usb_dev_configuration_descriptor_type config_des;
usb_dev_interface_descriptor_type cdc_inf_des;
usb_func_descriptor_type2 cdc_header;
usb_func_descriptor_type2 cdc_call_mng;
usb_func_descriptor_type1 cdc_abs_ctrl;
usb_func_descriptor_type2 cdc_union;
usb_dev_endpoint_descriptor_type cdc_ep_des;
usb_dev_interface_descriptor_type acm_inf_des;
usb_dev_endpoint_descriptor_type acm_ep_in_des;
usb_dev_endpoint_descriptor_type acm_ep_out_des;
usb_dev_interface_descriptor_type data_inf_des;
usb_dev_endpoint_descriptor_type data_ep_in_des;
usb_dev_endpoint_descriptor_type data_ep_out_des;
} usb_config_des_modem_data_type;
typedef __packed struct
{
usb_dev_configuration_descriptor_type config_des;
usb_dev_interface_descriptor_type inf_des;
usb_dev_endpoint_descriptor_type ms_ep_in_des;
usb_dev_endpoint_descriptor_type ms_ep_out_des;
} usb_config_des_ms_type;
#endif /* __USB_DSC_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -