diff options
| -rw-r--r-- | fpm.c | 26 | ||||
| -rw-r--r-- | fpm.h | 4 | ||||
| -rw-r--r-- | main.c | 9 |
3 files changed, 33 insertions, 6 deletions
@@ -178,12 +178,30 @@ uint8_t fpm_setpwd(uint32_t pwd) uint8_t buf[MAXPDLEN]; buf[0] = 0x12; - buf[1] = (uint8_t)((uint32_t)pwd >> 24); - buf[2] = (uint8_t)((uint32_t)pwd >> 16); - buf[3] = (uint8_t)((uint32_t)pwd >> 8); - buf[4] = (uint8_t)((uint32_t)pwd & 0xFF); + buf[1] = (uint8_t)(pwd >> 24); + buf[2] = (uint8_t)(pwd >> 16); + buf[3] = (uint8_t)(pwd >> 8); + buf[4] = (uint8_t)(pwd & 0xFF); send(0x01, buf, 5); recv(buf, &n); return buf[0] == OK; } + +uint16_t fpm_getcount(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,6 +17,8 @@ uint8_t fpm_init(void); uint8_t fpm_getcfg(struct fpm_config *cfg); -uint8_t fpm_setpwd(); +uint8_t fpm_setpwd(uint32_t pwd); + +uint16_t fpm_getcount(void); #endif /* FPM_H */ @@ -85,13 +85,20 @@ static inline void print_config(void) int main(void) { + char s[20]; + uint16_t template_count; + cli(); Soft_UART_init(); bit_set(DDRB,5); sei(); - if (fpm_init()) + if (fpm_init()) { print_config(); + template_count = fpm_getcount(); + snprintf(s, 20, "Template count: %d", template_count); + uart_write(s); + } while (1) { |
