mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-04 22:53:08 +02:00
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.
This commit is contained in:
parent
ff38f1c249
commit
9930ae6576
@ -55,6 +55,14 @@ frequencies that don't exceed the specified value. Examples:
|
|||||||
Note that this form of invocation only searches the frequency
|
Note that this form of invocation only searches the frequency
|
||||||
table but does not produce any output on UBB.
|
table but does not produce any output on UBB.
|
||||||
|
|
||||||
|
ubb-patgen warns if the selected frequency does not match the
|
||||||
|
requested frequency, e.g.,
|
||||||
|
|
||||||
|
# ubb-patgen -f 100kHz
|
||||||
|
bus clk = 100.962 kHz (+0.96%)
|
||||||
|
|
||||||
|
This warning can be suppressed with the option -q.
|
||||||
|
|
||||||
|
|
||||||
Clock output
|
Clock output
|
||||||
------------
|
------------
|
||||||
@ -73,14 +81,6 @@ To stop the MMC bus clock, run
|
|||||||
|
|
||||||
# ubb-patgen -c 0
|
# ubb-patgen -c 0
|
||||||
|
|
||||||
ubb-patgen warns if the selected frequency does not match the
|
|
||||||
requested frequency, e.g.,
|
|
||||||
|
|
||||||
# ubb-patgen -f 100kHz -c
|
|
||||||
bus clk = 100.962 kHz (+0.96%)
|
|
||||||
|
|
||||||
This warning can be suppressed with the option -q.
|
|
||||||
|
|
||||||
|
|
||||||
Pattern output
|
Pattern output
|
||||||
--------------
|
--------------
|
||||||
|
@ -112,11 +112,12 @@ static void show_frequencies(int quiet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int select_freq(struct mmcclk *res, int hz, int rel)
|
static int select_freq(struct mmcclk *res, int hz, int rel, int quiet)
|
||||||
{
|
{
|
||||||
const struct mmcclk *clks, *p, *best = NULL;
|
const struct mmcclk *clks, *p, *best = NULL;
|
||||||
double d, best_d = 0;
|
double d, best_d = 0;
|
||||||
int n;
|
int n;
|
||||||
|
double err;
|
||||||
|
|
||||||
clks = frequencies(&n);
|
clks = frequencies(&n);
|
||||||
for (p = clks; p != clks+n; p++) {
|
for (p = clks; p != clks+n; p++) {
|
||||||
@ -134,6 +135,20 @@ static int select_freq(struct mmcclk *res, int hz, int rel)
|
|||||||
return 0;
|
return 0;
|
||||||
*res = *best;
|
*res = *best;
|
||||||
free((void *) clks);
|
free((void *) clks);
|
||||||
|
|
||||||
|
if (quiet)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (res->bus_clk_hz != hz) {
|
||||||
|
fprintf(stderr, "bus clk = ");
|
||||||
|
print_freq(stderr, res->bus_clk_hz);
|
||||||
|
err = (res->bus_clk_hz-hz)/hz;
|
||||||
|
if (err <= -0.0001 || err >= 0.0001)
|
||||||
|
fprintf(stderr, " (%+.2g%%)\n", err*100);
|
||||||
|
else
|
||||||
|
fprintf(stderr, " (%+d ppm)\n", (int) (err*1000000));
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +603,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
ubb_open(UBB_ALL);
|
ubb_open(UBB_ALL);
|
||||||
if (bus_hz) {
|
if (bus_hz) {
|
||||||
if (!select_freq(&clk, bus_hz, bus_rel)) {
|
if (!select_freq(&clk, bus_hz, bus_rel, quiet)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"no suitable frequency found\n");
|
"no suitable frequency found\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -626,21 +641,10 @@ int main(int argc, char **argv)
|
|||||||
if (!bus_hz)
|
if (!bus_hz)
|
||||||
bus_hz = 1000000;
|
bus_hz = 1000000;
|
||||||
|
|
||||||
if (!select_freq(&clk, bus_hz, bus_rel)) {
|
if (!select_freq(&clk, bus_hz, bus_rel, quiet)) {
|
||||||
fprintf(stderr, "no suitable frequency found\n");
|
fprintf(stderr, "no suitable frequency found\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (clk.bus_clk_hz != bus_hz && !quiet) {
|
|
||||||
double err;
|
|
||||||
|
|
||||||
fprintf(stderr, "bus clk = ");
|
|
||||||
print_freq(stderr, clk.bus_clk_hz);
|
|
||||||
err = (clk.bus_clk_hz-bus_hz)/bus_hz;
|
|
||||||
if (err <= -0.0001 || err >= 0.0001)
|
|
||||||
fprintf(stderr, " (%+.2g%%)\n", err*100);
|
|
||||||
else
|
|
||||||
fprintf(stderr, " (%+d ppm)\n", (int) (err*1000000));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clkout || clk_only)
|
if (clkout || clk_only)
|
||||||
PDFUNS = UBB_CLK;
|
PDFUNS = UBB_CLK;
|
||||||
|
Loading…
Reference in New Issue
Block a user