Aaron Reavley / Mbed 2 deprecated FingerPrintSenor

Dependencies:   mbed

Committer:
Reavley
Date:
Thu May 23 06:22:00 2019 +0000
Revision:
1:640d881ac3ee
Parent:
0:1c1e369b9269
Gamepad

Who changed what in which revision?

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