b15f/control/examples/wrapper/main.c

22 lines
434 B
C
Raw Normal View History

2022-12-06 19:29:20 +00:00
#include "b15f/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:05:18 +00:00
uint8_t dip = read_dip_switch(instance, NULL, 0);
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;
}