From f0c6e87222e7b56c79cb5b10948a128fbf80acd3 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 4 Jan 2013 05:40:19 -0300 Subject: [PATCH] ubbctl/: UBB pin status decoder --- ubbctl/Makefile | 19 +++++++++++++++++++ ubbctl/ubbctl.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 ubbctl/Makefile create mode 100644 ubbctl/ubbctl.c diff --git a/ubbctl/Makefile b/ubbctl/Makefile new file mode 100644 index 0000000..d3ed87b --- /dev/null +++ b/ubbctl/Makefile @@ -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) diff --git a/ubbctl/ubbctl.c b/ubbctl/ubbctl.c new file mode 100644 index 0000000..ebbab80 --- /dev/null +++ b/ubbctl/ubbctl.c @@ -0,0 +1,40 @@ +#include +#include +#include + +#include + + +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; +}