summaryrefslogtreecommitdiffstats
path: root/fpm.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-05-03 08:58:39 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-05-03 08:58:39 +0800
commitc7e275f2214cff86fa98da9a12c92b685351aad5 (patch)
treeba8f6e12632d2280d14dc7a7493e54cf4b648b27 /fpm.c
parent295f799ec9b7167063e10ca78caf2ceca6227040 (diff)
downloadavr-fpm-drivers-c7e275f2214cff86fa98da9a12c92b685351aad5.tar.gz
Get template count.
Diffstat (limited to 'fpm.c')
-rw-r--r--fpm.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/fpm.c b/fpm.c
index 41a106c..e157698 100644
--- a/fpm.c
+++ b/fpm.c
@@ -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;
+}