📄 fw.lst
字号:
167 void SetupCommand(void)
168 {
169 1 void *dscr_ptr;
170 1 DWORD i;
171 1
172 1 switch(SETUPDAT[1])
173 1 {
174 2 case SC_GET_DESCRIPTOR: // *** Get Descriptor
175 2 if(DR_GetDescriptor())
176 2 switch(SETUPDAT[3])
177 2 {
178 3 case GD_DEVICE: // Device
C51 COMPILER V7.01 FW 12/08/2004 16:34:03 PAGE 4
179 3 SUDPTRH = MSB(pDeviceDscr);
180 3 SUDPTRL = LSB(pDeviceDscr);
181 3 break;
182 3 case GD_CONFIGURATION: // Configuration
183 3 if(dscr_ptr = (void *)EZUSB_GetConfigDscr(SETUPDAT[2]))
184 3 {
185 4 SUDPTRH = MSB(dscr_ptr);
186 4 SUDPTRL = LSB(dscr_ptr);
187 4 }
188 3 else
189 3 EZUSB_STALL_EP0(); // Stall End Point 0
190 3 break;
191 3 case GD_STRING: // String
192 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
193 3 {
194 4 // Workaround for rev D errata number 8
195 4 // If you're certain that you will never run on rev D,
196 4 // you can just do this:
197 4 // SUDPTRH = MSB(dscr_ptr);
198 4 // SUDPTRL = LSB(dscr_ptr);
199 4 STRINGDSCR *sdp;
200 4 BYTE len;
201 4
202 4 sdp = dscr_ptr;
203 4
204 4 len = sdp->length;
205 4 if (len > SETUPDAT[6])
206 4 len = SETUPDAT[6]; //limit to the requested length
207 4
208 4 while (len)
209 4 {
210 5 for(i=0; i<min(len,64); i++)
211 5 *(IN0BUF+i) = *((BYTE xdata *)sdp+i);
212 5
213 5 //set length and arm Endpoint
214 5 EZUSB_SET_EP_BYTES(IN0BUF_ID,min(len,64));
215 5 len -= min(len,64);
216 5
217 5 // Wait for it to go out (Rev C and above)
218 5 while(EP0CS & 0x04)
219 5 ;
220 5 }
221 4
222 4 // Arm a 0 length packet just in case. There was some reflector traffic about
223 4 // Apple hosts asking for too much data. This will keep them happy and will
224 4 // not hurt valid hosts because the next SETUP will clear this.
225 4 EZUSB_SET_EP_BYTES(IN0BUF_ID,0);
226 4 // Clear the HS-nak bit
227 4 EP0CS = bmHS;
228 4 }
229 3 else
230 3 EZUSB_STALL_EP0(); // Stall End Point 0
231 3 break;
232 3 default: // Invalid request
233 3 EZUSB_STALL_EP0(); // Stall End Point 0
234 3 }
235 2 break;
236 2 case SC_GET_INTERFACE: // *** Get Interface
237 2 DR_GetInterface();
238 2 break;
239 2 case SC_SET_INTERFACE: // *** Set Interface
240 2 DR_SetInterface();
C51 COMPILER V7.01 FW 12/08/2004 16:34:03 PAGE 5
241 2 break;
242 2 case SC_SET_CONFIGURATION: // *** Set Configuration
243 2 DR_SetConfiguration();
244 2 break;
245 2 case SC_GET_CONFIGURATION: // *** Get Configuration
246 2 DR_GetConfiguration();
247 2 break;
248 2 case SC_GET_STATUS: // *** Get Status
249 2 if(DR_GetStatus())
250 2 switch(SETUPDAT[0])
251 2 {
252 3 case GS_DEVICE: // Device
253 3 IN0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
254 3 IN0BUF[1] = 0;
255 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
256 3 break;
257 3 case GS_INTERFACE: // Interface
258 3 IN0BUF[0] = 0;
259 3 IN0BUF[1] = 0;
260 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
261 3 break;
262 3 case GS_ENDPOINT: // End Point
263 3 IN0BUF[0] = EPIO[EPID(SETUPDAT[4])].cntrl & bmEPSTALL;
264 3 IN0BUF[1] = 0;
265 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
266 3 break;
267 3 default: // Invalid Command
268 3 EZUSB_STALL_EP0(); // Stall End Point 0
269 3 }
270 2 break;
271 2 case SC_CLEAR_FEATURE: // *** Clear Feature
272 2 if(DR_ClearFeature())
273 2 switch(SETUPDAT[0])
274 2 {
275 3 case FT_DEVICE: // Device
276 3 if(SETUPDAT[2] == 1)
277 3 Rwuen = FALSE; // Disable Remote Wakeup
278 3 else
279 3 EZUSB_STALL_EP0(); // Stall End Point 0
280 3 break;
281 3 case FT_ENDPOINT: // End Point
282 3 if(SETUPDAT[2] == 0)
283 3 {
284 4 EZUSB_UNSTALL_EP( EPID(SETUPDAT[4]) );
285 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
286 4 }
287 3 else
288 3 EZUSB_STALL_EP0(); // Stall End Point 0
289 3 break;
290 3 }
291 2 break;
292 2 case SC_SET_FEATURE: // *** Set Feature
293 2 if(DR_SetFeature())
294 2 switch(SETUPDAT[0])
295 2 {
296 3 case FT_DEVICE: // Device
297 3 if(SETUPDAT[2] == 1)
298 3 Rwuen = TRUE; // Enable Remote Wakeup
299 3 else
300 3 EZUSB_STALL_EP0(); // Stall End Point 0
301 3 break;
302 3 case FT_ENDPOINT: // End Point
C51 COMPILER V7.01 FW 12/08/2004 16:34:03 PAGE 6
303 3 if(SETUPDAT[2] == 0)
304 3 EZUSB_STALL_EP( EPID(SETUPDAT[4]) );
305 3 else
306 3 EZUSB_STALL_EP0(); // Stall End Point 0
307 3 break;
308 3 }
309 2 break;
310 2 default: // *** Invalid Command
311 2 if(DR_VendorCmnd())
312 2 EZUSB_STALL_EP0(); // Stall End Point 0
313 2 }
314 1
315 1 // Acknowledge handshake phase of device request
316 1 // Required for rev C does not effect rev B
317 1 EP0CS |= bmBIT1;
318 1 }
319
320 // Wake-up interrupt handler
321 void resume_isr(void) interrupt WKUP_VECT
322 {
323 1 EZUSB_CLEAR_RSMIRQ();
324 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1177 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 27
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -