⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb.h

📁 44b0板上的usb固件及上位机程序
💻 H
字号:
/******************************************************************************* USB Header File*------------------------------------------------------------------------------* Source: usb.h, v1.0 2004/06/26* Author: Tan Dewen******************************************************************************/#ifndef _USB_H_#define _USB_H_#include "isr.h"#define USB_SPEC_REV_BCD 0x0110 // USB specification ver 1.1// DEVICE_REQUEST structure#define SIZEOF_DEVICE_REQUEST 0x08typedef struct _tagDEVICE_REQUEST{	U8 bmRequestType;	// See bit definitions below	U8 bRequest;		// See value definitions below	U8 bValueL;		// Meaning varies with request type	U8 bValueH;		// Meaning varies with request type	U8 bIndexL;		// Meaning varies with request type	U8 bIndexH;		// Meaning varies with request type	U8 bLengthL;		// Number of bytes of data to transfer (LSByte)	U8 bLengthH;		// Number of bytes of data to transfer (MSByte)} tDEVICE_REQUEST, *ptDEVICE_REQUEST;// Bit definitions for DEVICE_REQUEST.bmRequestType// Bit 7: Data direction#define USB_REQ_TYPE_OUTPUT 0x00	// 0 = Host sends data to device#define USB_REQ_TYPE_INPUT 0X80		// 1 = Device sending data to the host// Bit 6-5: Type#define USB_REQ_TYPE_MASK 0x60		// Mask value for bits 6-5#define USB_REQ_TYPE_STANDARD 0x00	// 00 = Standard USB request#define USB_REQ_TYPE_CLASS 0x20		// 01 = Class specific#define USB_REQ_TYPE_VENDOR 0x40	// 10 = Vendor specific// Bit 4-0: Recipient#define USB_REQ_TYPE_RECIP_MASK 0x1f	// Mask value for bits 4-0#define USB_REQ_TYPE_DEVICE 0x00	// 00000 = Device#define USB_REQ_TYPE_INTERFACE 0x01	// 00001 = Interface#define USB_REQ_TYPE_ENDPOINT 0x02	// 00010 = Endoint#define USB_REQ_TYPE_OTHER 0x03		// 00011 = Other// Values for DEVICE_REQUEST.bRequest// Standard Device Requests#define USB_REQ_GET_STATUS 0#define USB_REQ_CLEAR_FEATURE 1#define USB_REQ_SET_FEATURE 3#define USB_REQ_SET_ADDRESS 5#define USB_REQ_GET_DESCRIPTOR 6#define USB_REQ_SET_DESCRIPTOR 7#define USB_REQ_GET_CONFIGURATION 8#define USB_REQ_SET_CONFIGURATION 9#define USB_REQ_GET_INTERFACE 10#define USB_REQ_SET_INTERFACE 11#define USB_REQ_SYNCH_FRAME 12// Descriptor Type Values#define DESC_TYPE_DEVICE 1	// Device Descriptor (Type 1)#define DESC_TYPE_CONFIG 2	// Configuration Descriptor (Type 2)#define DESC_TYPE_STRING 3	// String Descriptor (Type 3)#define DESC_TYPE_INTERFACE 4	// Interface Descriptor (Type 4)#define DESC_TYPE_ENDPOINT 5	// Endpoint Descriptor (Type 5)#define DESC_TYPE_HUB 0x29	// Hub Descriptor (Type 6)#define DESC_TYPE_HID 0x21	// HID Class Descriptor (Type 7)#define DESC_TYPE_REPORT 0x22	// HID Class Report Descriptor#define DESC_TYPE_PHY 0x23	// HID Class Physical Descriptor// Feature Selector Values#define FEATURE_REMOTE_WAKEUP 1	// Remote wakeup (Type 1)#define FEATURE_ENDPOINT_STALL 0	// Endpoint stall (Type 0)// Device Status Values#define DEVICE_STATUS_REMOTE_WAKEUP 0x02#define DEVICE_STATUS_SELF_POWER 0x01// DEVICE_DESCRIPTOR structure#define SIZEOF_DEVICE_DESCRIPTOR 0x12#define OFFSET_DEVICE_DESCRIPTOR_VID_L 0x08#define OFFSET_DEVICE_DESCRIPTOR_VID_H 0x09#define OFFSET_DEVICE_DESCRIPTOR_PID_L 0x0a#define OFFSET_DEVICE_DESCRIPTOR_PID_H 0x0b#define OFFSET_CONFIG_DESCRIPTOR_POWER 0x07#define OFFSET_CONFIG_DESCRIPTOR_CURT  0x08typedef struct _tagDEVICE_DESCRIPTOR{	U8 bLength;		// Length of this descriptor (12h bytes)	U8 bDescriptorType;	// Type code of this descriptor (01h)	U16 bcdUSB;		// Release of USB spec(0110h = rev 1.1)	U8 bDeviceClass;	// Device's base class code	U8 bDeviceSubClass;	// Device's sub class code	U8 bDeviceProtocol;	// Device's protocol type code	U8 bMaxPacketSize0;	// End point 0's max packet size (8/16/32/64)	U16 wIdVendor;		// Vendor ID for device	U16 wIdProduct;		// Product ID for device	U16 wBcdDevice;		// Revision level of device	U8 wManufacturer;	// Index of manufacturer name string desc	U8 wProduct;		// Index of product name string desc	U8 wSerialNumber;	// Index of serial number string desc	U8 bNumConfigurations; 	// Number of configurations supported} tDEVICE_DESCRIPTOR, *ptDEVICE_DESCRIPTOR;// CONFIG_DESCRIPTOR structure#define SIZEOF_CONFIG_DESCRIPTOR 0x09typedef struct _tagCONFIG_DESCRIPTOR{	U8 bLength;		// Length of this descriptor (9h bytes)	U8 bDescriptorType;	// Type code of this descriptor(02h)	U16 wTotalLength;	// Size of this config desc plus all interface,				// endpoint, class, and vendor descriptors	U8 bNumInterfaces;	// Number of interfaces in this config	U8 bConfigurationValue;	// Value to use in SetConfiguration command	U8 bConfiguration;	// Index of string desc describing this config	U8 bmAttributes;		// See CFG_DESC_ATTR_xxx values below	U8 bMaxPower;		// Power used by this config in 2mA units} tCONFIG_DESCRIPTOR, *ptCONFIG_DESCRIPTOR;// Bit definitions for CONFIG_DESCRIPTOR.bmAttributes#define CFG_DESC_ATTR_SELF_POWERED 0xc0	// Bit 6: If set, device is self powered, else bus powered#define CFG_DESC_ATTR_BUS_POWERED 0x80	// Bit 7: In USB1.1, this bit must be 1.#define CFG_DESC_ATTR_REMOTE_WAKE 0x20	// Bit 3: If set, device supports remote wakeup// INTERFACE_DESCRIPTOR structure#define SIZEOF_INTERFACE_DESCRIPTOR 0x09typedef struct _tagINTERFACE_DESCRIPTOR{	U8 bLength;		// Length of this descriptor (9h bytes)	U8 bDescriptorType;	// Type code of this descriptor (04h)	U8 bInterfaceNumber;	// Zero based index of interface in the configuration	U8 bAlternateSetting;	// Alternate setting number of this interface	U8 bNumEndpoints;	// Number of endpoint in this interface	U8 bInterfaceClass;	// Interface's base class code	U8 bInterfaceSubClass;	// Interface's sub class code	U8 bInterfaceProtocol;	// Interface's protocol type code	U8 bInterface;		// Index of string desc describing this interface} tINTERFACE_DESCRIPTOR, *ptINTERFACE_DESCRIPTOR;// HID Descriptor#define SIZEOF_HID_DESCRIPTOR 0x09typedef struct _tagHID_DESCRIPTOR{	U8 bLength;		// Length of this descriptor	U8 bDescriptorType;	// Type cod this descriptor (21h)	U16 bcdHID;		// HID spec version (BCD)	U8 bCountryCode;	// country code (BCD)	U8 bNumDescriptor;	// Number of sub descriptor	U8 bHidType;	// Type code of class descriptor	U16 wDescriptorLength;	// Total length of report } tHID_DESCRIPTOR, *ptHID_DESCRIPTOR;#define SIZEOF_REPORT_DESCRIPTOR 28// ENDPOINT_DESCRIPTOR structure#define SIZEOF_ENDPOINT_DESCRIPTOR 0x07typedef struct _tagENDPOINT_DESCRIPTOR{	U8 bLength;		// Length of this descriptor (7h bytes)	U8 bDescriptorType;	// Type code of this descriptor (05h)	U8 bEndpointAddress;	// See EP_DESC_ADDR_xxx values below	U8 bAttributes;		// See EP_DESC_ATTR_xxx value below	U16 wMaxPacketSize;	// Max packet size of endpoint	U8 bInterval;		// Polling interval of endpoint in milliseconds} tENDPOINT_DESCRIPTOR, *ptENDPOINT_DESCRIPTOR;// Bit definitions for EndpointDescriptor.EndpointAddr#define EP_DESC_ADDR_EP_NUM 0x0f	// Bit 3-0: Endpoint number#define EP_DESC_ADDR_DIR_IN 0x80	// Bit 7: Direction of endpoint, 1/0 = In/Out// Bit definitions for EndpointDescriptor.bAttributes#define EP_DESC_ATTR_TYPE_MASK 0x03	// Mask value for bits 1-0#define EP_DESC_ATTR_TYPE_CONT 0x00	// Bit 1-0: 00 = Endpoint does control transfers#define EP_DESC_ATTR_TYPE_ISOC 0x01	// Bit 1-0: 01 = Endpoint does isochronous transfers#define EP_DESC_ATTR_TYPE_BULK 0x02	// Bit 1-0: 10 = Endpoint does bulk transfers#define EP_DESC_ATTR_TYPE_INT 0x03	// Bit 1-0: 11 = Endpoint does interrupt transfers#define VID_L 0xe2#define VID_H 0x08#define PID_L 0x01#define PID_H 0x02#define SIZEOF_CONFIG_DESC_GROUP SIZEOF_CONFIG_DESCRIPTOR+SIZEOF_INTERFACE_DESCRIPTOR+SIZEOF_ENDPOINT_DESCRIPTOR*2+SIZEOF_HID_DESCRIPTOR/* USB.C */// usb standard requestvoid GetStatus(void);void ClearFeature(void);void USB_Reserved(void);void SetFeature(void);void SetAddress(void);void GetDescriptor(void);void SetDescriptor(void);void GetConfiguration(void);void SetConfiguration(void);void GetInterface(void);void SetInterface(void);void SyncFrame(void);// hid class requestvoid GetReport(void);void SetReport(void);void GetIdle(void);void SetIdle(void);void GetProtocol(void);void SetProtocol(void);void StallEndpoint0(void);void TransmitNullResponseOnEp0(void);void ControlHandler(void);void init_unconfig(void);void init_config(void);#endif /* _USB_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -