📄 bal.lst
字号:
02C7 0101 =1 569 DW 101H ; USB Rev 1.1
02C9 000000 =1 570 DB 0, 0, 0 ; Class, Subclass and Protocol
02CC 40 =1 571 DB 64 ; EP0 size
02CD 4242 =1 572 DW 4242H, 1, 1 ; Vendor ID, Product ID and Version
02CF 0001
02D1 0001
02D3 010200 =1 573 DB 1, 2, 0 ; Manufacturer, Product & Serial# Names
02D6 01 =1 574 DB 1 ; #Configs
02D7 =1 575 ConfigurationDescriptor:
02D7 0902 =1 576 DB 9, 2 ; Length, Type
02D9 2200 =1 577 DB LOW(ConfigLength), HIGH(ConfigLength)
02DB 010103 =1 578 DB 1, 1, 3 ; #Interfaces, Configuration#, Config. Name
02DE 80 =1 579 DB 10000000b ; Attributes = Bus Powered
02DF 32 =1 580 DB 50 ; Max. Power is 50x2 = 100mA
A51 MACRO ASSEMBLER BAL 21/07/99 16:17:43 PAGE 10
02E0 =1 581 InterfaceDescriptor:
02E0 0904 =1 582 DB 9, 4 ; Length, Type
02E2 000001 =1 583 DB 0, 0, 1 ; No alternate setting, HID uses EP1
02E5 03 =1 584 DB 3 ; Class = Human Interface Device
02E6 0000 =1 585 DB 0, 0 ; Subclass and Protocol
02E8 04 =1 586 DB 4 ; Interface Name
02E9 =1 587 HIDDescriptor:
02E9 0921 =1 588 DB 9, 21H ; Length, Type
02EB 0001 =1 589 DB 0, 1 ; HID Class Specification compliance
02ED 00 =1 590 DB 0 ; Country localization (=none)
02EE 01 =1 591 DB 1 ; Number of descriptors to follow
02EF 22 =1 592 DB 22H ; And it's a Report descriptor
02F0 1C00 =1 593 DB LOW(ReportLength), HIGH(ReportLength)
02F2 =1 594 EndpointDescriptor:
02F2 0705 =1 595 DB 7, 5 ; Length, Type
02F4 81 =1 596 DB 10000001b ; Address = IN 1
02F5 03 =1 597 DB 00000011b ; Interrupt
02F6 4000 =1 598 DB 64, 0 ; Maximum packet size (this example only uses 1)
02F8 64 =1 599 DB 100 ; Poll every 0.1 seconds
0022 =1 600 ConfigLength EQU $ - ConfigurationDescriptor
=1 601
02F9 =1 602 ReportDescriptor: ; Generated with HID Tool, copied to here
02F9 0600FF =1 603 DB 6, 0, 0FFH ; Usage_Page (Vendor Defined)
02FC 0901 =1 604 DB 9, 1 ; Usage (I/O Device)
02FE A101 =1 605 DB 0A1H, 1 ; Collection (Application)
0300 1901 =1 606 DB 19H, 1 ; Usage_Minimum (Button 1)
0302 2908 =1 607 DB 29H, 8 ; Usage_Maximum (Button 8)
0304 1500 =1 608 DB 15H, 0 ; Logical_Minimum (0)
0306 2501 =1 609 DB 25H, 1 ; Logical_Maximum (1)
0308 7501 =1 610 DB 75H, 1 ; Report_Size (1)
030A 9508 =1 611 DB 95H, 8 ; Report_Count (8)
030C 8102 =1 612 DB 81H, 2 ; Input (Data,Var,Abs)
030E 1901 =1 613 DB 19H, 1 ; Usage_Minimum (Led 1)
0310 2908 =1 614 DB 29H, 8 ; Usage_Maximum (Led 8)
0312 9102 =1 615 DB 91H, 2 ; Output (Data,Var,Abs)
0314 C0 =1 616 DB 0C0H ; End_Collection
001C =1 617 ReportLength EQU $-ReportDescriptor
=1 618
0315 =1 619 String0: ; Declare the UNICODE strings
0315 04030904 =1 620 DB 4, 3, 9, 4 ; Only English language strings supported
0319 =1 621 String1: ; Manufacturer
0319 2C03 =1 622 DB (String2-String1),3 ; Length, Type
031B 55005300 =1 623 DB "U",0,"S",0,"B",0," ",0,"D",0,"e",0,"s",0,"i",0,"g",0,"n",0," ", 0
031F 42002000
0323 44006500
0327 73006900
032B 67006E00
032F 2000
0331 42007900 =1 624 DB "B",0,"y",0," ",0,"E",0,"x",0,"a",0,"m",0,"p",0,"l",0,"e",0
0335 20004500
0339 78006100
033D 6D007000
0341 6C006500
0345 =1 625 String2: ; Product Name
0345 2203 =1 626 DB (String3-String2),3
0347 42007500 =1 627 DB "B",0,"u",0,"t",0,"t",0,"o",0,"n",0,"s",0," ",0
034B 74007400
034F 6F006E00
0353 73002000
0357 26002000 =1 628 DB "&",0," ",0,"L",0,"i",0,"g",0,"h",0,"t",0,"s",0
035B 4C006900
035F 67006800
0363 74007300
0367 =1 629 String3: ; Configuration Name
0367 2403 =1 630 DB (String4-String3),3
0369 53006900 =1 631 DB "S",0,"i",0,"m",0,"p",0,"l",0,"e",0," ",0,"I",0,"/",0
A51 MACRO ASSEMBLER BAL 21/07/99 16:17:43 PAGE 11
036D 6D007000
0371 6C006500
0375 20004900
0379 2F00
037B 4F002000 =1 632 DB "O",0," ",0,"D",0,"e",0,"v",0,"i",0,"c",0,"e",0
037F 44006500
0383 76006900
0387 63006500
038B =1 633 String4: ; Interface Name
038B 2403 =1 634 DB (EndOfDescriptors-String4),3
038D 46006900 =1 635 DB "F",0,"i",0,"r",0,"s",0,"t",0," ",0,"H",0,"I",0,"D",0
0391 72007300
0395 74002000
0399 48004900
039D 4400
039F 20004500 =1 636 DB " ",0,"E",0,"x",0,"a",0,"m",0,"p",0,"l",0,"e",0
03A3 78006100
03A7 6D007000
03AB 6C006500
03AF =1 637 EndOfDescriptors:
03AF 0000 =1 638 DW 0 ; Backstop for String Descriptors
=1 639
=1 640
=1 641
642 $INCLUDE(Main.A51)
=1 643 ; This module initializes the microcontroller then executes MAIN forever
=1 644 ;
=1 645
03B1 =1 646 Reset:
03B1 7581EB =1 647 MOV SP, #235 ; Initialize the Stack
03B4 75927F =1 648 MOV PageReg, #7FH ; Allows MOVX Ri to access EZ-USB memory
=1 649
03B7 78D6 =1 650 MOV R0, #Low(USBControl) ; Simulate a disconnect
03B9 E2 =1 651 MOVX A, @R0
03BA 54F3 =1 652 ANL A, #11110011b ; Clear DISCON, DISCOE
03BC F2 =1 653 MOVX @R0, A
03BD 120405 =1 654 CALL Wait100msec ; Give the host time to react
03C0 E2 =1 655 MOVX A, @R0 ; Reconnect with this new identity
03C1 4406 =1 656 ORL A, #00000110b ; Set DISCOE to enable pullup resistor
03C3 F2 =1 657 MOVX @R0, A ; Set RENUM so that 8051 handles USB requests
03C4 E4 =1 658 CLR A
03C5 F520 =1 659 MOV FLAGS, A ; Start in Default state
03C7 =1 660 TurnOffLEDs:
03C7 F548 =1 661 MOV LEDValue, A
03C9 F546 =1 662 MOV Old_Buttons, A
03CB 04 =1 663 INC A ; = 1
03CC F547 =1 664 MOV LEDstrobe, A
03CE =1 665 Initialize4msecCounter:
03CE F542 =1 666 MOV Expired_Time, A
03D0 F549 =1 667 MOV Msec_counter, A
03D2 =1 668 InitializeIOSystem: ; Work around the Dscope monitor I/O needs
=1 669 ; Setup Port A as 8-bit OUTPUT port (no alternate functions)
=1 670 ; Setup an 8-bit INPUT port using PortB_Bits [7:4] and PortC_Bits[3:0]
=1 671 ; Assume a pre-existing configuration (ie Dscope)
03D2 7893 =1 672 MOV R0, #LOW(PortA_Config) ; PageReg = 7F = HIGH(PortA_Config)
03D4 E4 =1 673 CLR A
03D5 F2 =1 674 MOVX @R0, A ; No alternate functions
03D6 799C =1 675 MOV R1, #LOW(PortA_OE)
03D8 F4 =1 676 CPL A ; = 0FFH
03D9 F3 =1 677 MOVX @R1, A ; Enable PortA for Output
03DA 08 =1 678 INC R0 ; Point to PortB_Config
03DB 09 =1 679 INC R1 ; Point to PortB_OE
03DC E2 =1 680 MOVX A, @R0 ; Get current configuration
03DD 540F =1 681 ANL A, #0FH
03DF F2 =1 682 MOVX @R0, A ; No alternate functions on upper nibble
03E0 E3 =1 683 MOVX A, @R1 ; Get current configuration
A51 MACRO ASSEMBLER BAL 21/07/99 16:17:43 PAGE 12
03E1 44F0 =1 684 ORL A, #0F0H
03E3 F3 =1 685 MOVX @R1, A ; Enable PortB_Bits[7:4] for Output
03E4 08 =1 686 INC R0 ; Point to PortC_Config
03E5 09 =1 687 INC R1 ; Point to PortC_OE
03E6 E2 =1 688 MOVX A, @R0 ; Get current configuration
03E7 54F0 =1 689 ANL A, #0F0H
03E9 F2 =1 690 MOVX @R0, A ; No alternate functions on lower nibble
03EA E3 =1 691 MOVX A, @R1 ; Get current configuration
03EB 440F =1 692 ORL A, #0FH
03ED F3 =1 693 MOVX @R1, A ; Enable PortC_Bits[3:0] for Output
03EE =1 694 InitializeInterruptSystem: ; First initialize the USB level
03EE E4 =1 695 CLR A
03EF 78AC =1 696 MOV R0, #LOW(IN07IEN)
03F1 F2 =1 697 MOVX @R0, A ; Disable interrupts from IN Endpoints 0-7
03F2 08 =1 698 INC R0
03F3 F2 =1 699 MOVX @R0, A ; Disable interrupts from OUT Endpoints 0-7
03F4 08 =1 700 INC R0
03F5 7403 =1 701 MOV A, #00000011b
03F7 F2 =1 702 MOVX @R0, A ; Enable (Resume, Suspend,) SOF and SUDAV INTs
03F8 08 =1 703 INC R0
03F9 7401 =1 704 MOV A, #00000001b
03FB F2 =1 705 MOVX @R0, A ; Enable Auto Vectoring for USB interrupts
=1 706 ; Now enable the main level
03FC 75E801 =1 707 MOV EIE, #00000001b ; Enable INT2 = USB Interrupt (only)
03FF 75A8C0 =1 708 MOV EI, #11000000b ; Enable interrupt subsystem (and Ser1 for dScope)
=1 709
=1 710 ; Initialization Complete.
=1 711 ;
0402 =1 712 MAIN:
0402 00 =1 713 NOP ; Not much of a main loop for this example
0403 80FD =1 714 JMP MAIN ; All actions are initiated by interrupts
=1 715 ; We are a slave, we wait to be told what to do
=1 716
0405 =1 717 Wait100msec:
0405 754064 =1 718 MOV Temp, #100
0408 =1 719 Wait1msec: ; A delay loop
0408 90FB50 =1 720 MOV DPTR, #-1200
040B A3 =1 721 More: INC DPTR ; 3 cycles
040C E582 =1 722 MOV A, DPL ; + 2
040E 4583 =1 723 ORL A, DPH ; + 2
0410 70F9 =1 724 JNZ More ; + 3 = 10 cycles x 1200 = 1msec
0412 D540F3 =1 725 DJNZ Temp, Wait1msec
0415 22 =1 726 RET
=1 727
0416 =1 728 ProcessOutputReport: ; A Report has just been received
=1 729 ; The report is only one byte long in this first example
=1 730 ; It contains a new value for the LEDs
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -