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

📄 usb_descriptor.h

📁 基於MCU c51/8051 讀寫SD/MMC card 再以USB 傳回電腦的範例程序
💻 H
字号:
/* ELEC254 Group32 USB SD Card Reader */
#ifndef __USB_Descriptor_H__
#define __USB_Descriptor_H__

#define  U8 unsigned char
#define U16 unsigned int
#define U32 unsigned long

/*USB Descriptor*/
typedef struct
{
	U8  bLength;							//Descriptor Size =12H
#define USB_Device_Descriptor_Size	0x12
	U8  bDescriptorType;					//Device Descriptor Type =01H
#define USB_Device_Descriptor_Type	0x01
	U16 bcdUSB;								//USB BCD code
#define USB_11						0x0110
#define USB_20						0x0200
	U8  bDeviceClass;						//USB Device Class
#define Default_DeviceClass			0x00
	U8  bDeviceSubClass;					//USB Device SubClass
#define Default_DeviceSubClass		0x00
	U8  bDeviceProtocol;					//USB Device protocol
#define Default_DeviceProtocol		0x00
	U8  bMaxPacketSize0;					//port 0 packet size(8.16.32.64), Max Packet Size of End Point 0
#define	Endpoint0_Packet_Size		0x10
	U16 idVendor;							//Vendor ID
#define Philip_IdVendor				0x0471
	U16 idProduct;							//Product ID
#define Default_IdProduct			0x0001
	U16 bcdDevice;							//Device code BCD
#define Default_BcdDevice			0x0001
	U8  iManufacturer;						//Index of Manufacturer Descriptor
#define No_Index					0x00
	U8  iProduct;							//Index of Product Descriptor
	U8  iSerialNumber;						//Index of Serial Number Descriptor
	U8  bNumConfigurations;					//The Number of Configuations
}USB_Device_Descriptor;


/*Interface Descriptor*/
typedef struct
{
	U8  bLength;								//Interface length =09H
#define USB_Interface_Descriptor_Size	0x09
	U8  bDescriptorType;						//Interface type=04H
#define USB_Interface_Descriptor_Type	0x04
	U8  bInterfaceNumber;						//Interface Number
	U8  bAlternateSetting;						//Alternate Setting
	U8  bNumEndpoint;							//Number of End Point, except 0
#define Endpoint_Count					0x02
	U8  bInterfaceClass;						//Interface Class, assign by USB
#define	UsbClassMassStorage				0x08
	U8  bInterfaceSubClass;						//Interface Sub Class, assign by USB
#define	UsbSubClassRbc					0x01
#define	UsbSubClassSff8020i				0x02
#define	UsbSubClassQic157				0x03
#define	UsbSubClassUfi					0x04
#define	UsbSubClassSff8070i				0x05
#define	UsbSubClassScsi					0x06
	U8  bInterfaceProtocol;						//Interface Protocol, assign by USB
#define	UsbProtocolCbi0					0x00
#define	UsbProtocolCbi1					0x01
#define	UsbProtocolBulk					0x50
	U8  iInterface;								//Interface index
}USB_Interface_Descriptor;

/*Endpoint Descriptor*/
typedef struct
{
	U8  bLength;									//Endpoint Descriptor Length=07H
#define	USB_Endpoint_Descriptor_Size        0x07
	U8  bDescriptorType;							//Endpoint Descriptor Type=05H
#define	USB_Endpoint_Descriptor_Type        0x05
	U8  bEndpointAddress;							//USB Endpoint Address: Bit0~3:Point Number ; Bit4~6:Reserve =0; Bit7:Direction 0:Out 1:In
#define Endpoint_In(n)						0x80|n
#define Endpoint_Out(n)						0x00|n
	U8  bmAttributes;								//Point Attributes Bit0~1: 0:Control; 1:Sync ;2: Batch; 3:Interrupt.其Other Reserve
#define	UsbEndpControl						0x00
#define	UsbEndpIsochronous					0x01
#define	UsbEndpBulk							0x02
#define	UsbEndpInterrupt					0x03 
	U16 wMaxPacketSize;								//EndPoint  Packet Size
#define	Endpoint2_Packet_Size				0x0040
	U8  bInterval;									//EndPoint Time Interval
#define Default_Interval					0x00
}USB_Endpoint_Descriptor;

/*String_Descriptor*/
typedef struct
{
	U8  bLength;									//String_Descriptor Length
	U8  bDescriptorType;							//String_Descriptor Type
#define USB_String_Descriptor_Type          0x03
	U16 * bString;									//Unicode string
}USB_String_Descriptor;


/*Configuration_Descriptor*/
typedef struct
{
	U8  bLength;									//Configuration_Descriptor Length =09H
#define USB_Configuration_Descriptor_Size	0x09
	U8  bDescriptorType;							//Configuration_Descriptor Type =02H
#define USB_Configuration_Descriptor_Type	0x02
	U16 wTotalLength;								//Configuration_Descriptor Total Length
#define USB_Total_Configuration_Descriptor_Size	USB_Configuration_Descriptor_Size+USB_Interface_Descriptor_Size+Endpoint_Count*USB_Endpoint_Descriptor_Size
	U8  bNumInterfaces;								//Number of Interface
	U8  bConfigurationValue;						//Set Configuration 
	U8  iConfiguration;								//Configuration index
	U8  bmAttributes;								//Attributes:D7--Bus Power; D6--Self Power; D5--Remote Awake; D4-D0 Reserved 0 at reset.
#define Bus_Power							0x80
#define Self_Power							0x40
#define Remote_Awake						0x20
	U8  MaxPower;									//Max Power, Unit is 2mA
#define PowerConsumption_Nma(n)				(U8)(n/2)
}USB_Configuraton_Descriptor;

#endif

⌨️ 快捷键说明

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