📄 subp.lst
字号:
434 6 EP0A_OUT_Arm(4);
435 6 // SL811Write(EP1AControl,SEND_STALL);
436 6 break;
437 6 case FEATURE:
438 6 SL811Write(EP0AControl,SEND_STALL);
439 6 break;
440 6 default:
441 6 SL811Write(EP0AControl,SEND_STALL);
442 6 break;
443 6 }
444 5 break;
445 5 case GET_REPORT:
446 5 break;
447 5
448 5 case GET_IDLE:
449 5 SL811Write(EP0A_Slave_Buf,Slave_IdleRate); // load current idle rate value
450 5 EP0A_IN_Arm(EP0A_Slave_Buf,1,1); // send 1 unsigned char data back to host
451 5 len_req = 0;
452 5 break;
453 5
454 5 case GET_PROTOCOL:
455 5 SL811Write(EP0A_Slave_Buf,Slave_Protocol); // load current protocol state
456 5 EP0A_IN_Arm(EP0A_Slave_Buf,1,1); // send 1 unsigned char data back to host
457 5 len_req = 0;
458 5 break;
459 5
460 5 case SET_IDLE:
461 5 Slave_IdleRate = ( unsigned char)dReq.wValue; // update Idle Rate (upper unsigned char of wVa
-lue)
462 5 EP0A_IN_Arm(0,0,1); // IN status stage
463 5 break;
464 5
465 5 case SET_PROTOCOL:
466 5 Slave_Protocol = dReq.wValue>>8; // update protocol value, 0=Boot, 1=report
467 5 EP0A_IN_Arm(0,0,1); // IN status stage
468 5 break;
469 5
470 5 default:
471 5 SL811Write(EP0AControl,SEND_STALL); // Stall all unsupported requests
472 5 break;
473 5 }
474 4 break;
475 4
476 4 //---------------------------------------------------------------------
477 4 // Specific Vendor Requests
478 4 //---------------------------------------------------------------------
479 4 case VENDOR_REQUEST:
480 4 SL811Write(EP0AControl,SEND_STALL); // Stall all unsupported requests
481 4 break;
482 4
483 4 //---------------------------------------------------------------------
484 4 // Unsupported Requests
485 4 //---------------------------------------------------------------------
486 4 default:
487 4 SL811Write(EP0AControl,SEND_STALL); // Stall all unsupported requests
488 4 break;
C51 COMPILER V7.20 SUBP 06/11/2004 19:40:15 PAGE 9
489 4 }
490 3
491 3 } // if(statuse&EP_setup)
492 2
493 2 //================================================================
494 2 // IN/OUT token received from host
495 2 //================================================================
496 2
497 2 else
498 2 {
499 3 //---------------------------------
500 3 // IN's ACKed
501 3 //---------------------------------
502 3 if(SL811Read(EP0AControl)&DIRECTION)
503 3 {
504 4 if(dev_first==0) // happens on the first get device descp
505 4 { // the host terminate IN transfer prematurely
506 5 len_req = 0; // (if EP0 maxpktsize is only 8 unsigned chars)
507 5 dev_first = 1; // reset len_req, end with OUT status stage
508 5 }
509 4
510 4 //--------------------------------------
511 4 // Continue with next IN if needed
512 4 //--------------------------------------
513 4 if(len_req)
514 4 {
515 5 data_seq = (((SL811Read(EP0AControl)&DATAX)==0) ? 1:0); // toggle DATA sequence
516 5 len_xfr = (len_req>=EP0_LEN) ? EP0_LEN:( unsigned char)len_req; // get transfer length for EP0
517 5
518 5 if(!IN_NULL) // point to correct buffer location
519 5 {
520 6 EP0A_IN_Arm(EP0A_Slave_Buf+in_buffer_idx, len_xfr, data_seq);
521 6 }
522 5 else
523 5 {EP0A_IN_Arm(0,0,data_seq);} // transfer zero Null packet
524 5
525 5 in_buffer_idx += len_xfr; // update buffer location
526 5 len_req -= len_xfr; // update remaining data length
527 5
528 5 if(len_req==0 && len_xfr==EP0_LEN && !IN_EXACT) // handles null packet of data length
529 5 { // to host is multiple of EP0_LEN, and
530 6 len_req = 1; // only if host request more than this
531 6 IN_NULL = TRUE; // value of length, otherwise, the extra
532 6 } // null pkt is not require.
533 5 }
534 4
535 4 //--------------------------------------
536 4 // Arm Status Stage OUT or new SETUP
537 4 //--------------------------------------
538 4 else// Arm status OUT or next SETUP requests
539 4 {
540 5 EP0A_OUT_Arm(EP0_LEN); // i.e. end of IN status stage.
541 5 }
542 4 }
543 3
544 3 //---------------------------------
545 3 // OUT's ACKed
546 3 //---------------------------------
547 3 else
548 3 {
549 4 if( byte_rx!=0) // zero data packet received
550 4 {
C51 COMPILER V7.20 SUBP 06/11/2004 19:40:15 PAGE 10
551 5 // EP0A_OUT_Arm(byte_rx);
552 5 // if(bReport==1)
553 5 // {
554 5 // SL811BufRead(EP0A_Slave_Buf, ( unsigned char*)&dReq, byte_rx);
555 5 bReport=0;
556 5 // EP0A_IN_Arm(0,0,1);
557 5 // }
558 5 // SL811Write(EP0AAddress,EP0A_Slave_Buf); // ep0 address buffer start adress after 64 u
-nsigned char
559 5 // SL811Write(EP0AXferLen,byte_rx); // max length of transfer allowed
560 5 // SL811Write(EP0AControl,DATA1_OUT);
561 5
562 5 }
563 4 else
564 4 EP0A_OUT_Arm(EP0_LEN);
565 4 }
566 3
567 3 }
568 2 }
569 1 //----------------------------------------------------------------------------------------
570 1 // End of ACK received
571 1 //----------------------------------------------------------------------------------------
572 1
573 1 //----------------------------------------------------------------------------------------
574 1 // If a STALL was sent out by device, it will still interrupt, but
575 1 // STALL bit in status register does not reflect this when in slave mode.
576 1 //----------------------------------------------------------------------------------------
577 1 else if( SL811Read(EP0AControl)&0x20 ) // check for previous stall sent
578 1 EP0A_OUT_Arm(EP0_LEN); // get ready for next SETUP token
579 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -