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

📄 csd2x_1.asm

📁 带触摸按键的高端电磁炉设计 该方案采用CYPRESS的新器件CY8C22545,是一款专门针对中高端的家电触摸产品设计。除了集成触摸按键功能外
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;*****************************************************************************
;*****************************************************************************
;  FILENAME: CSD2X_1.asm
;  Version: 1.0, Updated on 2008/12/13 at 11:0:40
;  Generated by PSoC Designer ???
;
;  DESCRIPTION: CSD 2X User Module software implementation file
;;               for the 22x45 PSoC 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) 2008 Cypress Semiconductor Corporation. All rights reserved.
;
; This file contains Source Code. You may not use this file except in compliance with the
; Cypress Semiconductor Corporation IP Library License and Usage Agreement.
;
; Please obtain a copy of the Agreement at
;
; http://www.cypress.com/IP_Library_License_Agreement.pdf
;
; and read it before using this file.
;
; The Source Code and all software distributed under the Agreement are distributed on an 'AS IS' basis,
; WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS, IMPLIED OR STATUTORY, REGARDING THE SUFFICIENCY,
; ACCURACY OR COMPLETENESS OF THE INFORMATION AND CYPRESS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
; INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
; AND NON-INFRINGEMENT. Cypress Semiconductor Corporation reserves the right to make changes to the
; Source Code and any software distributed under the Agreement without further notice.
;
; Please see the License and Usage Agreement for the specific language governing rights and
; limitations under the Agreement.
;----------------------------------------------------------------------------

include "m8c.inc"
include "memory.inc"
include "GlobalParams.inc"
include "CSD2X_1.inc"

;-----------------------------------------------
;  Global Labels
;-----------------------------------------------

; Exported functions
export _CSD2X_1_Start
export  CSD2X_1_Start
export _CSD2X_1_Stop
export  CSD2X_1_Stop
export _CSD2X_1_ClearSensors
export  CSD2X_1_ClearSensors
export _CSD2X_1_wReadSensor
export  CSD2X_1_wReadSensor
export _CSD2X_1_wGetPortPinLeft
export  CSD2X_1_wGetPortPinLeft
export _CSD2X_1_wGetPortPinRight
export  CSD2X_1_wGetPortPinRight
export _CSD2X_1_EnableSensor
export  CSD2X_1_EnableSensor
export _CSD2X_1_DisableSensor
export  CSD2X_1_DisableSensor
export _CSD2X_1_ScanSensor
export  CSD2X_1_ScanSensor
export _CSD2X_1_ScanAllSensors
export  CSD2X_1_ScanAllSensors
export _CSD2X_1_SetLeftRefValue
export  CSD2X_1_SetLeftRefValue
export _CSD2X_1_SetRightRefValue
export  CSD2X_1_SetRightRefValue
export _CSD2X_1_SetLeftDACValue
export  CSD2X_1_SetLeftDACValue
export _CSD2X_1_SetRightDACValue
export  CSD2X_1_SetRightDACValue
export _CSD2X_1_SetDACRange
export  CSD2X_1_SetDACRange

IF CSD2X_1_AUTOCALIBRATION
export  CSD2X_1_Calibrate
export _CSD2X_1_Calibrate
ENDIF

; Exported variables
export  CSD2X_1_bSensorNumLeft
export _CSD2X_1_bSensorNumLeft
export  CSD2X_1_bSensorNumRight
export _CSD2X_1_bSensorNumRight
export  CSD2X_1_bSensorNum
export _CSD2X_1_bSensorNum
export  CSD2X_1_waSnsResult
export _CSD2X_1_waSnsResult
export  CSD2X_1_bfStatus_Left
export _CSD2X_1_bfStatus_Left
export  CSD2X_1_bfStatus_Right
export _CSD2X_1_bfStatus_Right

LSB:  equ  1
MSB:  equ  0

AREA bss
_CSD2X_1_waSnsResult:                           ; Current raw results
 CSD2X_1_waSnsResult:                   BLK  (2*CSD2X_1_TotalSensorCount)

IF CSD2X_1_AUTOCALIBRATION
_CSD2X_1_baDACCodeBaselineL:                    ; Left Chanel DAC codes
 CSD2X_1_baDACCodeBaselineL:            BLK   CSD2X_1_TotalSensorCount
_CSD2X_1_baDACCodeBaselineR:                    ; Right Chanel DAC codes
 CSD2X_1_baDACCodeBaselineR:            BLK   CSD2X_1_TotalSensorCount
ENDIF

AREA InterruptRAM (RAM, REL, CON)
_CSD2X_1_bSensorNum:   	                        ; Current sensor to scan for HL API
 CSD2X_1_bSensorNum:	                   BLK  1
_CSD2X_1_bSensorNumLeft:                        ; Current sensor to scan left channel
 CSD2X_1_bSensorNumLeft:                BLK  1
 _CSD2X_1_bSensorNumRight:                      ; Current sensor to scan right channel
 CSD2X_1_bSensorNumRight:               BLK  1
 _CSD2X_1_bBitMask:  			                        ; Temporary Bit mask
 CSD2X_1_bBitMask:                      BLK  1
 _CSD2X_1_bfStatus_Left:	                       ; Status for left channel
 CSD2X_1_bfStatus_Left:                 BLK  1
  _CSD2X_1_bfStatus_Right:	                     ; Status for right channel
 CSD2X_1_bfStatus_Right:                BLK  1

 IF CSD2X_1_AUTOCALIBRATION
 _CSD2X_1_wTmp2:                        BLK  2  ; Temporary variable for Autocalibration
 CSD2X_1_wTmp2:                         BLK  2
