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

📄 hub_ep0.asm

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


;**************************************************************************
;**                                                                      **
;**                  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:40  $
;**$Revision:   1.2  $
;***************************************************************************


; Remarks about this code:
;*************************
; The code is in an absolute format starting at location 00:4000 hex
; This location should be used if this code is to be downloded through
; a serial RS232 port to the 8x930AX\Hx board with RISM programmed in
; the EPROM. The main code starts at label "main" located at 004080.
; There is no need to include the configuration bytes in this code
; because RISM already takes care of that.
;
; If users want to adapt this code to their own board or if they want
; to change the EPROM provided with the board with their own EPROM,
; then they need to relocate the code. They need to change the
; starting location to 0FF:0000 hex and the label main to 0FF:0080.
; They will also need to program the Chip Cconfiguration Bytes.
;
; This code should run on all assebmlers provided by third party
; vendors. Minimum changes may be required. Users may need to change
; the include files, and use the ones provided by the Third party
; vendor they are using.


;$INCLUDE (8x930HX.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 8x930HX.INC      ;  Select the other format if assembling for
INCLUDE ONE_OH.INC       ;  Intel Compatibility


FIFO_SIZE             equ     008h
GET_COMMAND           equ     080h
SETUP_PHASE           equ     000h
DATA_PHASE            equ     001h
STATUS_PHASE          equ     002h


EP0_MAX_PACKET_SIZE     equ      08h
NULL_DATA_PACKET        equ     000h

C_HUB_LOCAL_POWER       EQU   0
C_HUB_OVER_CURRENT      EQU   1
PORT_CONNECTION         EQU   0
PORT_ENABLE             EQU   1
PORT_SUSPEND            EQU   2
PORT_OVER_CURRENT       EQU   3
PORT_RESET              EQU   4
PORT_POWER              EQU   8
PORT_LOW_SPEED          EQU   9
C_PORT_CONNECTION       EQU   16
C_PORT_ENABLE           EQU   17
C_PORT_SUSPEND          EQU   18
C_PORT_OVER_CURRENT     EQU   19
C_PORT_RESET            EQU   20


DISABLE_PORT_CMD        EQU   00h
ENABLE_PORT_CMD         EQU   01h
RESET_ENABLE_PORT_CMD   EQU   02h
SUSPEND_PORT_CMD        EQU   03h
RESUME_PORT_CMD         EQU   04h

CLEAR_PCSC_MASK         EQU  0FEh
CLEAR_PESC_MASK         EQU  0FDh
CLEAR_PSSC_MASK         EQU  0FBh
CLEAR_RSTSC_MASK        EQU  0EFH
CLEAR_OVISC_MASK        EQU  0F7h

$$IF$ IPORT
EMBEDDED_PORT_NUMBER    EQU    4h

extern InitilizeEmbeddedFunction:CODE
extern FifoWatchDog:CODE

extern FUNCTION_ISR:CODE
extern EmbeddedFunctionSofRoutine:CODE
extern FUNCTION_SUSPEND_ROUTINE:CODE, FUNCTION_RESUME_ROUTINE:CODE
extern STACK_DATA:PDATA

public FwValue, RWUTimer
$$END$

public END_VECTORS,RESET_VECTOR

;***************
; Program origin
;****************

ORG 00:4000h                 ; Change to ORG 0FF:0000h for your
                             ; own EPROM/design


RESET_VECTOR:       LJMP main
INT0_VECTOR:        LJMP $
                    ds      5

TIM0_VECTOR:        LJMP $
                    ds      5

INT1_VECTOR:        LJMP $
                    ds      5

TIM1_VECTOR:        LJMP $
                    ds      5

SER_VECTOR:         LJMP $
                    ds      5

TIM2_VECTOR:        LJMP $
                    ds      5

PCA_VECTOR:         LJMP $
                    ds 13

SOF_VECTOR:          LJMP SOF_ISR
                    ds 5

$$IF$ IPORT
USB_FUNC_VECTOR:     LJMP FUNCTION_ISR
$$END$
$$IFN$ IPORT
USB_FUNC_VECTOR:     LJMP $
$$END$
                    ds 5


SUS_RSM_VECTOR:      LJMP SUSPEND_RESUME_ISR
                    ds 25h

TRAP_VECTOR:         LJMP $
END_VECTORS:

;*******************

;SEGMENT HUB_EP0_CODE_SEGMENT

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

ORG 00:4080H                  ; Change to 0FF:0080 for you own
                              ; EPROM/design

main:
$$IF$ IPORT
        mov     SP,     #LOW (STACK_DATA)
        mov     SPH,    #HIGH(STACK_DATA)  ; Set the stack to start @ 00:0500h
$$END$
$$IFN$ IPORT
        mov     SP,     #00h
        mov     SPH,    #02h
$$END$
        mov     DPXL,   #0ffh              ; Set DPXL to point at the FLASH device
                                           ; to access constants

        inc     FTLOCK_FLG

        lCall   INIT_VARIABLES             ; Initialize the RAM space as required
        lCall   INIT_USB




        Lcall   InitilizeHubVariables


                                           ;----------------------------------------
                                           ;--- Enable Function Interrupts
                                           ;----------------------------------------
                                           ;----------------------------------------
                                           ;--- Enable HUB Interrupts
                                           ;----------------------------------------
        mov     EPINDEX, #80h              ; Select Hub EP1
        mov     EPCON,  #0$$HEPCON$h              ; CNTL, ENable all
        mov     HIE,    #0$$HFIE$h               ; Enable the USB FunctionHUB EP0
        orl     IEN1,   #0$$IEN1$h                     ; Enable HUB/SOF ISR
        mov     EPINDEX, #00h


          ; Resume is set here
        mov     RWUTimer, #00h             ; CLear RWU Timer
        mov     EmbeddedFunctionInReset, #00h      ; Used to track when we are sending a reset to the Embdeeded function.
;        setb    IEN1.2                     ; ENable Suspend/Resume ISR
        setb    EA                                  ; Enable Interrupts.
$$IFN$ IPORT
        setb    SOFIE
$$END$
;------------------------------------------------------------------
        SETB    LC
;        CLR     LC                ; Increase the clock speed so we can go with this.
                                  ; (KLS) SET LC will reduce current draw
                                  ; by dropping the clk frequency by 75%
                                  ; Default mode..


       ljmp    ActiveLoop                  ; Jump over the ISR stubs to the main loop.




;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.
;--------------------------------------------------------------------*

;COMMENT *------------------------------------------------------------
;Function name     : ActiveLoop
;Brief Description : This routine simply sets and clears P1.3 at a periodic rate
;                  : It purpose is to let the user know the part is alive.
;
;Regs preserved    : No reg. is saved
;--------------------------------------------------------------------*
;SCOPE

ActiveLoop:

;------------------------------------------------------------------
;-- Check to see if a Suspend/Resume Event is pending.
;------------------------------------------------------------------
;        mov     A,      SuspendResumeFlag
;        jz      HeartBeat
;       lcall    SuspendCode
;------------------------------------------------------------------
;-- Heart Beat
;------------------------------------------------------------------
HeartBeat:
                                     ; Debug code to toggle Port 3.3 when a disable event is detected

        mov     HPINDEX, #1
        mov     A,  HPSC
        anl     A,  #017h
        jz      NO_SC
        cpl     P3.4
        cpl     P3.4
        cpl     P3.4
        cpl     P3.4
        cpl     P3.4
        cpl     P3.4


NO_SC:
        mov     WR0,    Heart1
        inc     WR0,    #1
        mov     Heart1, WR0
        cmp     WR0,    #7FFFh
        jl      ClearBit
        setb    P1.3
       sjmp     ActiveLoop
ClearBit:
        clr     P1.3
       sjmp     ActiveLoop



;----------------------------------------------------------------
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;SS                 SUSPEND/RESUME ISR
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;----------------------------------------------------------------
;COMMENT *------------------------------------------------------------
;Function name     : SUSPEND_RESUME_ISR
;BrieS Description : Service the SUSPEND_RESUME Interrupt
;                  :
;Regs preserved    : Reg. A, B  & EPINDEX are saved
;--------------------------------------------------------------------*
;SCOPE
SUSPEND_RESUME_ISR:
$$IF$ IPORT
        push   PSW
        push   PSW1

       lcall  FUNCTION_SUSPEND_ROUTINE
$$END$

        push   ACC
        push   DR0

        mov    P1, #33h
        mov   R11, RWUTimer             ; If timmer is zero, do a normal suspend.
        orl   R11, RWUTimer+1
        JZ    DoSuspend                 ; Otherwise wait a delay and then resume.

DoRWU:

        push WR2
        mov  WR2,   RWUTimer
        mov  WR0,   #0
WaitLoop:
        dec  DR0,  #1h
        cpl  P1.1
        jne  WaitLoop

        setb RWU
D1:
        jb   RWU,   D1                   ; Wait until RWU is done.
         pop  WR2

        sjmp  RESUME_CODE



DoSuspend:

        setb  PD
        nop
        nop

⌨️ 快捷键说明

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