1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-12-26 20:17:21 +02:00

ubb-patgen/ubb-patgen.c: new option -m MASK to choose which DATx lines to use

This commit is contained in:
Werner Almesberger 2013-01-15 17:40:49 -03:00
parent d60ef14022
commit 1c76cab66c

View File

@ -489,10 +489,11 @@ static void usage(const char *name)
"usage: %s\n"
" %s [-q] -f freq_hz\n"
" %s [-q] [-f freq_hz] -c [active_s]\n"
" %s [-q] [-f freq_hz] [-C] [-p] file|pattern\n\n"
" %s [-q] [-f freq_hz] [-C] [-m mask] [-p] file|pattern\n\n"
" -c output bus clock on CLK without sending a pattern\n"
" -C temporarily output bus clock on CLK (for debugging)\n"
" -f freq_hz set bus clock to the specified frequency (default: 1 MHz)\n"
" -m mask use only the DATx lines specified in the mask (default: 0xf)\n"
" -p force interpretation of argument as pattern (and not file)\n"
" -q quiet. Don't pretty-print frequencies; don't report clock\n"
" differences.\n\n"
@ -520,10 +521,12 @@ int main(int argc, char **argv)
double active_s = 0;
struct timespec active_ns;
int keep_clk = 1;
uint8_t mask = 0xf;
char *end;
int c;
unsigned long tmp;
while ((c = getopt(argc, argv, "cCf:pq")) != EOF)
while ((c = getopt(argc, argv, "cCf:m:pq")) != EOF)
switch (c) {
case 'f':
if (!frequency(optarg, &bus_hz, &bus_rel))
@ -535,6 +538,16 @@ int main(int argc, char **argv)
case 'C':
clkout = 1;
break;
case 'm':
tmp = strtoul(optarg, &end, 0);
if (*end)
usage(*argv);
if (tmp & ~0xfUL) {
fprintf(stderr, "mask is too large\n");
exit(1);
}
mask = tmp;
break;
case 'p':
force_pattern = 1;
break;
@ -616,15 +629,14 @@ int main(int argc, char **argv)
mmcclk_start(&clk);
if (pattern)
dma_pattern(&clk, pattern,
UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
dma_pattern(&clk, pattern, mask << 10);
if (active_s)
if (nanosleep(&active_ns, NULL))
perror("nanosleep");
if (pattern) {
mmcclk_stop();
ubb_close(UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
ubb_close(mask << 10);
} else if (keep_clk) {
ubb_close(UBB_CLK);
} else {