|
這是一個(gè)真實(shí)項(xiàng)目工程!
項(xiàng)目目的:做一套刷卡系統(tǒng),識(shí)別并控制讀寫(xiě)NFC卡中的信息,其中NFC是主動(dòng)卡(含電源MCU,并有私有命令)
本項(xiàng)目是系統(tǒng)里面刷卡端,功能是發(fā)送無(wú)線(xiàn)命令到NFC卡,控制卡信息信息寫(xiě)入,讀取刷卡記錄,
本代碼包括一個(gè)LCD屏,一個(gè)鍵盤(pán),拼音輸入法,NFC控制器,低功耗設(shè)置等
0.png (63.33 KB, 下載次數(shù): 155)
下載附件
2017-1-13 01:41 上傳
完整代碼下載:
ZCardA.zip
(582.06 KB, 下載次數(shù): 22)
2017-1-12 15:29 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
部分源碼預(yù)覽:
- #include <tam3lib.h>
- #include <fcard_hal.h>
- #include "flash_initiator.h"
- #include "uart_dep_initiator.h"
- #include "dep_initiator.h"
- extern int main_app_init_user(void);
- extern int main_app_init_finger(void);
- extern int main_app_card_login(void);
- extern int main_app_set_datetime(void);
- extern int main_app_set_location(void);
- extern int main_app_set_password(void);
- extern int main_app_card_format(void);
- static void show_main_menu(int index){
- static char *menu[]={
- "設(shè)置本機(jī)密碼",
- "設(shè)置日期時(shí)間",
- "設(shè)置位置信息",
- "初始化卡用戶(hù)",
- "下載用戶(hù)指紋",
- "卡管理員登錄",
- "格式化卡系統(tǒng)"
- };
- fcard_lcd_clear();
- fcard_lcd_printh1("%d:%s",index+0,menu[index+0]);
- fcard_lcd_printh2("%d:%s",index+1,menu[index+1]);
- fcard_lcd_printh3("%d:%s",index+2,menu[index+2]);
- fcard_lcd_printh4("%d:%s",index+3,menu[index+3]);
- }
- int get_choice(void){
- int select = 0;
- do{
- mdelay(50);
- select = fcard_kbd_peek();
- if (select == 27 || select == 13)
- break;
- }while(select<'0'||select>'9');
- return select;
- }
- int check_quit(void){
- int select = 0;
- do{
- mdelay(50);
- select = fcard_kbd_peek();
- }while(select!=27&&select!=13);
- return select;
- }
- int main_setting(){
- int select=0;
- for(;;){
- show_main_menu(1);
- select = get_choice();
- if (select == 27) break;
- switch(select){
- case '0':
- printf("select 0\r\n");
- fcard_lcd_clear();
- main_app_set_password();
- //select=check_quit();
- break;
- case '1':
- printf("select 1\r\n");
- fcard_lcd_clear();
- main_app_set_datetime();
- //select=check_quit();
- break;
- case '2':
- printf("select 2\r\n");
- fcard_lcd_clear();
- main_app_set_location();
- break;
- case '3':
- printf("select 3\r\n");
- fcard_lcd_clear();
- main_app_init_user();
- break;
- case '4':
- printf("select 4\r\n");
- fcard_lcd_clear();
- main_app_init_finger();
- break;
- case '5':
- printf("select 5\r\n");
- fcard_lcd_clear();
- main_app_card_login();
- break;
- case '6':
- printf("select 6\r\n");
- fcard_lcd_clear();
- main_app_card_format();
- break;
- default:
- printf("default\r\n");
- //fcard_lcd_clear();
- break;
- }
- }
- return 0;
- }
- int main_login(){
- int i,key,length;
- int timeout=15000;
- char line[36];
- char password[36];
- char showinfo[36];
-
- fcard_beep_off();
-
- if (!hasAdministratorPassword()){
- return main_setting();
- }
-
- fcard_kbd_flush();
- fcard_lcd_clear();
- sprintf(line,"請(qǐng)輸入管理員密碼");
- fcard_lcd_printh1(line);
- memset(showinfo,0x00,sizeof(showinfo));
- memset(password,0x00,sizeof(password));
- length = 0;
- for (timeout=15000;timeout>0;){
- if (length>=8)break;
- key = fcard_kbd_peek();
- if (key==0){
- mdelay(20);
- timeout -= 20;
- continue;
- }
- if (key>='0'&&key<='9'){
- showinfo[length]='*';
- password[length++]=key;
- fcard_lcd_printh2(showinfo);
- fcard_lcd_printh3(password);
- }
- if (key==27){
- if (length>0){
- showinfo[--length]=' ';
- password[length]=' ';
- //fcard_kbd_flush();
- //fcard_lcd_clear();
- fcard_lcd_printh2(showinfo);
- fcard_lcd_printh3(password);
- }else{
- break;
- }
- }
- if (key==13){
- break;
- }
- }
- if (strlen(password)<=0){
- //timeout -= 20;
- //continue;
- }else if (strncmp(password,administratorPassword,8)==0){
- main_setting();
- }else{
- sprintf(line," 輸入密碼錯(cuò)誤 ");
- fcard_lcd_printh4(line);
- }
- return 0;
- }
- int main(void){
- struct tm itm;
- unsigned char line[32];
- unsigned char txbuff[128];
- char username[20];
- int key,i;
- int length;
- broadcastinfo_t info;
-
- fcard_sysclk_init();
- fcard_nvic_init();
- fcard_leds_init();
- fcard_beep_init();
- fcard_flash_init();
- fcard_kbd_init();
- fcard_lcd_init();
- fcard_rtc_init();
- fcard_uart3_init(BAUD_115200,8,0,1);
- //formatSystemZone();
- initFingerFeatureZone();
- if (!hasFingerBackgroundPicture()){
- saveFingerBackgroundPictureToFlash();
- }
- fcard_kbd_flush();
- fcard_lcd_clear();
- zigbeeProtocolProcessInit();
- memset(username,0x00,sizeof(username));
- for (;;){
- fcard_lcd_clear();
- fcard_get_datetime(&itm);
- sprintf(line,"仁石科技有限公司");
- fcard_lcd_printh1(line);
- sprintf(line," %04d-%02d-%02d ", itm.tm_year,itm.tm_mon,itm.tm_mday);
- fcard_lcd_printh2(line);
- sprintf(line," %02d:%02d:%02d ", itm.tm_hour,itm.tm_min,itm.tm_sec);
- fcard_lcd_printh3(line);
- if (strlen(username)>0){
- fcard_lcd_printh4(username);
- fcard_beep_off();
- }else{
- if (hasLocationInformation()){
- int istr=strlen(locationInformation)/2;
- if (istr>=8){
- istr=0;
- }else{
- istr=(8-istr)/2;
- }
- for (i=0;i<istr*2;i++){
- username[i]=' ';
- }
- sprintf(&username[istr*2],"%s",locationInformation);
- fcard_lcd_printh4(username);
- fcard_beep_off();
- }
- }
- memset(&info,0x00,sizeof(info));
- if (hasLocationInformation()){
- snprintf(info.location,96,"%s",locationInformation);
- }
- snprintf(info.time,32,"%04d-%02d-%02d %02d:%02d:%02d",itm.tm_year,itm.tm_mon,itm.tm_mday,itm.tm_hour,itm.tm_min,itm.tm_sec);
-
- length = depMakeFrame(txbuff,0xFF,0x20,(unsigned char*)&info,sizeof(info));
- if (zigbeeProtocolTalkToTarget(txbuff,length,line,22)==22){
- if (line[0]==0xAA && line[21]==0x55 && line[1]==0x00){
- snprintf(username,16,"%s",&line[4]);
- fcard_beep_on();
- }else{
- memset(username,0x00,sizeof(username));
- }
- }else{
- memset(username,0x00,sizeof(username));
- }
-
- key = fcard_kbd_peek();
- if (key==13){
- main_login();
- }
- }
- zigbeeProtocolProcessExit();
- return 0;
- }
復(fù)制代碼 |
|