-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdump_ts.c
48 lines (38 loc) · 864 Bytes
/
dump_ts.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <stdint.h>
#include "modem.h"
#define TS_CLK (80*1000*1000) // 80MHz
int main(int argc, char *argv[])
{
FILE *fp;
uint32_t ts0 = 0, ts, tso = 0;
uint32_t level;
double f0 = 0, f;
if (argc != 2) {
fprintf(stderr, "usage: dump_ts ts_file\n");
return 1;
}
fp = fopen(argv[1], "r");
if (fp == NULL) {
fprintf(stderr, "file can not open: %s\n", argv[1]);
return 1;
}
//#define BAUD 1200
while (fread(&ts, sizeof(ts), 1, fp) == 1) {
if (tso == 0) {
printf("0 %u\n", ts & 1);
tso = ts;
continue;
}
level = ts & 1;
ts -= tso;
f = (double)ts0 / (TS_CLK / BAUD_RATE);
printf("%f %u\n", f, level);
ts0 = ts;
f = (double)ts0 / (TS_CLK / BAUD_RATE);
if (f < f0) break; // wrap around
printf("%f %u\n", f, level);
f0 = f;
}
return 0;
}