sar8.asm
来自「PSOC 电动自行车代码 器件采用CYPRESS新电动自行车器件CY8C245」· 汇编 代码 · 共 594 行 · 第 1/2 页
ASM
594 行
;
; 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_AutoAlign:
_SAR8_AutoAlign:
RAM_PROLOGUE RAM_USE_CLASS_1
and A, SAR8_AUTOALIGN ; remove extraneous data if any
jnz .Set1
and reg[SAR8_CONTROL_1_REG], ~SAR8_AUTOALIGN
jmp .Done
.Set1:
or reg[SAR8_CONTROL_1_REG], SAR8_AUTOALIGN
.Done:
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SAR8_SetAlignPath
;
; DESCRIPTION: Selects Trigger logic
;
;-----------------------------------------------------------------------------
;
; 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_SetAlignPath:
_SAR8_SetAlignPath:
RAM_PROLOGUE RAM_USE_CLASS_2
and A, 0x06 ; remove extraneous data if any
mov X, SP
push A
mov A, reg[SAR8_CONTROL_1_REG]
and A, ~0x06 ; clear previous settings
or A, [X]
mov reg[SAR8_CONTROL_1_REG], A
pop A
RAM_EPILOGUE RAM_USE_CLASS_2
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SAR8_SetHighAlignSrc
;
; DESCRIPTION:
; Sets path for high align source
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: input BYTE Value:
; 0 = None
; 1 = DBB00
; 2 = DBB01
; 3 = DCB02
; 4 = DCB03
;
; 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_SetHighAlignSrc:
_SAR8_SetHighAlignSrc:
RAM_PROLOGUE RAM_USE_CLASS_2
and A, 0x07 ; remove extraneous data if any
index SAR8_AlignSrc
asl A
mov X, SP
push A
M8C_SetBank1
mov A, reg[SAR8_TRIGGER_SRC_REG]
and A, 0x55 ; empty trigger high bits: 7,5,3,1
or A, [X]
mov reg[SAR8_TRIGGER_SRC_REG], A
M8C_SetBank0
pop A
RAM_EPILOGUE RAM_USE_CLASS_2
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SAR8_SetLowAlignSrc
;
; DESCRIPTION:
; Sets path for low align source
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: Byte: 0 = None
; 1 = DBB00
; 2 = DBB01
; 3 = DCB02
; 4 = DCB03
;
; 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_SetLowAlignSrc:
_SAR8_SetLowAlignSrc:
RAM_PROLOGUE RAM_USE_CLASS_2
and A, 0x07 ; remove extraneous data if any
index SAR8_AlignSrc
mov X, SP
push A
M8C_SetBank1
mov A, reg[SAR8_TRIGGER_SRC_REG]
and A, 0xAA ; empty trigger high bits: 6,4,2,0
or A, [X]
mov reg[SAR8_TRIGGER_SRC_REG], A
M8C_SetBank0
pop A
RAM_EPILOGUE RAM_USE_CLASS_2
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SAR8_SetCmpL
;
; DESCRIPTION:
; Places the input value into the compare low trigger register as the
; compare high value
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
; an input of one BYTE will be used for the comparators low reference
;
; 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_SetCmpL:
_SAR8_SetCmpL:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_SetBank1
mov reg[SAR8_COMPARE_LO_REG], A ; place input value into compare low reg
M8C_SetBank0
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SAR8_SetCmpH
;
; DESCRIPTION:
; Places the input value into the compare high trigger register as the
; compare high value
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: an input of one BYTE will be used for the comparators
; high reference
;
; 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_SetCmpH:
_SAR8_SetCmpH:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_SetBank1
mov reg[SAR8_COMPARE_HI_REG], A ; place input value into compare high reg
M8C_SetBank0
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SAR8_SetScale
;
; DESCRIPTION:
; Divides raw ADC results by 2^n depending on input argument n.
; ***check for corner case of 111!
;-----------------------------------------------------------------------------
;
; ARGUMENTS: Byte:
; 00h = no divide
; 08h = divide by 2
; 10h = divide by 4
; 18h = divide by 8
; 20h = divide by 16
; 28h = divide by 32
; 30h = divide by 64
;
; 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_SetScale:
_SAR8_SetScale:
RAM_PROLOGUE RAM_USE_CLASS_2
and A, 0x38 ; remove extraneous data if any
cmp A, 0x38 ; set scale=64 for invalid entry
jnz .L1
mov A, 0x30
.L1:
mov X, SP
push A
M8C_SetBank1
mov A, reg[SAR8_CONTROL_2_REG]
and A, ~0x38 ; clear previous settings
or A, [X]
mov reg[SAR8_CONTROL_2_REG], A
M8C_SetBank0
pop A
RAM_EPILOGUE RAM_USE_CLASS_2
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: SAR8_SetRunMode
;
; DESCRIPTION:
; Sets run mode for ADC to Free Run or One-Shot
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: Byte: 0 = ADC in One-Shot Mode
; 1 = ADC in Free Running Mode
;
; 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_SetRunMode:
_SAR8_SetRunMode:
RAM_PROLOGUE RAM_USE_CLASS_1
M8C_SetBank1
and A, 0x01 ; remove extraneous data if any
jnz .FreeRun
and reg[SAR8_CONTROL_2_REG], ~0x40
jmp .Done
.FreeRun:
or reg[SAR8_CONTROL_2_REG], 0x40
.Done:
M8C_SetBank0
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
; End of File SAR8.asm
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?