Time Stamp using fingerprint with WIZwiki-W7500.
Dependencies: GT511C3 NTPClient SDFileSystem WIZnetInterface mbed-src
Fork of GT511C3_HelloWorld_WIZwiki-W7500 by
GT511C3.h@4:3dd0f98e6f09, 2014-01-03 (annotated)
- 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?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| tosihisa | 4:3dd0f98e6f09 | 1 | /** |
| tosihisa | 4:3dd0f98e6f09 | 2 | * @section LICENSE |
| tosihisa | 4:3dd0f98e6f09 | 3 | * |
| tosihisa | 4:3dd0f98e6f09 | 4 | * Copyright (c) 2013 @tosihisa, MIT License |
| tosihisa | 4:3dd0f98e6f09 | 5 | * |
| tosihisa | 4:3dd0f98e6f09 | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| tosihisa | 4:3dd0f98e6f09 | 7 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
| tosihisa | 4:3dd0f98e6f09 | 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
| tosihisa | 4:3dd0f98e6f09 | 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
| tosihisa | 4:3dd0f98e6f09 | 10 | * furnished to do so, subject to the following conditions: |
| tosihisa | 4:3dd0f98e6f09 | 11 | * |
| tosihisa | 4:3dd0f98e6f09 | 12 | * The above copyright notice and this permission notice shall be included in all copies or |
| tosihisa | 4:3dd0f98e6f09 | 13 | * substantial portions of the Software. |
| tosihisa | 4:3dd0f98e6f09 | 14 | * |
| tosihisa | 4:3dd0f98e6f09 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
| tosihisa | 4:3dd0f98e6f09 | 16 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| tosihisa | 4:3dd0f98e6f09 | 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| tosihisa | 4:3dd0f98e6f09 | 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| tosihisa | 4:3dd0f98e6f09 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| tosihisa | 4:3dd0f98e6f09 | 20 | * |
| tosihisa | 4:3dd0f98e6f09 | 21 | * @section DESCRIPTION |
| tosihisa | 4:3dd0f98e6f09 | 22 | * |
| tosihisa | 4:3dd0f98e6f09 | 23 | * Fingerprint reader module "GT-511C3" class. |
| tosihisa | 4:3dd0f98e6f09 | 24 | * |
| tosihisa | 4:3dd0f98e6f09 | 25 | * http://www.adh-tech.com.tw/?22,gt-511c3-gt-511c31 |
| tosihisa | 4:3dd0f98e6f09 | 26 | * http://www.adh-tech.com.tw/files/GT-511C3_datasheet_V1%201_20131127[1].pdf |
| tosihisa | 4:3dd0f98e6f09 | 27 | * https://www.sparkfun.com/products/11792 |
| tosihisa | 4:3dd0f98e6f09 | 28 | * https://github.com/sparkfun/Fingerprint_Scanner-TTL/ |
| tosihisa | 4:3dd0f98e6f09 | 29 | * http://blog.digit-parts.com/archives/51894096.html |
| tosihisa | 4:3dd0f98e6f09 | 30 | */ |
| tosihisa | 4:3dd0f98e6f09 | 31 | #ifndef __GT511C3_H |
| tosihisa | 4:3dd0f98e6f09 | 32 | #define __GT511C3_H |
| tosihisa | 0:b11b455d4997 | 33 | #include "mbed.h" |
| tosihisa | 0:b11b455d4997 | 34 | |
| tosihisa | 0:b11b455d4997 | 35 | class GT511C3 : public Serial { |
| tosihisa | 0:b11b455d4997 | 36 | public: |
| tosihisa | 0:b11b455d4997 | 37 | enum Command { |
| tosihisa | 0:b11b455d4997 | 38 | CMD_Open = 0x01, // 01 Open Initialization |
| tosihisa | 0:b11b455d4997 | 39 | CMD_Close = 0x02, // 02 Close Termination |
| tosihisa | 0:b11b455d4997 | 40 | CMD_UsbInternalCheck = 0x03, // 03 UsbInternalCheck Check if the connected USB device is valid |
| tosihisa | 0:b11b455d4997 | 41 | CMD_ChangeBaudrate = 0x04, // 04 ChangeBaudrate Change UART baud rate |
| tosihisa | 0:b11b455d4997 | 42 | CMD_SetIAPMode = 0x05, // 05 SetIAPMode Enter IAP Mode In this mode, FW Upgrade is available |
| tosihisa | 0:b11b455d4997 | 43 | CMD_CmosLed = 0x12, // 12 CmosLed Control CMOS LED |
| tosihisa | 0:b11b455d4997 | 44 | CMD_GetEnrollCount = 0x20, // 20 GetEnrollCount Get enrolled fingerprint count |
| tosihisa | 0:b11b455d4997 | 45 | CMD_CheckEnrolled = 0x21, // 21 CheckEnrolled Check whether the specified ID is already enrolled |
| tosihisa | 0:b11b455d4997 | 46 | CMD_EnrollStart = 0x22, // 22 EnrollStart Start an enrollment |
| tosihisa | 0:b11b455d4997 | 47 | CMD_Enroll1 = 0x23, // 23 Enroll1 Make 1st template for an enrollment |
| tosihisa | 0:b11b455d4997 | 48 | CMD_Enroll2 = 0x24, // 24 Enroll2 Make 2nd template for an enrollment |
| tosihisa | 0:b11b455d4997 | 49 | CMD_Enroll3 = 0x25, // 25 Enroll3 Make 3rd template for an enrollment, merge three templates into one template, save merged template to the database |
| tosihisa | 0:b11b455d4997 | 50 | CMD_IsPressFinger = 0x26, // 26 IsPressFinger Check if a finger is placed on the sensor |
| tosihisa | 0:b11b455d4997 | 51 | CMD_DeleteID = 0x40, // 40 DeleteID Delete the fingerprint with the specified ID |
| tosihisa | 0:b11b455d4997 | 52 | CMD_DeleteAll = 0x41, // 41 DeleteAll Delete all fingerprints from the database |
| tosihisa | 0:b11b455d4997 | 53 | CMD_Verify = 0x50, // 50 Verify 1:1 Verification of the capture fingerprint image with the specified ID |
| tosihisa | 0:b11b455d4997 | 54 | CMD_Identify = 0x51, // 51 Identify 1:N Identification of the capture fingerprint image with the database |
| tosihisa | 0:b11b455d4997 | 55 | CMD_VerifyTemplate = 0x52, // 52 VerifyTemplate 1:1 Verification of a fingerprint template with the specified ID |
| tosihisa | 0:b11b455d4997 | 56 | CMD_IdentifyTemplate = 0x53, // 53 IdentifyTemplate 1:N Identification of a fingerprint template with the database |
| tosihisa | 0:b11b455d4997 | 57 | CMD_CaptureFinger = 0x60, // 60 CaptureFinger Capture a fingerprint image(256x256) from the sensor |
| tosihisa | 0:b11b455d4997 | 58 | CMD_MakeTemplate = 0x61, // 61 MakeTemplate Make template for transmission |
| tosihisa | 0:b11b455d4997 | 59 | CMD_GetImage = 0x62, // 62 GetImage Download the captured fingerprint image(256x256) |
| tosihisa | 0:b11b455d4997 | 60 | CMD_GetRawImage = 0x63, // 63 GetRawImage Capture & Download raw fingerprint image(320x240) |
| tosihisa | 0:b11b455d4997 | 61 | CMD_GetTemplate = 0x70, // 70 GetTemplate Download the template of the specified ID |
| tosihisa | 0:b11b455d4997 | 62 | CMD_SetTemplate = 0x71, // 71 SetTemplate Upload the template of the specified ID |
| tosihisa | 0:b11b455d4997 | 63 | CMD_GetDatabaseStart = 0x72, // 72 GetDatabaseStart Start database download, obsolete |
| tosihisa | 0:b11b455d4997 | 64 | CMD_GetDatabaseEnd = 0x73, // 73 GetDatabaseEnd End database download, obsolete |
| tosihisa | 0:b11b455d4997 | 65 | CMD_UpgradeFirmware = 0x80, // 80 UpgradeFirmware Not supported |
| tosihisa | 0:b11b455d4997 | 66 | CMD_UpgradeISOCDImage = 0x81, // 81 UpgradeISOCDImage Not supported |
| tosihisa | 0:b11b455d4997 | 67 | CMD_Ack = 0x30, // 30 Ack Acknowledge. |
| tosihisa | 0:b11b455d4997 | 68 | CMD_Nack = 0x31, // 31 Nack Non-acknowledge. |
| tosihisa | 1:4a1be9379e92 | 69 | }; |
| tosihisa | 1:4a1be9379e92 | 70 | enum Error { |
| tosihisa | 1:4a1be9379e92 | 71 | NACK_TIMEOUT = 0x1001, // NACK_TIMEOUT 0x1001 Obsolete, capture timeout |
| tosihisa | 1:4a1be9379e92 | 72 | NACK_INVALID_BAUDRATE = 0x1002, // NACK_INVALID_BAUDRATE 0x1002 Obsolete, Invalid serial baud rate |
| tosihisa | 1:4a1be9379e92 | 73 | NACK_INVALID_POS = 0x1003, // NACK_INVALID_POS 0x1003 The specified ID is not between 0~199 |
| tosihisa | 1:4a1be9379e92 | 74 | NACK_IS_NOT_USED = 0x1004, // NACK_IS_NOT_USED 0x1004 The specified ID is not used |
| tosihisa | 1:4a1be9379e92 | 75 | NACK_IS_ALREADY_USED = 0x1005, // NACK_IS_ALREADY_USED 0x1005 The specified ID is already used |
| tosihisa | 1:4a1be9379e92 | 76 | NACK_COMM_ERR = 0x1006, // NACK_COMM_ERR 0x1006 Communication Error |
| tosihisa | 1:4a1be9379e92 | 77 | NACK_VERIFY_FAILED = 0x1007, // NACK_VERIFY_FAILED 0x1007 1:1 Verification Failure |
| tosihisa | 1:4a1be9379e92 | 78 | NACK_IDENTIFY_FAILED = 0x1008, // NACK_IDENTIFY_FAILED 0x1008 1:N Identification Failure |
| tosihisa | 1:4a1be9379e92 | 79 | NACK_DB_IS_FULL = 0x1009, // NACK_DB_IS_FULL 0x1009 The database is full |
| tosihisa | 1:4a1be9379e92 | 80 | NACK_DB_IS_EMPTY = 0x100A, // NACK_DB_IS_EMPTY 0x100A The database is empty |
| tosihisa | 1:4a1be9379e92 | 81 | NACK_TURN_ERR = 0x100B, // NACK_TURN_ERR 0x100B Obsolete, Invalid order of the enrollment (The order was not as: EnrollStart -> Enroll1 -> Enroll2 -> Enroll3) |
| tosihisa | 1:4a1be9379e92 | 82 | NACK_BAD_FINGER = 0x100C, // NACK_BAD_FINGER 0x100C Too bad fingerprint |
| tosihisa | 1:4a1be9379e92 | 83 | NACK_ENROLL_FAILED = 0x100D, // NACK_ENROLL_FAILED 0x100D Enrollment Failure |
| tosihisa | 1:4a1be9379e92 | 84 | NACK_IS_NOT_SUPPORTED = 0x100E, // NACK_IS_NOT_SUPPORTED 0x100E The specified command is not supported |
| tosihisa | 1:4a1be9379e92 | 85 | NACK_DEV_ERR = 0x100F, // NACK_DEV_ERR 0x100F Device Error, especially if Crypto-Chip is trouble |
| tosihisa | 1:4a1be9379e92 | 86 | NACK_CAPTURE_CANCELED = 0x1010, // NACK_CAPTURE_CANCELED 0x1010 Obsolete, The capturing is canceled |
| tosihisa | 1:4a1be9379e92 | 87 | NACK_INVALID_PARAM = 0x1011, // NACK_INVALID_PARAM 0x1011 Invalid parameter |
| tosihisa | 1:4a1be9379e92 | 88 | NACK_FINGER_IS_NOT_PRESSED = 0x1012, // NACK_FINGER_IS_NOT_PRESSED 0x1012 Finger is not pressed |
| tosihisa | 4:3dd0f98e6f09 | 89 | NACK_IO_ERR = 0xF000, // ORIGINAL ERROR CODE. Serial line error. |
| tosihisa | 1:4a1be9379e92 | 90 | }; |
| tosihisa | 4:3dd0f98e6f09 | 91 | unsigned long LastError; |
| tosihisa | 4:3dd0f98e6f09 | 92 | unsigned long FirmwareVersion; |
| tosihisa | 4:3dd0f98e6f09 | 93 | unsigned long IsoAreaMaxSize; |
| tosihisa | 4:3dd0f98e6f09 | 94 | unsigned char DeviceSerialNumber[16]; |
| tosihisa | 4:3dd0f98e6f09 | 95 | |
| tosihisa | 4:3dd0f98e6f09 | 96 | GT511C3(PinName _tx, PinName _rx) : Serial(_tx,_rx) , LastError(0) {} |
| tosihisa | 0:b11b455d4997 | 97 | int Init(void); |
| tosihisa | 0:b11b455d4997 | 98 | int SendCommand(unsigned long Parameter,unsigned short Command); |
| tosihisa | 0:b11b455d4997 | 99 | int RecvResponse(unsigned long *Parameter,unsigned short *Response); |
| tosihisa | 4:3dd0f98e6f09 | 100 | int RecvData(unsigned char *data,unsigned long size); |
| tosihisa | 2:34a647292050 | 101 | int SendRecv(unsigned short Command,unsigned long *Parameter,unsigned short *Response); |
| tosihisa | 0:b11b455d4997 | 102 | int ClearLine(void); |
| tosihisa | 4:3dd0f98e6f09 | 103 | int Open(void); |
| tosihisa | 3:459a4f985a45 | 104 | int WaitPress(int press); |
| tosihisa | 3:459a4f985a45 | 105 | int CmosLed(int onoff); |
| tosihisa | 3:459a4f985a45 | 106 | int IsPress(void); |
| tosihisa | 3:459a4f985a45 | 107 | int Capture(int best); |
| tosihisa | 3:459a4f985a45 | 108 | int Enroll_N(int N); |
| tosihisa | 3:459a4f985a45 | 109 | int Identify(void); |
| tosihisa | 0:b11b455d4997 | 110 | }; |
| tosihisa | 4:3dd0f98e6f09 | 111 | |
| tosihisa | 4:3dd0f98e6f09 | 112 | #endif //__GT511C3_H |
