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

📄 sp200.asm

📁 合泰MCU写的电话机源程序
💻 ASM
📖 第 1 页 / 共 5 页
字号:

	mov		a,R_key_value
	xor		a,D_zero_key
	sz		acc
	jmp		L_isnot_zero_key
	;// is zero key  //
	mov		a,R_flash_time
	mov		a,0ah
	mov		R_flash_time,a	
	jmp		L_save_flash_time_to_ee
L_isnot_zero_key:
	mov		a,9
	sub		a,R_key_value
	sz		c
	jmp		L_is1_9key

L_play_fail_sound_exit:
	mov		a,D_headset_key
	xor		a,R_key_value
	sz		acc
	jmp		L_11_15_3
	call	F_key_process
	jmp		L_Main_exit_set
L_11_15_3:

	clr		Flag_store          ;clr store flag
	call	F_fail_sound
	jmp		L_Main_exit_set
L_is1_9key:	
	mov		a,R_key_value
	mov		R_flash_time,a
L_save_flash_time_to_ee:
	call	F_set_sound
	clr		R_key_value

    F_item_set_commond          ;macro
	mov		a,R_key_value       ;test # key
	xor		a,D_number_key
	sz		acc
	jmp		L_play_fail_sound_exit    ;up 
	call	F_set_sound
	call	F_setting_flash_time
	jmp		L_Main_exit
;-----------------------------------------------
L_is_33key:             ;mute key 

	snz		flag_phone_use   ;[16h].5
	jmp		L_Main_exit

	clr		flag_onhook_T      ;clear onhook flag
	clr		R_onhook_T         ;clear onhook counting          

	sz		[16h].6           ;test SDNPO
	jmp		L_clear_this_bit_active_mute
	;/// inactive mute 
	set		[16h].6
	jmp		L_Main_exit
L_clear_this_bit_active_mute:
	clr		[16h].6
	jmp		L_Main_exit
;;----------------------------------------------------------------
L_is_34key:              ;Vup key

;	mov		a,5
;	mov	    R_Hold_time,a
;	call	F_turn_on_real_time
;L_Check_store_key_hold2S:
;	call	F_Turn_off_PFD    
;	call	F_key_Scan_in_setting  ;F_key_scan
;	sz		R_key_hold
;	jmp		L_storekey_holding
;	jmp		L_Main_exitaaa      ;store key hold less than 5s         
;L_storekey_holding:
;	sz		R_Hold_time
;	jmp		L_Check_store_key_hold2S

;L_wait_key_open: 	
;	call	F_Turn_off_PFD   ;Flag_counting=0 stop pfd   
;	call	F_key_Scan_in_setting    ;F_key_scan

;	sz		R_key_hold
;	jmp		L_wait_key_open          ;9/20 debug qpj
;	clr		flag_off_ring
;	jmp		L_Main_exit
    ;// vup key hold 5s ok // 
;L_Main_exitaaa:

	sz		pd.1
	jmp		L_earphone_add
	snz		[16h].4
	jmp		L_headset_add
	sz		[16h].1
	jmp		L_handfree_add
	set		pbc.6
	call	nop4t
	snz		pb.6
	jmp		L_ring_add
	sz		R_ring_ajust  ;R_ring_timea
	jmp		L_ring_add

	snz		flag_phone_use
	jmp			L_item4_setting_b
	jmp		L_Main_exit
L_item4_setting_b:
	set		pdc.2
	call	nop4t
	snz		pd.2            ;have power=H
	jmp		L_Main_exit  ;L_no_power      ;no power exit 
	jmp			L_item4_setting
;	jmp		L_Main_exit

;;/////////
L_earphone_add:
	mov		a,R_Vearphone_Vhandset
	swap	acc
	and		a,07h
	mov		R_temp1,a
	mov		a,6
	sub		a,R_temp1
	snz		c	
	jmp		L_Main_exit_11          ;>6 exit not add
	;// <=6
	inc		R_temp1
	
	swap    R_temp1

	mov		a,R_Vearphone_Vhandset
	and		a,0fh
	or		a,R_temp1
	mov		R_Vearphone_Vhandset,a   ;

	swap	R_temp1      
	call	F_adjust_volume   ;F_volume_control     ;control volume
	jmp		L_Main_exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
