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

📄 emb_f.asm

📁 mcs51,2051,x86系列MCU
💻 ASM
📖 第 1 页 / 共 5 页
字号:
##82930H USB#200#
##82930H EMB#200#

;**************************************************************************
;**                                                                      **
;**                  I N T E L   P R O P R I E T A R Y                   **
;**                                                                      **
;**     COPYRIGHT (c)  1996, 1997 BY  INTEL  CORPORATION.  ALL RIGHTS    **
;**     RESERVED.                                                        **
;**$Modtime:   19 Dec 1996 14:42:24  $
;**$Revision:   1.3  $
;***************************************************************************

;$INCLUDE (8x930AX.INC)  ;  you may need to change this file and use
                        ;  the one provided by the tool vendor you
                        ;  are using.
;$INCLUDE (ONE_OH.INC)   ; This file is provided by Intel

INCLUDE 8x930ax.inc      ;  Select the other format if assembling for
INCLUDE ONE_OH.INC       ;  Intel Compatibility



FIFO_SIZE             equ     008h
GET_COMMAND           equ     080h
EP1_TX_FIFO_SIZE      equ     0$$EP1TXGAR$h
EP1_RX_FIFO_SIZE      equ     0$$EP1RXGAR$h
EP2_TX_FIFO_SIZE      equ     0$$EP2TXGAR$h
EP3_TX_FIFO_SIZE      equ     0$$EP3TXGAR$h
EP1_TX_LOOP_BACK_FIFO_SIZE    equ  0$$EP1TXGAR$h
EP1_RX_LOOP_BACK_FIFO_SIZE    equ  0$$EP1RXGAR$h
EP2_TX_LOOP_BACK_FIFO_SIZE    equ  0$$EP2TXGAR$h
EP2_RX_LOOP_BACK_FIFO_SIZE    equ  0$$EP2RXGAR$h
EP3_TX_LOOP_BACK_FIFO_SIZE    equ  0$$EP3TXGAR$h
EP3_RX_LOOP_BACK_FIFO_SIZE    equ  0$$EP3RXGAR$h


SETUP_PHASE           equ     000h
DATA_PHASE            equ     001h
STATUS_PHASE          equ     002h


EP0_MAX_PACKET_SIZE     equ     0$$MAXPACKET$h
NULL_DATA_PACKET        equ     000h


public   FUNCTION_ISR
public   InitilizeEmbeddedFunction
$$IF$ (EPATT11 == 1) || (EPATT12 == 1) || (EPATT13 == 1) || (EPATT14 == 1) || (EPATT15 == 1) || (EPATT16 == 1)
public   EmbeddedFunctionSofRoutine
$$END$
public   FUNCTION_SUSPEND_ROUTINE,FUNCTION_RESUME_ROUTINE
public   FbRequest
public   STACK_DATA
public   FifoWatchDog


DEFINE EMBEDDED_CODE_SEGMENT, SPACE=CODE

SEGMENT EMBEDDED_CODE_SEGMENT

;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
;M---------------------------------------------------------------------M
;M                   MAIN                                              M
;M---------------------------------------------------------------------M
;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM


InitilizeEmbeddedFunction:


        Call    INIT_VARIABLES             ; Initialize the RAM space as required
        Call    INIT_FUNCTION_EP0

        ret



;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
;A---------------------------------------------------------------------A
;A                  ACTIVE LOOP                                        A
;A---------------------------------------------------------------------A
;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

;COMMENT *------------------------------------------------------------
;ISR Registers
;IF the user makes this into an ISR, they will need to save certain registers
;upon entry into this code.  The firmware has been writen such that the
;only registers which are modified in this code are A, R0, R1 & EPINDEX.
;While DPX is used within the code, it is saved locally only when needed.
;This will allow the ISR to run slightly faster.
;--------------------------------------------------------------------*


;----------------------------------------------------------------
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SS                 FUNCTION SUSPEND ROUTINE
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;----------------------------------------------------------------
FUNCTION_SUSPEND_ROUTINE:
        ret
;----------------------------------------------------------------
;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
;RR                 FUNCTION RESUME ROUTINE
;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
;----------------------------------------------------------------
FUNCTION_RESUME_ROUTINE:
        ret

