summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.txt18
-rw-r--r--fpm.c40
-rw-r--r--main.c38
3 files changed, 36 insertions, 60 deletions
diff --git a/README.txt b/README.txt
index b951c18..ded7d77 100644
--- a/README.txt
+++ b/README.txt
@@ -1,15 +1,17 @@
-ZFM20 FINGERPRINT MODULE
+FPM10A FINGERPRINT MODULE
-This is a UART-based driver for ZFM20 family of fingerprint modules for AVR
-microcontrollers. I wrote this for and tested with ATmega328P. It should work
-with other AVR microcontrollers as well.
+This is a UART-based driver for FPM10A fingerprint module for AVR
+microcontrollers. I've tested with ATmega328P.
Since ATmega328P has only one hardware UART, I'm using lynxzp's software UART
-implementation [1] for debugging purposes.
+implementation [1] for debugging purposes. Thank you, lynxzp!
-[1] https://github.com/lynxzp/Software_UART_for_AVR
-
-BUILD
+BUILDING AND UPLOADING
make -FPM_PWD=$(pasword) hex
+make -FPM_PWD=$(pasword) upload
+
+Default password: 0x00.
+
+[1] https://github.com/lynxzp/Software_UART_for_AVR
diff --git a/fpm.c b/fpm.c
index 7bfc4be..4f058ef 100644
--- a/fpm.c
+++ b/fpm.c
@@ -129,24 +129,6 @@ static inline uint8_t check_pwd(void)
return buf[0] == OK;
}
-static inline void scan(uint8_t bufid)
-{
- uint16_t n;
- uint8_t buf[MAXPDLEN];
-
- do {
- buf[0] = 0x01;
- send(0x01, buf, 1);
- recv(buf, &n);
- if (buf[0] == OK) {
- buf[0] = 0x02;
- buf[1] = bufid;
- send(0x01, buf, 2);
- recv(buf, &n);
- }
- } while (buf[0] != OK);
-}
-
uint8_t fpm_init(void)
{
UBRR0H = UBRRH_VALUE;
@@ -230,6 +212,7 @@ uint8_t fpm_enroll(void)
uint8_t buf[MAXPDLEN];
retries = 0;
+
do {
_delay_ms(100);
buf[0] = 0x10;
@@ -243,20 +226,17 @@ uint8_t fpm_enroll(void)
uint8_t fpm_match(void)
{
- uint16_t n, count;
+ uint16_t n, retries;
uint8_t buf[MAXPDLEN];
- scan(1);
- count = fpm_getcount();
-
- buf[0] = 0x04;
- buf[1] = 1;
- buf[2] = 0x00;
- buf[3] = 0x00;
- buf[4] = (uint8_t)(count >> 8);
- buf[5] = (uint8_t)(count & 0xFF);
+ retries = 0;
+
+ do {
+ _delay_ms(100);
+ buf[0] = 0x11;
+ send(0x01, buf, 1);
+ recv(buf, &n);
+ } while (buf[0] != OK && retries < 50);
- send(0x01, buf, 6);
- recv(buf, &n);
return buf[0] == OK;
}
diff --git a/main.c b/main.c
index cde37e3..3ee8fc6 100644
--- a/main.c
+++ b/main.c
@@ -100,30 +100,24 @@ int main(void)
snprintf(s, 30, "Template count: %d", template_count);
uart_write(s);
- uart_write("Enroll fingerprint");
- _delay_ms(2000);
- if (fpm_enroll()) {
- uart_write("Enrolled fingerprint");
- } else {
- uart_write("Enrollment error");
+ if (template_count == 0) {
+ uart_write("Enroll fingerprint");
+ if (fpm_enroll()) {
+ uart_write("Enrolled fingerprint");
+ } else {
+ uart_write("Enrollment error");
+ }
+
+ template_count = fpm_getcount();
+ snprintf(s, 30, "New template count: %d", template_count);
+ uart_write(s);
}
- template_count = fpm_getcount();
- snprintf(s, 30, "New template count: %d", template_count);
- uart_write(s);
-
- //uart_write("Authentcate");
- //_delay_ms(1000);
- //
- //do {
- // ismatch = fpm_match();
- // if (ismatch)
- // uart_write("Matched!");
- // else {
- // uart_write("No match!");
- // _delay_ms(1500);
- // }
- //} while (!ismatch);
+ uart_write("Authentcating...");
+ if (fpm_match())
+ uart_write("Fingerprint match");
+ else
+ uart_write("No match");
}
while (1)