usb driver, sample for usb driver develop. rised for reference

源代码在线查看: usb100.h

软件大小: 141 K
上传用户: hwyzy
关键词: driver usb for reference
下载地址: 免注册下载 普通下载 VIP

相关代码

				/***************************************************************************
				* C Source Header File:  USB100.H
				*
				* Copyright 2001 DeVaSys
				* All rights are reserved.
				* No part of this document may be reproduced, stored, or transmitted in any
				* form or by any means without the prior written permission of DeVaSys
				*
				* Description:
				*
				* This header contains declarations and defines pertaining to items defined
				* in the USB 1.0 specification.
				*
				* ........................ Revision History ................................
				*
				* Creation date: 02/22/2001 - Michael A. DeVault, DeVaSys
				*
				* Revision History Summary:
				*
				* Rev 1.0   22 February 2001 12:00:00   mad
				*   Initial revision.
				*
				***************************************************************************/
				/* following ifndef is for skipping double includes of this header file */
				#if !defined(__USB100_H)
					#define __USB100_H
				
				#include "portable.h"
				
				
				#define USB_REQUEST_TYPE_MASK    (unsigned char)0x60
				#define USB_STANDARD_REQUEST     (unsigned char)0x00
				#define USB_CLASS_REQUEST        (unsigned char)0x20
				#define USB_VENDOR_REQUEST       (unsigned char)0x40
				
				#define USB_REQUEST_MASK         (unsigned char)0x0F
				
				#define MAXIMUM_USB_STRING_LENGTH 255
				
				/* values for the bits returned by the USB GET_STATUS command */
				#define USB_GETSTATUS_SELF_POWERED                0x01
				#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED       0x02
				
				
				#define USB_DEVICE_DESCRIPTOR_TYPE                0x01
				#define USB_CONFIGURATION_DESCRIPTOR_TYPE         0x02
				#define USB_STRING_DESCRIPTOR_TYPE                0x03
				#define USB_INTERFACE_DESCRIPTOR_TYPE             0x04
				#define USB_ENDPOINT_DESCRIPTOR_TYPE              0x05
				#define USB_POWER_DESCRIPTOR_TYPE                 0x06
				
				#define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((WORD)((WORD)d				
				/*
					Values for bmAttributes field of an
					endpoint descriptor
				*/
				
				#define USB_ENDPOINT_TYPE_MASK                    0x03
				
				#define USB_ENDPOINT_TYPE_CONTROL                 0x00
				#define USB_ENDPOINT_TYPE_ISOCHRONOUS             0x01
				#define USB_ENDPOINT_TYPE_BULK                    0x02
				#define USB_ENDPOINT_TYPE_INTERRUPT               0x03
				
				
				/*
					definitions for bits in the bmAttributes field of a
					configuration descriptor.
				*/
				#define USB_CONFIG_POWERED_MASK                   0xc0
				
				#define USB_CONFIG_BUS_POWERED                    0x80
				#define USB_CONFIG_SELF_POWERED                   0x40
				#define USB_CONFIG_REMOTE_WAKEUP                  0x20
				
				/*
					Endpoint direction bit, stored in address
				*/
				
				#define USB_ENDPOINT_DIRECTION_MASK               0x80
				
				/*
					test direction bit in the bEndpointAddress field of
					an endpoint descriptor.
				*/
				#define USB_ENDPOINT_DIRECTION_OUT(addr)          (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
				#define USB_ENDPOINT_DIRECTION_IN(addr)           ((addr) & USB_ENDPOINT_DIRECTION_MASK)
				
				/*
					USB defined request codes
					see chapter 9 of the USB 1.0 specifcation for
					more information.
				*/
				
				/*
					These are the correct values based on the USB 1.0
					specification
				*/
				#define USB_REQUEST_GET_STATUS                    0x00
				#define USB_REQUEST_CLEAR_FEATURE                 0x01
				
				#define USB_REQUEST_SET_FEATURE                   0x03
				
				#define USB_REQUEST_SET_ADDRESS                   0x05
				#define USB_REQUEST_GET_DESCRIPTOR                0x06
				#define USB_REQUEST_SET_DESCRIPTOR                0x07
				#define USB_REQUEST_GET_CONFIGURATION             0x08
				#define USB_REQUEST_SET_CONFIGURATION             0x09
				#define USB_REQUEST_GET_INTERFACE                 0x0A
				#define USB_REQUEST_SET_INTERFACE                 0x0B
				#define USB_REQUEST_SYNC_FRAME                    0x0C
				
				
				/*
					defined USB device classes
				*/
				#define USB_DEVICE_CLASS_RESERVED           0x00
				#define USB_DEVICE_CLASS_AUDIO              0x01
				#define USB_DEVICE_CLASS_COMMUNICATIONS     0x02
				#define USB_DEVICE_CLASS_HUMAN_INTERFACE    0x03
				#define USB_DEVICE_CLASS_MONITOR            0x04
				#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
				#define USB_DEVICE_CLASS_POWER              0x06
				#define USB_DEVICE_CLASS_PRINTER            0x07
				#define USB_DEVICE_CLASS_STORAGE            0x08
				#define USB_DEVICE_CLASS_HUB                0x09
				#define USB_DEVICE_CLASS_VENDOR_SPECIFIC    0xFF
				
				/*
					USB defined Feature selectors
				*/
				#define USB_FEATURE_ENDPOINT_STALL          0x0000
				#define USB_FEATURE_REMOTE_WAKEUP           0x0001
				#define USB_FEATURE_POWER_D0                0x0002
				#define USB_FEATURE_POWER_D1                0x0003
				#define USB_FEATURE_POWER_D2                0x0004
				#define USB_FEATURE_POWER_D3                0x0005
				
				typedef packed struct _USB_DEVICE_DESCRIPTOR {
						BYTE bLength;
						BYTE bDescriptorType;
						WORD bcdUSB;
						BYTE bDeviceClass;
						BYTE bDeviceSubClass;
						BYTE bDeviceProtocol;
						BYTE bMaxPacketSize0;
						WORD idVendor;
						WORD idProduct;
						WORD bcdDevice;
						BYTE iManufacturer;
						BYTE iProduct;
						BYTE iSerialNumber;
						BYTE bNumConfigurations;
				} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
				
				typedef packed struct _USB_ENDPOINT_DESCRIPTOR {
						BYTE bLength;
						BYTE bDescriptorType;
						BYTE bEndpointAddress;
						BYTE bmAttributes;
						WORD wMaxPacketSize;
						BYTE bInterval;
				} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
				
				/*
					values for bmAttributes Field in
					USB_CONFIGURATION_DESCRIPTOR
				*/
				#define BUS_POWERED                           0x80
				#define SELF_POWERED                          0x40
				#define REMOTE_WAKEUP                         0x20
				
				typedef packed struct _USB_CONFIGURATION_DESCRIPTOR {
						BYTE bLength;
						BYTE bDescriptorType;
						WORD wTotalLength;
						BYTE bNumInterfaces;
						BYTE bConfigurationValue;
						BYTE iConfiguration;
						BYTE bmAttributes;
						BYTE MaxPower;
				} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
				
				typedef packed struct _USB_INTERFACE_DESCRIPTOR {
						BYTE bLength;
						BYTE bDescriptorType;
						BYTE bInterfaceNumber;
						BYTE bAlternateSetting;
						BYTE bNumEndpoints;
						BYTE bInterfaceClass;
						BYTE bInterfaceSubClass;
						BYTE bInterfaceProtocol;
						BYTE iInterface;
				} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
				
				typedef packed struct _USB_STRING_DESCRIPTOR {
						BYTE bLength;
						BYTE bDescriptorType;
						BYTE bString[MAXIMUM_USB_STRING_LENGTH];
				} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
				
				/*
					USB power descriptor added to core specification
				*/
				#define USB_SUPPORT_D0_COMMAND      0x01
				#define USB_SUPPORT_D1_COMMAND      0x02
				#define USB_SUPPORT_D2_COMMAND      0x04
				#define USB_SUPPORT_D3_COMMAND      0x08
				
				#define USB_SUPPORT_D1_WAKEUP       0x10
				#define USB_SUPPORT_D2_WAKEUP       0x20
				
				
				typedef packed struct _USB_POWER_DESCRIPTOR {
						BYTE bLength;
						BYTE bDescriptorType;
						BYTE bCapabilitiesFlags;
						WORD EventNotification;
						WORD D1LatencyTime;
						WORD D2LatencyTime;
						WORD D3LatencyTime;
						BYTE PowerUnit;
						WORD D0PowerConsumption;
						WORD D1PowerConsumption;
						WORD D2PowerConsumption;
				} USB_POWER_DESCRIPTOR, *PUSB_POWER_DESCRIPTOR;
				
				
				typedef packed struct _USB_COMMON_DESCRIPTOR {
						BYTE bLength;
						BYTE bDescriptorType;
				} USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
				
				
				/*
					Standard USB HUB definitions
					See Chapter 11
				*/
				typedef packed struct _USB_HUB_DESCRIPTOR {
						BYTE        bDescriptorLength;      /* Length of this descriptor */
						BYTE        bDescriptorType;        /* Hub configuration type */
						BYTE        bNumberOfPorts;         /* number of ports on this hub */
						WORD       wHubCharacteristics;    /* Hub Charateristics */
						BYTE        bPowerOnToPowerGood;    /* port power on till power good in 2ms */
						BYTE        bHubControlCurrent;     /* max current in mA */
						/* room for 255 ports power control and removable bitmask */
						BYTE        bRemoveAndPowerMask[64];
				} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
				
				
				/* following endif is for skipping double includes of this header file */
				#endif
							

相关资源