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

📄 rbdc.lst

📁 演示了如何开发WINDOES下I/O口驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
03A7 6F006100                
03AB 72006400                
03AF            =1   709     String3:                        ; Configuration Name
03AF 1403       =1   710             DB      (String4-String3),3
03B1 54006500   =1   711             DB      "T",0,"e",0,"x",0,"t",0," ",0,"M",0,"o",0,"d",0,"e",0
03B5 78007400                
03B9 20004D00                
03BD 6F006400                
03C1 6500                    
03C3            =1   712     String4:                        ; Configuration Name
03C3 1203       =1   713             DB      (EndOfDescriptors-String4),3
03C5 44006F00   =1   714             DB      "D",0,"o",0,"t",0," ",0,"M",0,"o",0,"d",0,"e",0
03C9 74002000                
03CD 4D006F00                
03D1 64006500                
03D5            =1   715     EndOfDescriptors:
03D5 0000       =1   716             DW      0               ; Backstop for String Descriptors
                =1   717     
                =1   718     
                =1   719     
                     720     $INCLUDE(Main.A51)
                =1   721     ; This module initializes the microcontroller then executes MAIN forever
                =1   722     ;
                =1   723     
03D7            =1   724     Reset:
03D7 7581EB     =1   725             MOV     SP, #235                ; Initialize the Stack at top of internal memory
03DA 75927F     =1   726             MOV     PageReg, #7FH           ; Needed to use MOVX @Ri
                =1   727     
03DD 78D6       =1   728             MOV     R0, #LOW(USBControl)    ; Simulate a disconnect
03DF E2         =1   729             MOVX    A, @R0
03E0 54F3       =1   730             ANL     A, #11110011b           ; Clear DISCON, DISCOE
03E2 F2         =1   731             MOVX    @R0, A
03E3 12042E     =1   732             CALL    Wait100msec             ; Give the host time to react
03E6 E2         =1   733             MOVX    A, @R0                  ; Reconnect with this new identity
03E7 4406       =1   734             ORL     A, #00000110b           ; Set DISCOE to enable pullup resistor
03E9 F2         =1   735             MOVX    @R0, A                  ; Set RENUM so that 8051 handles USB requests
03EA E4         =1   736             CLR     A
03EB F520       =1   737             MOV     FLAGS, A                ; Start in Default state
03ED F546       =1   738             MOV     CurrentConfiguration, A ; This example supports two configurations
03EF 7848       =1   739             MOV     R0, #DisplayPosition    ; Note LEDBuffer follows DisplayPosition
03F1 7F2B       =1   740             MOV     R7, #43
03F3 7408       =1   741             MOV     A, #8                   ; Display a horizontal line
03F5            =1   742     ClearDisplay:
03F5 F6         =1   743             MOV     @R0, A
03F6 08         =1   744             INC     R0
03F7 DFFC       =1   745             DJNZ    R7, ClearDisplay
                =1   746                             
03F9            =1   747     InitializeIOSystem:                     ; This example uses PortA an IN/OUT and 
                =1   748                                             ; the lower 4 bits of PortC as OUT
                =1   749     ; Assume a pre-existing configuration (ie Dscope)       
03F9 7893       =1   750             MOV     R0, #LOW(PortA_Config)  ; PageReg = 7F = HIGH(PortA_Config)
03FB E4         =1   751             CLR     A
03FC F2         =1   752             MOVX    @R0, A                  ; No alternate functions
03FD 799C       =1   753             MOV     R1, #LOW(PortA_OE)
03FF F4         =1   754             CPL     A                       ; = 0FFH
0400 F3         =1   755             MOVX    @R1, A                  ; Enable PortA for Output
0401 7895       =1   756             MOV     R0, #LOW(PortC_Config)  ; PageReg = 7F = HIGH(PortC_Config)
0403 799E       =1   757             MOV     R1, #LOW(PortC_OE)
0405 E2         =1   758             MOVX    A, @R0                  ; Get current configuration
A51 MACRO ASSEMBLER  RBDC                                                                   25/07/99 15:58:57 PAGE    13

