📄 finger.c
字号:
//////////////////////////////////////////////////////////////////////////////
void InitPort()
{
P1DIR = 0x00; /* P1 is input port */
P2DIR |= (BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6); /*latchOn,latchOff,Horn,Engine,T_lamp,Alarm,Learn */
P1IES &= ~(BIT2+BIT3+BIT4+BIT5); /* LOW-HIGH TO Interrupt */
P1IE &= ~(BIT2+BIT3+BIT4+BIT5+BIT6+BIT7); /* Disable interrupt */
P3DIR &= ~(BIT0+BIT1+BIT2+BIT3); /* SIDEDOOR,KEY_ON3,FOOTBRAK,LATCHTYPE */
P5DIR |= BIT4; /* SEL0 is hich select Master_Slave channel ,
is low select finger channel*/
P4DIR = 0x00; /* 4X4 KEY */
P2OUT &= ~(BIT0+BIT1+BIT2+BIT3+BIT4+BIT5+BIT6);
P5OUT &= ~BIT4; /* SELECT Finger Channel */
}
/////////////////////////////////////////////////////////////////////////////
void play_number(uchar voice_data)
{
switch(voice_data)
{
case 0: play(0x0000);break;
case 1: play(0x0002);break;
case 2: play(0x0004);break;
case 3: play(0x0006);break;
case 4: play(0x0008);break;
case 5: play(0x000a);break;
case 6: play(0x000d);break;
case 7: play(0x000f);break;
case 8: play(0x0011);break;
case 9: play(0x0013);break;
}
}
//----------------------------------------------------------------
uchar InPass(uchar * pTem)
{
uchar count=0,Pass=1;
while(count < 6)
{
Time_count=100;
while((!(KeyA))&&(Time_count>0))
{
if(KeyB)
{
Time_count=100;
while(KeyB)
{;}
delay(500);
Pass--;
if(Pass<=0)
Pass=0;
play_number(Pass);
}
if(KeyC)
{
Time_count=100;
while(KeyC)
{;}
delay(500);
Pass++;
if(Pass>9)
Pass=9;
play_number(Pass);
}
if(TACTL & TAIFG)
{
Time_count--;
TACTL &= ~TAIFG; //轻重断标志
}
}
if(Time_count==0)
return ERROR;
else
{
while(KeyA);
delay(500);
*(pTem+count)=Pass;
count++;
}
}
if(count==6)
return RIGHT;
}
//----------------------------------------------------------------
void RegisterMaster()
{
uchar MasterNumber;
uchar Status,KeyStatus;
uchar Pass=0,count=0;
uchar TemUnlockPass1[6],TemUnlockPass2[6];
P1IE &= ~BIT7; // 屏蔽触发感应的对比键
CCTL0 &= ~CCIE;
Status = CMDDeviceTest();
if(Status == M2ERROR_NONE)
{
Status = CMDIsRootMaster();
if(Status == M2ERROR_MASTERFP_NOT_FOUND)
{
// ",按01号车主1号指纹"
play(0x006c);
play(0x0002);
play(0x0055);
delay(500);
Status = CMDFpRegisterStart(0x01,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{
//play("再按01号车主1号指纹");
play(0x006e);
play(0x0055);
delay(3500);
Status = CMDFpRegisterEnd(0x01,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{
//play("1号车主1号指纹登陆成功");
play(0x0002);
play(0x0074);
play(0x0076);
play(0x0002);
play(0x0074);
play(0x0071);
play(0x00ba);
//Status=CMDSetSystemInfo(0x00,0x00); //非主模式
//play("比对模式,按1好车主1号指纹");
delay(100);
play(0x0020);
play(0x006c);
play(0x0002);
play(0x0055);
delay(500);
Status = CMDFpVerifyMaster(0x00,0x00); //比对通过后允许n次操作
if(Status == M2ERROR_NONE)
{
//play(",比对成功,按01号车主2号指纹");
play(0x00b0);
delay(100);
play(0x006c);
play(0x0002);
play(0x005d);
delay(500);
Status = CMDFpRegisterStart(0x02,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{
//play("再按01号车主2号指纹");
play(0x006e);
play(0x0002);
play(0x005d);
delay(3500);
Status = CMDFpRegisterEnd(0x02,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{ //play("01号车主注册成功");
play(0x0002);
play(0x0079);
}
else
//play("超时失败");
play(0x009a);
}
else
//play("超时失败");
play(0x009a);
Status=CMDSetSystemInfo(0x01,0x00); //主模式
}
else
//比对失败
play(0x00ab);
Status = CMDFpVerifyEnd(); //结束比对通过后可操作的次数
}
else
//play("超时失败");
play(0x009a);
}
else
//play("超时失败");
play(0x009a);
}
else
if(Status == M2ERROR_NONE)
{
Status = CMDSetSystemInfo(0x01,0x00); //设为主模式
delay(1000);
Status = CMDGetMasterCount();
MasterNumber = Param1_L;
if(Param1_L < 4)
{
delay(1000);
//play("比对模式,按1号车主1号指纹");
play(0x0020);
play(0x006c);
play(0x0002);
play(0x0055);
delay(500);
Status = CMDFpVerifyMaster(0x00,0x00); //比对通过后允许n次操作
if(Status == M2ERROR_NONE)
{
MasterNumber = Param1_L; //获得当前比对通过的指纹id
//比对成功
play(0x00b0);
delay(500);
//play(",按Param1_L/2+1车主1号指纹");
play(0x006c);
play_number(MasterNumber/2+1);
play(0x0055);
delay(500);
Status = CMDFpRegisterStart(MasterNumber+1,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{
//play("再按XX车主1号指纹");
play(0x006e);
play_number(MasterNumber/2+1);
play(0x0055);
delay(3500);
Status = CMDFpRegisterEnd(MasterNumber+1,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{
play_number(MasterNumber/2+1);
play(0x0055);
play(0x00ba);
delay(500);
// Status = CMDSetSystemInfo(0x00,0x00); //非主模式
//play("按XX车主2号指纹");
play(0x006c);
play_number(MasterNumber/2+1);
play(0x005d);
delay(500);
Status = CMDFpRegisterStart(MasterNumber+2,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{
//play("再按XX车主2号指纹");
play(0x006e);
play_number(MasterNumber/2+1);
play(0x005d);
delay(3500);
Status = CMDFpRegisterEnd(MasterNumber+2,0x00,0x01,0x00); //登录管理者指纹
if(Status == M2ERROR_NONE)
{ //play("xx好车主2号指纹设置成功,xx号车主注册成功");
play_number(MasterNumber/2+1);
play(0x0055);
play(0x00ba);
delay(500);
play_number(MasterNumber/2+1);
play(0x0079);
//Status = CMDFpVerifyEnd(); //结束比对通过后可操作的次数
}
else
//play("超时失败");
play(0x009a);
}
else
//play("超时失败");
play(0x009a);
}
else
//play("超时失败");
play(0x009a);
}
else
//play("超时失败");
play(0x009a);
Status = CMDFpVerifyEnd(); //结束比对通过后可操作的次数
}
else
//play("比对失败")
play(0x00ab);
}
else //play("指纹库已满");
play(0x0109);
}
else
//play("设备故障");
play(0x009f);
}
else
//play("设备故障");
play(0x009f);
delay(300);
Status=CMDSetSystemInfo(0x01,0x00); //主模式
}
//---------------------------------------------------------------
void RegisterSlave()
{
uchar ten=0,one=1; //ID号不能为0
uchar Status;
flash_read((char *)0x01018,UserTwoCode_Flag,50);
P1IE &= ~BIT7; // 屏蔽触发感应的对比键
CCTL0 &= ~CCIE;
Status = CMDDeviceTest();
if(Status == M2ERROR_NONE)
{
//Status = CMDSetSystemInfo(0x01,0x00); //主控方式 ????????????????????
if(Status == M2ERROR_NONE)
{
Status = CMDGetRecCount();
if(Status == M2ERROR_NONE)
{
if(Param1_L < 20)
{
//play("比对模式,按1号车主1号指纹");
play(0x0020);
play(0x006c);
play(0x0076);
play(0x0071);
delay(500);
Status = CMDFpVerifyMaster(0x00,0x00); //比对通过后可n次操作
if(Status == M2ERROR_NONE)
{
//比对成功
play(0x00b0);
//play("输入使用者两位编码");
play(0x0082);
while(!(KeyA))
{
if(KeyB)
{
while(KeyB)
{;}
ten++;
if(ten > 4)
ten=0;
//play("ten十");
play_number(ten);
if(ten != 0)
play(0x0016);
}
if(KeyC)
{
while(KeyC)
{;}
one++;
if(one > 9)
one=1;
//play("one");
play_number(one);
}
}
UserTwoCode = ten*10+one;
if(UserTwoCode_Flag[UserTwoCode] == 1)
{
//play("此编号用户已存在");
play_number(ten);
play_number(one);
play(0x00a4);
}
else
{
UserTwoCode_Flag[UserTwoCode]=1;
//play("按xx号使用者指纹");
play(0x006c);
play_number(ten);
play_number(one);
play(0x0065);
delay(500);
Status = CMDFpRegisterStart(UserTwoCode,0x00,0x00,0x00); //登录xx号使用者指纹
if(Status == M2ERROR_NONE)
{
//play("再按xx号使用者指纹");
play(0x006e);
play_number(ten);
play_number(one);
play(0x0065);
delay(4000);
Status = CMDFpRegisterEnd(UserTwoCode,0x00,0x00,0x00); //登录xx号使用者指纹
if(Status == M2ERROR_NONE)
{
//play("xx号使用者注册成功");
play_number(ten);
play_number(one);
play(0x0091);
flash_write((char *)0x01018,UserTwoCode_Flag,50);
}
else
play(0x009a);
//play("超时错误");
}
else
//play("超时失败");
play(0x009a);
}
Status = CMDFpVerifyEnd(); //结束比对通过后可操作的次数
}
else
//play("比对失败");
play(0x00ab);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -