if (cntBuzTimes == -1){
BUZPIN = 1 ; // END OF SOUND
return;
}
if (bBuzSW){
BUZPIN = 1 ;
if (cntBuz-- == 0){
cntBuz = 25 ; // RELOAD DATA
bBuzSW = 0 ; // CHANGE STATUS
}
}else{
BUZPIN = 0 ;
if (cntBuz-- == 0){
cntBuz = 25 ;
bBuzSW = 1 ;
cntBuzTimes--; // 1 TIMES
}
}
if (cntBuzTimes == 0){
bBuzEn = 0; // END OF SOUND
}
}
}
void Beep(s8 time) // time = n*tICk
{
bBuzEn = 1;
bBuzSW = 1;
cntBuz = 25;
cntBuzTimes = time;
}
void StopBeep(void)
{
bBuzEn = 0;
BUZPIN = 0;
}
/**************************************************
KEY SCAN ROUTINE
P60 door 0 : close 1 : open
P61 ACC 0 : open 1 : close
P62 Break 0 : open 1 : close
**************************************************/
u8 KeyScan(void)
{
u8 temp=0;
temp = PORT6;
temp &= 0x07 ;
temp ^= 0x06 ;
if (temp != SaveKey){
SaveKey = temp;
return 0;
}else{
Trg = SaveKey & (SaveKey ^ Cont); // trigger entry
Cont = SaveKey; // continuous entry
return 1;
}
}
/**************************************************
IR PROCESS ROUTINE
**************************************************/
#define ir_port 0x05
#define ir_pin 2
#define ir_pass 0
#define ir_lead 1
#define ir_receive 2
#define ir_syn 3
#define ir_delay 4
#define ir_dat_code 6
#define ir_dat_bit 24
u8 ir_flag=0;
u8 ir_reg_bit;
u8 ir_reg_code;
u8 ir_addr_hig;
u8 ir_addr_low;
u8 ir_user;
#define CODE_LOCK 0x41
#define CODE_UNLOCK 0x42
#define CODE_SOUND 0x44
#define CODE_BACK 0x49
#define CODE_FIND 0x48
void ScanIR(void)
{
if (CheckIR() == 0) // if check error ,return
{
return;
}
ir_flag = 0;
switch(ir_user)
{
case CODE_LOCK:
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] 下一页
本文关键字:单片机 无线 程序 义隆单片机,单片机-工控设备 - 义隆单片机