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

📄 chap9.h

📁 zlg_fs.rar
💻 H
字号:
/*
**
**  These are chapter9 related
**
*/
#ifndef _CAHP9_H
#define _CAHP9_H


/****************************************************************************/
/*	constants (1/2)															*/
/****************************************************************************/

/*	bRequest	*/
//	Table 9-4. Standard Request Codes

#define		GET_STATUS					0
#define		CLEAR_FEATURE				1
#define		Reserved_for_future_use_2	2
#define		SET_FEATURE					3
#define		Reserved_for_future_use_4	4
#define		SET_ADDRESS					5
#define		GET_DESCRIPTOR				6
#define		SET_DESCRIPTOR				7
#define		GET_CONFIGURATION			8
#define		SET_CONFIGURATION			9
#define		GET_INTERFACE				10
#define		SET_INTERFACE				11
#define		SYNCH_FRAME					12


/*
 *  Standard Device Requests
 *      std_Dv_request_...(15:08)   = Standard Device Requests; Sec 9.4, Table 9-3, page250
 *      std_Dv_request_...(07:00)   = Standard Request Codes;   Sec 9.4, Table 9-4, page251
 */

#define     std_Dv_request_CLEAR_FEATURE_Dv       0x0001
#define     std_Dv_request_CLEAR_FEATURE_If         0x0101
#define     std_Dv_request_CLEAR_FEATURE_Ep        0x0201
#define     std_Dv_request_GET_CONFIGURATION    0x8008
#define     std_Dv_request_GET_DESCRIPTOR         	0x8006
#define     std_Dv_request_GET_INTERFACE              	0x810A
#define     std_Dv_request_GET_STATUS_Dv            	0x8000
#define     std_Dv_request_GET_STATUS_If            0x8100
#define     std_Dv_request_GET_STATUS_Ep            0x8200
#define     std_Dv_request_SET_ADDRESS              0x0005
#define     std_Dv_request_SET_CONFIGURATION        0x0009
#define     std_Dv_request_SET_DESCRIPTOR           0x0007
#define     std_Dv_request_SET_FEATURE_Dv           0x0003
#define     std_Dv_request_SET_FEATURE_If           0x0103
#define     std_Dv_request_SET_FEATURE_Ep           0x0203
#define     std_Dv_request_SET_INTERFACE            0x010B
#define     std_Dv_request_SYNCH_FRAME              0x820C


/*
 *  Descriptor Types
 *      Sec 9.4, Table 9-5, page251
 */


#define     descriptor_type_DEVICE                      0x0100
#define     descriptor_type_CONFIGURATION               0x0200
#define     descriptor_type_STRING                      0x0300
#define     descriptor_type_INTERFACE                   0x0400
#define     descriptor_type_ENDPOINT                    0x0500
#define     descriptor_type_DEVICE_QUALIFIER            0x0600
#define     descriptor_type_OTHER_SPEED_CONFIGURATION   0x0700
#define     descriptor_type_INTERFACE_POWER             0x0800


/****************************************************************************/
/*	types																	*/
/****************************************************************************/

/*
 *  Standard USB Descriptor Definitions
 *      Sec 9.6, page 261
 */

typedef struct  std_dev_desc    {   /*  Sec9.6.1, Table 9-8, p262   */

                                    unsigned char   bLength;
                                    unsigned char   bDescriptorType;
                                    unsigned short  bcdUSB;
                                    unsigned char   bDeviceClass;
                                    unsigned char   bDeviceSubClass;
                                    unsigned char   bDeviceProtocol;
                                    unsigned char   bMaxPacketSize0;
                                    unsigned short  idVendor;
                                    unsigned short  idProduct;
                                    unsigned short  bcdDevice;
                                    unsigned char   iManufacturer;
                                    unsigned char   iProduct;
                                    unsigned char   iSerialNumber;
                                    unsigned char   bNumConfigurations;
                                }
                                std_dev_descriptor;

