Program for R306 fingerprint module interfaced with Wiz750SR S2E device
Dependencies: FPC_R306 MQTT WIZnetInterface mbed
Fork of GT511C3_TimeStamp_WIZwiki-W7500 by
Revision 0:b11b455d4997, committed 2014-01-03
- Comitter:
- tosihisa
- Date:
- Fri Jan 03 06:20:34 2014 +0000
- Child:
- 1:4a1be9379e92
- Commit message:
- 1st Commit.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GT511C3.cpp Fri Jan 03 06:20:34 2014 +0000
@@ -0,0 +1,84 @@
+
+#include "mbed.h"
+#include "GT511C3.h"
+
+#define SET_AND_SUMADD(idx,val) sendbuf[idx]=((unsigned char)(val));sum += sendbuf[idx]
+
+int GT511C3::Init(void)
+{
+ baud(9600);
+ ClearLine();
+ return 0;
+}
+
+int GT511C3::SendCommand(unsigned long Parameter,unsigned short Command)
+{
+ unsigned char sendbuf[12];
+ unsigned short sum = 0;
+ int idx = 0;
+ int i;
+
+ SET_AND_SUMADD(idx,0x55); idx++;
+ SET_AND_SUMADD(idx,0xAA); idx++;
+ SET_AND_SUMADD(idx,0x01); idx++;
+ SET_AND_SUMADD(idx,0x00); idx++;
+ SET_AND_SUMADD(idx,Parameter & 0xff); idx++;
+ SET_AND_SUMADD(idx,(Parameter >> 8) & 0xff); idx++;
+ SET_AND_SUMADD(idx,(Parameter >> 16) & 0xff); idx++;
+ SET_AND_SUMADD(idx,(Parameter >> 24) & 0xff); idx++;
+ SET_AND_SUMADD(idx,Command & 0xff); idx++;
+ SET_AND_SUMADD(idx,(Command >> 8) & 0xff); idx++;
+ sendbuf[idx] = sum & 0xff; idx++;
+ sendbuf[idx] = (sum >> 8) & 0xff; idx++;
+
+ for(i = 0;i < idx;i++){
+ while(!writeable());
+ putc(sendbuf[i]);
+ }
+ return idx;
+}
+
+int GT511C3::RecvResponse(unsigned long *Parameter,unsigned short *Response)
+{
+ unsigned char buf[12];
+ unsigned short sum = 0;
+ int i;
+
+ *Parameter = 0;
+ *Response = CMD_Nack;
+
+ for(i = 0;i < sizeof(buf);i++){
+ while(!readable());
+ buf[i] = getc();
+ if(i < 9){
+ sum += buf[i];
+ }
+ if((i == 0) && (buf[i] != 0x55))
+ return -1;
+ if((i == 1) && (buf[i] != 0xAA))
+ return -1;
+ }
+ if(buf[10] != (sum & 0xff))
+ return -2;
+ if(buf[11] != ((sum >> 8) & 0xff))
+ return -2;
+
+ *Parameter = buf[7];
+ *Parameter = (*Parameter << 8) | buf[6];
+ *Parameter = (*Parameter << 8) | buf[5];
+ *Parameter = (*Parameter << 8) | buf[4];
+
+ *Response = buf[9];
+ *Response = (*Response << 8) | buf[8];
+
+ return 0;
+}
+
+int GT511C3::ClearLine(void)
+{
+ while(readable()){
+ (void)getc();
+ }
+ return 0;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GT511C3.h Fri Jan 03 06:20:34 2014 +0000
@@ -0,0 +1,44 @@
+
+#include "mbed.h"
+
+class GT511C3 : public Serial {
+public:
+ enum Command {
+ CMD_Open = 0x01, // 01 Open Initialization
+ CMD_Close = 0x02, // 02 Close Termination
+ CMD_UsbInternalCheck = 0x03, // 03 UsbInternalCheck Check if the connected USB device is valid
+ CMD_ChangeBaudrate = 0x04, // 04 ChangeBaudrate Change UART baud rate
+ CMD_SetIAPMode = 0x05, // 05 SetIAPMode Enter IAP Mode In this mode, FW Upgrade is available
+ CMD_CmosLed = 0x12, // 12 CmosLed Control CMOS LED
+ CMD_GetEnrollCount = 0x20, // 20 GetEnrollCount Get enrolled fingerprint count
+ CMD_CheckEnrolled = 0x21, // 21 CheckEnrolled Check whether the specified ID is already enrolled
+ CMD_EnrollStart = 0x22, // 22 EnrollStart Start an enrollment
+ CMD_Enroll1 = 0x23, // 23 Enroll1 Make 1st template for an enrollment
+ CMD_Enroll2 = 0x24, // 24 Enroll2 Make 2nd template for an enrollment
+ CMD_Enroll3 = 0x25, // 25 Enroll3 Make 3rd template for an enrollment, merge three templates into one template, save merged template to the database
+ CMD_IsPressFinger = 0x26, // 26 IsPressFinger Check if a finger is placed on the sensor
+ CMD_DeleteID = 0x40, // 40 DeleteID Delete the fingerprint with the specified ID
+ CMD_DeleteAll = 0x41, // 41 DeleteAll Delete all fingerprints from the database
+ CMD_Verify = 0x50, // 50 Verify 1:1 Verification of the capture fingerprint image with the specified ID
+ CMD_Identify = 0x51, // 51 Identify 1:N Identification of the capture fingerprint image with the database
+ CMD_VerifyTemplate = 0x52, // 52 VerifyTemplate 1:1 Verification of a fingerprint template with the specified ID
+ CMD_IdentifyTemplate = 0x53, // 53 IdentifyTemplate 1:N Identification of a fingerprint template with the database
+ CMD_CaptureFinger = 0x60, // 60 CaptureFinger Capture a fingerprint image(256x256) from the sensor
+ CMD_MakeTemplate = 0x61, // 61 MakeTemplate Make template for transmission
+ CMD_GetImage = 0x62, // 62 GetImage Download the captured fingerprint image(256x256)
+ CMD_GetRawImage = 0x63, // 63 GetRawImage Capture & Download raw fingerprint image(320x240)
+ CMD_GetTemplate = 0x70, // 70 GetTemplate Download the template of the specified ID
+ CMD_SetTemplate = 0x71, // 71 SetTemplate Upload the template of the specified ID
+ CMD_GetDatabaseStart = 0x72, // 72 GetDatabaseStart Start database download, obsolete
+ CMD_GetDatabaseEnd = 0x73, // 73 GetDatabaseEnd End database download, obsolete
+ CMD_UpgradeFirmware = 0x80, // 80 UpgradeFirmware Not supported
+ CMD_UpgradeISOCDImage = 0x81, // 81 UpgradeISOCDImage Not supported
+ CMD_Ack = 0x30, // 30 Ack Acknowledge.
+ CMD_Nack = 0x31, // 31 Nack Non-acknowledge.
+p };
+ GT511C3(PinName _tx, PinName _rx) : Serial(_tx,_rx){}
+ int Init(void);
+ int SendCommand(unsigned long Parameter,unsigned short Command);
+ int RecvResponse(unsigned long *Parameter,unsigned short *Response);
+ int ClearLine(void);
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jan 03 06:20:34 2014 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "GT511C3.h"
+
+Serial debug(USBTX,USBRX);
+
+DigitalOut myled(LED1);
+GT511C3 finger(p28,p27);
+
+int main() {
+ unsigned long Parameter;
+ unsigned short Response;
+ int sts = 0;
+
+ debug.format(8,Serial::None,1);
+ debug.baud(115200);
+
+ debug.printf("Init\n");
+ finger.Init();
+ debug.printf("Open\n");
+ finger.SendCommand(0,GT511C3::CMD_Open);
+ sts = finger.RecvResponse(&Parameter,&Response);
+ debug.printf("sts = %d,Response=0x%04x\n",sts,Response);
+
+ while(1) {
+ myled = 1;
+ wait(0.2);
+ myled = 0;
+ wait(0.2);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 03 06:20:34 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file
