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 14:12:18 2014 +0000
Revision:
4:3dd0f98e6f09
Parent:
3:459a4f985a45
Child:
5:d3ebe6d1ed92
Add LICENSE.;

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 int sts = 0;
tosihisa 4:3dd0f98e6f09 76 int ispress = 0;
tosihisa 4:3dd0f98e6f09 77 int ID = 0;
tosihisa 0:b11b455d4997 78
tosihisa 0:b11b455d4997 79 debug.format(8,Serial::None,1);
tosihisa 0:b11b455d4997 80 debug.baud(115200);
tosihisa 0:b11b455d4997 81
tosihisa 0:b11b455d4997 82 debug.printf("Open\n");
tosihisa 4:3dd0f98e6f09 83 sts = finger.Open();
tosihisa 4:3dd0f98e6f09 84 debug.printf("sts = %d\n",sts);
tosihisa 4:3dd0f98e6f09 85 if(sts == 0){
tosihisa 4:3dd0f98e6f09 86 int i;
tosihisa 4:3dd0f98e6f09 87 debug.printf("FirmwareVersion = %lx\n",finger.FirmwareVersion);
tosihisa 4:3dd0f98e6f09 88 debug.printf("IsoAreaMaxSize = %ld\n",finger.IsoAreaMaxSize);
tosihisa 4:3dd0f98e6f09 89 debug.printf("DeviceSerialNumber = ");
tosihisa 4:3dd0f98e6f09 90 for(i = 0; i < sizeof(finger.DeviceSerialNumber);i++){
tosihisa 4:3dd0f98e6f09 91 debug.printf("%02X",finger.DeviceSerialNumber[i]);
tosihisa 4:3dd0f98e6f09 92 }
tosihisa 4:3dd0f98e6f09 93 debug.printf("\n");
tosihisa 4:3dd0f98e6f09 94 }
tosihisa 0:b11b455d4997 95
tosihisa 3:459a4f985a45 96 if(1){
tosihisa 3:459a4f985a45 97 Enroll();
tosihisa 3:459a4f985a45 98 }
tosihisa 3:459a4f985a45 99
tosihisa 3:459a4f985a45 100 finger.CmosLed(1);
tosihisa 0:b11b455d4997 101 while(1) {
tosihisa 3:459a4f985a45 102 ispress = finger.IsPress();
tosihisa 3:459a4f985a45 103 debug.printf("IsPressFinger=%d\n",ispress);
tosihisa 3:459a4f985a45 104 if(ispress){
tosihisa 3:459a4f985a45 105 if(finger.Capture(1) != 0)
tosihisa 3:459a4f985a45 106 continue;
tosihisa 3:459a4f985a45 107 ID = finger.Identify();
tosihisa 3:459a4f985a45 108 debug.printf("ID = %d\n",ID);
tosihisa 2:34a647292050 109 }
tosihisa 0:b11b455d4997 110 }
tosihisa 0:b11b455d4997 111 }