0406 54F0       =1   759             ANL     A, #0F0H
0408 F2         =1   760             MOVX    @R0, A                  ; No alternate functions on lower nibble
0409 E3         =1   761             MOVX    A, @R1                  ; Get current configuration
040A 440F       =1   762             ORL     A, #0FH
040C F3         =1   763             MOVX    @R1, A                  ; Enable PortC_Bits[3:0] for Output
040D 7898       =1   764             MOV     R0, #LOW(PortC_Out)
040F E2         =1   765             MOVX    A, @R0
0410 54F0       =1   766             ANL     A, #0F0H
0412 F2         =1   767             MOVX    @R0, A                  ; Set Bits [3:0] low
                =1   768     
0413            =1   769     InitializeInterruptSystem:              ; First initialize the USB level
0413 78AC       =1   770             MOV     R0, #LOW(IN07IEN)
0415 F2         =1   771             MOVX    @R0, A                  ; Disable interrupts from IN Endpoints 0-7
0416 08         =1   772             INC     R0
0417 F2         =1   773             MOVX    @R0, A                  ; Disable interrupts from OUT Endpoints 0-7
0418 08         =1   774             INC     R0
0419 7403       =1   775             MOV     A, #00000011b
041B F2         =1   776             MOVX    @R0, A                  ; Enable (Resume, Suspend,) SOF and SUDAV INTs
041C 08         =1   777             INC     R0
041D 7401       =1   778             MOV     A, #00000001b
041F F2         =1   779             MOVX    @R0, A                  ; Enable Auto Vectoring for USB interrupts
0420 78AA       =1   780             MOV     R0, #LOW(OUT07IRQ)
0422 74FF       =1   781             MOV     A, #0FFH
0424 F2         =1   782             MOVX    @R0, A                  ; Clear out any pending interrupts
                =1   783                                             ; Now enable the main level
0425 75E801     =1   784             MOV     EIE, #00000001b         ; Enable INT2 = USB Interrupt (only)            
0428 75A8C0     =1   785             MOV     EI, #11000000b          ; Enable interrupt subsystem (and Ser1 for Dscope)
                =1   786      
                =1   787     ; Initialization Complete.
                =1   788     ; 
042B            =1   789     MAIN:
042B 00         =1   790             NOP                             ; Not much of a main loop for this example
042C 80FD       =1   791             JMP     MAIN                    ; All actions are initiated by interrupts
                =1   792     ; We are a slave, we wait to be told what to do
                =1   793     
042E            =1   794     Wait100msec:
042E 754064     =1   795             MOV     Temp, #100
0431            =1   796     Wait1msec:                              ; A delay loop
0431 90FB50     =1   797             MOV     DPTR, #-1200            
0434 A3         =1   798     More:   INC     DPTR                    ; 3 cycles
0435 E582       =1   799             MOV     A, DPL                  ; + 2
0437 4583       =1   800             ORL     A, DPH                  ; + 2
0439 70F9       =1   801             JNZ     More                    ; + 3 = 10 cycles x 1200 = 1msec
043B D540F3     =1   802             DJNZ    Temp, Wait1msec
043E 22         =1   803             RET
                =1   804     
043F            =1   805     ProcessOutputReport:                    ; A Report has just been received
                =1   806     ; See comment re SetConfiguration in DTables.A51
043F 907EC0     =1   807             MOV     DPTR, #EP0OutBuffer
0442 E0         =1   808             MOVX    A, @DPTR
                =1   809     
                =1   810     ; The interpretation of the Report is different depending upon the MODE we are in
                =1   811     ;       MOV     A, CurrentConfiguration
0443 B4020D     =1   812             CJNE    A, #2, TextMode
                =1   813     
0446            =1   814     DOTmode:
                =1   815     ; The report is 41 bytes long and is a mode byte then a buffer
0446 907EC1     =1   816             MOV     DPTR, #EP0OutBuffer+1   ; Point to the Report (after Mode Byte)
0449 7849       =1   817             MOV     R0, #LEDBuffer
044B E0         =1   818             MOVX    A, @DPTR
044C 7F28       =1   819             MOV     R7, #40                 ; Have room for 40 Columns
044E E0         =1   820     DMLoop: MOVX    A, @DPTR                ; Update the local buffer
044F F6         =1   821             MOV     @R0, A
0450 DFFC       =1   822             DJNZ    R7, DMloop
0452 22         =1   823             RET
                =1   824     
