Program for R306 fingerprint module interfaced with Wiz750SR S2E device

Dependencies:   FPC_R306 MQTT WIZnetInterface mbed

Fork of GT511C3_TimeStamp_WIZwiki-W7500 by WIZnet

Committer:
tosihisa
Date:
Fri Jan 03 12:56:03 2014 +0000
Revision:
3:459a4f985a45
Parent:
2:34a647292050
Child:
4:3dd0f98e6f09
Add Enroll and Identify!;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tosihisa 0:b11b455d4997 1 #include "mbed.h"
tosihisa 0:b11b455d4997 2 #include "GT511C3.h"
tosihisa 0:b11b455d4997 3
tosihisa 0:b11b455d4997 4 Serial debug(USBTX,USBRX);
tosihisa 0:b11b455d4997 5
tosihisa 0:b11b455d4997 6 DigitalOut myled(LED1);
tosihisa 0:b11b455d4997 7 GT511C3 finger(p28,p27);
tosihisa 0:b11b455d4997 8
tosihisa 2:34a647292050 9 int Enroll(void)
tosihisa 2:34a647292050 10 {
tosihisa 2:34a647292050 11 int EnrollID = 10;
tosihisa 2:34a647292050 12 unsigned long Parameter = 0;
tosihisa 2:34a647292050 13 unsigned short Response = 0;
tosihisa 2:34a647292050 14 int sts = 0;
tosihisa 2:34a647292050 15
tosihisa 3:459a4f985a45 16 debug.printf("EnrollStart\n");
tosihisa 3:459a4f985a45 17 finger.CmosLed(1);
tosihisa 3:459a4f985a45 18
tosihisa 3:459a4f985a45 19 while(1){
tosihisa 3:459a4f985a45 20 debug.printf("CMD_EnrollStart\n");
tosihisa 3:459a4f985a45 21 Parameter = EnrollID;
tosihisa 3:459a4f985a45 22 sts = finger.SendRecv(GT511C3::CMD_EnrollStart,&Parameter,&Response);
tosihisa 3:459a4f985a45 23 debug.printf("sts = %d,Response=0x%04x Parameter=0x%08lx\n",sts,Response,Parameter);
tosihisa 3:459a4f985a45 24 if(sts != 0)
tosihisa 3:459a4f985a45 25 return sts;
tosihisa 3:459a4f985a45 26 if(Response != GT511C3::CMD_Ack)
tosihisa 3:459a4f985a45 27 return -100;
tosihisa 3:459a4f985a45 28
tosihisa 3:459a4f985a45 29 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 30 finger.WaitPress(0);
tosihisa 3:459a4f985a45 31
tosihisa 3:459a4f985a45 32 while(1){
tosihisa 3:459a4f985a45 33 debug.printf("Press finger to Enroll (1st)\n");
tosihisa 3:459a4f985a45 34 finger.WaitPress(1);
tosihisa 3:459a4f985a45 35 if(finger.Capture(1) == 0)
tosihisa 3:459a4f985a45 36 break;
tosihisa 3:459a4f985a45 37 }
tosihisa 3:459a4f985a45 38
tosihisa 3:459a4f985a45 39 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 40 if(finger.Enroll_N(1) != 0)
tosihisa 3:459a4f985a45 41 continue;
tosihisa 3:459a4f985a45 42 finger.WaitPress(0);
tosihisa 3:459a4f985a45 43
tosihisa 3:459a4f985a45 44 while(1){
tosihisa 3:459a4f985a45 45 debug.printf("Press finger to Enroll (2nd)\n");
tosihisa 3:459a4f985a45 46 finger.WaitPress(1);
tosihisa 3:459a4f985a45 47 if(finger.Capture(1) == 0)
tosihisa 3:459a4f985a45 48 break;
tosihisa 3:459a4f985a45 49 }
tosihisa 3:459a4f985a45 50
tosihisa 3:459a4f985a45 51 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 52 if(finger.Enroll_N(2) != 0)
tosihisa 3:459a4f985a45 53 continue;
tosihisa 3:459a4f985a45 54 finger.WaitPress(0);
tosihisa 3:459a4f985a45 55
tosihisa 3:459a4f985a45 56 while(1){
tosihisa 3:459a4f985a45 57 debug.printf("Press finger to Enroll (3rd)\n");
tosihisa 3:459a4f985a45 58 finger.WaitPress(1);
tosihisa 3:459a4f985a45 59 if(finger.Capture(1) == 0)
tosihisa 3:459a4f985a45 60 break;
tosihisa 3:459a4f985a45 61 }
tosihisa 3:459a4f985a45 62
tosihisa 3:459a4f985a45 63 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 64 if(finger.Enroll_N(3) != 0)
tosihisa 3:459a4f985a45 65 continue;
tosihisa 3:459a4f985a45 66 finger.WaitPress(0);
tosihisa 3:459a4f985a45 67
tosihisa 3:459a4f985a45 68 debug.printf("Enroll OK!\n");
tosihisa 3:459a4f985a45 69 break;
tosihisa 3:459a4f985a45 70 }
tosihisa 3:459a4f985a45 71 return 0;
tosihisa 2:34a647292050 72 }
tosihisa 2:34a647292050 73
tosihisa 0:b11b455d4997 74 int main() {
tosihisa 0:b11b455d4997 75 unsigned long Parameter;
tosihisa 0:b11b455d4997 76 unsigned short Response;
tosihisa 0:b11b455d4997 77 int sts = 0;
tosihisa 1:4a1be9379e92 78 int count = 0;
tosihisa 2:34a647292050 79 int ispress;
tosihisa 3:459a4f985a45 80 int ID;
tosihisa 0:b11b455d4997 81
tosihisa 0:b11b455d4997 82 debug.format(8,Serial::None,1);
tosihisa 0:b11b455d4997 83 debug.baud(115200);
tosihisa 0:b11b455d4997 84
tosihisa 0:b11b455d4997 85 debug.printf("Init\n");
tosihisa 0:b11b455d4997 86 finger.Init();
tosihisa 0:b11b455d4997 87 debug.printf("Open\n");
tosihisa 2:34a647292050 88 Parameter = 0;
tosihisa 2:34a647292050 89 sts = finger.SendRecv(GT511C3::CMD_Open,&Parameter,&Response);
tosihisa 0:b11b455d4997 90 debug.printf("sts = %d,Response=0x%04x\n",sts,Response);
tosihisa 0:b11b455d4997 91
tosihisa 3:459a4f985a45 92 if(1){
tosihisa 3:459a4f985a45 93 Enroll();
tosihisa 3:459a4f985a45 94 }
tosihisa 3:459a4f985a45 95
tosihisa 3:459a4f985a45 96 finger.CmosLed(1);
tosihisa 0:b11b455d4997 97 while(1) {
tosihisa 3:459a4f985a45 98 ispress = finger.IsPress();
tosihisa 3:459a4f985a45 99 debug.printf("IsPressFinger=%d\n",ispress);
tosihisa 3:459a4f985a45 100 if(ispress){
tosihisa 3:459a4f985a45 101 if(finger.Capture(1) != 0)
tosihisa 3:459a4f985a45 102 continue;
tosihisa 3:459a4f985a45 103 ID = finger.Identify();
tosihisa 3:459a4f985a45 104 debug.printf("ID = %d\n",ID);
tosihisa 2:34a647292050 105 }
tosihisa 2:34a647292050 106 #if 0
tosihisa 0:b11b455d4997 107 myled = 1;
tosihisa 1:4a1be9379e92 108 wait(0.5);
tosihisa 0:b11b455d4997 109 myled = 0;
tosihisa 1:4a1be9379e92 110 wait(0.5);
tosihisa 2:34a647292050 111 #endif
tosihisa 1:4a1be9379e92 112 count++;
tosihisa 0:b11b455d4997 113 }
tosihisa 0:b11b455d4997 114 }