mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 22:11:53 +02:00
lpc111x-isp/lpc111x.c: new option -r to reset the target and let it run
This commit is contained in:
parent
66d091317a
commit
c7a7d358bb
@ -563,17 +563,45 @@ static void start_isp(int power)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Reset and run target ---------------------------------------------- */
|
||||
|
||||
|
||||
static void run_target(int power)
|
||||
{
|
||||
if (ubb_open(0) < 0) {
|
||||
perror("ubb_open");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (power)
|
||||
ubb_power(1);
|
||||
|
||||
SET(TGT_nRESET);
|
||||
OUT(TGT_nRESET);
|
||||
|
||||
IN(TGT_nISP);
|
||||
|
||||
CLR(TGT_nRESET);
|
||||
usleep(10); /* DS Table 9 pg 29 says min 50 ns */
|
||||
SET(TGT_nRESET);
|
||||
|
||||
ubb_close(UBB_nPWR | TGT_nRESET | TGT_nISP);
|
||||
}
|
||||
|
||||
|
||||
/* ----- Command-line processing ------------------------------------------- */
|
||||
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-n] [-q] [-v ...] [file.bin]\n\n"
|
||||
"usage: %s [-n] [-q] [-v ...] [file.bin]\n"
|
||||
" %s [-n] -r\n\n"
|
||||
" -n don't power the device\n"
|
||||
" -q suppress basic progress messages\n"
|
||||
" -r reset the target and let it run\n"
|
||||
" -v increase verbosity level\n"
|
||||
, name);
|
||||
, name, name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -582,9 +610,10 @@ int main(int argc, char **argv)
|
||||
{
|
||||
FILE *file = NULL;
|
||||
int power = 1;
|
||||
int run = 0;
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "nqv")) != EOF)
|
||||
while ((c = getopt(argc, argv, "nqrv")) != EOF)
|
||||
switch (c) {
|
||||
case 'n':
|
||||
power = 0;
|
||||
@ -592,6 +621,9 @@ int main(int argc, char **argv)
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
case 'r':
|
||||
run = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
@ -599,6 +631,13 @@ int main(int argc, char **argv)
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
if (run) {
|
||||
if (quiet || verbose || argc != optind)
|
||||
usage(*argv);
|
||||
run_target(power);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (argc-optind) {
|
||||
case 0:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user