$$IF$ (EPATT11 == 1) || (EPATT12 == 1) || (EPATT13 == 1) || (EPATT14 == 1) || (EPATT15 == 1) || (EPATT16 == 1)
;----------------------------------------------------------------
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SS                 SOF ISR
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;----------------------------------------------------------------
;COMMENT *------------------------------------------------------------
;Function name     : SOF_ISR
;Brief Description : Service the SOF_ISR Interrupt
;                  : This routine simply displays the upper three bytes of the
;                  : SOF in the lower three bits of the LEDs on P1.
;                  : It does not affect the other LEDS.  Very usefull
;                  : in determining when the function is receiveing SOFs
;Regs preserved    : Reg. A is saved
;--------------------------------------------------------------------*
;SCOPE

SOF_ISR:
EmbeddedFunctionSofRoutine:


        jnb     ASOF,   ExitSofIsr              ; If this ASOF bit not set, the ISR could be a HUB.  Go Check.

        clr     ASOF
        push    ACC
        mov     A,      P1
        anl     A,      #0F8h
        mov     P1,     A


        mov     A,      SOFH
        anl     A,      #07h
        orl     P1,     A

        pop     ACC

ExitSofIsr:

        ret
$$END$

;----------------------------------------------------------------
;FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
;FF                 FUNCTION ISR
;FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
;----------------------------------------------------------------
;COMMENT *------------------------------------------------------------
;Function name     : FUNCTION_ISR
;Brief Description : Service the FUNCTION_ISR Interrupt
;                  : This routine scans the interrupt pending bits in order
;                  : and branches to any routines that have pending interrupts.
;                  : After finishing the routine jumps back to the top of
;                  : the scanning loop to preserve interrupt priority.
;                  :
;                  : NOTE: The order of precidence is set by the order in which the
;                  : user places the checks.
;                  :
;Regs preserved    : Reg. A, B  & EPINDEX are saved
;--------------------------------------------------------------------*
;SCOPE

FUNCTION_ISR:
         push   PSW
         push   PSW1
         push   ACC
         push   B
         push   EPINDEX


ProcessFunctionEndpoints:

;----------------------------------------------------------------
;-- NOTE: Priority of the check sequence determines priority.  --
;----------------------------------------------------------------

F_EP0:
        mov     A,   FIFLG                  ; First check to see if this is EP0 Command
        anl     A,   #03h                   ; As they require extra overhead. Mask off all but EP0 Interrupts
        jz      NonEp0ISR

                                             ;----------------------------------------------------------------
                                             ;-- Process the EP0 COmmand in the correct order
                                             ;----------------------------------------------------------------

                                            ; If this an EP0 command then we need to process TX & RX
                                            ; ISRs in the correct order if, for whatever reason they occurred
                                            ; back to back.  This happens in OHCI systems.
        mov     A, gbSetupSeqTX
        cjne    A, #SETUP_PHASE, CheckDataStatusStage
        jmp     DoRxFirst                   ; If the status stage is Setup then check the RX First.

CheckDataStatusStage:
                                            ; Now check to see what stage the TX is in.
                                            ; If it is in the data stage then check it first.
                                            ; If it's in the status stage then check the RX first.

        cjne    A, #DATA_PHASE, DoRxFirst   ; If current stage a data stage->a control read
                                            ; and we should process TX before RX ISR

                                            ;----------------------------------------------------------------
                                            ;-- Process the TX FIFO first
                                            ;----------------------------------------------------------------

DoTxFirst:
F_EP0_TXA:
        jnb     FTXD0,  F_EP0_RXA
        mov     EPINDEX,#00
        lCall   ProcessInToken              ; 82930 has sent a packet to HC
        ljmp     ProcessFunctionEndpoints    ; Look at all Interrupt flags again

F_EP0_RXA:
        jnb     FRXD0,  NonEp0ISR
        mov     EPINDEX,#00
        lCall   ProcessOutToken             ; 82930 has received a packet from HC
        ljmp     ProcessFunctionEndpoints    ; Look at all Interrupt flags again

;--------------------------------------------------------------------------------

DoRxFirst:
                                            ;----------------------------------------------------------------
                                            ;-- Process the RX FIFO first
                                            ;----------------------------------------------------------------