L_Main_exit_11:
	call	F_fail_sound1          ;while can not adjust active the sound
	jmp		L_Main_exit
;;;;;;;;;;;;;;;;;;;
L_handfree_add:
	mov		a,R_Vspeaker_Vring
	swap	acc
	and		a,07h
	mov		R_temp1,a
	mov		a,6
	sub		a,R_temp1
	snz		c	
	jmp		L_Main_exit_11          ;>6 exit not add
	inc		R_temp1

	swap    R_temp1

	mov		a,R_Vspeaker_Vring
	and		a,0fh
	or		a,R_temp1
	mov		R_Vspeaker_Vring,a   ;

	swap	R_temp1      
	call	F_adjust_volume   ;F_volume_control     ;control volume
	jmp		L_Main_exit
L_headset_add:
	mov		a,R_Vearphone_Vhandset
	and		a,07h
	mov		R_temp1,a
	mov		a,6
	sub		a,R_temp1
	snz		c	
	jmp		L_Main_exit_11          ;>6 exit not add
	inc		R_temp1
	
	mov		a,R_Vearphone_Vhandset
	and		a,0f0h
	or		a,R_temp1
	mov		R_Vearphone_Vhandset,a   ;

	call	F_adjust_volume   ;F_volume_control     ;control volume
	jmp		L_Main_exit
L_ring_add:
	sz		flag_off_ring
	jmp		L_Main_exit

	mov		a,R_Vspeaker_Vring
	and		a,07h
	mov		R_temp1,a
	mov		a,6
	sub		a,R_temp1
	snz		c	
	jmp		L_Main_exit          ;>6 exit not add
	inc		R_temp1

	mov		a,R_Vspeaker_Vring
	and		a,0f0h
	or		a,R_temp1
	mov		R_Vspeaker_Vring,a   ;

	call	F_adjust_volume   ;F_volume_control     ;control volume
	jmp		L_Main_exit
;;----------------------------------------------------------------
L_is_35key:				 ;Vdown key
;	mov		a,5
;	mov	    R_Hold_time,a
;	call	F_turn_on_real_time
;L_Check_store_key_hold2Sq:
;	call	F_Turn_off_PFD    
;	call	F_key_Scan_in_setting  ;F_key_scan
;	sz		R_key_hold
;	jmp		L_storekey_holdingq
;	jmp		L_Main_exitaaaq      ;store key hold less than 5s         
;L_storekey_holdingq:
;	sz		R_Hold_time
;	jmp		L_Check_store_key_hold2Sq

;L_wait_key_openq: 	
;	call	F_Turn_off_PFD   ;Flag_counting=0 stop pfd   
;	call	F_key_Scan_in_setting    ;F_key_scan

;	sz		R_key_hold
;	jmp		L_wait_key_openq          ;9/20 debug qpj
;	set		flag_off_ring
;	jmp		L_Main_exit
    ;// vup key hold 5s ok // 
;L_Main_exitaaaq:

	sz		pd.1
	jmp		L_earphone_dec
	snz		[16h].4
	jmp		L_headset_dec
	sz		[16h].1
	jmp		L_handfree_dec
	set		pbc.6
	call	nop4t
	snz		pb.6
	jmp		L_ring_dec
	sz		R_ring_ajust  ;R_ring_timea
	jmp		L_ring_dec

	snz		flag_phone_use
	jmp			L_item4_setting_b
	jmp		L_Main_exit
;;/////////
L_earphone_dec:
	mov		a,R_Vearphone_Vhandset
	swap	acc
	and		a,07h
	mov		R_temp1,a
	sz		R_temp1
	jmp		L_continue1_1
	call	F_fail_sound1          ;while can not adjust active the sound
	jmp		L_Main_exit          ;>6 exit not add
L_continue1_1:
	dec		R_temp1
	
	swap    R_temp1

	mov		a,R_Vearphone_Vhandset
	and		a,0fh
	or		a,R_temp1
	mov		R_Vearphone_Vhandset,a   ;

	swap	R_temp1      
	call	F_adjust_volume  ;F_volume_control     ;control volume
	jmp		L_Main_exit
L_handfree_dec:
	mov		a,R_Vspeaker_Vring
	swap	acc
	and		a,07h
	mov		R_temp1,a
	sz		R_temp1
	jmp		L_continue2_2
	call	F_fail_sound1          ;while can not adjust active the sound
	jmp		L_Main_exit          ;>6 exit not add
L_continue2_2:
	dec		R_temp1

	swap    R_temp1

	mov		a,R_Vspeaker_Vring
	and		a,0fh
	or		a,R_temp1
	mov		R_Vspeaker_Vring,a   ;

	swap	R_temp1      
	call	F_adjust_volume   ;F_volume_control     ;control volume
	jmp		L_Main_exit
L_headset_dec:
	mov		a,R_Vearphone_Vhandset
	and		a,07h
	mov		R_temp1,a
	mov		R_temp1,a
	sz		R_temp1
	jmp		L_continue3_3
	call	F_fail_sound1          ;while can not adjust active the sound
	jmp		L_Main_exit          ;>6 exit not add
L_continue3_3:
	dec		R_temp1
	
	mov		a,R_Vearphone_Vhandset
	and		a,0f0h
	or		a,R_temp1
	mov		R_Vearphone_Vhandset,a   ;

	call	F_adjust_volume    ;F_volume_control     ;control volume
	jmp		L_Main_exit
L_ring_dec:
	sz		flag_off_ring
	jmp		L_Main_exit

	mov		a,R_Vspeaker_Vring
	and		a,07h
	mov		R_temp1,a
	sz		R_temp1
	jmp		L_continue4_4
	jmp		L_Main_exit          ;>6 exit not add
L_continue4_4:
	dec		R_temp1

	mov		a,R_Vspeaker_Vring
	and		a,0f0h
	or		a,R_temp1
	mov		R_Vspeaker_Vring,a   ;

	call	F_adjust_volume   ;F_volume_control     ;control volume
	jmp		L_Main_exit

;;----------------------------------------------------------------
L_is_36key:              ; HeadSET key
	set		flag_set_exit
	clr		flag_store

	clr		pdc.1
;	clr		flag_over_3232
	set		[16h].6  ;11/10 add    ;disable mute 

    clr		PFDC.4                ;disable PFD output
	clr		R_key_value
	set		pdc.2           ;set pd.2 as input
	call	nop4t			;wait port stable 
	snz		pd.2            ;have power=H
	jmp		L_Main_exit

	clr		flag_save_over32              ;9/11 debug add

	set		flag_hook_status_change

	sz		headset_countral
	jmp		headset_output_low
	;//// output high
;				set	   headset_countral          ;8/21 add control output 
	set		R_key_hold        ;;;;; qpj
	mov			a,pd
	or			a,2
	mov			pd,a
;		set		[16h].7           ;off mute XMute pin =0 

	;///  handset change to earphone  ///
	clr		flag_onhook_T      ;clear onhook flag
	clr		R_onhook_T         ;clear onhook counting          

                snz            hdo
                jmp             headset_output_high_2                 
    	        set				headset_countral          ;control output 
                set             auto_spo
                call            F_wait_time_100ms
                clr             auto_spo
               
headset_output_high_2:                                
		   call			F_turn_on_real_time
                set      [22h].7  ;       linec                    ;enable line contral             
                set             spo               ;use to on hook
	clr		flag_onhook_T      ;clear onhook flag
	clr		R_onhook_T         ;clear onhook counting          
            
                snz             hfo           ;免提吗? 
                jmp             headset_output_high
;;				clr		hfo
 
				snz				[16h].6
				jmp				L_in_mute

				set	   headset_countral          ;control output 

                set             auto_spo    ;auto off handfree
                call            F_wait_time_100ms     ;0.1s
                clr             auto_spo
				jmp				headset_output_high
L_in_mute:
                set             auto_spo    ;auto off handfree
                call            F_wait_time_100ms     ;0.1s
                clr             auto_spo
	clr		R_key_value
				clr				[16h].6

headset_output_high:  

	clr		flag_onhook_T      ;clear onhook flag
	clr		R_onhook_T         ;clear onhook counting          
                clr    flag_line_hold       
                set    Flag_phone_use
                set    flag_hook_status_change

				set	   headset_countral          ;control output 

		mov		a,R_Vearphone_Vhandset
		swap	        acc
		and		a,0fh
		mov		R_temp1,a      ;control earphone volume
		call	        F_volume_control
		clr		R_key_value
		jmp		headset_off_hook_exit