ENDIF

AREA UserModules (ROM, REL, CON)

.LITERAL
CSD2X_1_PRS_Poly_Table:
;    9bit    10bit   11bit   12bit   13bit  14bit    15bit   16bit
 DW 0x0134, 0x02C2, 0x0524, 0x0CA0, 0x1B00, 0x3802, 0x5280, 0xD008  ;  PRS polynomials table

CSD2X_1_Timer_Res_Table:
;  9bit 10bit 11bit 12bit 13bi  14bi  15bit  16bit
DB 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF  ;  Timer resolution table
.ENDLITERAL

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: CSD2X_1_Start
;  DESCRIPTION: Start the CSD2X UM
;-----------------------------------------------------------------------------
;  ARGUMENTS: None
;  RETURNS:  None
;  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.
;-----------------------------------------------------------------------------
 CSD2X_1_Start:
_CSD2X_1_Start:
	RAM_PROLOGUE RAM_USE_CLASS_4
    RAM_SETPAGE_CUR 0 ; direct access ram will always be in interrupt ram area

    mov     [CSD2X_1_bNoiseThreshold], CSD2X_1_NOISE_THRESHOLD
    mov     [CSD2X_1_bNegativeNoiseThreshold], CSD2X_1_NEGATIVE_NOISE_THRESHOLD
    mov     [CSD2X_1_bBaselineUpdateThreshold], CSD2X_1_BASELINE_UPDATE_THRESHOLD
    mov     [CSD2X_1_bHysteresis], CSD2X_1_HYSTERESIS
    mov     [CSD2X_1_bDebounce], CSD2X_1_Debounce
    mov     [CSD2X_1_bLowBaselineReset], CSD2X_1_LowBaselineReset

    ; Filter Capacitor Configuration
    or      reg[AMUXCFG], 31h                              ; Capacitor on P0.5/P0.7 and muxbus clocked from CSD0/CSD1

	M8C_SetBank1

	mov reg[VDAC_TRIM], CSD2X_1_LEFT_REFERENCE            ; Configure reference source

; Shield electrode configuration Left
IF CSD2X_1_LEFT_SHIELD_ENABLE
	or reg[DAC_CR0], 40h                                                          ; Enable shield to GOO6 for Left channel
ENDIF

; Shield electrode configuration Right
IF CSD2X_1_RIGHT_SHIELD_ENABLE
	or reg[DAC_CR1], 40h                                                          ; Enable shield to GOO7 for Right channel
ENDIF

    ; Comparator Configuration
    or reg[CMP0CR2], 1                                     ; Enable Left Comparator power
	or reg[CMP1CR2], 1                                    ; Enable Right Comparator power

    ; Prechardge clock configuration
	or reg[CMPCLK0], 30h                                  ; Set CSD0/CSD1 clocks as left and right comparator clock sources
	and reg[AMUXCFG1], 0F0h
	or reg[AMUXCFG1], 09h                                 ; Use CSD0/CSD1 as clocks sources for prechardge switches

    ; IDAC Configuration
	or reg[DAC_CR0], 1
	or reg[DAC_CR1], 80h
	mov A, CSD2X_1_iDAC_Range
    call  CSD2X_1_SetDACRange
	or reg[IDACMODE], 05h                                 ; IDAC On/Off switch following CSD_CNT_EN

    M8C_SetBank0

   RAM_EPILOGUE RAM_USE_CLASS_4
   ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: CSD2X_1_ClearSensors(void)
;
;  DESCRIPTION:
;    Clears all sensor connections to the analog mux bus and shunts all sensor
;    pins to ground.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    None
;  RETURNS:      None
;  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.
;
 CSD2X_1_ClearSensors:
_CSD2X_1_ClearSensors:
   RAM_PROLOGUE RAM_USE_CLASS_4
   RAM_SETPAGE_CUR 0 ; direct access ram will always be in interrupt ram area

   mov   A,CSD2X_1_TotalLeftSensorCount
   dec   A
   ; Left Channel
.InitLoop:                                                ; Loop through all left sensors and deactivate
   push  A
   call  CSD2X_1_wGetPortPinLeft
   call  CSD2X_1_DisableSensor
   pop   A
   dec   A
   jnc   .InitLoop

   mov   A,CSD2X_1_TotalRightSensorCount
   dec   A
   ; Right Channel
.InitLoop1:                                               ; Loop through all right sensors and deactivate
   push  A
   call  CSD2X_1_wGetPortPinRight
   call  CSD2X_1_DisableSensor
   pop   A
   dec   A
   jnc   .InitLoop1

   RAM_EPILOGUE RAM_USE_CLASS_4
   ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: CSD2X_1_Stop
;  DESCRIPTION: Stop the CSD2X UM
;-----------------------------------------------------------------------------
;  ARGUMENTS: None
;  RETURNS: None
;  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.
;-----------------------------------------------------------------------------
 CSD2X_1_Stop:
_CSD2X_1_Stop:
    RAM_PROLOGUE RAM_USE_CLASS_4

; Filter Capacitor Configuration
    and      reg[AMUXCFG], ~31h                        ; Capacitor on P0.5/P0.7  and muxbus clocked from CSD0/CSD1 disable

	M8C_SetBank1

; Shield electrode configuration Left
IF CSD2X_1_LEFT_SHIELD_ENABLE
	and reg[DAC_CR0], ~40h                                               ; Disable shield to GOO6 for Left channel
ENDIF

⌨️ 快捷键说明

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