📄 f32x_usb_standard_requests.lst
字号:
257
258 //-----------------------------------------------------------------------------
259 // SetInterfaceRequest
260 //-----------------------------------------------------------------------------
261 //
262 // Return Value : None
263 // Parameters : None
264 //
265 //-----------------------------------------------------------------------------
266 void SetInterfaceRequest()
267 {
268 1 /*
269 1 // Length field must be zero
270 1 if ((gEp0Command.wLength.i) || (gDeviceStatus.bDevState != DEV_CONFIG))
271 1 bEpState = EP_ERROR;
272 1
273 1 else
274 1 {
275 1 // Check that target interface exists for this configuration
276 1 if(gEp0Command.wIndex.i > gDeviceStatus.bNumInterf - 1)
277 1 bEpState = EP_ERROR;
278 1
279 1 else
280 1 {
281 1 // Get pointer to interface status structure
282 1 pIfStatus = (PIF_STATUS)&gDeviceStatus.IfStatus;
283 1
284 1 // Check that alternate setting exists for the interface
285 1 if (gEp0Command.wValue.i > pIfStatus->bNumAlts)
286 1 bEpState = EP_ERROR;
287 1
288 1 // Assign alternate setting
289 1 else
290 1 {
291 1 pIfStatus->bCurrentAlt = gEp0Command.wValue.i;
292 1 bEpState = SetInterface(pIfStatus);
293 1 }
294 1 }
295 1 }
296 1 gEp0Status.bEpState = bEpState;
297 1 */
298 1 }
299
300 //-----------------------------------------------------------------------------
301 // GetStatusRequest
302 //-----------------------------------------------------------------------------
303 //
C51 COMPILER V7.06 F32X_USB_STANDARD_REQUESTS 07/16/2008 15:35:21 PAGE 6
304 // Return Value : None
305 // Parameters : None
306 //
307 //-----------------------------------------------------------------------------
308 void GetStatusRequest ()
309 {
310 1 // Value field must be zero; Length field must be 2
311 1 if ((gEp0Command.wValue.i != 0) || (gEp0Command.wLength.i != 0x02) ||
312 1 (gDeviceStatus.bDevState == DEV_DEFAULT) ||
313 1 (gDeviceStatus.bDevState == DEV_ADDRESS && gEp0Command.wIndex.i != 0))
314 1 {
315 2 bEpState = EP_ERROR;
316 2 }
317 1
318 1 else
319 1 {
320 2 // Check for desired status (device, interface, endpoint)
321 2 switch (gEp0Command.bmRequestType & CMD_MASK_RECIP)
322 2 {
323 3 // Device
324 3 case CMD_RECIP_DEV:
325 3 // Index must be zero for a Device status request
326 3 if (gEp0Command.wIndex.i != 0)
327 3 bEpState = EP_ERROR;
328 3 else
329 3 {
330 4 // Prepare data_out for transmission
331 4 gEp0Status.wData.c[1] = 0;
332 4 gEp0Status.wData.c[0] = gDeviceStatus.bRemoteWakeupStatus;
333 4 gEp0Status.wData.c[0] |= gDeviceStatus.bSelfPoweredStatus;
334 4 }
335 3 break;
336 3
337 3 // Interface
338 3 case CMD_RECIP_IF:
339 3 // Prepare data_out for transmission
340 3 gEp0Status.wData.i = 0;
341 3 break;
342 3
343 3 // Endpoint
344 3 case CMD_RECIP_EP:
345 3 // Prepare data_out for transmission
346 3 gEp0Status.wData.i = 0;
347 3 if (GetEpStatus(gEp0Command.wIndex.i) == EP_HALTED)
348 3 gEp0Status.wData.c[0] |= 0x01;
349 3 break;
350 3
351 3 // Other cases unsupported
352 3 default:
353 3 bEpState = EP_ERROR;
354 3 break;
355 3 }
356 2
357 2 // Endpoint0 state assignment
358 2 bEpState = EP_TX;
359 2
360 2 // Point ep0 data pointer to transmit data_out
361 2 gEp0Status.pData = (BYTE *)&gEp0Status.wData.i;
362 2 gEp0Status.uNumBytes = 2;
363 2 }
364 1 gEp0Status.bEpState = bEpState;
365 1 }
C51 COMPILER V7.06 F32X_USB_STANDARD_REQUESTS 07/16/2008 15:35:21 PAGE 7
366
367 //-----------------------------------------------------------------------------
368 // GetDescriptorRequest
369 //-----------------------------------------------------------------------------
370 //
371 // Return Value : None
372 // Parameters : None
373 //
374 //-----------------------------------------------------------------------------
375 void GetDescriptorRequest ()
376 {
377 1 WORD wTempInt;
378 1
379 1 // This request is valid in all device states
380 1 // Switch on requested descriptor (Value field)
381 1 switch (gEp0Command.wValue.c[0])
382 1 {
383 2 // Device Descriptor Request
384 2 case DSC_DEVICE:
385 2 // Get size of the requested descriptor
386 2 uNumBytes = STD_DSC_SIZE;
387 2 // Prep to send the requested length
388 2 if (uNumBytes > gEp0Command.wLength.i)
389 2 {
390 3 uNumBytes = gEp0Command.wLength.i;
391 3 }
392 2 // Point data pointer to the requested descriptor
393 2 gEp0Status.pData = (void*)&gDescriptorMap.bStdDevDsc;
394 2 bEpState = EP_TX;
395 2 break;
396 2
397 2 // Configuration Descriptor Request
398 2 case DSC_CONFIG:
399 2 // Make sure requested descriptor exists
400 2 if (gEp0Command.wValue.c[1] >
401 2 gDescriptorMap.bStdDevDsc[std_bNumConfigurations])
402 2 {
403 3 bEpState = EP_ERROR;
404 3 }
405 2 else
406 2 {
407 3 // Get total length of this configuration descriptor
408 3 // (includes all associated interface and endpoints)
409 3 wTempInt.c[1] = gDescriptorMap.bCfg1[cfg_wTotalLength_lsb];
410 3 wTempInt.c[0] = gDescriptorMap.bCfg1[cfg_wTotalLength_msb];
411 3 uNumBytes = wTempInt.i;
412 3
413 3 // Prep to transmit the requested length
414 3 if (uNumBytes > gEp0Command.wLength.i)
415 3 {
416 4 uNumBytes = gEp0Command.wLength.i;
417 4 }
418 3 // Point data pointer to requested descriptor
419 3 gEp0Status.pData = &gDescriptorMap.bCfg1;
420 3 bEpState = EP_TX;
421 3 }
422 2 break;
423 2 }
424 1 gEp0Status.uNumBytes = uNumBytes;
425 1 gEp0Status.bEpState = bEpState;
426 1 }
427
C51 COMPILER V7.06 F32X_USB_STANDARD_REQUESTS 07/16/2008 15:35:21 PAGE 8
428 //-----------------------------------------------------------------------------
429 // GetConfigurationRequest
430 //-----------------------------------------------------------------------------
431 //
432 // Return Value : None
433 // Parameters : None
434 //
435 //-----------------------------------------------------------------------------
436 void GetConfigurationRequest ()
437 {
438 1 // Length field must be 1; Index field must be 0;
439 1 // Value field must be 0
440 1 if ((gEp0Command.wLength.i != 1) || (gEp0Command.wIndex.i) ||
441 1 (gEp0Command.wValue.i) || (gDeviceStatus.bDevState == DEV_DEFAULT))
442 1 {
443 2 bEpState = EP_ERROR;
444 2 }
445 1
446 1 else if (gDeviceStatus.bDevState == DEV_ADDRESS)
447 1 {
448 2 // Prepare data_out for transmission
449 2 gEp0Status.wData.i = 0;
450 2 // Point ep0 data pointer to transmit data_out
451 2 gEp0Status.pData = (BYTE *)&gEp0Status.wData.i;
452 2 // ep0 state assignment
453 2 bEpState = EP_TX;
454 2 }
455 1
456 1 else
457 1 {
458 2 // Index to desired field
459 2 gEp0Status.pData = (void *)&gDescriptorMap.bCfg1[cfg_bConfigurationValue];
460 2
461 2 // ep0 state assignment
462 2 bEpState = EP_TX;
463 2 }
464 1 gEp0Status.uNumBytes = 1;
465 1 gEp0Status.bEpState = bEpState;
466 1 }
467
468 //-----------------------------------------------------------------------------
469 // GetInterfaceRequest
470 //-----------------------------------------------------------------------------
471 //
472 // Return Value : None
473 // Parameters : None
474 //
475 //-----------------------------------------------------------------------------
476 void GetInterfaceRequest ()
477 {
478 1 // Value field must be 0; Length field must be 1
479 1 if ((gEp0Command.wValue.i) || (gEp0Command.wLength.i != 1) ||
480 1 (gDeviceStatus.bDevState != DEV_CONFIG))
481 1 {
482 2 bEpState = EP_ERROR;
483 2 }
484 1
485 1 else
486 1 {
487 2 // Make sure requested interface exists
488 2 if (gEp0Command.wIndex.i > gDeviceStatus.bNumInterf - 1)
489 2 bEpState = EP_ERROR;
C51 COMPILER V7.06 F32X_USB_STANDARD_REQUESTS 07/16/2008 15:35:21 PAGE 9
490 2 else
491 2 {
492 3 // Get current interface setting
493 3 gEp0Status.pData = (void *)&gDeviceStatus.IfStatus->bCurrentAlt;
494 3
495 3 // Length must be 1
496 3 gEp0Status.uNumBytes = 1;
497 3 bEpState = EP_TX;
498 3 }
499 2 }
500 1 gEp0Status.bEpState = bEpState;
501 1 }
502
503 //-----------------------------------------------------------------------------
504 // End Of File
505 //-----------------------------------------------------------------------------
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 608 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 2
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -