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

📄 bal.lst

📁 演示了如何开发WINDOES下I/O口驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
0118            =1   186     EP2In_ISR:
0118            =1   187     EP2Out_ISR:
0118            =1   188     EP3In_ISR:
0118            =1   189     EP3Out_ISR:
A51 MACRO ASSEMBLER  BAL                                                                    21/07/99 16:17:43 PAGE     4

0118            =1   190     EP4In_ISR:
0118            =1   191     EP4Out_ISR:
0118            =1   192     EP5In_ISR:
0118            =1   193     EP5Out_ISR:
0118            =1   194     EP6In_ISR:
0118            =1   195     EP6Out_ISR:
0118            =1   196     EP7In_ISR :
0118            =1   197     EP7Out_ISR:
0118            =1   198     Not_Used:                       ; Should not get any of these
0118 32         =1   199             RETI
                =1   200     
0119            =1   201     ClearINT2:                      ; Tell the hardware that we're done
0119 E591       =1   202             MOV     A, EXIF
011B C2E4       =1   203             CLR     ACC.4           ; Clear the Interrupt 2 bit
011D F591       =1   204             MOV     EXIF, A
011F 22         =1   205             RET
                =1   206     
0120            =1   207     USBReset_ISR:                   ; Bus has been Reset, move to DEFAULT state
0120 C0E0       =1   208             PUSH    ACC
0122 C200       =1   209             CLR     Configured
0124 3119       =1   210             CALL    ClearINT2
                =1   211                                     ; No need to clear source of interrupt
0126 D0E0       =1   212             POP     ACC
0128 32         =1   213             RETI
                =1   214     
0129            =1   215     Suspend_ISR:                    ; SIE detected an Idle bus
0129 C0E0       =1   216             PUSH    ACC
012B E587       =1   217             MOV     A, PCON
012D 4401       =1   218             ORL     A, #1
012F F587       =1   219             MOV     PCON, A         ; Go to sleep!
0131 00         =1   220             NOP
0132 00         =1   221             NOP                     ; Wake up here due to a USBResume
0133 00         =1   222             NOP
0134 3119       =1   223             CALL    ClearINT2
0136 D0E0       =1   224             POP     ACC
0138 32         =1   225             RETI
                =1   226             
0139            =1   227     WakeUp_ISR:                     ; Not using external WAKEUP in these examples
                =1   228                                     ; So this must be due to a USBResume
0139 C2DC       =1   229             CLR     EICON.4         ; Clear the wakeup interrupt source
013B 32         =1   230             RETI
                =1   231     
013C            =1   232     SUDAV_ISR:                      ; A Setup packet has been received
013C C0D0       =1   233             PUSH    PSW             ; Save Registers before the service routine
013E C0E0       =1   234             PUSH    ACC
0140 C082       =1   235             PUSH    DPL
0142 C083       =1   236             PUSH    DPH
0144 120169     =1   237             CALL    ServiceSetupPacket
0147 3119       =1   238             CALL    ClearINT2                               
                =1   239                                     ; Clear the source of the interrupt
0149 7401       =1   240             MOV     A, #00000001b
014B 907FAB     =1   241     ExitISR:MOV     DPTR, #USBIRQ
014E F0         =1   242             MOVX    @DPTR, A
014F D083       =1   243             POP     DPH             ; Restore Registers
0151 D082       =1   244             POP     DPL
0153 D0E0       =1   245             POP     ACC
0155 D0D0       =1   246             POP     PSW
0157 32         =1   247             RETI
                =1   248     
0158            =1   249     SOF_ISR:                        ; A Start-Of-Frame packet has been received
0158 C0D0       =1   250             PUSH    PSW             ; Save Registers before the service routine
015A C0E0       =1   251             PUSH    ACC
015C C082       =1   252             PUSH    DPL
015E C083       =1   253             PUSH    DPH
0160 120428     =1   254             CALL    ServiceTimerRoutine
0163 3119       =1   255             CALL    ClearINT2                               
A51 MACRO ASSEMBLER  BAL                                                                    21/07/99 16:17:43 PAGE     5

                =1   256                                     ; Clear the source of the interrupt
0165 7402       =1   257             MOV     A, #00000010b
0167 80E2       =1   258             JMP     ExitISR
                =1   259     
                =1   260     
                     261     $INCLUDE(..\USB_INT.A51)
                =1   262     ; This module is common to all of the examples.
                =1   263     ; It services USB Requests from the SIE.
                =1   264     ; Interpretation of the Output Reports is handled by MAIN
                =1   265     ;
----            =1   266             CSEG
0169            =1   267     ServiceSetupPacket:
0169 907FE8     =1   268             MOV     DPTR, #SETUPDAT         ; Point to Setup Packet data
016C E0         =1   269             MOVX    A, @DPTR                ; Get the RequestType
016D A2E7       =1   270             MOV     C, ACC.7                ; Bit 7 = 1 means IO device needs to send data to P
                             C Host
016F 9202       =1   271             MOV     SendData, C
0171 545C       =1   272             ANL     A, #01011100b           ; IF RequestType[6.4.3.2] = 1 THEN goto BadRequest
0173 7051       =1   273             JNZ     BadRequest
0175 E0         =1   274             MOVX    A, @DPTR                ; IF RequestType[1&0] = 1 THEN goto BadRequest
0176 A2E0       =1   275             MOV     C, ACC.0
0178 82E1       =1   276             ANL     C, ACC.1
017A 404A       =1   277             JC      BadRequest
017C 30E502     =1   278             JNB     ACC.5, NotB5            ; IF RequestType[5] = 1 THEN RequestType[1,0] = [1,
                             1]
017F 7403       =1   279             MOV     A, #00000011b
0181 5403       =1   280     NotB5:  ANL     A, #00000011b           ; Set CommandIndex[5,4] = RequestType[1,0]
0183 C4         =1   281             SWAP    A
0184 F540       =1   282             MOV     Temp, A                 ; Save HI nibble of CommandIndex
                =1   283                                             ; Set CommandIndex[3,0] = Request[3,0]
0186 A3         =1   284             INC     DPTR                    ; Point to Request
0187 E0         =1   285             MOVX    A, @DPTR
0188 540F       =1   286             ANL     A, #00001111b           ; Only 13 are defined today, handle in table
018A 4540       =1   287             ORL     A, Temp 
018C 1201D5     =1   288             CALL    CorrectSubroutine       ; goto CommandTable(CommandIndex)
                =1   289                                             ; Returns STALL=1 if a stall is required
018F 200134     =1   290             JB      STALL, BadRequest
0192 300218     =1   291             JNB     SendData, HandShake
0195 200320     =1   292             JB      IsDescriptor, LoadSUDPTR; EZ-USB has a short cut for descriptors
                =1   293                                             ; Send data in ReplyBuffer
0198 907F02     =1   294             MOV     DPTR, #EP0InBuffer+2
019B 7846       =1   295             MOV     R0, #ReplyBuffer+3
019D 754003     =1   296             MOV     Temp, #3                ; Copy maximum byte count
01A0 E6         =1   297     CopyRB: MOV     A, @R0
01A1 F0         =1   298             MOVX    @DPTR, A
01A2 1582       =1   299             DEC     DPL
01A4 18         =1   300             DEC     R0
01A5 D540F8     =1   301             DJNZ    Temp, CopyRB
01A8 E6         =1   302             MOV     A, @R0                  ; Get real byte count
01A9            =1   303     SendEP0InBuffer:
01A9 907FB5     =1   304             MOV     DPTR, #In0ByteCount
01AC            =1   305     StartXfer:
01AC F0         =1   306             MOVX    @DPTR, A                ; This write initiates the transfer
01AD            =1   307     HandShake:                              ; Handshake with host
01AD 754002     =1   308             MOV     Temp, #00000010b        ; Set HSNAK to tell the SIE that we're done
01B0            =1   309     SetEP0Control:
01B0 907FB4     =1   310             MOV     DPTR, #EP0Control
01B3 E0         =1   311             MOVX    A, @DPTR
01B4 4540       =1   312             ORL     A, Temp
01B6 F0         =1   313             MOVX    @DPTR, A
01B7 22         =1   314             RET
01B8            =1   315     LoadSUDPTR:                             ; Send the data pointed to by DPTR
01B8 858240     =1   316             MOV     Temp, DPL
01BB E583       =1   317             MOV     A, DPH
01BD 907FD4     =1   318             MOV     DPTR, #SUDPTR
01C0 F0         =1   319             MOVX    @DPTR, A
A51 MACRO ASSEMBLER  BAL                                                                    21/07/99 16:17:43 PAGE     6

01C1 E540       =1   320             MOV     A, Temp
01C3 A3         =1   321             INC     DPTR
01C4 80E6       =1   322             JMP     StartXfer
01C6            =1   323     BadRequest:                             ; Invalid Request was received
01C6 754003     =1   324             MOV     Temp, #00000011b        ; Set EP0STALL and HSNAK
01C9 80E5       =1   325             JMP     SetEP0Control
                =1   326     
01CB            =1   327     NextDPTR:                               ; Returns (DPTR + byte DPTR is pointing to)
01CB E0         =1   328             MOVX    A, @DPTR
01CC            =1   329     BumpDPTR:                               ; Returns (DPTR + ACC)
01CC 2582       =1   330             ADD     A, DPL
01CE F582       =1   331             MOV     DPL, A
01D0 5002       =1   332             JNC     Skip
01D2 0583       =1   333             INC     DPH                     ; Need 16 bit arithmetic here
01D4 22         =1   334     Skip:   RET
                =1   335     
01D5            =1   336     CorrectSubroutine:                      ; Jump to the subroutine that DPTR is pointing to
01D5 9001FA     =1   337             MOV     DPTR, #CommandTable
01D8 31CC       =1   338             CALL    BumpDPTR                ; Point to entry
01DA E0         =1   339             MOVX    A, @DPTR                ; Get the offset
01DB 9001FA     =1   340             MOV     DPTR, #CommandTable
01DE 31CC       =1   341             CALL    BumpDPTR                ; Get the routine address
01E0 C082       =1   342             PUSH    DPL                     ; Create a RETURN address on stack
01E2 C083       =1   343             PUSH    DPH                     ; Note: JMP @A+DPTR not used since A, DPTR needed
01E4 7845       =1   344             MOV     R0, #ReplyBuffer+2
01E6 E4         =1   345             CLR     A
01E7 F6         =1   346             MOV     @R0, A                  ; Clear ReplyBuffer
01E8 18         =1   347             DEC     R0
01E9 F6         =1   348             MOV     @R0, A
01EA 18         =1   349             DEC     R0
01EB 7601       =1   350             MOV     @R0, #1                 ; Default non-descriptor reply
01ED 907FEA     =1   351             MOV     DPTR, #SETUPDAT+2       ; Point to LOW(wValue)
01F0 E0         =1   352             MOVX    A, @DPTR                ; Many of the routines need these
01F1 F5F0       =1   353             MOV     B, A                    ; LOW(wValue) in B
01F3 A3         =1   354             INC     DPTR
01F4 E0         =1   355             MOVX    A, @DPTR                ; HIGH(wValue) in A
01F5 C201       =1   356             CLR     STALL
01F7 C203       =1   357             CLR     IsDescriptor
01F9 22         =1   358             RET                             ; Go to service routine
                =1   359     
                =1   360     ; Since the table only contains byte offsets, it is important that all these routines are
                =1   361     ; within one page (100H) of CommandTable
                =1   362     ;
01FA            =1   363     CommandTable:
                =1   364     ; First 16 commands are for the Device
01FA 6D         =1   365             DB Device_Get_Status - CommandTable
01FB 40         =1   366             DB Device_Clear_Feature - CommandTable
01FC 40         =1   367             DB Invalid - CommandTable
01FD 40         =1   368             DB Device_Set_Feature - CommandTable
01FE 40         =1   369             DB Invalid - CommandTable
01FF 40         =1   370             DB Invalid - CommandTable               ; SIE implements Device_Set_Address
0200 81         =1   371             DB Get_Descriptor - CommandTable
0201 40         =1   372             DB Set_Descriptor - CommandTable
0202 6A         =1   373             DB Get_Configuration - CommandTable
0203 74         =1   374             DB Set_Configuration - CommandTable
0204 40         =1   375             DB Invalid - CommandTable
0205 40         =1   376             DB Invalid - CommandTable

⌨️ 快捷键说明

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