F_EP0_RXB:
        jnb     FRXD0,  F_EP0_TXB
        mov     EPINDEX,#00
        lCall   ProcessOutToken             ; 82930 has received a packet from HC
        ljmp     ProcessFunctionEndpoints    ; Look at all Interrupt flags again

F_EP0_TXB:
        jnb     FTXD0,  NonEp0ISR
        mov     EPINDEX,#00
        lCall   ProcessInToken              ; 82930 has sent a packet to HC
        ljmp     ProcessFunctionEndpoints    ; Look at all Interrupt flags again


;--------------------------------------------------------------------------------
;--------------------------------------------------------------------------------

                                            ;----------------------------------------------------------------
                                            ;-- Process the Other EPs next
                                            ;----------------------------------------------------------------

NonEp0ISR:
F_EP1_TX:
$$IF$ (BENCFG11 == 1)
$$IF$ (EPADDR11 == 129)
$$IFN$ (EPATT11 == 1)

        jnb     FTXD1,  F_EP1_RX
        mov     EPINDEX,#01

        lcall   Ep1TxLoopBack
        jb      RXFIF0, GetEp1RxData        ; If data is pending in the FIFOs go get it.
        jb      RXFIF1, GetEp1RxData        ; This is quicker than calling the routines.
        ljmp     F_EP1_RX                    ; Look at all Interrupt flags again
GetEp1RxData:
        lCall   Ep1RxLoopBack               ; 82930 has received a packet from HC
$$END$
$$END$
$$END$
$$IF$ (BENCFG12 == 1)
$$IF$ (EPADDR12 == 129)
$$IFN$ (EPATT12 == 1)

        jnb     FTXD1,  F_EP1_RX
        mov     EPINDEX,#01

        lcall   Ep1TxLoopBack
        jb      RXFIF0, GetEp1RxData        ; If data is pending in the FIFOs go get it.
        jb      RXFIF1, GetEp1RxData        ; This is quicker than calling the routines.
        ljmp     F_EP1_RX                    ; Look at all Interrupt flags again
GetEp1RxData:
        lCall   Ep1RxLoopBack               ; 82930 has received a packet from HC
$$END$
$$END$
$$END$
$$IF$ (BENCFG13 == 1)
$$IF$ (EPADDR13 == 129)
$$IFN$ (EPATT13 == 1)

        jnb     FTXD1,  F_EP1_RX
        mov     EPINDEX,#01

        lcall   Ep1TxLoopBack
        jb      RXFIF0, GetEp1RxData        ; If data is pending in the FIFOs go get it.
        jb      RXFIF1, GetEp1RxData        ; This is quicker than calling the routines.
        ljmp     F_EP1_RX                    ; Look at all Interrupt flags again
GetEp1RxData:
        lCall   Ep1RxLoopBack               ; 82930 has received a packet from HC
$$END$
$$END$
$$END$
$$IF$ (BENCFG14 == 1)
$$IF$ (EPADDR14 == 129)
$$IFN$ (EPATT14 == 1)

        jnb     FTXD1,  F_EP1_RX
        mov     EPINDEX,#01

        lcall   Ep1TxLoopBack
        jb      RXFIF0, GetEp1RxData        ; If data is pending in the FIFOs go get it.
        jb      RXFIF1, GetEp1RxData        ; This is quicker than calling the routines.
        ljmp     F_EP1_RX                    ; Look at all Interrupt flags again
GetEp1RxData:
        lCall   Ep1RxLoopBack               ; 82930 has received a packet from HC
$$END$
$$END$
$$END$
$$IF$ (BENCFG15 == 1)
$$IF$ (EPADDR15 == 129)
$$IFN$ (EPATT15 == 1)

        jnb     FTXD1,  F_EP1_RX
        mov     EPINDEX,#01

        lcall   Ep1TxLoopBack
        jb      RXFIF0, GetEp1RxData        ; If data is pending in the FIFOs go get it.
        jb      RXFIF1, GetEp1RxData        ; This is quicker than calling the routines.
        ljmp     F_EP1_RX                    ; Look at all Interrupt flags again
GetEp1RxData:
        lCall   Ep1RxLoopBack               ; 82930 has received a packet from HC
$$END$
$$END$
$$END$

⌨️ 快捷键说明

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