FreeCalypso > hg > freecalypso-tools
annotate ffstools/caltools/fc-rftab2c.c @ 555:0093bf43c813
loadtools/scripts: added leonardo and tango configs
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 05 Jan 2020 22:43:18 +0000 |
parents | 5bcf12be0834 |
children | a684dd7799f8 |
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> |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 u_char binbuf[512]; |
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 static unsigned |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 get_u16(bin) |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 u_char *bin; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 return le16toh(*(uint16_t *)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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 static int |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 get_s16(bin) |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 u_char *bin; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 int i; |
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 i = le16toh(*(uint16_t *)bin); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (i >= 32768) |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 i -= 65536; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 return(i); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 do_rx_cal_params() |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 u_char *bp = binbuf; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 int i; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 puts(" { /* T_RX_CAL_PARAMS */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 for (i = 0; i < 4; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 printf("%10u,\n", get_u16(bp)); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 bp += 2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 puts(" },"); |
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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 do_rx_agc_bands() |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 u_char *bp = binbuf; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 int i, s; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 unsigned u; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 puts(" { /* T_RF_AGC_BANDs */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 for (i = 0; i < 10; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 u = get_u16(bp); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 bp += 2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 s = get_s16(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 printf(" {%5u,%6d},\n", u, s); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 puts(" },"); |
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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 do_rx_temp_comp() |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 u_char *bp = binbuf; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 int i, s1, s2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 puts(" { /* Rx temperature compensation */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 for (i = 0; i < 11; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 s1 = get_s16(bp); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 bp += 2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 s2 = 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 printf(" {%6d,%6d},\n", s1, s2); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 puts(" },"); |
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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 do_tx_levels() |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 u_char *bp = binbuf; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 unsigned i, u, b1, b2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 puts(" { /* levels */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 for (i = 0; i < 32; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 u = get_u16(bp); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 bp += 2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 b1 = *bp++; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 b2 = *bp++; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 printf(" {%5u,%3u,%3u}, /* %u */\n", u, b1, b2, i); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 puts(" },"); |
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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 do_tx_calchan() |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 u_char *bp = binbuf; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 int i, j, s; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 unsigned u; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 puts(" { /* channel calibration tables */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 for (i = 0; i < 4; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 printf(" { /* calibration table %d */\n", i); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 for (j = 0; j < 8; j++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 u = get_u16(bp); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 bp += 2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 s = get_s16(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 printf("\t{%5u,%6d},\n", u, s); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 puts(" },"); |
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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 static void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 do_ramp_16bytes(bin) |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 u_char *bin; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 u_char *bp = bin; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 int i, b; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 putchar('\t'); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 putchar('{'); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 for (i = 0; i < 16; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 b = *bp++; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 printf("%3d%c", b, i == 15 ? '}' : ','); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 putchar(','); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 putchar('\n'); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 do_tx_ramps() |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 u_char *bp = binbuf; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 int i; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 puts(" { /* ramps */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 for (i = 0; i < 16; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 printf(" { /* profile %d */\n", i); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 puts("\t/* ramp-up */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 do_ramp_16bytes(bp); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 bp += 16; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 puts("\t/* ramp-down */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 do_ramp_16bytes(bp); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 bp += 16; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 puts(" },"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } |
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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 void |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 do_tx_temp_comp() |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 u_char *bp = binbuf; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 int i, j, s[4]; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 puts(" { /* Tx temperature compensation */"); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 for (i = 0; i < 5; i++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 for (j = 0; j < 4; j++) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 s[j] = get_s16(bp); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 bp += 2; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 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
|
182 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 puts(" },"); |
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 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 static struct map { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 char *format; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 void (*func)(); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 } map_table[] = { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 {"tx-ramps", do_tx_ramps}, |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 {"tx-levels", do_tx_levels}, |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 {"tx-calchan", do_tx_calchan}, |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 {"tx-caltemp", do_tx_temp_comp}, |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 {"rx-calchan", do_rx_agc_bands}, |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 {"rx-caltemp", do_rx_temp_comp}, |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 {"rx-agc-params", do_rx_cal_params}, |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 {0, 0} |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 }; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 main(argc, argv) |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 char **argv; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 char *format; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 struct map *map; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 if (argc < 2 || argc > 3) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 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
|
208 argv[0]); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 exit(1); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 } |
466
5bcf12be0834
ffstools/caltools: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
439
diff
changeset
|
211 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
|
212 exit(1); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 for (map = map_table; map->format; map++) |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 if (!strcmp(map->format, format)) |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 break; |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 if (!map->func) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 printf("error: %s tables are not supported\n", format); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 exit(1); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 if (argc >= 3 && !freopen(argv[2], "w", stdout)) { |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 perror(argv[2]); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 exit(1); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 } |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 map->func(); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 exit(0); |
f4a32c1025a2
fc-rftab2c program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 } |