//***********************************************
//函 数 名:id_Operate(void);
//入口参数:无
//出口参数:无
//函数作用:MAIN函数
//说 明:
//***********************************************
void id_Operate(void)
{
uchar i=0;
if(id_OK_flag) //有ID刷卡
{
if(work_mode==0)
{
i2c_readdata_8bit(ADD_ADMIN_CARD); //读母卡删除卡和ID卡末尾存储地址数据
if((wreep_data[2]==readmin_card[2])&&(wreep_data[1]==readmin_card[1])&&(wreep_data[0]==readmin_card[0]))
{
if((readmin_card[7]==0XFF)&&(readmin_card[6]=0XFF))
{
wraddr_data[1]=0X00;
wraddr_data[0]=0X00;
i2c_wradd_data(FIRST_ID_ADDR);
DelayMs(3000);
}
work_mode=ADD_ADMINCARD; //是增加母卡,准备存储ID卡数据
voice_win6(VOICE_CARDADD); //播放锁已开
id_wrover_flag=0;
id_OK_flag=0;
time_sec=20;
}
else if((wreep_data[2]==readmin_card[5])&&(wreep_data[1]==readmin_card[4])&&(wreep_data[0]==readmin_card[3]))
{
if((readmin_card[7]==0XFF)&&(readmin_card[6]=0XFF))
{
wraddr_data[1]==0X00;
wraddr_data[0]==0X00;
i2c_wradd_data(FIRST_ID_ADDR);
DelayMs(3000);
}
work_mode=DEL_ADMINCARD; //是删除卡,准备删除存储器里ID卡数据
voice_win6(VOICE_CARDEDL); //播放锁已开
id_wrover_flag=0;
id_OK_flag=0;
time_sec=20;
}
else
{
work_mode=USER_CARD; //是用户卡,准备读取存储卡里信息对比
newid_addr=0x0000;
voice_win6(VOICE_CALLING);
i=1;
}
i2c_readdata(FIRST_ID_ADDR);
oldid_addr=reeep_data[1]; //读取24C128里存储的地址数据
oldid_addr=(oldid_addr<<8)+reeep_data[0];
send_byte(0x11);
send_byte(readmin_card[2]);
send_byte(readmin_card[1]);
send_byte(readmin_card[0]);
send_byte(readmin_card[5]);
send_byte(readmin_card[4]);
send_byte(readmin_card[3]);
send_byte(reeep_data[2]);
send_byte(reeep_data[1]);
send_byte(reeep_data[0]);
send_byte(0x11);
}
while(id_OK_flag)
{
i2c_readdata(FIRST_ID_ADDR);
oldid_addr=reeep_data[1]; //读取24C128里存储的地址数据
oldid_addr=(oldid_addr<<8)+reeep_data[0];
send_byte(0x11);
send_byte(reeep_data[2]);
send_byte(reeep_data[1]);
send_byte(reeep_data[0]);
send_byte(0x11);
switch(work_mode)
目标板第一次上电时,刷卡调用 i2c_readdata(FIRST_ID_ADDR);读取存储ID卡数据的地址是正确的,开锁设置标志,延时5秒标志清零后,再次调用读取FIRST_ID_ADDR地址里的数据就变成了0XFF,找了很久没找出问题,但上电复位重启后第一次正常,是什么原因,请大侠指教!
|