typedef struct  dev_qual_desc   {   /*  Sec 9.6.2, Table 9-9, p264  */
                                    /*  This is for Hi-speed        */

                                    unsigned char   bLength;
                                    unsigned char   bDescriptorType;
                                    unsigned short  bcdUSB;
                                    unsigned char   bDeviceClass;
                                    unsigned char   bDeviceSubClass;
                                    unsigned char   bDeviceProtocol;
                                    unsigned char   bMaxPacketSize0;
                                    unsigned char   bNumConfigurations;
                                }
                                dev_qualifier_descriptor;

typedef struct  std_conf_desc   {   /*  Sec9.6.3, Table 9-10, p265  */

                                    unsigned char   bLength;
                                    unsigned char   bDescriptorType;
                                    unsigned short  wTotalLength;
                                    unsigned char   bNumInterfaces;
                                    unsigned char   bConfigurationValue;
                                    unsigned char   iConfiguration;
                                    unsigned char   bmAttributes;
                                    unsigned char   bMaxPower;
                                }
                                std_conf_descriptor;

typedef std_conf_descriptor     other_speed_conf_descriptor;    /*  Sec9.6.4, Table 9-11, p267  */

typedef struct  std_if_desc     {   /*  Sec9.6.5, Table 9-12, p268  */

                                    unsigned char   bLength;
                                    unsigned char   bDescriptorType;
                                    unsigned char   bInterfaceNumber;
                                    unsigned char   bAlternateSetting;
                                    unsigned char   bNumEndpoints;
                                    unsigned char   bInterfaceClass;
                                    unsigned char   bInterfaceSubClass;
                                    unsigned char   bInterfaceProtocol;
                                    unsigned char   iInterface;
                                }
                                std_interface_descriptor;

typedef struct  std_ep_desc     {   /*  Sec9.6.6, Table 9-13, p269  */

                                    unsigned char   bLength;
                                    unsigned char   bDescriptorType;
                                    unsigned char   bEndpointAddress;
                                    unsigned char   bmAttributes;
                                    unsigned short  wMaxPacketSize;
                                    unsigned char   bInterval;
                                }
                                std_endpoint_descriptor;

typedef struct  std_str_desc    {   /*  Sec9.6.7, Table 9-15, p273  */

                                    unsigned char   bLength;
                                    unsigned char   bDescriptorType;
                                    unsigned short  bString;			//	bString[ (254) >> 1 ];
                                }
                                std_string_descriptor;



/****************************************************************************/
/*	constants (2/2)															*/
/****************************************************************************/

/*
 *  Data conversions constants, macro
 */

/*  Configuration   */

#define     bMaxPower_to_mA( x )                			((x) << 1)

#define     bmAttributes_SelfPowered            			0x40
#define     bmAttributes_RemoteWakeup           			0x20

/*  Endpoint    */

#define     EpNum_bEndAdd( x )      			((x) & 0x0F)
#define     EpDir_bEndAdd( x )   			(((x) & 0x80) >> 7)

#define     Ep_Direction_OUT_ENDPOINT           			0
#define     Ep_Direction_IN_ENDPOINT            			1
#define     Ep_Direction_CONTROL_ENDPOINT      				2

#define     Ep_TranType_bmAttr( x )   			((x) & 0x03)

#define     Ep_TransferType_Control             			0x0
#define     Ep_TransferType_Isochronous         			0x1
#define     Ep_TransferType_Bulk                			0x2
#define     Ep_TransferType_Interrupt           			0x3

#define     Ep_SynchronizationType_bmAttributes( x )        (((x) & 0x03) >> 2)

#define     Ep_SynchronizationType_NoSynchronization    	0x0
#define     Ep_SynchronizationType_Asynchronous         	0x1
#define     Ep_SynchronizationType_Adaptive             	0x2
#define     Ep_SynchronizationType_Synchronous          	0x3

#define     Ep_UsageType_bmAttributes( x )					(((x) & 0x03) >> 4)

#define     Ep_UsageType_Data                   			0x0
#define     Ep_UsageType_Feedback               			0x1
#define     Ep_UsageType_ImplicitFB             			0x2


#endif

⌨️ 快捷键说明

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