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

📄 3vcd_ad.asm

📁 接收红外遥控,控制2314
💻 ASM
字号:

;**********************************************************************
.IF 0
Get_AD2_Key	proc
.ENDIF
Get_AD2_Key:

		clr		R0
		ld     ADCON,#022H
		or     ADCON,#01H   ;start A/D
		nop
		nop
		nop
  ADCS41:	tm     ADCON,#00001000B   ;A/D convert
		jr     Z,ADCS41
		and    ADCON,#0FEH        ;STOP ADC
		and    ADCON,#11110111B
		ld		ACC_SEN_VAL,ADDATAH

		and		ACC_SEN_VAL,#0E0H
		
		push	ACC_SEN_VAL

con_ad2:
		call	Delay_10ms

		ld     ADCON,#022H
		or     ADCON,#01H   ;start A/D
		nop
		nop
		nop
  ADCS2:	tm     ADCON,#00001000B   ;A/D convert
		jr     Z,ADCS2
		and    ADCON,#0FEH        ;STOP ADC
		and    ADCON,#11110111B
		ld		ACC_SEN_VAL,ADDATAH
		and		ACC_SEN_VAL,#0E0H
		pop		ACC_RET_VAL
		cp		ACC_RET_VAL,ACC_SEN_VAL
		jp		NE,ADCS2_RET
		inc		R0
		push	ACC_SEN_VAL
		cp	R0,#2
		jp	ULT,con_ad2
		pop		ACC_SEN_VAL
		

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS2_RET

.IF DEF_TEST_AD_VOLTAGE

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS2_RET
		or	ACC_SEN_VAL,#2
		ld	ACC_SEN_VAL,ADDATAH
		call	REMOTE_SEND_CODE
		call	DELAY_200MS

ADCS2_RET:
.ELSE

;GET_KEY
		cp	ACC_SEN_VAL,#0H
		jp	NE,no_power_key
		ld	Current_Key,#IR_POWER_KEY
		ret
no_power_key:	
		cp	ACC_SEN_VAL,#20H;3b
		jp	NE,no_turndisc_key
		ld	Current_Key,#IR_CLOSE_KEY
		ret
no_turndisc_key:
		cp	ACC_SEN_VAL,#40H;55
		jp	NE,no_disc1_key
		ld	Current_Key,#IR_STOP_KEY
		ret
no_disc1_key:
		cp	ACC_SEN_VAL,#80H;89
		jp	NE,no_disc2_key
		ld	Current_Key,#IR_FORMAT_KEY
		ret
no_disc2_key:
		cp	ACC_SEN_VAL,#0A0H;a9
		jp	NE,no_disc3_key
		ld	Current_Key,#IR_CHANNEL_KEY

		ret
no_disc3_key:
		cp	ACC_SEN_VAL,#0C0h;d4
		jp	NE,no_close_key
		ld	Current_Key,#IR_PREV_KEY
no_close_key:

ADCS2_RET:
.ENDIF


		ret
;**********************************************************************


;**********************************************************************
.IF 0
Get_AD3_Key	proc
.ENDIF
Get_AD3_Key:
		
		ld     ADCON,#032H
		or     ADCON,#01H   ;start A/D
		nop
		nop
  ADCS51:	tm     ADCON,#00001000B   ;A/D convert
		jr     Z,ADCS51
		and    ADCON,#0FEH        ;STOP ADC
		and    ADCON,#11110111B
		ld	ACC_SEN_VAL,ADDATAH
		and	ACC_SEN_VAL,#0E0H

		push	ACC_SEN_VAL
		clr		R0
con_ad3:
		call	Delay_10ms

		ld     ADCON,#032H
		or     ADCON,#01H   ;start A/D
		nop
		nop
ADCS3:		tm     	ADCON,#00001000B   ;A/D convert
		jr	Z,ADCS3
		and 	ADCON,#0FEH        ;STOP ADC
		and	ADCON,#11110111B
		ld	ACC_SEN_VAL,ADDATAH
		and	ACC_SEN_VAL,#0E0H
		pop	ACC_RET_VAL
		
		cp	ACC_SEN_VAL,ACC_RET_VAL
		jp	NE,ADCS3_RET
		inc	R0
		push	ACC_SEN_VAL
		cp	R0,#2
		jp	ULT,con_ad3
		pop	ACC_SEN_VAL

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS3_RET
.IF DEF_TEST_AD_VOLTAGE

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS3_RET
		or	ACC_SEN_VAL,#3
		ld	ACC_SEN_VAL,ADDATAH
		call	REMOTE_SEND_CODE
		call	DELAY_200MS
ADCS3_RET:
.ELSE


.if 0
;GET_KEY
		cp	ACC_SEN_VAL,#00H
		jp	NE,no_program_key
		ld	Current_Key,#IR_MEM_KEY
		ret
no_program_key:
.endif
		cp	ACC_SEN_VAL,#20H;2a
		jp	NE,no_repeat_key
		ld	Current_Key,#IR_NEXT_KEY
		ret
no_repeat_key:	
		cp	ACC_SEN_VAL,#40H;54
		jp	NE,no_next_key
		ld	Current_Key,#IR_REPEAT_KEY
		ret
no_next_key:
		cp	ACC_SEN_VAL,#80H;8a
		jp	NE,no_play_key
		ld	Current_Key,#IR_TURN_DISC
		ret
no_play_key:
		cp	ACC_SEN_VAL,#0A0H;a9
		jp	NE,no_stop_key
		ld	Current_Key,#IR_PLAY_KEY
		ret
	
no_stop_key:
.if 0
		cp	ACC_SEN_VAL,#0c0h
		jp	NE,ADCS3_RET
		ld	Current_Key,#IR_PREV_KEY
.endif
ADCS3_RET:
.ENDIF
		ret
;**********************************************************************


;**********************************************************************
.IF 0
Get_AD4_Key	proc
.ENDIF
Get_AD4_Key:
		
		ld     ADCON,#42H
		or     ADCON,#01H   ;start A/D
		nop
		nop
		nop
  ADCS61:		tm     ADCON,#00001000B   ;A/D convert
		jr     	Z,ADCS61
		and    	ADCON,#0FEH        ;STOP ADC
		and   	ADCON,#11110111B
		ld		ACC_SEN_VAL,ADDATAH

		and	ACC_SEN_VAL,#0E0H
		push	ACC_SEN_VAL

		clr	R0
con_ad4:
		call	Delay_10ms

		ld     	ADCON,#42H
		or     	ADCON,#01H   ;start A/D
		nop
		nop
		nop
  ADCS4:	tm     	ADCON,#00001000B   ;A/D convert
		jr     	Z,ADCS4
		and    	ADCON,#0FEH        ;STOP ADC
		and    	ADCON,#11110111B
		ld	ACC_SEN_VAL,ADDATAH
		and	ACC_SEN_VAL,#0E0H
		pop	ACC_RET_VAL
		cp	ACC_SEN_VAL,ACC_RET_VAL
		jp	NE,ADCS4_RET
		push	ACC_SEN_VAL
		inc	R0
		cp	R0,#2
		jp	ULT,con_ad4
		pop	ACC_SEN_VAL

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS4_RET
.IF DEF_TEST_AD_VOLTAGE

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS4_RET
		or	ACC_SEN_VAL,#4
		ld	ACC_SEN_VAL,ADDATAH
		
		call	REMOTE_SEND_CODE
		call	DELAY_200MS
ADCS4_RET:
.ELSE

;GET_KEY
		cp	ACC_SEN_VAL,#00H
		jp	NE,no_pop_key
		ld	Current_Key,#IR_VOL_DEC_KEY
		ret
no_pop_key:	
		cp	ACC_SEN_VAL,#20H;2c
		jp	NE,no_rock_key
		ld	Current_Key,#IR_VOL_INC_KEY
		ret
no_rock_key:
	
		cp	ACC_SEN_VAL,#40H;55
		jp	NE,no_flat_key
		ld	Current_Key,#IR_FLAT_KEY
		ret
no_flat_key:
		cp	ACC_SEN_VAL,#080H;88
		jp	NE,no_vol_inc_key
		ld	Current_Key,#IR_CLASSIC_KEY;
		ret
no_vol_inc_key:
		cp	ACC_SEN_VAL,#0A0h;a8
		jp	ne,no_vol_dec_key
		ld	Current_Key,#IR_JAZZ_KEY;
		ret
no_vol_dec_key:

		cp	ACC_SEN_VAL,#0C0h;d4
		jp	ne,ADCS4_RET
		ld	Current_Key,#IR_ROCK_KEY;
		ret
ADCS4_RET:
.ENDIF


		ret
;**********************************************************************


;**********************************************************************
.IF 0
Get_AD5_Key	proc
.ENDIF
Get_AD5_Key:
		
		POWER_IS_LOW
		jp	z,ADCS15_RET

		ld     ADCON,#052H
		or     ADCON,#01H   ;start A/D
		nop
		nop
		nop
  ADCS151:		tm     ADCON,#00001000B   ;A/D convert
		jr     	Z,ADCS151
		and    	ADCON,#0FEH        ;STOP ADC
		and    	ADCON,#11110111B
		ld		ACC_SEN_VAL,ADDATAH

		and	ACC_SEN_VAL,#0E0H
		push	ACC_SEN_VAL

		clr		R0
