summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fpm.c2
-rw-r--r--main.c10
-rw-r--r--r503.c18
-rw-r--r--r503.h2
4 files changed, 29 insertions, 3 deletions
diff --git a/fpm.c b/fpm.c
index 657a1a8..a58045e 100644
--- a/fpm.c
+++ b/fpm.c
@@ -195,7 +195,7 @@ uint8_t fpm_setpwd(uint32_t pwd)
return buf[0] == OK;
}
-uint16_t fpm_getcount(void)
+uint16_t fpm_get_count(void)
{
uint16_t n, count;
uint8_t buf[MAXPDLEN];
diff --git a/main.c b/main.c
index 5b616b3..ba5f6e6 100644
--- a/main.c
+++ b/main.c
@@ -39,8 +39,14 @@ int main(void)
sei();
fpm_init();
- if (fpm_clear_db())
- fpm_led_on(PURPLE);
+ if (fpm_get_count() == 0) {
+ for (;;) {
+ fpm_led_on(PURPLE);
+ _delay_ms(500);
+ fpm_led_off();
+ _delay_ms(500);
+ }
+ }
while (1)
{
diff --git a/r503.c b/r503.c
index e970c59..434e3fe 100644
--- a/r503.c
+++ b/r503.c
@@ -182,3 +182,21 @@ uint8_t fpm_clear_db(void)
recv(buf, &n);
return buf[0] == OK;
}
+
+uint16_t fpm_get_count(void)
+{
+ uint16_t n, count;
+ uint8_t buf[MAXPDLEN];
+
+ buf[0] = 0x1D;
+ send(0x01, buf, 1);
+ recv(buf, &n);
+
+ count = 0;
+ if (buf[0] == OK && n >= 2) {
+ count = buf[1];
+ count <<= 8;
+ count |= buf[2];
+ }
+ return count;
+}
diff --git a/r503.h b/r503.h
index f941cb9..e12b8f2 100644
--- a/r503.h
+++ b/r503.h
@@ -17,4 +17,6 @@ void fpm_led_off(void);
uint8_t fpm_clear_db(void);
+uint16_t fpm_get_count(void);
+
#endif /* FPM_R50_H */