51单片机各类源程序集锦
源代码在线查看: usb.h
//***********************************************************************
// *
// P H I L I P S P R O P R I E T A R Y *
// *
// COPYRIGHT (c) 1999 BY PHILIPS SINGAPORE (APIC). *
// -- ALL RIGHTS RESERVED -- *
// *
// File Name : USB.h *
// Author : Albert Goh *
// Created : 3 March 2000 *
// *
//***********************************************************************
//***********************************************************************
// *
// Module History *
// ************** *
// *
// Date Version Author Changes *
// ==== ======= ====== ======= *
// 030300 0.1 Albert Created *
// *
// *
//***********************************************************************
//#define ENDPT_NUMBER 8
//#define INTERFACE_NO 2
#define ENDPT_NUMBER 4
#define INTERFACE_NO 1
#define SWAP(x) ((((x) & 0xFF) > 8) & 0xFF))
#define CONFIG_LENGTH sizeof(CONFIGURATION_DESCRIPTOR) + \
(INTERFACE_NO * sizeof(INTERFACE_DESCRIPTOR)) + \
(ENDPT_NUMBER * sizeof(ENDPOINT_DESCRIPTOR))
typedef struct DEVICE_DESCRIPTOR
{
UC bLength;
UC bDescriptorType;
UI bcdUSB;
UC bDeviceClass;
UC bDeviceSubClass;
UC bDeviceProtocol;
UC bMaxPacketSize0;
UI idVendor;
UI idProduct;
UI bcdDevice;
UC iManufacturer;
UC iProduct;
UC iSerialNumber;
UC bNumConfigurations;
} DEVICE_DESCRIPTOR;
typedef struct HS_DEVICE_QUALIFIER
{
UC bLength; //length of HS Device Descriptor
UC bQualifier; //HS Device Qualifier Type
UI wVersion; // USB 2.0 version
UC bDeviceClass; //Device class
UC bDeviceSubClasss; //Device SubClass
UC bProtocol; //Device Protocol Code
UC MaxPktSize; //Maximum Packet SIze for other speed
UC bOther_Config; //Number of Other speed configurations
UC Reserved; //Reserved
}HS_DEVICE_QUALIFIER;
typedef struct CONFIGURATION_DESCRIPTOR
{
UC bLength;
UC bDescriptorType;
UI wTotalLength;
UC bNumInterfaces;
UC bConfigurationValue;
UC iConfiguration;
UC bmAttributes;
UC MaxPower;
} CONFIGURATION_DESCRIPTOR;
typedef struct OTHER_SPEED_CONFIG_DESCRIPTOR
{
UC bLength; //length of other speed configuration descriptor
UC bDescriptorType; //Other speed configuration Type
UI bTotalLength; //Total length
UC No_Interface; //No of interface supported
UC Configuration_Value; //Configuration Value
UC String_Index_Descriptor; //Index of string descriptor
UC Config_Characteristic; //Configurations Characteristic
UC Max_Power; //Maximun Power
}OTHER_SPEED_CONFIG_DESCRIPTOR;
typedef struct INTERFACE_DESCRIPTOR
{
UC bLength;
UC bDescriptorType;
UC bInterfaceNumber;
UC bAlternateSetting;
UC bNumEndpoints;
UC bInterfaceClass;
UC bInterfaceSubClass;
UC bInterfaceProtocol;
UC iInterface;
} INTERFACE_DESCRIPTOR;
typedef struct ENDPOINT_DESCRIPTOR
{
UC bLength;
UC bDescriptorType;
UC bEndpointAddress;
UC bmAttributes;
UI wMaxPacketSize;
UC bInterval;
} ENDPOINT_DESCRIPTOR;
typedef struct STRING_ID
{
UC bLength;
UC bDescriptorType;
UC bString[2];
} STRING_ID;
typedef struct STRING_DESCRIPTOR
{
UC bLength;
UC bDescriptorType;
UC bString[30];
} STRING_DESCRIPTOR;