⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcp.lst

📁 演示了如何开发WINDOES下I/O口驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
02B6 E0         =1   569             MOVX    A, @DPTR
02B7 DFFA       =1   570             DJNZ    R7, CopySD
                =1   571     ; Fixup complete, get back to the program flow
02B9 D0E0       =1   572             POP     ACC                     ; Get rid of the return address
02BB D0E0       =1   573             POP     ACC
02BD E5F0       =1   574             MOV     A, B                    ; Retrieve byte count
02BF 21A5       =1   575             JMP     SendEP0InBuffer
                     576     $INCLUDE(DTables.A51)
                =1   577     ; This module declares the descriptors
                =1   578     ;
                =1   579     ; This example has one Device Descriptor with:
                =1   580     ;       One Configuration - single IN port and single OUT port
                =1   581     ;       One Interface - there is only one method of accessing the ports
                =1   582     ;       One HID Descriptor - to make PC host software simpler
A51 MACRO ASSEMBLER  LCP                                                                    25/07/99 18:37:13 PAGE    10

                =1   583     ;       No Endpoint Descriptors - HID Output Reports use EP0
                =1   584     ;       One Report Descriptor - six bytes OUT
                =1   585     ;       Multiple Sting Descriptors - to aid the user
                =1   586     ;
----            =1   587             CSEG
02C1            =1   588     DeviceDescriptor:
02C1 1201       =1   589             DB      18, 1           ; Length, Type
02C3 0101       =1   590             DW      101H            ; USB Rev 1.1
02C5 000000     =1   591             DB      0, 0, 0         ; Class, Subclass and Protocol
02C8 40         =1   592             DB      64              ; EP0 size
02C9 4242       =1   593             DW      4242H, 1, 1     ; Vendor ID, Product ID and Version
02CB 0001                    
02CD 0001                    
02CF 010200     =1   594             DB      1, 2, 0         ; Manufacturer, Product & Serial# Names
02D2 01         =1   595             DB      1               ; #Configs
02D3            =1   596     ConfigurationDescriptor:
02D3 0902       =1   597             DB      9, 2            ; Length, Type
02D5 1B00       =1   598             DB      LOW(ConfigLength), HIGH(ConfigLength)
02D7 010100     =1   599             DB      1, 1, 0         ; #Interfaces, Configuration#, Config. Name
02DA 80         =1   600             DB      10000000b       ; Attributes = Bus Powered
02DB 32         =1   601             DB      50              ; Max. Power is 50x2 = 100mA
02DC            =1   602     InterfaceDescriptor:
02DC 0904       =1   603             DB      9, 4            ; Length, Type
02DE 000000     =1   604             DB      0, 0, 0         ; No alternate setting, HID OUTPUT uses EP0
02E1 03         =1   605             DB      3               ; Class = Human Interface Device
02E2 0000       =1   606             DB      0, 0            ; Subclass and Protocol
02E4 00         =1   607             DB      0               ; Interface Name
02E5            =1   608     HIDDescriptor:
02E5 0921       =1   609             DB      9, 21H          ; Length, Type
02E7 0001       =1   610             DB      0, 1            ; HID Class Specification compliance
02E9 00         =1   611             DB      0               ; Country localization (=none)
02EA 01         =1   612             DB      1               ; Number of descriptors to follow
02EB 22         =1   613             DB      22H             ; And it's a Report descriptor
02EC 1700       =1   614             DB      LOW(ReportLength), HIGH(ReportLength)
  001B          =1   615     ConfigLength    EQU $ - ConfigurationDescriptor
                =1   616     
02EE            =1   617     ReportDescriptor:               ; Generated with HID Tool, copied to here
02EE 0600FF     =1   618             DB      6, 0, 0FFH      ; Usage_Page (Vendor Defined)
02F1 0901       =1   619             DB      9, 1            ; Usage (I/O Device)
02F3 A101       =1   620             DB      0A1H, 1         ; Collection (Application)
02F5 1901       =1   621             DB      19H, 1          ;   Usage_Minimum
02F7 2902       =1   622             DB      29H, 2          ;   Usage_Maximum
02F9 1500       =1   623             DB      15H, 0          ;   Logical_Minimum (0)
02FB 26FF00     =1   624             DB      26H, 255, 0     ;   Logical_Maximum (255)
02FE 7508       =1   625             DB      75H, 8          ;   Report_Size (8)
0300 9506       =1   626             DB      95H, 6          ;   Report_Count (6) = Lighting Values
0302 9102       =1   627             DB      91H, 2          ;   Output (Data,Var,Abs)
0304 C0         =1   628             DB      0C0H            ; End_Collection
  0017          =1   629     ReportLength    EQU $-ReportDescriptor
                =1   630              