A51 MACRO ASSEMBLER  RBDC                                                                   25/07/99 15:58:57 PAGE    14

0453            =1   825     TextMode:
                =1   826     ; The report is 7 characters long and must be translated into a dot pattern
0453 758601     =1   827             MOV     DPS, #1                 ; Select the other Data Pointer
0456 907EC1     =1   828             MOV     DPTR, #EP0OutBuffer+1   ; Point to the Report
0459 7849       =1   829             MOV     R0, #LEDBuffer
045B 7F07       =1   830             MOV     R7, #7                  ; Have room for 7 characters
045D E0         =1   831     ORLoop: MOVX    A, @DPTR
045E 30E702     =1   832             JNB     ACC.7, Skip1            ; Valid Characters are 20H to 7FH
0461 743F       =1   833             MOV     A, #3FH                 ; Replace characters > 7FH with ?
0463 C3         =1   834     Skip1:  CLR     C
0464 9420       =1   835             SUBB    A, #20H
0466 5002       =1   836             JNC     Skip2
0468 743C       =1   837             MOV     A, #3CH                 ; Replace characters < 20H with []
046A 75F005     =1   838     Skip2:  MOV     B, #5
046D A4         =1   839             MUL     AB                      ; B = HI((Char-20H)*5), A = LOW
046E 0586       =1   840             INC     DPS                     ; Swap to "other" DPTR
0470 9004A3     =1   841             MOV     DPTR, #LookupTable
0473 2582       =1   842             ADD     A, DPL
0475 F582       =1   843             MOV     DPL, A
0477 E5F0       =1   844             MOV     A, B
0479 3583       =1   845             ADDC    A, DPH
047B F583       =1   846             MOV     DPH, A                  ; DPTR now pointing into Lookup Table
047D 7E05       =1   847             MOV     R6, #5
047F E0         =1   848     LTCopy: MOVX    A, @DPTR
0480 F6         =1   849             MOV     @R0, A
0481 A3         =1   850             INC     DPTR
0482 08         =1   851             INC     R0
0483 DEFA       =1   852             DJNZ    R6, LTCopy
0485 7600       =1   853             MOV     @R0, #0                 ; Put a space between characters
0487 08         =1   854             INC     R0
0488 0586       =1   855             INC     DPS                     ; Switch to DPTR1
048A A3         =1   856             INC     DPTR                    ; Point to next character in Output Report 
048B DFD0       =1   857             DJNZ    R7, ORLoop
048D 0586       =1   858             INC     DPS                     ; Return DPTR to DPTR0
                =1   859                                             ; Fall into CreateInputReport
048F            =1   860     CreateInputReport:
                =1   861     ; The report is 40 bytes long in this example
                =1   862     ; It contains the LED Buffer 
048F 907E80     =1   863             MOV     DPTR, #EP1InBuffer      ; Point to the buffer
0492 7849       =1   864             MOV     R0, #LEDBuffer
0494 7F28       =1   865             MOV     R7, #40
0496 E6         =1   866     IRLoop: MOV     A, @R0
0497 F0         =1   867             MOVX    @DPTR, A
0498 A3         =1   868             INC     DPTR
0499 08         =1   869             INC     R0
049A DFFA       =1   870             DJNZ    R7, IRLoop 
049C 907FB7     =1   871             MOV     DPTR, #IN1ByteCount
049F 7428       =1   872             MOV     A, #40
04A1 F0         =1   873             MOVX    @DPTR, A                ; Endpoint 1 now 'armed', next IN will get data
04A2 22         =1   874             RET
                =1   875     
04A3            =1   876     LookupTable:                            ; Contains the 5 columns of the 7x5 display
04A3 00000000   =1   877             DB      00H,00H,00H,00H,00H     ; SPACE
04A7 00                      
04A8 00007D00   =1   878             DB      00H,00H,7DH,00H,00H     ; !
04AC 00                      
04AD 00700070   =1   879             DB      00H

⌨️ 快捷键说明

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