mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-12-28 03:26:25 +02:00
ubbctl/: UBB pin status decoder
This commit is contained in:
parent
d33da7076c
commit
f0c6e87222
19
ubbctl/Makefile
Normal file
19
ubbctl/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
CC = mipsel-openwrt-linux-gcc
|
||||
CFLAGS = -g -Wall -O9 -I../libubb/include
|
||||
LDFLAGS = -static
|
||||
LDLIBS = -L../libubb -lubb
|
||||
|
||||
MAIN = ubbctl
|
||||
OBJS = ubbctl.o
|
||||
|
||||
.PHONY: all clean spotless
|
||||
|
||||
all: $(MAIN)
|
||||
|
||||
$(MAIN): $(OBJS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
|
||||
spotless: clean
|
||||
rm -f $(MAIN)
|
40
ubbctl/ubbctl.c
Normal file
40
ubbctl/ubbctl.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ubb/ubb.h>
|
||||
|
||||
|
||||
static struct pin {
|
||||
const char *name;
|
||||
uint32_t mask;
|
||||
} pins[] = {
|
||||
{ "nPWR", UBB_nPWR },
|
||||
{ "DAT2", UBB_DAT2 },
|
||||
{ "DAT3", UBB_DAT3 },
|
||||
{ "CMD", UBB_CMD },
|
||||
{ "CLK", UBB_CLK },
|
||||
{ "DAT0", UBB_DAT0 },
|
||||
{ "DAT1", UBB_DAT1 },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const struct pin *p;
|
||||
|
||||
ubb_open(UBB_ALL);
|
||||
for (p = pins; p->name; p++) {
|
||||
printf("%s%s=", p == pins ? "" : " ", p->name);
|
||||
if (PDFUN & p->mask)
|
||||
printf("FN");
|
||||
else if (PDDIR & p->mask)
|
||||
printf("%d", !!(PDDAT & p->mask));
|
||||
else
|
||||
putchar(PDPULL & p->mask ? 'Z' : 'R');
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user