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
Leah Rowe 2023-05-16 08:17:29 +01:00
parent 3722c1e67a
commit e286470432
1 changed files with 24 additions and 22 deletions

View File

@ -26,28 +26,7 @@ static int pos, f1, f2;
static int amplitude = 0; static int amplitude = 0;
static int lp = 0; static int lp = 0;
static void static void read_sample (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++;
}
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
@ -97,3 +76,26 @@ main (int argc, char *argv[])
} }
return 0; 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++;
}