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

📄 usb_1.asm

📁 详细的无线键盘,鼠标,无线桥 开发文档.包含电路原理图,电路板光汇文件.FIREWALL, 驱动程序等.有此文档,就可以完全直接生产出来无线键盘,鼠标,无线桥.整个一套完整的解决方案.
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: USB_1.asm
;;   Version: 1.5, Updated on 2006/06/19 at 11:43:56
;;  Generated by PSoC Designer ver 4.3  b1884 : 23 June, 2006
;;
;;  DESCRIPTION: USB Device User Module software implementation file
;;               for the enCoRe II family of devices
;;
;;  NOTE: User Module APIs conform to the fastcall 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
;;        function returns. Even though these registers may be preserved now,
;;        there is no guarantee they will be preserved in future releases.
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress Semiconductor 2004, 2005. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************

include "m8c.inc"
include "USB_1_macros.inc"
include "USB_1.inc"
IF 0x2 & 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 USB_1_Start
EXPORT _USB_1_Start
;EXPORT USB_1_Stop
;EXPORT _USB_1_Stop
EXPORT USB_1_bCheckActivity
EXPORT _USB_1_bCheckActivity
EXPORT USB_1_bGetConfiguration
EXPORT _USB_1_bGetConfiguration
EXPORT USB_1_bGetEPState
EXPORT _USB_1_bGetEPState
;EXPORT USB_1_bGetEPCount
;EXPORT _USB_1_bGetEPCount
EXPORT USB_1_XLoadEP
EXPORT _USB_1_XLoadEP
;EXPORT USB_1_EnableOutEP
;EXPORT _USB_1_EnableOutEP
;EXPORT USB_1_DisableOutEP
;EXPORT _USB_1_DisableOutEP
;EXPORT USB_1_EnableEP
;EXPORT _USB_1_EnableEP
;EXPORT USB_1_DisableEP
;EXPORT _USB_1_DisableEP
EXPORT USB_1_Force
EXPORT _USB_1_Force
EXPORT USB_1_Suspend
EXPORT _USB_1_Suspend
EXPORT USB_1_Resume
EXPORT _USB_1_Resume
EXPORT USB_1_bRWUEnabled
EXPORT _USB_1_bRWUEnabled

AREA bss (RAM,REL)
;-----------------------------------------------
;  Variable Allocation
;-----------------------------------------------
;----------------------------------------------------------------------------
EXPORT USB_1_APITemp
 USB_1_APITemp:                        BLK   2 ; Two bytes of temporary
                                                ; storage shared by the API
                                                ; functions
EXPORT USB_1_APIEPNumber, _USB_1_APIEPNumber
_USB_1_APIEPNumber:
 USB_1_APIEPNumber:                    BLK   1 ; API storage for speed
EXPORT USB_1_APICount, _USB_1_APICount
_USB_1_APICount:
 USB_1_APICount:                       BLK   1 ; API storage for speed

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

AREA UserModules (ROM, REL)

;-----------------------------------------------------------------------------
;  FUNCTION NAME: USB_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 setting
;
;  RETURNS:
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
 USB_1_Start:
_USB_1_Start:
    MOV    REG[P10CR], 0x00            ; Disable the states
    MOV    REG[P11CR], 0x00            ; 

    MOV     [USB_1_bCurrentDevice], A  ; The app selects the desired device

    MOV     [USB_1_TransferType], USB_TRANS_STATE_IDLE ; Transaction Idle State
    MOV     [USB_1_Configuration], 0   ; Unconfigured
    MOV     [USB_1_DeviceStatus], 0    ; Clears device status

    MOV     [USB_1_EPDataToggle], 0    ; Clear all EP data toggles
	MOV     [_back_channel_buffer], 0   ; Initialize Set Report RAMs
	MOV     [set_output_report_flags], 0      

	
    MOV     [USB_1_Protocol], 1    	   ; Set default as Report Protocol
    MOV     [USB_1_Protocol +1], 1     ; Set default as Report Protocol

; Flow here to enable the SIE
    MOV     REG[USB_1_ADDR], USB_ADDR_ENABLE ; Enable Address 0
    OR      REG[USB_1_USBXCR], USB_PULLUP_ENABLE ; Pullup D-
    MOV     REG[USB_1_EP0MODE], USB_MODE_STALL_IN_OUT ; ACK Setup/Stall IN/OUT
    NOP
    MOV     A, REG[USB_1_EP0MODE]      ; Read the mode register as a debug marker

    M8C_EnableIntMask INT_MSK1, (INT_MSK1_USB_ACTIVITY | INT_MSK1_USB_BUS_RESET | INT_MSK1_USB_EP0)
    RET
.ENDSECTION
IF 0
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USB_1_Stop
;
;  DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;
;  RETURNS:
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
 USB_1_Stop:
_USB_1_Stop:
    MOV     [USB_1_bCurrentDevice], 0  ; The app selects the desired device

    MOV     [USB_1_TransferType], USB_TRANS_STATE_IDLE ; Transaction Idle State
    MOV     [USB_1_Configuration], 0   ; Unconfigured
    MOV     [USB_1_DeviceStatus], 0    ; Clear the  device status
    MOV     [USB_1_bActivity], 0       ; Clear the activity flag
    MOV     REG[USB_1_ADDR], 0         ; Clear the addfress and Address 0
    AND     REG[USB_1_USBXCR], ~USB_PULLUP_ENABLE ; Release D-
    M8C_DisableIntMask    INT_MSK1, (INT_MSK1_USB_ACTIVITY | INT_MSK1_USB_BUS_RESET | INT_MSK1_USB_EP0 | INT_MSK1_USB_EP1 | INT_MSK1_USB_EP2) ; Enable the interrupt

    RET
.ENDSECTION
ENDIF
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USB_1_bCheckActivity
;
;  DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;
;  RETURNS:
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;   The activity interrupt sets a RAM flag indicating activity and disables the
;   interrupt.  Disabling the interrupt keeps the bus activity from creating too
;   many interrupts.  bCheckActivity checks and clears the flag, the enables
;   interrupts for the next interval.
;
;-----------------------------------------------------------------------------
.SECTION
 USB_1_bCheckActivity:
_USB_1_bCheckActivity:
    MOV    A, [USB_1_bActivity]        ; Activity?
    CMP    A, 1                        ; 
    JZ     .active                     ; Jump on Activity
; Flow here on no activity
    RET
; Jump here if activity was detected
.active:
    MOV    [USB_1_bActivity], 0        ; Clear the activity flag for next time
    M8C_EnableIntMask INT_MSK1, INT_MSK1_USB_ACTIVITY ; Enable the activity interupt
    RET
.ENDSECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USB_1_bGetConfiguration
;
;  DESCRIPTION:   Returns the current configuration number
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    None
;
;  RETURNS:      A contains the current configuration number
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
 USB_1_bGetConfiguration:
_USB_1_bGetConfiguration:
    MOV     A,[USB_1_Configuration]
    RET
.ENDSECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USB_1_bGetEPState
;
;  DESCRIPTION:   Returns the current endpoint state
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:   A: Endpoint Number
;
;  RETURNS:     A: NO_EVENT_ALLOWED
;                  EVENT_PENDING
;                  NO_EVENT_PENDING
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
 USB_1_bGetEPState:
_USB_1_bGetEPState:
    CMP     A, (USB_MAX_EP_NUMBER + 1) ; Range check
    JNC     .invalid_ep                ; Bail out
; Flow here to enable an endpoint        
    MOV     X, A                       ; Endpoint number is the index
    MOV     A, [X+USB_1_EndpointAPIStatus]; Get the state
    JMP     .exit                      ; Go to the common exit
; Jump here for an invalid endpoint
.invalid_ep:
    MOV     A, 0                       ; Return 0 for an invalid ep
; Jump or flow here for a common exit
.exit:
    RET                                ; All done
.ENDSECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USB_1_bRWUEnabled
;
;  DESCRIPTION:   Returns 1 if Remote Wake Up is enabled, otherwise 0
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:   None
;
;  RETURNS:     A: 1--Remote Wake Up Enabled
;                  0--Remote Wake Up Disabled
;
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
 USB_1_bRWUEnabled:
_USB_1_bRWUEnabled:
    TST     [USB_1_DeviceStatus], USB_DEVICE_STATUS_REMOTE_WAKEUP
    JNZ     .enabled                   ; Jump if enabled
; Flow here if RWU is disabled        
    MOV     A, 0                       ; Return disabled
    JMP     .exit                      ; Go to the common exit
; Jump when RWU is enabled
.enabled:
    MOV     A, 1                       ; Return enabled
; Jump or flow here for a common exit
.exit:
    RET                                ; All done
.ENDSECTION
IF 0
;-----------------------------------------------------------------------------
;  FUNCTION NAME: USB_1_bGetEPCount
;

⌨️ 快捷键说明

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