Fingerprint sensor example with WIZwiki-W7500. 1st release.
Dependencies: GT511C3 mbed-src
Fork of GT511C3test by
main.cpp@2:34a647292050, 2014-01-03 (annotated)
- Committer:
- tosihisa
- Date:
- Fri Jan 03 07:24:39 2014 +0000
- Revision:
- 2:34a647292050
- Parent:
- 1:4a1be9379e92
- Child:
- 3:459a4f985a45
??ON/OFF????;
Who changed what in which revision?
User | Revision | Line number | New 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 | 2:34a647292050 | 16 | debug.printf("CMD_EnrollStart\n"); |
tosihisa | 2:34a647292050 | 17 | Parameter = EnrollID; |
tosihisa | 2:34a647292050 | 18 | sts = finger.SendRecv(GT511C3::CMD_EnrollStart,&Parameter,&Response); |
tosihisa | 2:34a647292050 | 19 | debug.printf("sts = %d,Response=0x%04x Parameter=0x%08lx\n",sts,Response,Parameter); |
tosihisa | 2:34a647292050 | 20 | if(sts != 0) |
tosihisa | 2:34a647292050 | 21 | return sts; |
tosihisa | 2:34a647292050 | 22 | if(Response != GT511C3::CMD_Ack) |
tosihisa | 2:34a647292050 | 23 | return -100; |
tosihisa | 2:34a647292050 | 24 | // |
tosihisa | 2:34a647292050 | 25 | return sts; |
tosihisa | 2:34a647292050 | 26 | } |
tosihisa | 2:34a647292050 | 27 | |
tosihisa | 0:b11b455d4997 | 28 | int main() { |
tosihisa | 0:b11b455d4997 | 29 | unsigned long Parameter; |
tosihisa | 0:b11b455d4997 | 30 | unsigned short Response; |
tosihisa | 0:b11b455d4997 | 31 | int sts = 0; |
tosihisa | 1:4a1be9379e92 | 32 | int count = 0; |
tosihisa | 2:34a647292050 | 33 | int ispress; |
tosihisa | 0:b11b455d4997 | 34 | |
tosihisa | 0:b11b455d4997 | 35 | debug.format(8,Serial::None,1); |
tosihisa | 0:b11b455d4997 | 36 | debug.baud(115200); |
tosihisa | 0:b11b455d4997 | 37 | |
tosihisa | 0:b11b455d4997 | 38 | debug.printf("Init\n"); |
tosihisa | 0:b11b455d4997 | 39 | finger.Init(); |
tosihisa | 0:b11b455d4997 | 40 | debug.printf("Open\n"); |
tosihisa | 2:34a647292050 | 41 | Parameter = 0; |
tosihisa | 2:34a647292050 | 42 | sts = finger.SendRecv(GT511C3::CMD_Open,&Parameter,&Response); |
tosihisa | 0:b11b455d4997 | 43 | debug.printf("sts = %d,Response=0x%04x\n",sts,Response); |
tosihisa | 0:b11b455d4997 | 44 | |
tosihisa | 2:34a647292050 | 45 | Parameter = 1; |
tosihisa | 2:34a647292050 | 46 | sts = finger.SendRecv(GT511C3::CMD_CmosLed,&Parameter,&Response); |
tosihisa | 2:34a647292050 | 47 | debug.printf("sts = %d,Response=0x%04x\n",sts,Response); |
tosihisa | 0:b11b455d4997 | 48 | while(1) { |
tosihisa | 2:34a647292050 | 49 | ispress = 0; |
tosihisa | 2:34a647292050 | 50 | Parameter = 0; |
tosihisa | 2:34a647292050 | 51 | sts = finger.SendRecv(GT511C3::CMD_IsPressFinger,&Parameter,&Response); |
tosihisa | 2:34a647292050 | 52 | debug.printf("sts = %d,Response=0x%04x Parameter=0x%08lx\n",sts,Response,Parameter); |
tosihisa | 2:34a647292050 | 53 | if(sts == 0){ |
tosihisa | 2:34a647292050 | 54 | if((Response == GT511C3::CMD_Ack) && (Parameter == 0)){ |
tosihisa | 2:34a647292050 | 55 | ispress = 1; |
tosihisa | 2:34a647292050 | 56 | } |
tosihisa | 2:34a647292050 | 57 | } |
tosihisa | 2:34a647292050 | 58 | #if 0 |
tosihisa | 0:b11b455d4997 | 59 | myled = 1; |
tosihisa | 1:4a1be9379e92 | 60 | wait(0.5); |
tosihisa | 0:b11b455d4997 | 61 | myled = 0; |
tosihisa | 1:4a1be9379e92 | 62 | wait(0.5); |
tosihisa | 2:34a647292050 | 63 | #endif |
tosihisa | 1:4a1be9379e92 | 64 | count++; |
tosihisa | 0:b11b455d4997 | 65 | } |
tosihisa | 0:b11b455d4997 | 66 | } |