headset_output_low:
	sz		flag_save_over32
	clr		R_dial_code_buffer


    ;// earphone change to handset //
        clr             [22h].7          ;linec
        snz             hks
        jmp             headset_output_low_1
		set		flag_onhook_T      ;set on hook flag !
		clr		R_onhook_T
        clr             Flag_phone_use
	set		[16h].6            ;disable mute 
headset_output_low_1:
	mov		a,R_dial_code_buffer    
	mov		R_dial_count_p,a       ;debug add 10/9      

	clr		R_key_value
        set             flag_hook_status_change
		clr		headset_countral          ;control output
	clr		R_flag
        snz             hks              ;;;qpj
		jmp				L_headset_no_at_hook
		jmp				L_headset_at_hook
L_headset_no_at_hook:
        set             Flag_phone_use   ;;;qpj
		jmp				lllll8l
L_headset_at_hook:
	clr		flag_first_pause    ;10/17
	clr		flag_first_memory

lllll8l:
	mov		a,R_Vearphone_Vhandset
	and		a,0fh
	mov		R_temp1,a      ;control handset volume
	call	        F_volume_control
headset_off_hook_exit:
	set		R_key_hold        ;;;;; qpj
	jmp		L_Main_exit
;-----------------------------------------------------------
L_is_37key:                         ;Hold key 
;	sz		flag_line_hold	
;	jmp		L_Main_exit         ;line already holded before      

	set		[16h].6            ;10/12

	sz		hfo                 ;test hfo
	jmp		L_in_handfree_mode
	;//     test handset mode
	snz		[16h].4             ;test HKS
	jmp		L_in_headset_mode	 
	;//     test earphone mode
	snz		pd.1                ;test earphone 
	jmp		L_Main_exit         ;not in earphone mode exit
	;//     in earphone mode
	set		[16h].6            ;turn off mute function
	set		pd.7                ;hold output
		clr		[16h].7           ;XMute pin =0 

	clr     pd.1                ;off earphone
	clr		[16h].5             ;turn off po 
	call	F_wait_time_100ms
	clr		pd.7 
	set		flag_line_hold      ;set line hold flag
;	clr		flag_phone_use    
	jmp		L_Main_exit
L_in_headset_mode:
	set		[16h].6            ;turn off mute function
	set		pd.7                ;hold output

		clr		[16h].7           ;XMute pin =0 

	clr		[16h].5             ;turn off po 
	call	F_wait_time_100ms
	clr		pd.7 
	set		flag_line_hold      ;set line hold flag
;	clr		flag_phone_use    
	clr		pd.1                ;clear earphone 
   	jmp		L_Main_exit
L_in_handfree_mode:
	set		pd.7                ;hold output
		clr		[16h].7           ;XMute pin =0 

	set		auto_spo            ;pd.3
	call	F_wait_time_100ms
	clr		auto_spo
	clr		pd.7
	set		flag_line_hold      ;set line hold flag
;	clr		flag_phone_use    
	clr		[16h].5             ;turn off po 
   	jmp		L_Main_exit
;----------------------------------------------------------------
L_is_38key:
	sz		flag_store
	jmp		L_Main_exit
	sz		flag_phone_use
	jmp		L_38key_1         ;redial function
    jmp		L_Main_exit
L_38key_1:
;	jmp		L_38key
	jmp		L_38key_11       ;2003/1/11 add 
;_______________________________________________________________________

F_timer0_int:                         ;every 833us int
;        mov		R_TempA,a        ;save acc
;        mov		a,status 
;        mov		R_status,a       ;save status falgmov             a,1
        set             flag_fskbit
;		mov		a,R_status
;		mov		status,a         ;back up status flag
;		mov		a,R_TempA        ;back up acc
		reti
;------------------------------------------------------------------
;   Ring detector INt pin
;------------------------------------------------------------------
;F_Ring_INT:
;		reti
;------------------------------------------------------------------
F_Hook_INT:

⌨️ 快捷键说明

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