mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 22:42:49 +02:00
ubb-patgen/ubb-patgen.c: new option -m MASK to choose which DATx lines to use
This commit is contained in:
parent
d60ef14022
commit
1c76cab66c
@ -489,10 +489,11 @@ static void usage(const char *name)
|
|||||||
"usage: %s\n"
|
"usage: %s\n"
|
||||||
" %s [-q] -f freq_hz\n"
|
" %s [-q] -f freq_hz\n"
|
||||||
" %s [-q] [-f freq_hz] -c [active_s]\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 output bus clock on CLK without sending a pattern\n"
|
||||||
" -C temporarily output bus clock on CLK (for debugging)\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"
|
" -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"
|
" -p force interpretation of argument as pattern (and not file)\n"
|
||||||
" -q quiet. Don't pretty-print frequencies; don't report clock\n"
|
" -q quiet. Don't pretty-print frequencies; don't report clock\n"
|
||||||
" differences.\n\n"
|
" differences.\n\n"
|
||||||
@ -520,10 +521,12 @@ int main(int argc, char **argv)
|
|||||||
double active_s = 0;
|
double active_s = 0;
|
||||||
struct timespec active_ns;
|
struct timespec active_ns;
|
||||||
int keep_clk = 1;
|
int keep_clk = 1;
|
||||||
|
uint8_t mask = 0xf;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int c;
|
||||||
|
unsigned long tmp;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "cCf:pq")) != EOF)
|
while ((c = getopt(argc, argv, "cCf:m:pq")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'f':
|
case 'f':
|
||||||
if (!frequency(optarg, &bus_hz, &bus_rel))
|
if (!frequency(optarg, &bus_hz, &bus_rel))
|
||||||
@ -535,6 +538,16 @@ int main(int argc, char **argv)
|
|||||||
case 'C':
|
case 'C':
|
||||||
clkout = 1;
|
clkout = 1;
|
||||||
break;
|
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':
|
case 'p':
|
||||||
force_pattern = 1;
|
force_pattern = 1;
|
||||||
break;
|
break;
|
||||||
@ -616,15 +629,14 @@ int main(int argc, char **argv)
|
|||||||
mmcclk_start(&clk);
|
mmcclk_start(&clk);
|
||||||
|
|
||||||
if (pattern)
|
if (pattern)
|
||||||
dma_pattern(&clk, pattern,
|
dma_pattern(&clk, pattern, mask << 10);
|
||||||
UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
|
|
||||||
|
|
||||||
if (active_s)
|
if (active_s)
|
||||||
if (nanosleep(&active_ns, NULL))
|
if (nanosleep(&active_ns, NULL))
|
||||||
perror("nanosleep");
|
perror("nanosleep");
|
||||||
if (pattern) {
|
if (pattern) {
|
||||||
mmcclk_stop();
|
mmcclk_stop();
|
||||||
ubb_close(UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
|
ubb_close(mask << 10);
|
||||||
} else if (keep_clk) {
|
} else if (keep_clk) {
|
||||||
ubb_close(UBB_CLK);
|
ubb_close(UBB_CLK);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user