Date: | 2013-01-16 03:48:57 (11 years 2 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 9930ae6576b7f4d8c01fbf8dad259ef081f4aa1c |
Message: | ubb-patgen/ubb-patgen.c: move frequency difference warning into
select_freq This way, all frequency selections print a warning when there's a difference. |
Files: |
ubb-patgen/README (2 diffs) ubb-patgen/ubb-patgen.c (4 diffs) |
Change Details
ubb-patgen/README | ||
---|---|---|
55 | 55 | Note that this form of invocation only searches the frequency |
56 | 56 | table but does not produce any output on UBB. |
57 | 57 | |
58 | ubb-patgen warns if the selected frequency does not match the | |
59 | requested frequency, e.g., | |
60 | ||
61 | # ubb-patgen -f 100kHz | |
62 | bus clk = 100.962 kHz (+0.96%) | |
63 | ||
64 | This warning can be suppressed with the option -q. | |
65 | ||
58 | 66 | |
59 | 67 | Clock output |
60 | 68 | ------------ |
... | ... | |
73 | 81 | |
74 | 82 | # ubb-patgen -c 0 |
75 | 83 | |
76 | ubb-patgen warns if the selected frequency does not match the | |
77 | requested frequency, e.g., | |
78 | ||
79 | # ubb-patgen -f 100kHz -c | |
80 | bus clk = 100.962 kHz (+0.96%) | |
81 | ||
82 | This warning can be suppressed with the option -q. | |
83 | ||
84 | 84 | |
85 | 85 | Pattern output |
86 | 86 | -------------- |
ubb-patgen/ubb-patgen.c | ||
---|---|---|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | static int select_freq(struct mmcclk *res, int hz, int rel) | |
115 | static int select_freq(struct mmcclk *res, int hz, int rel, int quiet) | |
116 | 116 | { |
117 | 117 | const struct mmcclk *clks, *p, *best = NULL; |
118 | 118 | double d, best_d = 0; |
119 | 119 | int n; |
120 | double err; | |
120 | 121 | |
121 | 122 | clks = frequencies(&n); |
122 | 123 | for (p = clks; p != clks+n; p++) { |
... | ... | |
134 | 135 | return 0; |
135 | 136 | *res = *best; |
136 | 137 | free((void *) clks); |
138 | ||
139 | if (quiet) | |
140 | return 1; | |
141 | ||
142 | if (res->bus_clk_hz != hz) { | |
143 | fprintf(stderr, "bus clk = "); | |
144 | print_freq(stderr, res->bus_clk_hz); | |
145 | err = (res->bus_clk_hz-hz)/hz; | |
146 | if (err <= -0.0001 || err >= 0.0001) | |
147 | fprintf(stderr, " (%+.2g%%)\n", err*100); | |
148 | else | |
149 | fprintf(stderr, " (%+d ppm)\n", (int) (err*1000000)); | |
150 | } | |
151 | ||
137 | 152 | return 1; |
138 | 153 | } |
139 | 154 | |
... | ... | |
588 | 603 | |
589 | 604 | ubb_open(UBB_ALL); |
590 | 605 | if (bus_hz) { |
591 | if (!select_freq(&clk, bus_hz, bus_rel)) { | |
606 | if (!select_freq(&clk, bus_hz, bus_rel, quiet)) { | |
592 | 607 | fprintf(stderr, |
593 | 608 | "no suitable frequency found\n"); |
594 | 609 | exit(1); |
... | ... | |
626 | 641 | if (!bus_hz) |
627 | 642 | bus_hz = 1000000; |
628 | 643 | |
629 | if (!select_freq(&clk, bus_hz, bus_rel)) { | |
644 | if (!select_freq(&clk, bus_hz, bus_rel, quiet)) { | |
630 | 645 | fprintf(stderr, "no suitable frequency found\n"); |
631 | 646 | exit(1); |
632 | 647 | } |
633 | if (clk.bus_clk_hz != bus_hz && !quiet) { | |
634 | double err; | |
635 | ||
636 | fprintf(stderr, "bus clk = "); | |
637 | print_freq(stderr, clk.bus_clk_hz); | |
638 | err = (clk.bus_clk_hz-bus_hz)/bus_hz; | |
639 | if (err <= -0.0001 || err >= 0.0001) | |
640 | fprintf(stderr, " (%+.2g%%)\n", err*100); | |
641 | else | |
642 | fprintf(stderr, " (%+d ppm)\n", (int) (err*1000000)); | |
643 | } | |
644 | 648 | |
645 | 649 | if (clkout || clk_only) |
646 | 650 | PDFUNS = UBB_CLK; |
Branches:
master