summaryrefslogtreecommitdiffstats
path: root/fpm.c
diff options
context:
space:
mode:
Diffstat (limited to 'fpm.c')
-rw-r--r--fpm.c40
1 files changed, 10 insertions, 30 deletions
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;
}