sar8.asm

来自「PSOC 电动自行车代码 器件采用CYPRESS新电动自行车器件CY8C245」· 汇编 代码 · 共 594 行 · 第 1/2 页

ASM
594
字号
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME:   SAR8.asm
;;  Version: 1.0, Updated on 2007/09/06 at 14:58:30
;;  Generated by PSoC Designer ver 4.4  b1884 : 14 Jan, 2007
;;
;;  DESCRIPTION:  SAR8 User Module software implementation file for the
;;                24x33 PSoC family of devices.
;;
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress Semiconductor 2007. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "memory.inc"
include "SAR8.inc"

;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
export  SAR8_Start
export _SAR8_Start
export  SAR8_Stop
export _SAR8_Stop
export  SAR8_EnableInt
export _SAR8_EnableInt
export  SAR8_DisableInt
export _SAR8_DisableInt
export  SAR8_Trigger
export _SAR8_Trigger
export  SAR8_fIsDataAvailable
export _SAR8_fIsDataAvailable
export  SAR8_bGetData
export _SAR8_bGetData
export  SAR8_SelectADCChannel
export _SAR8_SelectADCChannel
export  SAR8_AutoAlign
export _SAR8_AutoAlign
export  SAR8_SetAlignPath
export _SAR8_SetAlignPath
export  SAR8_SetHighAlignSrc
export _SAR8_SetHighAlignSrc
export  SAR8_SetLowAlignSrc
export _SAR8_SetLowAlignSrc
export  SAR8_SetCmpL
export _SAR8_SetCmpL
export  SAR8_SetCmpH
export _SAR8_SetCmpH
export  SAR8_SetScale
export _SAR8_SetScale
export  SAR8_SetRunMode
export _SAR8_SetRunMode


AREA UserModules (ROM, REL)

.LITERAL
SAR8_AlignSrc:  DB  0x00, 0x01, 0x04, 0x10, 0x40, 0x40, 0x40, 0x40
.ENDLITERAL

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_Start
;
;  DESCRIPTION:
;       Starts ADC
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:  void
;
;  RETURNS: void
;
;  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 preserve their values across calls to fastcall16
;    functions.
;
 SAR8_Start:
_SAR8_Start:
    RAM_PROLOGUE RAM_USE_CLASS_1
    or  reg[SAR8_CONTROL_0_REG], SAR8_ENABLE
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_Stop
;
;  DESCRIPTION:
;    Stops ADC
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:  void
;
;  RETURNS: void
;
;  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 preserve their values across calls to fastcall16
;    functions.
;
 SAR8_Stop:
_SAR8_Stop:
    RAM_PROLOGUE RAM_USE_CLASS_1
    and  reg[SAR8_CONTROL_0_REG], ~SAR8_ENABLE
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_EnableInt
;
;  DESCRIPTION:
;     Enables SAR8 interrupt by setting the interrupt enable mask bit
;     associated with this User Module. This function has no effect until and
;     unless the global interrupts are enabled (for example by using the
;     macro M8C_EnableGInt).
;-----------------------------------------------------------------------------
;
;  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.
;
 SAR8_EnableInt:
_SAR8_EnableInt:
   RAM_PROLOGUE RAM_USE_CLASS_1
   M8C_EnableIntMask SAR8_INT_REG, SAR8_INT_MASK
   RAM_EPILOGUE RAM_USE_CLASS_1
   ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_DisableInt
;
;  DESCRIPTION:
;     Disables interrupt by clearing the interrupt enable
;     mask bit associated with this User Module.
;-----------------------------------------------------------------------------
;
;  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.
;
 SAR8_DisableInt:
_SAR8_DisableInt:
   RAM_PROLOGUE RAM_USE_CLASS_1
   M8C_DisableIntMask SAR8_INT_REG, SAR8_INT_MASK
   RAM_EPILOGUE RAM_USE_CLASS_1
   ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_Trigger
;
;  DESCRIPTION:
;    reset the Start/Busy bit to 1 and initialize a fresh conversion
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:  void
;
;  RETURNS: void
;
;  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 preserve their values across calls to fastcall16
;    functions.
;
 SAR8_Trigger:
_SAR8_Trigger:
    RAM_PROLOGUE RAM_USE_CLASS_1
    or  reg[SAR8_CONTROL_0_REG], SAR8_StartBusy
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_fIsDataAvailable
;
;  DESCRIPTION:
;    checks for data availability,then returns non-0 if ready or 0 if not
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:  void
;
;  RETURNS: BYTE unsigned
;
;  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 preserve their values across calls to fastcall16
;    functions.
;
 SAR8_fIsDataAvailable:
_SAR8_fIsDataAvailable:
    RAM_PROLOGUE RAM_USE_CLASS_1
    mov  A, reg[SAR8_CONTROL_0_REG]
    and  A, SAR8_Ready                         ; isolate Data
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_bGetData
;
;  DESCRIPTION:
;    Returns ADC result. SAR8_flsDataAvailable should
;    be called first to ensure the convertered data is available.
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:  void
;
;  RETURNS: BYTE unsigned
;
;  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 preserve their values across calls to fastcall16
;    functions.
;
 SAR8_bGetData:
_SAR8_bGetData:
    RAM_PROLOGUE RAM_USE_CLASS_1
    mov  A, reg[SAR8_DATA_LO_REG]
    RAM_EPILOGUE RAM_USE_CLASS_1
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR8_SelectADCChannel
;
;  DESCRIPTION:
;   Select the ADC channel from one of all Port 0 pins or from ACB00 and ACB01
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:  Byte:
;
;  RETURNS: No return value
;
;  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 preserve their values across calls to fastcall16
;    functions.
;
 SAR8_SelectADCChannel:
_SAR8_SelectADCChannel:
    RAM_PROLOGUE RAM_USE_CLASS_2
    and  A, 0x78                                    ; remove extraneous data if any
    mov  X, SP
    push A
    mov  A, reg[SAR8_CONTROL_0_REG]
    and  A, ~0x78
    or   A, [X]                                     ; clear previous channel
    mov  reg[SAR8_CONTROL_0_REG], A
    pop  A
    RAM_EPILOGUE RAM_USE_CLASS_2
    ret
.ENDSECTION

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

⌨️ 快捷键说明

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