0305            =1   631     String0:                        ; Declare the UNICODE strings
0305 04030904   =1   632             DB      4, 3, 9, 4      ; Only English language strings supported
0309            =1   633     String1:                        ; Manufacturer
0309 2C03       =1   634             DB      (String2-String1),3 ; Length, Type 
030B 55005300   =1   635             DB      "U",0,"S",0,"B",0," ",0,"D",0,"e",0,"s",0,"i",0,"g",0,"n",0," ", 0
030F 42002000                
0313 44006500                
0317 73006900                
031B 67006E00                
031F 2000                    
0321 42007900   =1   636             DB      "B",0,"y",0," ",0,"E",0,"x",0,"a",0,"m",0,"p",0,"l",0,"e",0
0325 20004500                
0329 78006100                
032D 6D007000                
0331 6C006500                
0335            =1   637     String2:                        ; Product Name
A51 MACRO ASSEMBLER  LCP                                                                    25/07/99 18:37:13 PAGE    11

0335 1E03       =1   638             DB      (EndOfDescriptors-String2),3
0337 4C006900   =1   639             DB      "L",0,"i",0,"g",0,"h",0,"t",0,"i",0,"n",0,"g",0
033B 67006800                
033F 74006900                
0343 6E006700                
0347 20005000   =1   640             DB      " ",0,"P",0,"a",0,"n",0,"e",0,"l",0
034B 61006E00                
034F 65006C00                
0353            =1   641     EndOfDescriptors:
0353 0000       =1   642             DW      0               ; Backstop for String Descriptors
                =1   643     
                =1   644     
                =1   645     
                     646     $INCLUDE(Main.A51)
                =1   647     ; This module initializes the microcontroller then executes MAIN forever
                =1   648     ;
                =1   649     
0355            =1   650     Reset:
0355 7581EB     =1   651             MOV     SP, #235                ; Initialize the Stack at top of internal memory
0358 75927F     =1   652             MOV     PageReg, #7FH           ; Needed to use MOVX @Ri
                =1   653     
035B 78D6       =1   654             MOV     R0, #LOW(USBControl)    ; Simulate a disconnect
035D E2         =1   655             MOVX    A, @R0
035E 54F3       =1   656             ANL     A, #11110011b           ; Clear DISCON, DISCOE
0360 F2         =1   657             MOVX    @R0, A
0361 1203AB     =1   658             CALL    Wait100msec             ; Give the host time to react
0364 E2         =1   659             MOVX    A, @R0                  ; Reconnect with this new identity
0365 4406       =1   660             ORL     A, #00000110b           ; Set DISCOE to enable pullup resistor
0367 F2         =1   661             MOVX    @R0, A                  ; Set RENUM so that 8051 handles USB requests
0368 E4         =1   662             CLR     A
0369 F520       =1   663             MOV     FLAGS, A                ; Start in Default state
036B            =1   664     InitializeIOSystem:                     ; This example uses PortA an OUT and 
                =1   665                                             ; the lower 4 bits of PortC as IN
                =1   666     ; Assume a pre-existing configuration (ie Dscope)       
036B 7893       =1   667             MOV     R0, #LOW(PortA_Config)  ; PageReg = 7F = HIGH(PortA_Config)
036D E4         =1   668             CLR     A
036E F2         =1   669             MOVX    @R0, A                  ; No alternate functions
036F 799C       =1   670             MOV     R1, #LOW(PortA_OE)
0371 F4         =1   671             CPL     A                       ; = 0FFH
0372 F3         =1   672             MOVX    @R1, A                  ; Enable PortA for Output
0373 7895       =1   673             MOV     R0, #LOW(PortC_Config)  ; PageReg = 7F = HIGH(PortC_Config)
0375 799E       =1   674             MOV     R1, #LOW(PortC_OE)
0377 E2         =1   675             MOVX    A, @R0                  ; Get current configuration
0378 54F0       =1   676             ANL     A, #0F0H
037A F2         =1   677             MOVX    @R0, A                  ; No alternate functions on lower nibble
037B E3         =1   678             MOVX    A, @R1                  ; Get current configuration
037C 54F0       =1   679             ANL     A, #0F0H
037E F3         =1   680             MOVX    @R1, A                  ; Enable PortC_Bits[3:0] for Input
                =1   681     ; Need to initialize Timer 0 to generate 40 microsecond interrupts
