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

📄 rb.lst

📁 演示了如何开发WINDOES下I/O口驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
02BB DFFA       =1   566             DJNZ    R7, CopySD
                =1   567     ; Fixup complete, get back to the program flow
02BD D0E0       =1   568             POP     ACC                     ; Get rid of the return address
02BF D0E0       =1   569             POP     ACC
02C1 E5F0       =1   570             MOV     A, B                    ; Retrieve byte count
02C3 21A9       =1   571             JMP     SendEP0InBuffer
                     572     $INCLUDE(DTables.A51)
                =1   573     ; This module declares the descriptors
                =1   574     ;
                =1   575     ; This example has one Device Descriptor with:
                =1   576     ;       One Configuration - single IN port and single OUT port
                =1   577     ;       One Interface - there is only one method of accessing the ports
                =1   578     ;       One HID Descriptor - to make PC host software simpler
                =1   579     ;       One Endpoint Descriptor - for HID Input Reports
                =1   580     ;       One Report Descriptor - 40 byte IN and 40 byte OUT reports
                =1   581     ;       Multiple Sting Descriptors - to aid the user
                =1   582     ;
A51 MACRO ASSEMBLER  RB                                                                     23/07/99 16:57:48 PAGE    10

----            =1   583             CSEG
02C5            =1   584     DeviceDescriptor:
02C5 1201       =1   585             DB      18, 1           ; Length, Type
02C7 0101       =1   586             DW      101H            ; USB Rev 1.1
02C9 000000     =1   587             DB      0, 0, 0         ; Class, Subclass and Protocol
02CC 40         =1   588             DB      64              ; EP0 size
02CD 4242       =1   589             DW      4242H, 1, 1     ; Vendor ID, Product ID and Version
02CF 0001                    
02D1 0001                    
02D3 010200     =1   590             DB      1, 2, 0         ; Manufacturer, Product & Serial# Names
02D6 01         =1   591             DB      1               ; #Configs
02D7            =1   592     ConfigurationDescriptor:
02D7 0902       =1   593             DB      9, 2            ; Length, Type
02D9 2200       =1   594             DB      LOW(ConfigLength), HIGH(ConfigLength)
02DB 010100     =1   595             DB      1, 1, 0         ; #Interfaces, Configuration#, Config. Name
02DE 80         =1   596             DB      10000000b       ; Attributes = Bus Powered
02DF 32         =1   597             DB      50              ; Max. Power is 50x2 = 100mA
02E0            =1   598     InterfaceDescriptor:
02E0 0904       =1   599             DB      9, 4            ; Length, Type
02E2 000001     =1   600             DB      0, 0, 1         ; No alternate setting, HID uses EP1
02E5 03         =1   601             DB      3               ; Class = Human Interface Device
02E6 0000       =1   602             DB      0, 0            ; Subclass and Protocol
02E8 00         =1   603             DB      0               ; Interface Name
02E9            =1   604     HIDDescriptor:
02E9 0921       =1   605             DB      9, 21H          ; Length, Type
02EB 0001       =1   606             DB      0, 1            ; HID Class Specification compliance
02ED 00         =1   607             DB      0               ; Country localization (=none)
02EE 01         =1   608             DB      1               ; Number of descriptors to follow
02EF 22         =1   609             DB      22H             ; And it's a Report descriptor
02F0 1D00       =1   610             DB      LOW(ReportLength), HIGH(ReportLength)
02F2            =1   611     EndpointDescriptor:
02F2 0705       =1   612             DB      7, 5            ; Length, Type
02F4 81         =1   613             DB      10000001b       ; Address = IN 1
02F5 03         =1   614             DB      00000011b       ; Interrupt
02F6 4000       =1   615             DB      64, 0           ; Maximum packet size (this example only uses 1)
02F8 64         =1   616             DB      100             ; Poll every 0.1 seconds 
  0022          =1   617     ConfigLength    EQU $ - ConfigurationDescriptor
                =1   618     
