Change Details
lpc111x-isp/lpc111x.c |
563 | 563 | } |
564 | 564 | |
565 | 565 | |
| 566 | /* ----- Reset and run target ---------------------------------------------- */ |
| 567 | |
| 568 | |
| 569 | static void run_target(int power) |
| 570 | { |
| 571 | if (ubb_open(0) < 0) { |
| 572 | perror("ubb_open"); |
| 573 | exit(1); |
| 574 | } |
| 575 | |
| 576 | if (power) |
| 577 | ubb_power(1); |
| 578 | |
| 579 | SET(TGT_nRESET); |
| 580 | OUT(TGT_nRESET); |
| 581 | |
| 582 | IN(TGT_nISP); |
| 583 | |
| 584 | CLR(TGT_nRESET); |
| 585 | usleep(10); /* DS Table 9 pg 29 says min 50 ns */ |
| 586 | SET(TGT_nRESET); |
| 587 | |
| 588 | ubb_close(UBB_nPWR | TGT_nRESET | TGT_nISP); |
| 589 | } |
| 590 | |
| 591 | |
566 | 592 | /* ----- Command-line processing ------------------------------------------- */ |
567 | 593 | |
568 | 594 | |
569 | 595 | static void usage(const char *name) |
570 | 596 | { |
571 | 597 | fprintf(stderr, |
572 | | "usage: %s [-n] [-q] [-v ...] [file.bin]\n\n" |
| 598 | "usage: %s [-n] [-q] [-v ...] [file.bin]\n" |
| 599 | " %s [-n] -r\n\n" |
573 | 600 | " -n don't power the device\n" |
574 | 601 | " -q suppress basic progress messages\n" |
| 602 | " -r reset the target and let it run\n" |
575 | 603 | " -v increase verbosity level\n" |
576 | | , name); |
| 604 | , name, name); |
577 | 605 | exit(1); |
578 | 606 | } |
579 | 607 | |
... | ... | |
582 | 610 | { |
583 | 611 | FILE *file = NULL; |
584 | 612 | int power = 1; |
| 613 | int run = 0; |
585 | 614 | int c; |
586 | 615 | |
587 | | while ((c = getopt(argc, argv, "nqv")) != EOF) |
| 616 | while ((c = getopt(argc, argv, "nqrv")) != EOF) |
588 | 617 | switch (c) { |
589 | 618 | case 'n': |
590 | 619 | power = 0; |
... | ... | |
592 | 621 | case 'q': |
593 | 622 | quiet = 1; |
594 | 623 | break; |
| 624 | case 'r': |
| 625 | run = 1; |
| 626 | break; |
595 | 627 | case 'v': |
596 | 628 | verbose++; |
597 | 629 | break; |
... | ... | |
599 | 631 | usage(*argv); |
600 | 632 | } |
601 | 633 | |
| 634 | if (run) { |
| 635 | if (quiet || verbose || argc != optind) |
| 636 | usage(*argv); |
| 637 | run_target(power); |
| 638 | return 0; |
| 639 | } |
| 640 | |
602 | 641 | switch (argc-optind) { |
603 | 642 | case 0: |
604 | 643 | break; |
Download the corresponding diff file