mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 22:30:37 +02:00
ubb-patgen/ubb-patgen.c: clean up usage (-c selects clkout only; -C to monitor)
... and active_s is no longer used with a pattern.
This commit is contained in:
parent
72f2125287
commit
6e6767175f
@ -275,13 +275,8 @@ static void mmc_buffer(const struct mmcclk *clk,
|
|||||||
* well-defined state.
|
* well-defined state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MSC_STRPCL = 1 << 3; /* reset the MSC */
|
|
||||||
|
|
||||||
while (MSC_STAT & (1 << 15)); /* wait until reset finishes */
|
|
||||||
|
|
||||||
dma_setup(buf, nibbles);
|
dma_setup(buf, nibbles);
|
||||||
|
|
||||||
MSC_CLKRT = clk->clkrt; /* cleared by MSC reset */
|
|
||||||
MSC_STRPCL = 2; /* start the bus clock */
|
MSC_STRPCL = 2; /* start the bus clock */
|
||||||
MSC_RESTO = 0xffff; /* maximum response time-out */
|
MSC_RESTO = 0xffff; /* maximum response time-out */
|
||||||
MSC_BLKLEN = 0xfff; /* never reach the end (with CRC) */
|
MSC_BLKLEN = 0xfff; /* never reach the end (with CRC) */
|
||||||
@ -448,12 +443,15 @@ static void usage(const char *name)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s\n"
|
"usage: %s\n"
|
||||||
"usage: %s [-b freq_hz] [-f freq_hz] [-c] [-q] [pattern] active_s\n\n"
|
" %s [-b freq_hz] [-f freq_hz] -c [-q] [active_s]\n"
|
||||||
|
" %s [-b freq_hz] [-f freq_hz] [-C] [-q] pattern\n\n"
|
||||||
" -b freq_hz set bus clock to the specified frequency (default: 1 MHz)\n"
|
" -b freq_hz set bus clock to the specified frequency (default: 1 MHz)\n"
|
||||||
" -c output bus clock on CLK\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 pattern rate (default: same as bus clock)\n"
|
" -f freq_hz set pattern rate (default: same as bus clock)\n"
|
||||||
" -q quiet. Don't report clock differences.\n\n"
|
" -q quiet. Don't report clock differences.\n\n"
|
||||||
" active_s keep running that many seconds after setting the clock\n"
|
" active_s keep running that many seconds after setting the clock\n"
|
||||||
|
" (default: exit immediately but leave the clock on)\n"
|
||||||
" pattern send the specified pattern on DAT0 through DAT3\n\n"
|
" pattern send the specified pattern on DAT0 through DAT3\n\n"
|
||||||
"Frequency: the frequency in Hz, optionally followed by \"M\" or \"k\",\n"
|
"Frequency: the frequency in Hz, optionally followed by \"M\" or \"k\",\n"
|
||||||
" optionally followed by \"Hz\", optionally followed by \"+\" or \"-\".\n"
|
" optionally followed by \"Hz\", optionally followed by \"+\" or \"-\".\n"
|
||||||
@ -461,7 +459,7 @@ static void usage(const char *name)
|
|||||||
" Without +/-, the closest available frequency is selected.\n"
|
" Without +/-, the closest available frequency is selected.\n"
|
||||||
"Pattern: hex digits corresponding to 1 for DAT0, 2 for DAT1, etc.\n"
|
"Pattern: hex digits corresponding to 1 for DAT0, 2 for DAT1, etc.\n"
|
||||||
" {n} repeats the preceding digit n times, e.g., 1{3} is equivalent to 111.\n"
|
" {n} repeats the preceding digit n times, e.g., 1{3} is equivalent to 111.\n"
|
||||||
, name, name);
|
, name, name, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,16 +467,17 @@ static void usage(const char *name)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct mmcclk clk;
|
struct mmcclk clk;
|
||||||
int bus_hz = 0, clkout = 0, bus_rel = 0;
|
int bus_hz = 0, clk_only = 0, clkout = 0, bus_rel = 0;
|
||||||
int pattern_hz = 0, pattern_rel = 0;
|
int pattern_hz = 0, pattern_rel = 0;
|
||||||
const char *pattern = NULL;
|
const char *pattern = NULL;
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
double active_s;
|
double active_s = 0;
|
||||||
struct timespec active_ns;
|
struct timespec active_ns;
|
||||||
|
int keep_clk = 1;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "b:cq")) != EOF)
|
while ((c = getopt(argc, argv, "b:cCq")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
if (!frequency(optarg, &bus_hz, &bus_rel))
|
if (!frequency(optarg, &bus_hz, &bus_rel))
|
||||||
@ -489,6 +488,9 @@ int main(int argc, char **argv)
|
|||||||
usage(*argv);
|
usage(*argv);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
clk_only = 1;
|
||||||
|
/* fall through */
|
||||||
|
case 'C':
|
||||||
clkout = 1;
|
clkout = 1;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
@ -500,20 +502,24 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
switch (argc-optind) {
|
switch (argc-optind) {
|
||||||
case 0:
|
case 0:
|
||||||
if (clkout || quiet)
|
if (clk_only)
|
||||||
|
break;
|
||||||
|
if (bus_hz || pattern_hz || clkout || quiet)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
ubb_open(UBB_ALL);
|
ubb_open(UBB_ALL);
|
||||||
show_frequencies();
|
show_frequencies();
|
||||||
return 1;
|
return 1;
|
||||||
case 2:
|
|
||||||
pattern = argv[optind];
|
|
||||||
/* fall through */
|
|
||||||
case 1:
|
case 1:
|
||||||
active_s = strtod(argv[argc-1], &end);
|
if (clk_only) {
|
||||||
if (*end)
|
active_s = strtod(argv[argc-1], &end);
|
||||||
usage(*argv);
|
if (*end)
|
||||||
active_ns.tv_sec = (int) active_s;
|
usage(*argv);
|
||||||
active_ns.tv_nsec = (active_s-(int) active_s)*1e9;
|
active_ns.tv_sec = (int) active_s;
|
||||||
|
active_ns.tv_nsec = (active_s-(int) active_s)*1e9;
|
||||||
|
keep_clk = 0;
|
||||||
|
} else {
|
||||||
|
pattern = argv[optind];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
@ -550,12 +556,18 @@ int main(int argc, char **argv)
|
|||||||
dma_pattern(&clk, pattern,
|
dma_pattern(&clk, pattern,
|
||||||
UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
|
UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
|
||||||
|
|
||||||
if (nanosleep(&active_ns, NULL))
|
if (active_s)
|
||||||
perror("nanosleep");
|
if (nanosleep(&active_ns, NULL))
|
||||||
|
perror("nanosleep");
|
||||||
mmcclk_stop();
|
if (pattern) {
|
||||||
|
mmcclk_stop();
|
||||||
ubb_close(UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
|
ubb_close(UBB_DAT0 | UBB_DAT1 | UBB_DAT2 | UBB_DAT3);
|
||||||
|
} else if (keep_clk) {
|
||||||
|
ubb_close(UBB_CLK);
|
||||||
|
} else {
|
||||||
|
mmcclk_stop();
|
||||||
|
ubb_close(0);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user