📄 protocol.lst
字号:
C51 COMPILER V7.01 PROTOCOL 02/17/2006 15:09:24 PAGE 1
C51 COMPILER V7.01, COMPILATION OF MODULE PROTOCOL
OBJECT MODULE PLACED IN PROTOCOL.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE PROTOCOL.C BROWSE MODP2 DEBUG OBJECTEXTEND
stmt level source
1
2 #include "InsUsb.h"
3
4 void SetDescriptor(void);
5 void RamControl(void);
6 void GetFirmWareVersion(void);
7 void SetDeviceSerialNumber(void);
8 void ControlOutDealWith(void);
9 void ControlOutComplete(void);
10 extern void D12SetDMA(unsigned char bValue);
11 extern void D12ReadCurrentFrameNumber(unsigned char *pBuffer);
12 extern unsigned char xdata mRamBuffer[RAM_BUFFER_SIZE];
13
14 //follow is descriptor :
15 USB_DEVICE_DESCRIPTOR code D12_DEVICE_DESCRIPTOR =
16 {
17 sizeof(USB_DEVICE_DESCRIPTOR), //bLength;
18 USB_DEVICE_DESCRIPTOR_TYPE, //bDescriptorType;
19 WORD_SWAP(0x0100), //bcdUSB;ver1.1,note high and low byte should WORD_SWAP
20 0xDC, //bDeviceClass;vendor specific
21 0x00, //bDeviceSubClass;
22 0x00, //bDeviceProtocol;
23 D12_EP0_MAX_PACKET_SIZE, //bMaxPacketSize0;
24 WORD_SWAP(0x0471), //idVendor;philips vendor ID is 0x0471
25 WORD_SWAP(0xFFF0), //idProduct;production ID
26 WORD_SWAP(0x0100), //bcdDevice;
27 0x00, //iManufacturer;
28 0x00, //iProduct;
29 0x00, //iSerialNumber;
30 0x01 //bNumConfigurations;
31 };
32
33
34 struct {
35 USB_CONFIGURATION_DESCRIPTOR D12_CONFIGURATION_DESCRIPTOR;
36 USB_INTERFACE_DESCRIPTOR D12_INTERFACE_DESCRIPTOR;
37 USB_ENDPOINT_DESCRIPTOR D12_ENDPOINT_DESCRIPTOR[4];
38 } code D12_CONFIGURATION_INTERFACE_ENDPOINT_DESCRIPTOR =
39
40 {
41 {
42 sizeof(USB_CONFIGURATION_DESCRIPTOR), //bLength;
43 USB_CONFIGURATION_DESCRIPTOR_TYPE, //bDescriptorType;
44 WORD_SWAP(USB_CONFIGURATION_DESCRIPTOR_LENGTH), //wTotalLength;
45 0x01, //bNumInterfaces;
46 0x01, //bConfigurationValue;
47 0x00, //iConfiguration;
48 0x60, //bmAttributes;
49 0x01 //MaxPower;
50 },
51 {
52 sizeof(USB_INTERFACE_DESCRIPTOR), //bLength;
53 USB_INTERFACE_DESCRIPTOR_TYPE, //bDescriptorType;
54 0x00, //bInterfaceNumber;
55 0x00, //bAlternateSetting;
C51 COMPILER V7.01 PROTOCOL 02/17/2006 15:09:24 PAGE 2
56 0x04, //bNumEndpoints;
57 0x00, //bInterfaceClass;
58 0x00, //bInterfaceSubClass;
59 0x00, //bInterfaceProtocol;
60 0x00 //iInterface;
61 },
62 {
63 sizeof(USB_ENDPOINT_DESCRIPTOR), //bLength;
64 USB_ENDPOINT_DESCRIPTOR_TYPE, //bDescriptorType;
65 0x81, //bEndpointAddress;
66 USB_ENDPOINT_TYPE_INTERRUPT, //bmAttributes;
67 WORD_SWAP(D12_EP1_MAX_PACKET_SIZE), //wMaxPacketSize;
68 200, //bInterval;200ms
69
70
71 sizeof(USB_ENDPOINT_DESCRIPTOR), //bLength;
72 USB_ENDPOINT_DESCRIPTOR_TYPE, //bDescriptorType;
73 0x01, //bEndpointAddress;
74 USB_ENDPOINT_TYPE_INTERRUPT, //bmAttributes;
75 WORD_SWAP(D12_EP1_MAX_PACKET_SIZE), //wMaxPacketSize;
76 200, //bInterval;200ms
77
78 sizeof(USB_ENDPOINT_DESCRIPTOR), //bLength;
79 USB_ENDPOINT_DESCRIPTOR_TYPE, //bDescriptorType;
80 0x82, //bEndpointAddress;
81 USB_ENDPOINT_TYPE_BULK, //bmAttributes;
82 WORD_SWAP(D12_EP2_MAX_PACKET_SIZE), //wMaxPacketSize;
83 0, //bInterval;
84
85 sizeof(USB_ENDPOINT_DESCRIPTOR), //bLength;
86 USB_ENDPOINT_DESCRIPTOR_TYPE, //bDescriptorType;
87 0x02, //bEndpointAddress;
88 USB_ENDPOINT_TYPE_BULK, //bmAttributes;
89 WORD_SWAP(D12_EP2_MAX_PACKET_SIZE), //wMaxPacketSize;
90 0 //bInterval;
91 }};
92
93
94 extern SYS_INFORMATION data sSysInformation;
95
96 extern unsigned char xdata mEp0OutBuffer[EP0_OUT_BUFFER_SIZE];
97 extern unsigned char data mEp0InBuffer[EP0_IN_BUFFER_SIZE];
98 extern unsigned char data mEp1OutBuffer[EP1_OUT_BUFFER_SIZE]; //store led status
99 extern unsigned char data mEp1InBuffer[EP1_IN_BUFFER_SIZE]; //store switch status
100 extern unsigned char xdata mSerialNumber[4];
101
102
103 extern void D12SetAddressEnable(unsigned char bAddress, unsigned char bEnable);
104 extern void D12SetEndpointEnable(unsigned char bEndpointEnable);
105 extern void D12WriteBuffer(unsigned char bEndpointIndex,unsigned char bLength, unsigned char * pBuffer);
106 extern void D12SetEndpointStatus(unsigned char bEndpointIndex, unsigned char bStalled);
107 extern unsigned char D12SelectEndpoint(unsigned char bEndpointIndex);
108
109
110 ////////////////////////////////////////////////////////////////////////////
111 ////////////////////////////USB standard request////////////////////////////
112
113 //
114 //*************************************************************************
115 // Parameter:
116 // In : None
117 // Out: None
C51 COMPILER V7.01 PROTOCOL 02/17/2006 15:09:24 PAGE 3
118 // Function:
119 // GetStatus will return two bytes,see USB1.1 specification "9.4.5"
120 void GetStatus(void)
121 {
122 1 unsigned char data bEndpointIndex;
123 1 unsigned char data bRecipient;
124 1 unsigned char data bSlectEndpoint;
125 1
126 1 //bRecipient is used to judge the recipient of SetUp packet is device/interface/endpoint or other
127 1 bRecipient = sSysInformation.sUsbDeviceRequest.bmRequestType & 0x1F;
128 1 if (bRecipient >2) //not supported request,and stall endpoint0
129 1 {
130 2 CONTROL_ENDPOINT_STALL //set control endpoint stall
131 2 }
132 1 else
133 1 {
134 2 if (bRecipient == 0) //if recipient is device
135 2 {
136 3 if(sSysInformation.bRemoteWakeUpEnable == TRUE)
137 3 mEp0InBuffer[0]=0x03; //self powered,remote wakeup enabled
138 3 else mEp0InBuffer[0]=0x01; //self powered,remote wakeup disabled
139 3
140 3 mEp0InBuffer[1]=0x00; //the second byte always is 0x00
141 3 #ifdef _Debug_
142 3 printf("GetStatus: Remote wakeup is %x.\n",(unsigned int)(mEp0InBuffer[0] & 0x02));
143 3 #endif
144 3 }
145 2 else if (bRecipient == 1) //else if recipient is interface
146 2 {
147 3 mEp0InBuffer[0]=0x00; //always return two bytes: 0x00,0x00
148 3 mEp0InBuffer[1]=0x00;
149 3 }
150 2 else // if (bRecipient == 2)
151 2 {
152 3 //when the recipient of GetStatus is endpoint
153 3 //the wIndex will express the endpoint direction and endpoint number,see "9.3.4"
154 3 bEndpointIndex = (unsigned char)(sSysInformation.sUsbDeviceRequest.wIndex) & 0x0F;
155 3 if (sSysInformation.sUsbDeviceRequest.wIndex & 0x80)
156 3 bSlectEndpoint = D12SelectEndpoint(bEndpointIndex*2 + 1); //if wIndex direction bit is 1,select
157 3 //endpoint index 1/3/5,and read one byte
158 3 else
159 3 bSlectEndpoint = D12SelectEndpoint(bEndpointIndex*2); //else select endpoint 0/2/4,
160 3 if(bSlectEndpoint & 0x02)
161 3 //if the bit1 of byte that read back is 1,this endpoint is in stall status,namely,halt status
162 3 mEp0InBuffer[0]=0x01;
163 3 else
164 3 mEp0InBuffer[0]=0x00; //else not halt
165 3 mEp0InBuffer[1] = 0x00; //the second byte will return is always 0x00
166 3
167 3 #ifdef _Debug_
168 3 printf("GetStatus: Endpoint status is %x.\n",(unsigned int)(mEp0InBuffer[0]));
169 3 #endif
170 3
171 3 }
172 2
173 2 D12WriteBuffer(D12_SELECT_ENDPOINT_CONTROL_IN,0x02,&mEp0InBuffer);
174 2 }
175 1 sSysInformation.sUsbSetUpDealwith.wRemaindLength = 0;
176 1 }
177 //
178 //*************************************************************************
179 // Parameter:
C51 COMPILER V7.01 PROTOCOL 02/17/2006 15:09:24 PAGE 4
180 // In : None
181 // Out: None
182 // Function:
183 // ClearFeature,see "9.4.1"
184 void ClearFeature(void)
185 {
186 1 unsigned char bEndpointIndex;
187 1 unsigned char bRecipient;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -