summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-05-16 08:17:29 +0100
committerLeah Rowe <leah@libreboot.org>2023-05-16 23:11:35 +0100
commite2864704320e9fdde78ea34088256d99df9d5931 (patch)
tree331f9f803cfecd5eaecdb0927c692ec53a2be438 /util
parent3722c1e67a2193d4e74106060183f80a92bd66fe (diff)
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>
Diffstat (limited to 'util')
-rw-r--r--util/spkmodem_recv/spkmodem-recv.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c
index 5efa25a7..d543d32e 100644
--- a/util/spkmodem_recv/spkmodem-recv.c
+++ b/util/spkmodem_recv/spkmodem-recv.c
@@ -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++;
+}