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

📄 stepper.lst

📁 演示了如何开发WINDOES下I/O口驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
A51 MACRO ASSEMBLER  STEPPER                                                                22/07/99 14:17:14 PAGE     4

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

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

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

⌨️ 快捷键说明

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