-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
36 lines (29 loc) · 842 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include "lcd.h"
#include "wiegand.h"
int main() {
LCD_Init();
wiegand_init();
uint64_t result;
uint8_t count;
char output[20];
LCD_Clear();
while (1) {
result = wiegand_read(&count); // blocks until read
if (count == 26) {
sprintf(output, "%03u %05u", (uint8_t)((result >> 17) & 0xff), (uint16_t)((result >> 1) & 0xffff));
} else if (count == 35) {
sprintf(output, "%04u %07lu", (uint16_t)((result >> 21) & 0xfff), (uint32_t)((result >> 1) & 0xfffff));
}
LCD_Clear();
LCD_String(output);
if (count > 32) {
sprintf(output, "%ub:%x%08lx", count, (uint16_t)(result >> 32 & 0xffff), (uint32_t)(result & 0xffffffff));
} else {
sprintf(output, "%ub:%lx", count, (uint32_t)result);
}
LCD_Cursor(1, 0);
LCD_String(output);
}
return 0;
}