b15f/control/examples/wrapper/main.c

27 lines
516 B
C
Raw Normal View History

2022-12-06 20:31:07 +00:00
#include "../src/wrapper/b15f.h"
#include <stdio.h>
2022-12-06 19:29:20 +00:00
int main() {
char buf[512];
b15f_t* instance = get_instance(buf, sizeof(buf));
if (instance == NULL) {
fprintf(stderr, "%s", buf);
return -1;
}
2022-12-06 19:29:20 +00:00
2022-12-06 20:31:07 +00:00
uint8_t dip;
if (read_dip_switch(instance, &dip, buf, sizeof(buf)) != 0) {
fprintf(stderr, "%s\n", buf);
return -1;
}
2022-12-06 20:05:18 +00:00
printf("DIP switch reads: ");
for(uint8_t mask = 1; mask != 0; mask <<= 1) {
printf("%d", (dip & mask) == mask ? 1 : 0);
}
printf("\n");
2022-12-06 19:29:20 +00:00
return 0;
2022-12-06 20:31:07 +00:00
}