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

📄 usb_macros.inc

📁 利用psoc进行usb及capsense的程序编写
💻 INC
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: USBmacros.inc
;;   Version: 0.1, Updated on 2004/11/29 at 23:25:42
;;  Generated by PSoC Designer ver 4.2  b1013 : 02 September, 2004
;;
;;  DESCRIPTION: Macros supporting the USB user module interface
;;               for the enCore II family of devices
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress Semiconductor 2004. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
;--------------------------------------------------
; Constants for USB API's.
;--------------------------------------------------

;--------------------------------------------------
; MACROs for Debugging
; TODO: Remove for production
;--------------------------------------------------

MACRO GET_REG
IF TEST_BENCH
    mov     a,[@0]                           ; Get the simulated reg
ELSE
    mov     a,reg[@0]                        ; Get the real reg
ENDIF    
ENDM    

MACRO PUT_REG
IF TEST_BENCH
    mov     [@0],a                           ; Set the simulated reg
ELSE
    mov     reg[@0],a                        ; Set the real reg
ENDIF    
ENDM    

MACRO PUT_REG_CONST
IF TEST_BENCH
    mov     [@0],@1                          ; Set the simulated reg
ELSE
    mov     reg[@0],@1                       ; Set the real reg
ENDIF    
ENDM    

;--------------------------------------------------
; GET_WORD MACRO
;--------------------------------------------------
; Parameters:
;   None
; Register setup
;   A = ROM Source Address MSB 
;   X = ROM Source Address LSB 
MACRO   GET_WORD
    PUSH A                              ; Quickly get a RAM temp
    PUSH A                              ; Save the source MSB
    ROMX                                ; Get the first byte
    PUSH X                              ; Save X
    MOV  X,SP                           ; Get SP, to index to the temp 
    MOV  [X - 3],A                      ; Save the first byte
    POP  X                              ; Get back the source LSB
    POP  A                              ; And the MSB
    INC  X                              ; Point to the second byte
    ADC  A, 0                           ; 
    ROMX                                ; Get the second byte
    MOV  X,A                            ; Save it in X
    POP  A                              ; And the first byte in A
ENDM

;--------------------------------------------------
; NULL_PTR_CHECK MACRO
;--------------------------------------------------
; Parameters:
;   Address to jump to on a NULL Pointer
; Register setup
;   A = ROM Address MSB 
;   X = ROM Address LSB 
MACRO   NULL_PTR_CHECK
    SWAP    A, X                        ; LSB non-zero?
    JNZ     .ok                         ; Exit on non-zero
    SWAP    A, X                        ; MSB zero
    JZ      @0                          ; Jump to the null pointer handler
    JMP     .exit
.ok:
    SWAP    A, X                        ; Put them back
.exit:
ENDM

NULL_PTR:   EQU 0                       ; Null pointer value

;--------------------------------------------------
; Transfer Descriptor--Data Source
;--------------------------------------------------
USB_DS_ROM:                                      EQU 0x00
USB_DS_RAM:                                      EQU 0x01
USB_DS_RAM_CB:                                   EQU 0x02
USB_DS_RAM_MASK:                                 EQU 0x03

;--------------------------------------------------
; TRANSFER DESCRIPTOR MACROS
;--------------------------------------------------

;-----------------------------------------------
; TD_START_TABLE MACRO
;-----------------------------------------------
; Parameters:
;   @0 = Number of table entries
; Register setup
;   N/A (builds ROM data at assembly time)
;-----------------------------------------------
MACRO   TD_START_TABLE
    DB      ((@0) - 1)                 ; Number of table entries - 1
ENDM
;-----------------------------------------------
; TD_START_TABLE MACRO
;-----------------------------------------------
; Parameters:
;   @0 = Data source (USB_DATA_SRC_*)
;   @1 = Transfer size
;   @2 = Data source address
; Register setup
;   N/A (builds ROM data at assembly time)
;-----------------------------------------------
MACRO   TD_ENTRY
    DB  @0                             ; Data source (USB_DS_*)
; TODO: Should this be a dwl to be consistent with the compiler?
    DW  @1                             ; Transfer size
    DW  @2                             ; Data source address
    DB  0xde                           ; Reserved 
ENDM
TD_ENTRY_SIZE:                         EQU 6
TD_START_SIZE:                         EQU 1
;-----------------------------------------------
; TD_INDEX_TO_OFFSET MACRO
;-----------------------------------------------
; Parameters:
;   @0 = RAM address of Index
; Register setup
;   A = DC (restored)
;   X = DC (not used)
;--------------------------------------------------
MACRO   TD_INDEX_TO_OFFSET
    PUSH    A                          ; Save a work register
    ASL     [@0]                       ; Index * 2
    MOV     A, [@0]                    ; Get Index * 2
    ASL     [@0]                       ; Index * 4
    ADD     [@0], A                    ; Index * 6
    POP     A                          ; Restore the work register
ENDM

;--------------------------------------------------
; LOOKUP TABLE MACROS
;--------------------------------------------------
;--------------------------------------------------
; LT_START
;--------------------------------------------------
; Start a lookup table
; Parameters:
;   @0 Table Size
; Register setup
;   N/A (builds ROM data at assembly time)
;--------------------------------------------------
MACRO LT_START
    DB      (@0)                       ; Table size
ENDM

;--------------------------------------------------
; LT_ENTRY
;--------------------------------------------------
; Insert a lookup table entry
; Parameters:
;   @0 Table entry 0
;   @1 Table entry 1
; Register setup
;   N/A (builds ROM data at assembly time)
;--------------------------------------------------
MACRO LT_ENTRY
    DW      (@0)                       ; Table entry
    DW      (@1)                       ; Table entry
ENDM
LT_ENTRY_SIZE:                         EQU 2
LT_START_SIZE:                         EQU 1

;-----------------------------------------------
; LT_INDEX_TO_OFFSET MACRO
;-----------------------------------------------
; Parameters:
;   @0 = RAM address of Index
; Register setup
;   A = DC (not used)
;   X = DC (not used)
;--------------------------------------------------
MACRO   LT_INDEX_TO_OFFSET
    ASL     [@0]                       ; Simply shift (mult by 2)
    ASL     [@0]                       ;              (mult by 4)
ENDM
;--------------------------------------------------
; DISPATCH Macros
;--------------------------------------------------
;--------------------------------------------------
; DISPATCHER MACRO
;--------------------------------------------------
; Dispatch through JACC Instruction
; Parameters:
;   @0 Address of the jump table
;   @1 Jump Table Size
;   @2 Address of the index out of range handler
; Register setup
;   A = Function Index
;--------------------------------------------------
MACRO DISPATCHER
    CMP   A,@1
    JNC   @2
    ASL   A
    JACC  @0
ENDM

; end of file USB_macro.inc

⌨️ 快捷键说明

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