037F 758C50     =1   682             MOV     Timer0High, #80         ; Reload Value
0382 E589       =1   683             MOV     A, TimerMode            ; Set up Timer 0 without changing Timer 1
0384 54F0       =1   684             ANL     A, #0F0H                ; Clear lower 4 bits
0386 D2E1       =1   685             SETB    ACC.1                   ; Set No Gate, Time, Mode 2
0388 F589       =1   686             MOV     TimerMode, A
038A E588       =1   687             MOV     A, TimerControl
038C 4430       =1   688             ORL     A, #00110000b           ; Turn on Timer 0
038E F588       =1   689             MOV     TimerControl, A
                =1   690     
0390            =1   691     InitializeInterruptSystem:              ; First initialize the USB level
0390 78AC       =1   692             MOV     R0, #LOW(IN07IEN)
0392 F2         =1   693             MOVX    @R0, A                  ; Disable interrupts from IN Endpoints 0-7
0393 08         =1   694             INC     R0
0394 F2         =1   695             MOVX    @R0, A                  ; Disable interrupts from OUT Endpoints 0-7
0395 08         =1   696             INC     R0
0396 7401       =1   697             MOV     A, #00000001b
0398 F2         =1   698             MOVX    @R0, A                  ; Enable (Resume, Suspend) and SUDAV INTs
A51 MACRO ASSEMBLER  LCP                                                                    25/07/99 18:37:13 PAGE    12

0399 08         =1   699             INC     R0
039A 7401       =1   700             MOV     A, #00000001b
039C F2         =1   701             MOVX    @R0, A                  ; Enable Auto Vectoring for USB interrupts
039D 78AA       =1   702             MOV     R0, #LOW(OUT07IRQ)
039F 74FF       =1   703             MOV     A, #0FFH
03A1 F2         =1   704             MOVX    @R0, A                  ; Clear out any pending interrupts
                =1   705                                             ; Now enable the main level
03A2 75E801     =1   706             MOV     EIE, #00000001b         ; Enable INT2 = USB Interrupt (only)            
03A5 75A8C2     =1   707             MOV     EI, #11000010b          ; Enable interrupt subsystem: Timer 0 overflow
                =1   708                                             ;   (and Ser1 for Dscope)
                =1   709      
                =1   710     ; Initialization Complete.
                =1   711     ; 
03A8            =1   712     MAIN:
03A8 00         =1   713             NOP                             ; Not much of a main loop for this example
03A9 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     
03AB            =1   717     Wait100msec:
03AB 754064     =1   718             MOV     Temp, #100
03AE            =1   719     Wait1msec:                              ; A delay loop
03AE 90FB50     =1   720             MOV     DPTR, #-1200            
03B1 A3         =1   721     More:   INC     DPTR                    ; 3 cycles
03B2 E582       =1   722             MOV     A, DPL                  ; + 2
03B4 4583       =1   723             ORL     A, DPH                  ; + 2
03B6 70F9       =1   724             JNZ     More                    ; + 3 = 10 cycles x 1200 = 1msec
03B8 D540F3     =1   725             DJNZ    Temp, Wait1msec
03BB 22         =1   726             RET
                =1   727     
03BC            =1   728     ProcessOutputReport:                    ; A Report has just been received
                =1   729     ; The report is six bytes long
                =1   730     ; Save the values for the INTERRUPT service routine
03BC 7847       =1   731             MOV     R0, #LightValues        ; Initialize the pointers to be used
03BE 907EC0     =1   732             MOV     DPTR, #EP0OutBuffer     ; Point to the Report
03C1 7F06       =1   733             MOV     R7, #6
03C3 E0         =1   734     CopyOR: MOVX    A, @DPTR                ; Retrieve Report Byte 1
03C4 F6         =1   735             MOV     @R0, A
03C5 A3         =1   736             INC     DPTR
03C6 08         =1   737             INC     R0
03C7 DFFA       =1   738             DJNZ    R7, CopyOR
03C9 22         =1   739             RET
                =1   740     
03CA            =1   741     CreateInputReport:
                =1   742     ; Not used in this example
                =1   743     
                =1   744     
                     745     $INCLUDE(Timer.A51)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -