📄 telephone.asm
字号:
pop DPHpop DPLpop ACCpop PSWreti;//*******************************End UART FUNCTION*******************************;//*********************************Simulate BUS FUNCTION********************************;--------------------;;;;--------------------_bus_initial:setb BUS_CSsetb BUS_WRsetb BUS_RDret;--------------------;;13;--------------------_bus_writeRegA:mov bus_reg,Arl Asetb ACC.6setb ACC.7setb ACC.5mov P0,Aclr BUS_CSclr BUS_WRnopsetb BUS_WRsetb BUS_CSret;--------------------;;26;--------------------_bus_writeRegB:push ACCmov A,bus_regsetb ACC.4;//Select RegBrl Asetb ACC.6setb ACC.7setb ACC.5mov P0,Aclr BUS_CSclr BUS_WRnopsetb BUS_WRsetb BUS_CSpop ACC;//Write data to RegBrl Asetb ACC.6setb ACC.7setb ACC.5mov P0,Aclr BUS_CSclr BUS_WRnopsetb BUS_WRsetb BUS_CSret;--------------------;;12;--------------------_bus_writeData:rl Asetb ACC.6setb ACC.7clr ACC.5mov P0,Aclr BUS_CSclr BUS_WRnopsetb BUS_WRsetb BUS_CSret;--------------------;;10;--------------------_bus_readData:clr BUS_RS0clr BUS_CSclr BUS_RDnopsetb BUS_RDmov A,P0setb BUS_CSrr Aret;--------------------;;10;--------------------_bus_readStatus:setb BUS_RS0clr BUS_CSclr BUS_RDnopsetb BUS_RDmov A,P0setb BUS_CSrr Aret;//*********************************End BUS FUNCTION****************************;//********************************Telephone Function**************************;- hold;H,h hook;ABC,abc 1101~1111;D,d 0000;0 1100;1~9 0001~1001TELEPHONE_CODE_TAB:DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,06h,0,0,0,0,0,0,05h,0,0,02h,0,0 DB 04h,03h,03h,03h,03h,03h,03h,03h,03h,03h,0,0,0,0,0,0 DB 0,07h,07h,07h,08h,0,0,0,01h,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,07h,07h,07h,08h,0,0,0,01h,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;--------------------;;;--------------------_phone_8889_initial:acall _bus_readStatusclr Aacall _bus_writeRegAclr Aacall _bus_writeRegAclr Aacall _bus_writeRegBret;--------------------;;7+PC(WRITEDATA)+PC(WRITEREGA);--------------------_phone_send_dtmf:acall _bus_writeDatamov A,#01hacall _bus_writeRegAret;--------------------;;5+PC(WRITEREGA);--------------------_phone_stop_dtmf:clr Aacall _bus_writeRegAret;--------------------;;;--------------------_dial_init:clr phone_dial_startclr dial_return_ok_flagmov phone_dial_counter,#00hmov phone_dial_length,#00hmov phone_dial_head,#00hmov phone_dial_tail,#00hret;--------------------;45+PC(_phone_send_dtmf);16+PC(TIME_FORMAT)+PC(DIAL_STOP_OK);--------------------_phone_dial:jnb phone_dial_start,_phone_dial_exitmov A,phone_dial_counterjnz _phone_dial_exitjnb phone_dial_code_flag,_phone_dial_notonemov A,phone_dial_lengthjnz _phone_dial_senddtmfclr phone_dial_startmov R2,#HIGH(dial_timer_stamp_buffer)mov R3,#LOW(dial_timer_stamp_buffer)lcall _time_formatsetb dial_return_ok_flagljmp _dial_stop_ok_phone_dial_senddtmf:mov DPTR,#phone_dial_buffermov A,phone_dial_headadd A,DPLmov DPL,Amovx A,@DPTRmov phone_dial_temp,Amov DPTR,#TELEPHONE_CODE_TABmovc A,@A+DPTRmov DPTR,#TELEPHONE_CODE_JUMP_TABrl Apush ACCmovc A,@A+DPTRmov R7,Apop ACCinc Amovc A,@A+DPTRmov DPH,R7mov DPL,#00hjmp @A+DPTR_phone_dial_notone:mov A,phone_dial_tempcjne A,#01h,$+14hsetb PHONE_HOOKinc phone_dial_headanl phone_dial_head,#PHONE_DIAL_SIZE_MASKdec phone_dial_lengthsjmp _phone_dialsetb phone_dial_code_flagacall _phone_stop_dtmfmov phone_dial_counter,dtmf_off_periodinc phone_dial_headanl phone_dial_head,#PHONE_DIAL_SIZE_MASKdec phone_dial_length_phone_dial_exit:retTELEPHONE_CODE_JUMP_TAB:DW ERR_CODE_PROC DW HOOK_PROC DW HOLD_PROC DW NORMAL_CODE_PROC DW ZERO_CODE_PROC DW ASTERISK_CODE_PROC DW WELL_CODE_PROC DW ABC_CODE_PROC DW D_CODE_PROCERR_CODE_PROC:inc phone_dial_headanl phone_dial_head,#PHONE_DIAL_SIZE_MASKdec phone_dial_lengthretHOOK_PROC:clr phone_dial_code_flagclr PHONE_HOOKmov phone_dial_counter,hook_updown_periodretHOLD_PROC:mov phone_dial_counter,hold_periodinc phone_dial_headanl phone_dial_head,#PHONE_DIAL_SIZE_MASKdec phone_dial_lengthretNORMAL_CODE_PROC:mov A,phone_dial_tempclr phone_dial_code_flaglcall _phone_send_dtmfmov phone_dial_counter,dtmf_on_periodretZERO_CODE_PROC:mov A,#0ahclr phone_dial_code_flaglcall _phone_send_dtmfmov phone_dial_counter,dtmf_on_periodretASTERISK_CODE_PROC:mov A,#0bhclr phone_dial_code_flaglcall _phone_send_dtmfmov phone_dial_counter,dtmf_on_periodretWELL_CODE_PROC:mov A,#0chclr phone_dial_code_flaglcall _phone_send_dtmfmov phone_dial_counter,dtmf_on_periodretABC_CODE_PROC:mov A,phone_dial_tempadd A,#0chclr phone_dial_code_flaglcall _phone_send_dtmfmov phone_dial_counter,dtmf_on_periodretD_CODE_PROC:clr Aclr phone_dial_code_flaglcall _phone_send_dtmfmov phone_dial_counter,dtmf_on_periodret;--------------------;;;--------------------phone_init:clr PHONE_HOOKclr PHONE_MONITORret;//********************************End Telephone Function***********************;//************************************Timer Function******************************;--------------------;;;--------------------_timer_initial:mov time_stamp,#00hmov time_stamp+1h,#00hmov time_stamp+2h,#00hmov time_stamp+3h,#00hmov TL0,#LOW (TLODER)mov TH0,#HIGH (TLODER)ORL IEN0,#TENABLE0ORL IP0,#TPRIORITYLORL IP0H,#TPRIORITYHsetb TR0ret;--------------------;;16+24+50;--------------------_timer_int:push PSWpush ACCpush DPLpush DPHclr TF0mov TH0,#HIGH(TLODER)mov TL0,#LOW(TLODER)setb TR0 ;reload timer and restart count;other timer function;dial function timer //***************DIAL FUNCTION SUPPORT**************************mov A,phone_dial_counterjz $+4hdec phone_dial_counter ;dec it till it is zero;//************************End DIAL FUNCTION SUPPORT**********************************;mov R1,#time_stamp ;timer countersetb Cclr Amov R6,#04h ;16_time_int_count:addc A,@R1 ;A=0 C=1(0) A= A+@R1+CYmov @R1,Ainc R1clr Adjnz R6,_time_int_count ;6*4;sample function timer//***************SAMPLE FUNCTION************************_timer_int_sample:jnb sample_start_flag,_timer_int_exit ;IF UN Start sample ,exitdjnz sample_counter,_timer_int_exit ;sample_counter--,and if no zero exitmov sample_counter,sample_interval ;reload sample_countermov A,sample_save ;load sample_save to ACC ;bit6 sample value ;bit0~bit5 current value countmov C,PHONE_SAMPLE ;read PHONE_SAMPLEjc _timer_int_sample_compare ;if Tone signal not change jnb ACC.6,_timer_int_sample_equal ;jump to _timer_int_sample_equalcpl ACC.6_timer_int_sample_compare:jb ACC.6,_timer_int_sample_equal;//unequalanl A,#1Fh ;Tone signal changejz _timer_int_sample_resetmov F0,C_timer_int_sample_save:;//savemov DPTR,#sample_buffermov A,sample_tailadd A,DPLmov DPL,Amov A,sample_savemovx @DPTR,Ainc sample_tailanl sample_tail,#SAMPLE_SIZE_MASKmov A,sample_tailinc sample_lengthcjne A,sample_head,_timer_int_sample_saveFininc sample_headdec sample_lengthanl sample_head,#SAMPLE_SIZE_MASK_timer_int_sample_saveFin:mov C,F0_timer_int_sample_reset: ;//new status save or counter overflowmov A,#01hmov ACC.6,Cmov sample_save,Asjmp _timer_int_exit;//equal_timer_int_sample_equal:anl A,#1Fhmov F0,Ccjne A,#1Fh,_timer_int_sample_incsjmp _timer_int_sample_save_timer_int_sample_inc:inc Amov C,F0mov ACC.6,Cmov sample_save,A;//***************************End SAMPLE FUNCTION*****************************_timer_int_exit:pop DPHpop DPLpop ACCpop PSWreti;//**************************End Timer Function*******************************;//**************************MSG PROC FUNCTION********************************MSG_PROC_INDEX_TAB:DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 01h,02h,0,03h,04h,05h,06h,07h,08h,09h,0ah,0bh,0ch,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;/*;27;*/_msg_proc:jb msg_rece_ready_flag,$+4hretmov DPTR,#msg_rece_buffermovx A,@DPTRmov DPTR,#MSG_PROC_INDEX_TABmovc A,@A+DPTRmov DPTR,#MSG_JUMP_TABrl Apush ACCmovc A,@A+DPTRmov R7,Apop ACCinc Amovc A,@A+DPTRmov DPH,R7mov DPL,#00hjmp @A+DPTRMSG_JUMP_TAB:DW _msg_error DW _msg_start_sample DW _msg_stop_sample DW _msg_set_sample_period DW _msg_start_dial DW _msg_stop_dial DW _msg_set_dial_parameter DW _msg_set_hold_period DW _msg_set_hook_period DW _msg_hook DW _msg_monitor DW _msg_send_dtmf DW _msg_stop_dtmf _msg_error:jnb msg_send_ready_flag,$+4hretmov DPTR,#msg_send_buffermov A,#MSG_ERROR ;'E'movx @DPTR,Ainc DPLmov A,#00h ;'\0'movx @DPTR,Amov msg_send_length,#02hmov msg_send_index,#00hsetb msg_send_ready_flagclr msg_rece_ready_flagmov msg_rece_length,#00hljmp _package_write_msg_start_sample:clr sample_start_flagmov sample_head,sample_tailmov sample_length,#00hmov sample_counter,#01hmov R2,#HIGH(sample_timer_stamp_buffer)mov R3,#LOW(sample_timer_stamp_buffer)lcall _time_formatsetb sample_start_flagclr msg_rece_ready_flagmov msg_rece_length,#00hsetb sample_return_ok_flagljmp _sample_start_return_msg_stop_sample:jnb msg_send_ready_flag,$+4hretclr sample_start_flagmov DPTR,#msg_send_buffermov A,#MSG_STOP_SAMPLE ;'U'movx @DPTR,Ainc DPLclr Amovx @DPTR,Amov msg_send_length,#02hmov msg_send_index,#00hsetb msg_send_ready_flagclr msg_rece_ready_flagmov msg_rece_length,#00hljmp _package_write_msg_set_sample_period:jnb msg_send_ready_flag,$+4hretjnb sample_start_flag,_msg_set_sample_successmov DPTR,#msg_send_buffermov A,#MSG_BUSY ;'O'movx @DPTR,Ainc DPLmov msg_send_length,#04hsjmp _msg_set_sample_load_msg_set_sample_success:mov DPTR,#msg_rece_bufferinc DPLmovx A,@DPTRmov sample_interval,Amov DPTR,#msg_send_buffermov msg_send_length,#03h_msg_set_sample_load:mov A,#MSG_SET_SAMPLE_INTERVAL ;'O'movx @DPTR,Ainc DPLmov A,sample_intervalmovx @DPTR,Ainc DPLclr Amovx @DPTR,Amov msg_send_index,#00hsetb msg_send_ready_flagclr msg_rece_ready_flag
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -