#include Project.inc #include PIC16F639.inc #define Delay_Repeat_Trans 0x03 #define Repeat_Trans_Counter 0x03 Button_Handler_VAR udata Counter res 1 code ------------------------------------------------------------ ;Button_Handler_Init用来初始化在Button_Handler中用到的寄存器 ------------------------------------------------------------ Button_Handler_Init banksel Counter clrf Counter clrf Button_Delay return ------------------------------------------------------------;每一个开锁、关锁信号要传送Repeat_Trans_Counter次,相邻两次传送之间要延时Delay_Repeat_Trans*Timer1长时间 ------------------------------------------------------------ Button_Handler banksel Counter movf Counter,f btfss STATUS,Z goto Button_Count movlw Repeat_Trans_Counter movwf Counter movlw Delay_Repeat_Trans movwf Button_Delay Button_Count btfss EVENT_REG,RF_Start goto End_Button_Handler decfsz Counter,f goto Button_Task_Disper movlw 0xCf andwf EVENT_REG,f;当已经传送完毕,清除所有的按键事件 goto End_Button_Handler Button_Task_Disper movlw Delay_Repeat_Trans movwf Button_Delay bcf EVENT_REG,RF_Start LOCK_Button btfss EVENT_REG,LOCK goto UNLOCK_Button call RF_Send_Header