annotate ffstools/caltools/fc-rftab2c.c @ 881:bb8ad7c0cee8

doc/opt-freecalypso-tree: new FC FFS bundle package coming soon
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 02 Apr 2022 23:48:53 +0000
parents a684dd7799f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
439
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This utility reads an RF parameter table of one of the supported types
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * in FreeCalypso ASCII format (it has to be one of the tables that go
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * into the T_RF_BAND structure) and converts it into a C code snippet
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * suitable for insertion into the firmware source in the L1 RF "customization"
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * code where compiled-in default RF parameter tables are defined.
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 * This tool is primarily intended for use with tx-ramps tables and maybe
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 * tx-levels, but it also supports tx-calchan, tx-caltemp, rx-agc-params,
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * rx-calchan and rx-caltemp tables.
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 *
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * This program is based on the calextract tool from 2014 (freecalypso-reveng
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 * repository) and the generated C code snippets feature the same style,
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 * indentation and comments.
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 */
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include <sys/types.h>
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include <stdio.h>
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include <stdint.h>
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #include <endian.h>
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include <stdlib.h>
858
a684dd7799f8 fc-rftab2c.c: missing includes for string functions
Mychaela Falconia <falcon@freecalypso.org>
parents: 466
diff changeset
22 #include <string.h>
a684dd7799f8 fc-rftab2c.c: missing includes for string functions
Mychaela Falconia <falcon@freecalypso.org>
parents: 466
diff changeset
23 #include <strings.h>
439
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 u_char binbuf[512];
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 static unsigned
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 get_u16(bin)
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 u_char *bin;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return le16toh(*(uint16_t *)bin);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 static int
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 get_s16(bin)
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 u_char *bin;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 int i;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 i = le16toh(*(uint16_t *)bin);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (i >= 32768)
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 i -= 65536;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 return(i);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 do_rx_cal_params()
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 u_char *bp = binbuf;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 int i;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 puts(" { /* T_RX_CAL_PARAMS */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 for (i = 0; i < 4; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 printf("%10u,\n", get_u16(bp));
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 do_rx_agc_bands()
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 u_char *bp = binbuf;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 int i, s;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 unsigned u;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 puts(" { /* T_RF_AGC_BANDs */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 for (i = 0; i < 10; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 u = get_u16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 s = get_s16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 printf(" {%5u,%6d},\n", u, s);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 do_rx_temp_comp()
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 u_char *bp = binbuf;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 int i, s1, s2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 puts(" { /* Rx temperature compensation */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 for (i = 0; i < 11; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 s1 = get_s16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 s2 = get_s16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 printf(" {%6d,%6d},\n", s1, s2);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 do_tx_levels()
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 u_char *bp = binbuf;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 unsigned i, u, b1, b2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 puts(" { /* levels */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 for (i = 0; i < 32; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 u = get_u16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 b1 = *bp++;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 b2 = *bp++;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 printf(" {%5u,%3u,%3u}, /* %u */\n", u, b1, b2, i);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 do_tx_calchan()
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 u_char *bp = binbuf;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 int i, j, s;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 unsigned u;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 puts(" { /* channel calibration tables */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 for (i = 0; i < 4; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 printf(" { /* calibration table %d */\n", i);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 for (j = 0; j < 8; j++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 u = get_u16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 s = get_s16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 printf("\t{%5u,%6d},\n", u, s);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 static void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 do_ramp_16bytes(bin)
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 u_char *bin;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 u_char *bp = bin;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 int i, b;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 putchar('\t');
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 putchar('{');
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 for (i = 0; i < 16; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 b = *bp++;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 printf("%3d%c", b, i == 15 ? '}' : ',');
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 putchar(',');
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 putchar('\n');
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 do_tx_ramps()
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 u_char *bp = binbuf;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 int i;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 puts(" { /* ramps */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 for (i = 0; i < 16; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 printf(" { /* profile %d */\n", i);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 puts("\t/* ramp-up */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 do_ramp_16bytes(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 bp += 16;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 puts("\t/* ramp-down */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 do_ramp_16bytes(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 bp += 16;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 void
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 do_tx_temp_comp()
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 u_char *bp = binbuf;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 int i, j, s[4];
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 puts(" { /* Tx temperature compensation */");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 for (i = 0; i < 5; i++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 for (j = 0; j < 4; j++) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 s[j] = get_s16(bp);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 bp += 2;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 printf(" {%6d,%6d,%6d,%6d},\n", s[0], s[1], s[2], s[3]);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 puts(" },");
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 static struct map {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 char *format;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 void (*func)();
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 } map_table[] = {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 {"tx-ramps", do_tx_ramps},
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 {"tx-levels", do_tx_levels},
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 {"tx-calchan", do_tx_calchan},
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 {"tx-caltemp", do_tx_temp_comp},
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 {"rx-calchan", do_rx_agc_bands},
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 {"rx-caltemp", do_rx_temp_comp},
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 {"rx-agc-params", do_rx_cal_params},
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 {0, 0}
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 };
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 main(argc, argv)
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 char **argv;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 char *format;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 struct map *map;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 if (argc < 2 || argc > 3) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 fprintf(stderr, "usage: %s ascii-rftab-file [C-output-file]\n",
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 argv[0]);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 exit(1);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 }
466
5bcf12be0834 ffstools/caltools: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 439
diff changeset
213 if (read_rf_table_ext(argv[1], binbuf, 1, &format, (unsigned *) 0))
439
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 exit(1);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 for (map = map_table; map->format; map++)
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 if (!strcmp(map->format, format))
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 break;
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 if (!map->func) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 printf("error: %s tables are not supported\n", format);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 exit(1);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 if (argc >= 3 && !freopen(argv[2], "w", stdout)) {
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 perror(argv[2]);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 exit(1);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 }
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 map->func();
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 exit(0);
f4a32c1025a2 fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 }