02F9            =1   619     ReportDescriptor:               ; Generated with HID Tool, copied to here
02F9 0600FF     =1   620             DB      6, 0, 0FFH      ; Usage_Page (Vendor Defined)
02FC 0901       =1   621             DB      9, 1            ; Usage (I/O Device)
02FE A101       =1   622             DB      0A1H, 1         ; Collection (Application)
0300 1901       =1   623             DB      19H, 1          ;   Usage_Minimum
0302 2902       =1   624             DB      29H, 2          ;   Usage_Maximum
0304 1500       =1   625             DB      15H, 0          ;   Logical_Minimum (0)
0306 26FF00     =1   626             DB      26H, 255, 0     ;   Logical_Maximum (255)
0309 7508       =1   627             DB      75H, 8          ;   Report_Size (8)
030B 9528       =1   628             DB      95H, 40         ;   Report_Count (40) 
030D 8102       =1   629             DB      81H, 2          ;   Input (Data,Var,Abs) = DOTs
030F 1901       =1   630             DB      19H, 1          ;   Usage_Minimum
0311 2902       =1   631             DB      29H, 2          ;   Usage_Maximum
0313 9102       =1   632             DB      91H, 2          ;   Output (Data,Var,Abs) = Text or DOTs
0315 C0         =1   633             DB      0C0H            ; End_Collection
  001D          =1   634     ReportLength    EQU $-ReportDescriptor
                =1   635              
0316            =1   636     String0:                        ; Declare the UNICODE strings
0316 04030904   =1   637             DB      4, 3, 9, 4      ; Only English language strings supported
031A            =1   638     String1:                        ; Manufacturer
031A 2C03       =1   639             DB      (String2-String1),3 ; Length, Type 
031C 55005300   =1   640             DB      "U",0,"S",0,"B",0," ",0,"D",0,"e",0,"s",0,"i",0,"g",0,"n",0," ", 0
0320 42002000                
0324 44006500                
0328 73006900                
032C 67006E00                
0330 2000                    
0332 42007900   =1   641             DB      "B",0,"y",0," ",0,"E",0,"x",0,"a",0,"m",0,"p",0,"l",0,"e",0
A51 MACRO ASSEMBLER  RB                                                                     23/07/99 16:57:48 PAGE    11

0336 20004500                
033A 78006100                
033E 6D007000                
0342 6C006500                
0346            =1   642     String2:                        ; Product Name
0346 1A03       =1   643             DB      (EndOfDescriptors-String2),3
0348 52006500   =1   644             DB      "R",0,"e",0,"a",0,"d",0,"e",0,"r",0
034C 61006400                
0350 65007200                
0354 20004200   =1   645             DB      " ",0,"B",0,"o",0,"a",0,"r",0,"d",0
0358 6F006100                
035C 72006400                
0360            =1   646     EndOfDescriptors:
0360 0000       =1   647             DW      0               ; Backstop for String Descriptors
                =1   648     
                =1   649     
                =1   650     
                     651     $INCLUDE(Main.A51)
                =1   652     ; This module initializes the microcontroller then executes MAIN forever
                =1   653     ;
                =1   654     
0362            =1   655     Reset:
0362 7581EB     =1   656             MOV     SP, #235                ; Initialize the Stack at top of internal memory
0365 75927F     =1   657             MOV     PageReg, #7FH           ; Needed to use MOVX @Ri
                =1   658     
0368 78D6       =1   659             MOV     R0, #LOW(USBControl)    ; Simulate a disconnect
036A E2         =1   660             MOVX    A, @R0
036B 54F3       =1   661             ANL     A, #11110011b           ; Clear DISCON, DISCOE
036D F2         =1   662             MOVX    @R0, A
036E 1203B9     =1   663             CALL    Wait100msec             ; Give the host time to react
0371 E2         =1   664             MOVX    A, @R0                  ; Reconnect with this new identity
0372 4406       =1   665             ORL     A, #00000110b           ; Set DISCOE to enable pullup resistor
0374 F2         =1   666             MOVX    @R0, A                  ; Set RENUM so that 8051 handles USB requests
0375 E4         =1   667             CLR     A
0376 F520       =1   668             MOV     FLAGS, A                ; Start in Default state
0378 F546       =1   669             MOV     CurrentConfiguration, A ; This example supports two configurations
037A 7848       =1   670             MOV     R0, #DisplayPosition    ; Note LEDBuffer follows DisplayPosition
037C 7F2B       =1   671             MOV     R7, #43
037E 7408       =1   672             MOV     A, #8                   ; Display a horizontal line
0380            =1   673     ClearDisplay:
0380 F6         =1   674             MOV     @R0, A
0381 08         =1   675             INC     R0
0382 DFFC       =1   676             DJNZ    R7, ClearDisplay
                =1   677                             
0384            =1   678     InitializeIOSystem:                     ; This example uses PortA an IN/OUT and 
                =1   679                                             ; the lower 4 bits of PortC as OUT
                =1   680     ; Assume a pre-existing configuration (ie Dscope)       
