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

📄 usbfs_1.asm

📁 cypresscy74294ic键盘和鼠标原码
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: USBFS_1.asm
;;   Version: 1.1, Updated on 2006/06/19 at 11:41:37
;;  Generated by PSoC Designer ver 4.4  b1884 : 14 Jan, 2007
;;
;;  DESCRIPTION: USB Device User Module software implementation file
;;               for the CY8C24090 and CY7C64215 family of devices
;;
;;  NOTE: User Module APIs conform to the fastcall16 convention for marshalling
;;        arguments and observe the associated "Registers are volatile" policy.
;;        This means it is the caller's responsibility to preserve any values
;;        in the X and A registers that are still needed after the API functions
;;        returns. For Large Memory Model devices it is also the caller's
;;        responsibility to perserve any value in the CUR_PP, IDX_PP, MVR_PP and
;;        MVW_PP registers. Even though some of these registers may not be modified
;;        now, there is no guarantee that will remain the case in future releases.
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress Semiconductor 2005. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************

include "m8c.inc"
include "memory.inc"
include "USBFS_1_macros.inc"
include "USBFS_1.inc"
IF 0x3 & 0x10000000
PSOC_ERROR Please run the USB Setup Wizard.  Device Editor, Right Click the USB User Module
; This message will only appear if the USB Setup Wizard has not be run and the descriptors
; and associated data structures have been created.
; After running the USB Setup Wizard, you must also select the Config/Generate Application
; menu item from PSoC Designer in order to generate USB User Module data structures and
; descriptors.
ENDIF
;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
EXPORT USBFS_1_Start
EXPORT _USBFS_1_Start
EXPORT USBFS_1_Stop
EXPORT _USBFS_1_Stop
EXPORT USBFS_1_bCheckActivity
EXPORT _USBFS_1_bCheckActivity
EXPORT USBFS_1_bGetConfiguration
EXPORT _USBFS_1_bGetConfiguration
EXPORT USBFS_1_bGetEPState
EXPORT _USBFS_1_bGetEPState
EXPORT USBFS_1_wGetEPCount
EXPORT _USBFS_1_wGetEPCount
EXPORT USBFS_1_LoadInEP
EXPORT _USBFS_1_LoadInEP
EXPORT USBFS_1_LoadInISOCEP
EXPORT _USBFS_1_LoadInISOCEP
EXPORT USBFS_1_EnableOutEP
EXPORT _USBFS_1_EnableOutEP
EXPORT USBFS_1_EnableOutISOCEP
EXPORT _USBFS_1_EnableOutISOCEP
EXPORT USBFS_1_DisableOutEP
EXPORT _USBFS_1_DisableOutEP
EXPORT USBFS_1_bReadOutEP
EXPORT _USBFS_1_bReadOutEP
EXPORT USBFS_1_Force
EXPORT _USBFS_1_Force
EXPORT USBFS_1_bGetEPAckState
EXPORT _USBFS_1_bGetEPAckState
;EXPORT USBFS_1_Suspend
;EXPORT _USBFS_1_Suspend
;EXPORT USBFS_1_Resume
;EXPORT _USBFS_1_Resume
EXPORT USBFS_1_bRWUEnabled
EXPORT _USBFS_1_bRWUEnabled

AREA InterruptRAM (RAM,REL,CON)
;-----------------------------------------------
;  Constant Definitions
;-----------------------------------------------

;-----------------------------------------------
;  Variable Allocation
;-----------------------------------------------
EXPORT USBFS_1_APITemp
 USBFS_1_APITemp:                       BLK   2 ; Two bytes of temporary
                                                ; storage shared by the API
                                                ; functions
EXPORT USBFS_1_APIEPNumber, _USBFS_1_APIEPNumber
_USBFS_1_APIEPNumber:
 USBFS_1_APIEPNumber:                  BLK   1 ; API storage for speed
EXPORT USBFS_1_APICount, _USBFS_1_APICount
_USBFS_1_APICount:
 USBFS_1_APICount:                     BLK   1 ; API storage for speed

EXPORT USBFS_1_bActivity
 USBFS_1_bActivity:                    BLK   1 ; Activity flag (Shared between the ISR and API)
;-----------------------------------------------
;  Constant Data Allocation
;-----------------------------------------------
AREA UserModules (ROM, REL)
EXPORT USBFS_1_USB_EP_BIT_LOOKUP
.LITERAL
USBFS_1_USB_EP_BIT_LOOKUP:  ;
    DB     01H                       ; EP0
    DB     02H                       ; EP1
    DB     04H                       ; EP2
    DB     08H                       ; EP3
    DB     010H                      ; EP4
.ENDLITERAL

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_Start
;
;  DESCRIPTION:    Starts the USB User Module
;                    Sets the device selection
;                    Set the configuration to unconfigured
;                    Enables the SIE for Address 0
;                    Enables the USB pullup (D- for low speed, D+ for full speed)
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    A is the desired device
;                X is the operation voltage
;
;  RETURNS:              Nothing
;
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16
;    functions.
;
 USBFS_1_Start:
_USBFS_1_Start:
    RAM_PROLOGUE RAM_USE_CLASS_4
    RAM_PROLOGUE RAM_USE_CLASS_3
        RAM_SETPAGE_CUR >USBFS_1_bCurrentDevice ; Set the CUR_PP to the right page
    RAM_SETPAGE_IDX >USBFS_1_bCurrentDevice ; Set the IDX_PP to the right page
    push    X
    mov     [USBFS_1_bCurrentDevice], A; The app selects the desired device

    mov     [USBFS_1_TransferType], USB_TRANS_STATE_IDLE ; Transaction Idle State
    mov     [USBFS_1_Configuration], 0 ; Unconfigured
    mov     [USBFS_1_DeviceStatus], 0  ; Clears device status

    MOV     [USBFS_1_EPDataToggle], 0  ; Clear all EP data toggles

    mov     reg[TMP_DR0], 0            ; EP1 start address in PMA space
        mov     reg[TMP_DR1], 64       ; EP2 start address in PMA space
        mov     reg[TMP_DR2], 128      ; EP3 start address in PMA space
        mov     reg[TMP_DR3], 192      ; EP4 start address in PMA space

;    mov     X, USB_MAX_EP_NUMBER      ; Set up loop to clear all of the endpoint data items
; Flow or jump here to clear the data for the next endpoint
;.loop:
;    mov     [X + USBFS_1_EPDataToggle], 0  ; Or in the toggle
;    dec     X                         ; Are we done?
;    jnz     .loop                     ; Jump to do another endpoint
; Flow here to enable the SIE

    mov     reg[USBFS_1_ADDR], USB_ADDR_ENABLE ; Enable Address 0
        mov     reg[USBFS_1_USBIO_CR0], USB_AUTO_DPDM

; Set the Operating Voltage at which the chip will run
    pop     A
    M8C_SetBank1
        mov     reg[USBFS_1_USB_CR1], A
        M8C_SetBank0
;   TODO
    mov     reg[USBFS_1_EP0MODE], USB_MODE_STALL_IN_OUT ; ACK Setup/Stall IN/OUT
    M8C_EnableIntMask USBFS_1_INT_REG, (USBFS_1_INT_RESET_MASK | USBFS_1_INT_EP0_MASK)

;   Enable the pullup so we can start to rock and roll
    mov     reg[USBFS_1_USBIO_CR1], USB_PULLUP_ENABLE ; Pullup D+

    RAM_EPILOGUE RAM_USE_CLASS_3
        RAM_EPILOGUE RAM_USE_CLASS_4
    RET
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_Stop
;
;  DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: None
;
;  RETURNS:   Nothing
;
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16
;    functions.
;
 USBFS_1_Stop:
_USBFS_1_Stop:
    RAM_PROLOGUE RAM_USE_CLASS_4
        RAM_SETPAGE_CUR >USBFS_1_bCurrentDevice ; Set the CUR_PP to the right page

    mov     [USBFS_1_bCurrentDevice], 0; The app selects the desired device

    mov     [USBFS_1_TransferType], USB_TRANS_STATE_IDLE ; Transaction Idle State
    mov     [USBFS_1_Configuration], 0 ; Unconfigured
    mov     [USBFS_1_DeviceStatus], 0  ; Clears device status
    mov     reg[USBFS_1_ADDR], 0       ; Clear the addfress and Address 0

    and     reg[USBFS_1_USBIO_CR1], ~USB_PULLUP_ENABLE ; Release D-
    mov     reg[USBFS_1_INT_REG], 0x00 ; Enable the interrupt

        RAM_EPILOGUE RAM_USE_CLASS_4
    RET
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_bCheckActivity
;
;  DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: Nothing
;
;  RETURNS:   A is a flag that indicates bus activity
;
;  SIDE EFFECTS: ;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16
;    functions.
;
 USBFS_1_bCheckActivity:
_USBFS_1_bCheckActivity:
    RAM_PROLOGUE RAM_USE_CLASS_1
    M8C_SetBank1
    mov    A, reg[USBFS_1_USB_CR1]     ; USB Activity bit indicates activity
    and    A, USB_BUS_ACTIVITY         ; Activity?
    jz     .no_activity                ; Jump on no activity?
; Flow here on bus activity
    mov    A, 1                        ; Return true
    jmp    .done
; Jump here on no activity
.no_activity:
    mov    A, 0                        ; Return false
; Jump or flow here to clear the activity bit, then return
.done:
    and    reg[USBFS_1_USB_CR1], ~USB_BUS_ACTIVITY  ; Clear the activity flag
    M8C_SetBank0
        RAM_EPILOGUE RAM_USE_CLASS_1
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_bGetConfiguration
;
;  DESCRIPTION:   Returns the current configuration number
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    None
;
;  RETURNS:      A contains the current configuration number
;
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  The same is true for all RAM page pointer registers in
;    the Large Memory Model.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16
;    functions.
;
 USBFS_1_bGetConfiguration:
_USBFS_1_bGetConfiguration:
        RAM_PROLOGUE RAM_USE_CLASS_4
        RAM_SETPAGE_CUR >USBFS_1_Configuration
    mov     A,[USBFS_1_Configuration]
        RAM_EPILOGUE RAM_USE_CLASS_4
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USBFS_1_bGetEPState
;
;  DESCRIPTION:
;
;-----------------------------------------------------------------------------

⌨️ 快捷键说明

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