diff options
| -rw-r--r-- | fpm.c | 2 | ||||
| -rw-r--r-- | main.c | 10 | ||||
| -rw-r--r-- | r503.c | 18 | ||||
| -rw-r--r-- | r503.h | 2 |
4 files changed, 29 insertions, 3 deletions
@@ -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]; @@ -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) { @@ -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; +} @@ -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 */ |
