util/spkmodem_recv: Top-down logic (main on top)
Add the appropriate prototype. Top-down function order is easier to read. Signed-off-by: Leah Rowe <leah@libreboot.org>fsdg20230625
parent
3722c1e67a
commit
e286470432
|
@ -26,28 +26,7 @@ static int pos, f1, f2;
|
|||
static int amplitude = 0;
|
||||
static int lp = 0;
|
||||
|
||||
static void
|
||||
read_sample (void)
|
||||
{
|
||||
amplitude -= abs (trame[ringpos]);
|
||||
f1 -= pulse[ringpos];
|
||||
f1 += pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
|
||||
f2 -= pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
|
||||
fread (trame + ringpos, 1, sizeof (trame[0]), stdin);
|
||||
amplitude += abs (trame[ringpos]);
|
||||
|
||||
if (abs(trame[ringpos]) > THRESHOLD) { /* rising/falling edge(pulse) */
|
||||
pulse[ringpos] = 1;
|
||||
pos = !pos;
|
||||
f2++;
|
||||
} else {
|
||||
pulse[ringpos] = 0;
|
||||
}
|
||||
|
||||
ringpos++;
|
||||
ringpos %= 2 * SAMPLES_PER_TRAME;
|
||||
lp++;
|
||||
}
|
||||
static void read_sample (void);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -97,3 +76,26 @@ main (int argc, char *argv[])
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
read_sample (void)
|
||||
{
|
||||
amplitude -= abs (trame[ringpos]);
|
||||
f1 -= pulse[ringpos];
|
||||
f1 += pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
|
||||
f2 -= pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
|
||||
fread (trame + ringpos, 1, sizeof (trame[0]), stdin);
|
||||
amplitude += abs (trame[ringpos]);
|
||||
|
||||
if (abs(trame[ringpos]) > THRESHOLD) { /* rising/falling edge(pulse) */
|
||||
pulse[ringpos] = 1;
|
||||
pos = !pos;
|
||||
f2++;
|
||||
} else {
|
||||
pulse[ringpos] = 0;
|
||||
}
|
||||
|
||||
ringpos++;
|
||||
ringpos %= 2 * SAMPLES_PER_TRAME;
|
||||
lp++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue