diff --git a/ubb-la/ubb-la.c b/ubb-la/ubb-la.c index ebeb3f7..286a787 100644 --- a/ubb-la/ubb-la.c +++ b/ubb-la/ubb-la.c @@ -24,6 +24,8 @@ #include #include +#include "gui.h" + #define DMA 5 @@ -266,7 +268,7 @@ static void print_samples(FILE *file, uint8_t *buf, int skip, int nibbles) /* ----- Capture ----------------------------------------------------------- */ -static int do_buf(int nibbles, uint32_t trigger, uint32_t mask) +static int do_buf(int nibbles, uint32_t trigger, uint32_t mask, int use_gui) { uint8_t *buf = physmem_malloc(4096); struct physmem_vec vec; @@ -288,7 +290,10 @@ static int do_buf(int nibbles, uint32_t trigger, uint32_t mask) if (!xfer(vec.addr, nibbles, trigger, mask)) return 0; - print_samples(stdout, buf, INITIAL_SKIP, nibbles); + if (use_gui) + gui(buf, INITIAL_SKIP, nibbles); + else + print_samples(stdout, buf, INITIAL_SKIP, nibbles); return 1; } @@ -367,10 +372,12 @@ static unsigned long xlat_pins(unsigned long pins) static void usage(const char *name) { fprintf(stderr, -"usage: %s [-C] [-t pattern/mask] [(-f|-F) frequency_MHz] [-n N]\n\n" +"usage: %s [-C] [-t pattern/mask] [(-f|-F) frequency_MHz] [-g] [-n N]\n\n" " -C output the MMC clock on CLK/TRIG (for debugging)\n" " -f freq_MHz select the specified frequency (default; 1 MHz)\n" " -F freq_MHz like -f, but also allow \"overclocking\"\n" +" -g display the captured waveforms graphically (default:\n" +" print as text to standard output)\n" " -n N capture N buffers worth of samples without waiting for a\n" " trigger\n" " -t pattern/mask start capture at the specified pattern (DAT0 = 1, etc.,\n" @@ -387,11 +394,12 @@ int main(int argc, char **argv) unsigned long trigger = 1, mask = 0; unsigned long multi = 0; int clkout = 0; + int use_gui = 0; struct mmcclk clk, fast_clk; char *end; int c, res; - while ((c = getopt(argc, argv, "Cf:F:n:t:")) != EOF) + while ((c = getopt(argc, argv, "Cf:F:gn:t:")) != EOF) switch (c) { case 'C': clkout = 1; @@ -404,6 +412,9 @@ int main(int argc, char **argv) if (*end) usage(*argv); break; + case 'g': + use_gui = 1; + break; case 'n': multi = strtoul(optarg, &end, 0); if (*end) @@ -444,8 +455,11 @@ int main(int argc, char **argv) mask = UBB_CLK; } + if (use_gui) + gui_init(); + if (!multi) { - res = !do_buf(8128, trigger, mask); + res = !do_buf(8128, trigger, mask, use_gui); } else { frequency(&fast_clk, 84e6, 1); do_bufs(multi, 8128, &clk, &fast_clk);