0384 7893       =1   681             MOV     R0, #LOW(PortA_Config)  ; PageReg = 7F = HIGH(PortA_Config)
0386 E4         =1   682             CLR     A
0387 F2         =1   683             MOVX    @R0, A                  ; No alternate functions
0388 799C       =1   684             MOV     R1, #LOW(PortA_OE)
038A F4         =1   685             CPL     A                       ; = 0FFH
038B F3         =1   686             MOVX    @R1, A                  ; Enable PortA for Output
038C 7895       =1   687             MOV     R0, #LOW(PortC_Config)  ; PageReg = 7F = HIGH(PortC_Config)
038E 799E       =1   688             MOV     R1, #LOW(PortC_OE)
0390 E2         =1   689             MOVX    A, @R0                  ; Get current configuration
0391 54F0       =1   690             ANL     A, #0F0H
0393 F2         =1   691             MOVX    @R0, A                  ; No alternate functions on lower nibble
0394 E3         =1   692             MOVX    A, @R1                  ; Get current configuration
0395 440F       =1   693             ORL     A, #0FH
0397 F3         =1   694             MOVX    @R1, A                  ; Enable PortC_Bits[3:0] for Output
0398 7898       =1   695             MOV     R0, #LOW(PortC_Out)
039A E2         =1   696             MOVX    A, @R0
039B 54F0       =1   697             ANL     A, #0F0H
039D F2         =1   698             MOVX    @R0, A                  ; Set Bits [3:0] low
                =1   699     
A51 MACRO ASSEMBLER  RB                                                                     23/07/99 16:57:48 PAGE    12

039E            =1   700     InitializeInterruptSystem:              ; First initialize the USB level
039E 78AC       =1   701             MOV     R0, #LOW(IN07IEN)
03A0 F2         =1   702             MOVX    @R0, A                  ; Disable interrupts from IN Endpoints 0-7
03A1 08         =1   703             INC     R0
03A2 F2         =1   704             MOVX    @R0, A                  ; Disable interrupts from OUT Endpoints 0-7
03A3 08         =1   705             INC     R0
03A4 7403       =1   706             MOV     A, #00000011b
03A6 F2         =1   707             MOVX    @R0, A                  ; Enable (Resume, Suspend,) SOF and SUDAV INTs
03A7 08         =1   708             INC     R0
03A8 7401       =1   709             MOV     A, #00000001b
03AA F2         =1   710             MOVX    @R0, A                  ; Enable Auto Vectoring for USB interrupts
03AB 78AA       =1   711             MOV     R0, #LOW(OUT07IRQ)
03AD 74FF       =1   712             MOV     A, #0FFH
03AF F2         =1   713             MOVX    @R0, A                  ; Clear out any pending interrupts
                =1   714                                             ; Now enable the main level
03B0 75E801     =1   715             MOV     EIE, #00000001b         ; Enable INT2 = USB Interrupt (only)            
03B3 75A8C0     =1   716             MOV     EI, #11000000b          ; Enable interrupt subsystem (and Ser1 for Dscope)
                =1   717      
                =1   718     ; Initialization Complete.
                =1   719     ; 
03B6            =1   720     MAIN:
03B6 00         =1   721             NOP                             ; Not much of a main loop for this example
03B7 80FD       =1   722             JMP     MAIN                    ; All actions are initiated by interrupts
                =1   723     ; We are a slave, we wait to be told what to do
                =1   724     
03B9            =1   725     Wait100msec:
03B9 754064     =1   726             MOV     Temp, #100
03BC            =1   727     Wait1msec:                              ; A delay loop
03BC 90FB50     =1   728             MOV     DPTR, #-1200            
03BF A3         =1   729     More:   INC     DPTR                    ; 3 cycles
03C0 E582       =1   730             MOV     A, DPL                  ; + 2
03C2 4583       =1   731             ORL     A, DPH                  ; + 2
03C4 70F9       =1   732             JNZ     More                    ; + 3 = 10 cycles x 1200 = 1msec
03C6 D540F3     =1   733             DJNZ    Temp, Wait1msec
03C9 22         =1   734             RET
                =1   735     
03CA            =1   736     ProcessOutputReport:                    ; A Report has just been received
                =1   737     ; The report is 7 characters long and must be translated into a dot pattern
03CA 758601     =1   738             MOV     DPS, #1                 ; Select the other Data Pointer
03CD 907EC0     =1   739             MOV     DPTR, #EP0OutBuffer     ; Point to the Report
03D0 7849       =1   740             MOV     R0, #LEDBuffer
03D2 7F07       =1   741             MOV     R7, #7                  ; Have room for 7 characters
03D4 E0         =1   742     ORLoop: MOVX    A, @DPTR

⌨️ 快捷键说明

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