annotate miscprog/calextract.c @ 275:cbd944ebeff0

Pirelli PCB RE: traced out Calypso FDP and flash reset input
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 24 Mar 2018 20:38:24 +0000
parents c38075b8a625
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
180
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * GSM firmwares constructed per TI's canon contain several hard-coded
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * T_RF_BAND structures, one per band, emitted literally in the .const
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 * section as they are constant initialized data, i.e.,
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * const T_RF_BAND rf_XXX = { blah }. This utility extracts one of these
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 * structures from a binary file (hex offset must be given) and parses it
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 * into a C form suitable for placement in l1_rf12.c in the FreeCalypso
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 * gsm-fw source.
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 */
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <stdio.h>
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include <stdlib.h>
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 char *binfilename;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 FILE *binf;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 u_long start_offset;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 getbyte()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 int c;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 c = getc(binf);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 if (c < 0) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 fprintf(stderr, "error or EOF reading from %s\n", binfilename);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 exit(1);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 return(c);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 get_u16()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 int lo, hi;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 lo = getbyte();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 hi = getbyte();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 return((hi << 8) | lo);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 get_s16()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 int i;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 i = get_u16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 if (i >= 32768)
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 i -= 65536;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 return(i);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 do_rx_cal_params()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 int i;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 puts(" { /* T_RX_CAL_PARAMS */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 for (i = 0; i < 4; i++)
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 printf("%10d,\n", get_u16());
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 do_rx_agc_bands()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 int i, u, s;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 puts(" { /* T_RF_AGC_BANDs */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 for (i = 0; i < 10; i++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 u = get_u16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 s = get_s16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 printf(" {%5d,%6d},\n", u, s);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 do_rx_temp_comp()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 int i, s1, s2;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 puts(" { /* Rx temperature compensation */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 for (i = 0; i < 11; i++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 s1 = get_s16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 s2 = get_s16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 printf(" {%6d,%6d},\n", s1, s2);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 do_rx()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 puts(" { /* Rx structure */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 do_rx_cal_params();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 do_rx_agc_bands();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 do_rx_temp_comp();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 do_tx_levels()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 int i, u, b1, b2;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 puts(" { /* levels */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 for (i = 0; i < 32; i++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 u = get_u16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 b1 = getbyte();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 b2 = getbyte();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 printf(" {%5d,%3d,%3d}, /* %d */\n", u, b1, b2, i);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 do_tx_calchan()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 int i, j, u, s;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 puts(" { /* channel calibration tables */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 for (i = 0; i < 4; i++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 printf(" { /* calibration table %d */\n", i);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 for (j = 0; j < 8; j++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 u = get_u16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 s = get_s16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 printf("\t{%5d,%6d},\n", u, s);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 do_ramp_16bytes()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 int i, b;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 putchar('\t');
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 putchar('{');
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 for (i = 0; i < 16; i++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 b = getbyte();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 printf("%3d%c", b, i == 15 ? '}' : ',');
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 putchar(',');
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 putchar('\n');
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 do_tx_ramps()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 int i;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 puts(" { /* ramps */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 for (i = 0; i < 16; i++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 printf(" { /* profile %d */\n", i);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 puts("\t/* ramp-up */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 do_ramp_16bytes();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 puts("\t/* ramp-down */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 do_ramp_16bytes();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 do_tx_temp_comp()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 int i, j, s[4];
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 puts(" { /* Tx temperature compensation */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 for (i = 0; i < 5; i++) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 for (j = 0; j < 4; j++)
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 s[j] = get_s16();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 printf(" {%6d,%6d,%6d,%6d},\n", s[0], s[1], s[2], s[3]);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 do_tx()
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 puts(" { /* Tx structure */");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 do_tx_levels();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 do_tx_calchan();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 do_tx_ramps();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 do_tx_temp_comp();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 puts(" },");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 main(argc, argv)
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 char **argv;
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 if (argc != 3) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 fprintf(stderr, "usage: %s binfile hex-offset\n", argv[0]);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 exit(1);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 binfilename = argv[1];
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186 start_offset = strtoul(argv[2], 0, 16);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 binf = fopen(binfilename, "r");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 if (!binf) {
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 perror(binfilename);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 exit(1);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 }
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 fseek(binf, start_offset, SEEK_SET);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 puts("const T_RF_BAND rf_XXX = {");
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 do_rx();
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195 do_tx();
182
c38075b8a625 calextract: forgot the final semicolon after the last closing brace
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 180
diff changeset
196 printf(" %d\n};\n", getbyte());
180
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 exit(0);
25b54c5ad6c2 calextract tool written, works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 }