con_ad15:
		call	Delay_10ms

		ld     	ADCON,#052H
		or     	ADCON,#01H   ;start A/D
		nop
		nop
		nop
  ADCS15:		tm     ADCON,#00001000B   ;A/D convert
		jr     	Z,ADCS15
		and    	ADCON,#0FEH        ;STOP ADC
		and    	ADCON,#11110111B
		ld	ACC_SEN_VAL,ADDATAH
		
		and	ACC_SEN_VAL,#0E0H
		pop	ACC_RET_VAL
		cp	ACC_RET_VAL,ACC_SEN_VAL
		jp	NE,ADCS15_RET
		push	ACC_SEN_VAL
		inc	R0
		cp	R0,#2
		jp	ULT,con_ad15
		pop	ACC_SEN_VAL
		

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS15_RET
.IF DEF_TEST_AD_VOLTAGE

		cp	ACC_SEN_VAL,#0E0H
		jp	UGE,ADCS15_RET
		or	ACC_SEN_VAL,#5
		ld	ACC_SEN_VAL,ADDATAH
		call	REMOTE_SEND_CODE
		call	DELAY_200MS

ADCS15_RET:
.ELSE
;GET_KEY
		cp	ACC_SEN_VAL,#00H
		jp	NE,no_radio_key
		cp	FUNCTION_STAT,#Function_Vcd
		jp	z,ADCS15_RET
		ld	FUNCTION_STAT,#Function_Vcd
		call	Check_Channel
		;ld	Current_Key,#IR_RADIO_KEY
		ret
no_radio_key:
		cp	ACC_SEN_VAL,#20H;2a
		jp	NE,no_tape_key
		cp	FUNCTION_STAT,#Function_Radio
		jp	z,ADCS15_RET
		;ld	Current_Key,#IR_TAPE_KEY
		
		ld	FUNCTION_STAT,#Function_Radio
		call	Check_Channel
		ret
no_tape_key:	
		cp	ACC_SEN_VAL,#40H;54
		jp	NE,no_vcd_key
		cp	FUNCTION_STAT,#Function_Tape
		jp	z,ADCS15_RET
		;ld	Current_Key,#IR_VCD_KEY
		
		ld	FUNCTION_STAT,#Function_Tape
		call	Check_Channel
		ret
no_vcd_key:
.if 0
		cp	ACC_SEN_VAL,#0e0H
		jp	ugt,no_aux_key
		cp	FUNCTION_STAT,#Function_Aux
		jp	z,ADCS15_RET
		;ld	Current_Key,#IR_AUX_KEY
		ld	FUNCTION_STAT,#Function_Aux
		call	Check_Channel
		
		ret
.endif
no_aux_key:
ADCS15_RET:
.endif

		ret
;**********************************************************************

;**********************************************************************
.IF 0
Get_AD_Key	proc
.ENDIF
Get_AD_Key:
		
		call	Get_AD2_Key
		cp	Current_Key,#0FFH
		jp	Z,get_next_ad5
		push	Current_Key
		call	Get_AD2_Key
		pop	ACC_SEN_VAL
		cp	Current_Key,ACC_SEN_VAL
		jp	Z,get_adkey_ret
		ld	Current_Key,#0FFH
get_next_ad5:
		call	Get_AD3_Key
		cp	Current_Key,#0FFH
		jp	Z,get_next_ad6
		
		push	Current_Key
		call	Get_AD3_Key
		pop	ACC_SEN_VAL
		cp	Current_Key,ACC_SEN_VAL
		jp	Z,get_adkey_ret		
		ld	Current_Key,#0FFH
get_next_ad6:

		call	Get_AD4_Key
		cp	Current_Key,#0FFH
		jp	Z,get_next_ad15
		push	Current_Key
		call	Get_AD4_Key
		pop	ACC_SEN_VAL
		cp	Current_Key,ACC_SEN_VAL
		jp	Z,get_adkey_ret
		ld	Current_Key,#0FFH
get_next_ad15:

.if 1
		call	Get_AD5_Key
		;cp	Current_Key,#0FFH
		;jp	Z,get_adkey_ret
		;;push	Current_Key
		;ld	ACC_SEN_VAL,#2
		;call	Delay_50ms
		;call	Get_AD5_Key
		;pop	ACC_SEN_VAL
		;cp	Current_Key,ACC_SEN_VAL
		;jp	Z,get_adkey_ret
		ld	Current_Key,#0FFH
.endif
get_adkey_ret:
		RET
;**********************************************************************


⌨️ 快捷键说明

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