pccomm.c
来自「指纹识别源代码,用于智能门紧,还有配合MF800卡使用」· C语言 代码 · 共 652 行 · 第 1/2 页
C
652 行
unsigned char holindex;
holindex=uart0buff[PCPACKAGEPARAMP];
//idata2idata(uart0buff+PCPACKAGEPARAMP+1,tempbuff,16);
uart02idata(PCPACKAGEPARAMP+1,tempbuff,16);
ram_write16(PAGEHOLSTART*16+holindex,0);
ackpccmd(PCASETHOLIDAY,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcgetdate()
{
//idata2idata(datetime,uart0buff+PCPACKAGEPARAMP,8);
idata2uart0(datetime,PCPACKAGEPARAMP,8);
ackpccmd(PCAGETDATE,RETOK,8);
}
//////////////////////////////////////////////////////////////
void pcgetts()
{
unsigned char tsindex;
tsindex=uart0buff[PCPACKAGEPARAMP];
ram_read16(PAGETSSTART*16+tsindex,0);
//idata2idata(tempbuff,uart0buff+PCPACKAGEPARAMP+1,16);
idata2uart0(tempbuff,PCPACKAGEPARAMP+1,16);
ackpccmd(PCAGETTS,RETOK,17);
}
//////////////////////////////////////////////////////////////
void pcgetholiday()
{
unsigned char holindex;
holindex=uart0buff[PCPACKAGEPARAMP];
ram_read16(PAGEHOLSTART*16+holindex,0);
//idata2idata(tempbuff,uart0buff+PCPACKAGEPARAMP+1,16);
idata2uart0(tempbuff,PCPACKAGEPARAMP+1,16);
ackpccmd(PCAGETHOLIDAY,RETOK,17);
}
//////////////////////////////////////////////////////////////
void pcsysinit()
{
initfpsystem();
ackpccmd(PCASYSINIT,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcidclear()
{
//deletealluser();
//rdeletealluser();
userclear();
ackpccmd(PCAIDCLEAR,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pctsclear()
{
clearts();
ackpccmd(PCATSCLEAR,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pceventclear()
{
clearevent();
ackpccmd(PCAEVENTCLEAR,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcsetmode()
{
unsigned char tempdata;
if(uart0buff[PCPACKAGEPARAMP]>=MAXSETMODESEL)return;
if(uart0buff[PCPACKAGEPARAMP+1]>=MAXMODEINDEX)return;
tempdata=uart0buff[PCPACKAGEPARAMP];
//if(tempdata>=MAXSETMODESEL)return;
ram_writep0(SECUMODE,tempdata);
tempdata=uart0buff[PCPACKAGEPARAMP+1];
ram_writep0(MODEINDEX,tempdata);
ackpccmd(PCASETMODE,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcsetduress()
{
unsigned char tempduress,tempduresspw;
tempduress=uart0buff[PCPACKAGEPARAMP];
tempduresspw=uart0buff[PCPACKAGEPARAMP+1];
if(tempduress>=MAXDURESSSEL)return;
if(tempduresspw>=MAXDURESSPW)return;
ram_writep0(DURESSMODE,tempduress);
ram_writep0(DURESSPW,tempduresspw);
ackpccmd(PCASETDURESS,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcsetinout()
{
unsigned char ioindex;
ioindex=uart0buff[PCPACKAGEPARAMP];
//idata2idata(uart0buff+PCPACKAGEPARAMP+1,tempbuff,16);
uart02idata(PCPACKAGEPARAMP+1,tempbuff,16);
ram_write16(ioindex,0);
ackpccmd(PCASETINOUT,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcgetinout()
{
unsigned char ioindex;
ioindex=uart0buff[PCPACKAGEPARAMP];
ram_read16(ioindex,0);
//idata2idata(tempbuff,uart0buff+PCPACKAGEPARAMP+1,16);
idata2uart0(tempbuff,PCPACKAGEPARAMP+1,16);
ackpccmd(PCAGETINOUT,RETOK,17);
}
//////////////////////////////////////////////////////////////
void pcsetapb()
{
unsigned char tempdata;
tempdata=uart0buff[PCPACKAGEPARAMP];
if(tempdata>=MAXSETAPBSEL)return;
ram_writep0(APBMODE,tempdata);
ackpccmd(PCASETAPB,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcsetkey()
{
//ram_write(KEYSTATE,0,uart1buff[1]);
unsigned char tempdata;
tempdata=uart0buff[PCPACKAGEPARAMP];
if(tempdata>=MAXPINKEYINSEL)return;
ram_writep0(KEYSTATE,tempdata);
ackpccmd(PCASETKEY,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcgetkey()
{
ackpccmd(PCRGETKEY,ram_readp0(KEYSTATE),1);
}
//////////////////////////////////////////////////////////////
void pcgetdoor()
{
unsigned char tempdata;
tempdata=0;
if(!(instate&bittbl[CONTACTCOUNT]))tempdata=1;
if(isdoorlocked())tempdata+=2;
uart0buff[PCPACKAGEPARAMP]=tempdata;
ackpccmd(PCAGETDOOR,RETOK,1);
}
//////////////////////////////////////////////////////////////
void pcsetdoor()
{
//doorstate=uart1buff[1];
unsigned char tempdata;
tempdata=uart0buff[PCPACKAGEPARAMP];
if(tempdata>=MAXDOORSTATE)return;
if(tempdata)
{
//set_373(DOORPORT);
lockdoor();
ackpccmd(PCRSETDOOR,RETOK,1);
}
else
{
//clr_373(DOORPORT);
unlockdoor();
ackpccmd(PCASETDOOR,RETOK,1);
}
}
//////////////////////////////////////////////////////////////
void pcsetram()
{
//DO nothing ????
ackpccmd(PCASETRAM,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcsetfunc()
{
//
unsigned char tempdata;
tempdata=uart0buff[PCPACKAGEPARAMP];
if(tempdata>=4)return;
switch(tempdata)
{
case 0: function1();break;
case 1: function2();break;
case 2: function3();break;
case 3: function4();break;
}
ackpccmd(PCASETFUNC,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcok()
{
if(removeeventflag)
{
removeeventflag=0;
removeoneevent();
}
else if(removeuserflag)
{
changenewuser();
removeuserflag=0;
}
//do nothing
}
//////////////////////////////////////////////////////////////
void pcchecklink()
{
ackpccmd(PCACHECKLINK,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcsetholindex()
{
uart02idata(PCPACKAGEPARAMP,tempbuff,10);
ram_write16(TSHOLINDEXSTART/16,0);
ackpccmd(PCASETHOLINDEX,RETOK,0);
}
//////////////////////////////////////////////////////////////
void pcgetusernum()
{
unsigned short tempdata;
tempdata=getusernum();
uart0buff[PCPACKAGEPARAMP]=tempdata;
uart0buff[PCPACKAGEPARAMP+1]=tempdata>>8;
ackpccmd(PCAGETUSERNUM,RETOK,2);
}
//////////////////////////////////////////////////////////////
/*unsigned short code pcpackagelen[]=
{
PCANPLEN,PCANPLEN+512,PCANPLEN,PCANPLEN+4,
PCANPLEN+8,PCANPLEN+161,PCANPLEN+65,PCANPLEN,
PCANPLEN+1,PCANPLEN+1,PCANPLEN,PCANPLEN,
PCANPLEN,PCANPLEN,PCANPLEN+2,PCANPLEN+2,
PCANPLEN+96,PCANPLEN+1,PCANPLEN+1,PCANPLEN,
PCANPLEN,PCANPLEN+1,PCANPLEN,PCANPLEN+1,
PCANPLEN
};
*/
//////////////////////////////////////////////////////////////
void deal_pccomm()
{
unsigned char tempcrclow,tempcrchigh;
unsigned short datalen;
if(setflag)return;
datalen=(uart0buff[2]<<8)|uart0buff[1];
tempcrclow=uart0buff[datalen+1];
tempcrchigh=uart0buff[datalen+2];
checkcrc(datalen);
if(tempcrclow!=uart0buff[datalen+1]||tempcrchigh!=uart0buff[datalen+2])return ;
if(uart0buff[PCPACKAGEIDP]!=readcommid())return;
//if(datalen!=pcpackagelen[uart0buff[PCPACKAGECMDP]])return;
switch(uart0buff[PCPACKAGECMDP])
{
case PCRGETNEWEVENT: pcgetnewevent();break;
case PCRSETNEWUSER: pcsetnewuser();break;
case PCRGETNEWUSER: pcgetnewuser();break;
case PCRGETUSER: pcgetuser();break;
case PCRSETDATETIME: pcsetdatetime();break;
case PCRSETTS: pcsetts();break;
case PCRSETHOLIDAY: pcsetholiday();break;
case PCRGETDATE: pcgetdate();break;
case PCRGETTS: pcgetts();break;
case PCRGETHOLIDAY: pcgetholiday();break;
case PCRSYSINIT: pcsysinit();break;
case PCRIDCLEAR: pcidclear();break;
case PCRTSCLEAR: pctsclear();break;
case PCREVENTCLEAR: pceventclear();break;
case PCRSETMODE: pcsetmode();break;
case PCRSETDURESS: pcsetduress();break;
case PCRSETINOUT: pcsetinout();break;
case PCRSETAPB: pcsetapb();break;
case PCRSETKEY: pcsetkey();break;
case PCRGETKEY: pcgetkey();break;
case PCRGETDOOR: pcgetdoor();break;
case PCRSETDOOR: pcsetdoor();break;
case PCRSETRAM: pcsetram();break;
case PCRSETFUNC: pcsetfunc();break;
case PCOK: pcok();break;
case PCRGETSTATE: pcgetstate();break;
case PCRCHECKLINK: pcchecklink();break;
case PCRGETINOUT: pcgetinout();break;
case PCRSETHOLINDEX: pcsetholindex();break;
case PCRGETUSERNUM: pcgetusernum();break;
case PCRGETALLUSER: pcgetalluser();break;
default: break;
}
}
///////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?