?? bal.lst
字號:
1378 A3 =1 546 More: INC DPTR ; 3 cycles
1379 E582 =1 547 MOV A, DPL ; + 2
137B 4583 =1 548 ORL A, DPH ; + 2
137D 70F9 =1 549 JNZ More ; + 3 = 10 cycles x 1200 = 1msec
137F DFF1 =1 550 DJNZ R7, Wait1msec
1381 22 =1 551 RET
=1 552
=1 553 ;*Jan's code start
1382 =1 554 Wait10Seconds:
1382 7FC8 =1 555 MOV R7, #200
1384 =1 556 Wait1msec2: ; A delay loop
1384 758600 =1 557 MOV DPS, #0
1387 900001 =1 558 MOV DPTR, #-65535
138A A3 =1 559 More2: INC DPTR ; 3 cycles
138B E582 =1 560 MOV A, DPL ; + 2
138D 4583 =1 561 ORL A, DPH ; + 2
138F 70F9 =1 562 JNZ More2 ; + 3 = 10 cycles x 65535 = 54 milliseconds
1391 DFF1 =1 563 DJNZ R7, Wait1msec2
1393 22 =1 564 RET
=1 565 ;*Jan's code end
=1 566
1394 =1 567 ProcessOutputReport: ; A Report has just been received
=1 568 ; The report is only one byte long in this first example
=1 569 ; It contains a new value for the LEDs
1394 907EC0 =1 570 MOV DPTR, #EP0OutBuffer ; Point to the Report
1397 E0 =1 571 MOVX A, @DPTR ; Get the Data
1398 F551 =1 572 MOV LEDValue, A ; Update the local variable
139A 22 =1 573 RET
=1 574
139B =1 575 CreateInputReport: ; Called from TIMER which detected the need
=1 576 ; The report is only one byte long in this first example
=1 577 ; It contains a new value for the Buttons
139B 907E80 =1 578 MOV DPTR, #EP1InBuffer ; Point to the buffer
139E F0 =1 579 MOVX @DPTR, A ; Update the Report
139F 907FB7 =1 580 MOV DPTR, #IN1ByteCount
13A2 7401 =1 581 MOV A, #1
13A4 F0 =1 582 MOVX @DPTR, A ; Endpoint 1 now 'armed', next IN will get data
13A5 22 =1 583 RET
=1 584
585 $INCLUDE(Decode.A51)
=1 586 ; This module is common to all of the examples.
A51 MACRO ASSEMBLER BAL 30/05/00 10:40:54 PAGE 10
=1 587 ; It decodes the USB Setup Packets and generates appropriate responses.
=1 588 ; Interpretation of Reports is handled by MAIN
=1 589 ;
---- =1 590 CSEG
13A6 =1 591 ServiceSetupPacket:
13A6 E547 =1 592 MOV A, RequestType
13A8 A2E7 =1 593 MOV C, ACC.7 ; Bit 7 = 1 means IO device needs to send data to P
C Host
13AA 9202 =1 594 MOV SendData, C
13AC 545C =1 595 ANL A, #01011100b ; IF RequestType[6.4.3.2] = 1 THEN goto BadRequest
13AE 7036 =1 596 JNZ BadRequest
13B0 E547 =1 597 MOV A, RequestType ; IF RequestType[1&0] = 1 THEN goto BadRequest
13B2 A2E0 =1 598 MOV C, ACC.0
13B4 82E1 =1 599 ANL C, ACC.1
13B6 402E =1 600 JC BadRequest
13B8 30E502 =1 601 JNB ACC.5, NotB5 ; IF RequestType[5] = 1 THEN RequestType[1,0] = [1,
1]
13BB 7403 =1 602 MOV A, #00000011b
13BD 5403 =1 603 NotB5: ANL A, #00000011b ; Set CommandIndex[5,4] = RequestType[1,0]
13BF C4 =1 604 SWAP A
13C0 FF =1 605 MOV R7, A ; Save HI nibble of CommandIndex
=1 606 ; Set CommandIndex[3,0] = Request[3,0]
13C1 E548 =1 607 MOV A, Request
13C3 54F0 =1 608 ANL A, #11110000b ; Check if Request > 15
13C5 701F =1 609 JNZ BadRequest
13C7 E548 =1 610 MOV A, Request
13C9 540F =1 611 ANL A, #00001111b ; Only 13 are defined today, handle in table
13CB 4F =1 612 ORL A, R7
=1 613 ; CALL CorrectSubroutine ; goto CommandTable(CommandIndex)
13CC =1 614 CorrectSubroutine: ; Jump to the subroutine that DPTR is pointing to
13CC 754001 =1 615 MOV ReplyCount, #1 ; Set up a default reply
13CF 754100 =1 616 MOV ReplyBuffer, #0
13D2 754200 =1 617 MOV ReplyBuffer+1, #0
13D5 C204 =1 618 CLR SetAddress ; Clear all flags
13D7 C201 =1 619 CLR STALL
13D9 C203 =1 620 CLR IsDescriptor
13DB 9013F3 =1 621 MOV DPTR, #CommandTable
13DE 1213EA =1 622 CALL BumpDPTR ; Point to entry
13E1 E0 =1 623 MOVX A, @DPTR ; Get the offset
13E2 901433 =1 624 MOV DPTR, #Subroutines
13E5 73 =1 625 JMP @A+DPTR ; Go to the correct Subroutine
=1 626
13E6 =1 627 BadRequest: ; Decoded a Bad Request, STALL the Endpoint
13E6 D201 =1 628 SETB STALL
13E8 22 =1 629 RET
=1 630 ; Support routines
13E9 =1 631 NextDPTR: ; Returns (DPTR + byte DPTR is pointing to)
13E9 E0 =1 632 MOVX A, @DPTR
13EA =1 633 BumpDPTR: ; Returns (DPTR + ACC)
13EA 2582 =1 634 ADD A, DPL
13EC F582 =1 635 MOV DPL, A
13EE 5002 =1 636 JNC Skip
13F0 0583 =1 637 INC DPH ; Need 16 bit arithmetic here
13F2 22 =1 638 Skip: RET
=1 639
=1 640 ; Since the table only contains byte offsets, it is important that all these routines are
=1 641 ; within one page (100H) of Subroutines
=1 642 ; V3.0 - CommandTable moved outside of this one page limited space
13F3 =1 643 CommandTable:
=1 644 ; First 16 commands are for the Device
13F3 18 =1 645 DB LOW(Device_Get_Status - Subroutines)
13F4 00 =1 646 DB LOW(Device_Clear_Feature - Subroutines)
13F5 00 =1 647 DB LOW(Invalid - Subroutines)
13F6 00 =1 648 DB LOW(Device_Set_Feature - Subroutines)
13F7 00 =1 649 DB LOW(Invalid - Subroutines)
13F8 03 =1 650 DB LOW(Set_Address - Subroutines)
A51 MACRO ASSEMBLER BAL 30/05/00 10:40:54 PAGE 11
13F9 32 =1 651 DB LOW(Get_Descriptor - Subroutines)
13FA 00 =1 652 DB LOW(Set_Descriptor - Subroutines)
13FB 14 =1 653 DB LOW(Get_Configuration - Subroutines)
13FC 20 =1 654 DB LOW(Set_Configuration - Subroutines)
13FD 00 =1 655 DB LOW(Invalid - Subroutines)
13FE 00 =1 656 DB LOW(Invalid - Subroutines)
13FF 00 =1 657 DB LOW(Invalid - Subroutines)
1400 00 =1 658 DB LOW(Invalid - Subroutines)
1401 00 =1 659 DB LOW(Invalid - Subroutines)
1402 00 =1 660 DB LOW(Invalid - Subroutines)
=1 661 ; Next 16 commands are for the Interface
1403 1C =1 662 DB LOW(Interface_Get_Status - Subroutines)
1404 00 =1 663 DB LOW(Interface_Clear_Feature - Subroutines)
1405 00 =1 664 DB LOW(Invalid - Subroutines)
1406 00 =1 665 DB LOW(Interface_Set_Feature - Subroutines)
1407 00 =1 666 DB LOW(Invalid - Subroutines)
1408 00 =1 667 DB LOW(Invalid - Subroutines)
1409 59 =1 668 DB LOW(Get_Class_Descriptor - Subroutines)
140A 00 =1 669 DB LOW(Set_Class_Descriptor - Subroutines)
140B 00 =1 670 DB LOW(Invalid - Subroutines)
140C 00 =1 671 DB LOW(Invalid - Subroutines)
140D 00 =1 672 DB LOW(Get_Interface - Subroutines)
140E 00 =1 673 DB LOW(Set_Interface - Subroutines)
140F 00 =1 674 DB LOW(Invalid - Subroutines)
1410 00 =1 675 DB LOW(Invalid - Subroutines)
1411 00 =1 676 DB LOW(Invalid - Subroutines)
1412 00 =1 677 DB LOW(Invalid - Subroutines)
=1 678 ; Next 16 commands are for the Endpoint
1413 1C =1 679 DB LOW(Endpoint_Get_Status - Subroutines)
1414 00 =1 680 DB LOW(Endpoint_Clear_Feature - Subroutines)
1415 00 =1 681 DB LOW(Invalid - Subroutines)
1416 00 =1 682 DB LOW(Endpoint_Set_Feature - Subroutines)
1417 00 =1 683 DB LOW(Invalid - Subroutines)
1418 00 =1 684 DB LOW(Invalid - Subroutines)
1419 00 =1 685 DB LOW(Invalid - Subroutines)
141A 00 =1 686 DB LOW(Invalid - Subroutines)
141B 00 =1 687 DB LOW(Invalid - Subroutines)
141C 00 =1 688 DB LOW(Invalid - Subroutines)
141D 00 =1 689 DB LOW(Invalid - Subroutines)
141E 00 =1 690 DB LOW(Invalid - Subroutines)
141F 00 =1 691 DB LOW(Endpoint_Sync_Frame - Subroutines)
1420 00 =1 692 DB LOW(Invalid - Subroutines)
1421 00 =1 693 DB LOW(Invalid - Subroutines)
1422 00 =1 694 DB LOW(Invalid - Subroutines)
=1 695 ; Next 16 commands are Class Requests
1423 00 =1 696 DB LOW(Invalid - Subroutines)
1424 0D =1 697 DB LOW(Get_Report - Subroutines)
1425 00 =1 698 DB LOW(Get_Idle - Subroutines)
1426 00 =1 699 DB LOW(Get_Protocol - Subroutines)
1427 00 =1 700 DB LOW(Invalid - Subroutines)
1428 00 =1 701 DB LOW(Invalid - Subroutines)
1429 00 =1 702 DB LOW(Invalid - Subroutines)
142A 00 =1 703 DB LOW(Invalid - Subroutines)
142B 00 =1 704 DB LOW(Invalid - Subroutines)
142C 06 =1 705 DB LOW(Set_Report - Subroutines)
142D 00 =1 706 DB LOW(Set_Idle - Subroutines)
142E 00 =1 707 DB LOW(Set_Protocol - Subroutines)
142F 00 =1 708 DB LOW(Invalid - Subroutines)
1430 00 =1 709 DB LOW(Invalid - Subroutines)
1431 00 =1 710 DB LOW(Invalid - Subroutines)
1432 00 =1 711 DB LOW(Invalid - Subroutines)
=1 712
1433 =1 713 Subroutines:
=1 714 ;
=1 715 ; Many requests are INVALID for this example
1433 =1 716 Get_Protocol: ; We are not a Boot device
A51 MACRO ASSEMBLER BAL 30/05/00 10:40:54 PAGE 12
1433 =1 717 Set_Protocol: ; We are not a Boot device
1433 =1 718 Set_Descriptor: ; Our Descriptors are static
1433 =1 719 Set_Class_Descriptor: ; Our Descriptors are static
1433 =1 720 Set_Interface: ; We only have one Interface
1433 =1 721 Get_Interface: ; We do not have an Alternate setting
1433 =1 722 Set_Idle: ; V3.0 Optional command, not supported
1433 =1 723 Get_Idle: ; V3.0 Optional command, not supported
1433 =1 724 Device_Set_Feature: ; We have no features that can be set or cleared
1433 =1 725 Interface_Set_Feature: ; We have no features that can be set or cleared
1433 =1 726 Endpoint_Set_Feature: ; We have no features that can be set or cleared
1433 =1 727 Endpoint_Clear_Feature: ; V3.0 We have no features that can be set or cleared
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -