1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-17 00:40:43 +02:00

ubb-la/ubb-la.c: new option -g to use the GUI to display results

For now, only in single-buffer mode.
This commit is contained in:
Werner Almesberger 2013-01-30 22:07:55 -03:00
parent 0925b0f060
commit 444e0811bf

View File

@ -24,6 +24,8 @@
#include <ubb/mmcclk.h> #include <ubb/mmcclk.h>
#include <ubb/physmem.h> #include <ubb/physmem.h>
#include "gui.h"
#define DMA 5 #define DMA 5
@ -266,7 +268,7 @@ static void print_samples(FILE *file, uint8_t *buf, int skip, int nibbles)
/* ----- Capture ----------------------------------------------------------- */ /* ----- 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); uint8_t *buf = physmem_malloc(4096);
struct physmem_vec vec; 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)) if (!xfer(vec.addr, nibbles, trigger, mask))
return 0; 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; return 1;
} }
@ -367,10 +372,12 @@ static unsigned long xlat_pins(unsigned long pins)
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, 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" " -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 select the specified frequency (default; 1 MHz)\n"
" -F freq_MHz like -f, but also allow \"overclocking\"\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" " -n N capture N buffers worth of samples without waiting for a\n"
" trigger\n" " trigger\n"
" -t pattern/mask start capture at the specified pattern (DAT0 = 1, etc.,\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 trigger = 1, mask = 0;
unsigned long multi = 0; unsigned long multi = 0;
int clkout = 0; int clkout = 0;
int use_gui = 0;
struct mmcclk clk, fast_clk; struct mmcclk clk, fast_clk;
char *end; char *end;
int c, res; 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) { switch (c) {
case 'C': case 'C':
clkout = 1; clkout = 1;
@ -404,6 +412,9 @@ int main(int argc, char **argv)
if (*end) if (*end)
usage(*argv); usage(*argv);
break; break;
case 'g':
use_gui = 1;
break;
case 'n': case 'n':
multi = strtoul(optarg, &end, 0); multi = strtoul(optarg, &end, 0);
if (*end) if (*end)
@ -444,8 +455,11 @@ int main(int argc, char **argv)
mask = UBB_CLK; mask = UBB_CLK;
} }
if (use_gui)
gui_init();
if (!multi) { if (!multi) {
res = !do_buf(8128, trigger, mask); res = !do_buf(8128, trigger, mask, use_gui);
} else { } else {
frequency(&fast_clk, 84e6, 1); frequency(&fast_clk, 84e6, 1);
do_bufs(multi, 8128, &clk, &fast_clk); do_bufs(multi, 8128, &clk, &fast_clk);