annotate autocal/txbandmain.c @ 113:01bae2629ffd

doc/Test-system-interface: txpwr-cal-channel addition documented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 13 Feb 2018 04:39:33 +0000
parents 661d122ed8e7
children ae8da516681c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
75
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the main() function for fc-rfcal-txband.
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/l1tm.h>
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/exitcodes.h>
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "txband.h"
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "stdband.h"
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 struct tx_calchan_range tx_calchan_850[] = {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {128, 134, 131},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {135, 150, 143},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {151, 166, 159},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {167, 182, 175},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {183, 197, 190},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {198, 213, 206},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {214, 229, 222},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {230, 251, 241}
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 };
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 struct tx_calchan_range tx_calchan_900[] = {
80
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
27 { 0, 27, 14},
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
28 { 28, 47, 40},
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
29 { 48, 66, 57},
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
30 { 67, 85, 76},
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
31 { 86, 104, 95},
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
32 {105, 124, 114},
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
33 {975, 994, 985},
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
34 {995, 1023, 1009}
75
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 };
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 struct tx_calchan_range tx_calchan_1800[] = {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 {512, 553, 533},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 {554, 594, 574},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 {595, 636, 615},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 {637, 677, 657},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 {678, 720, 700},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 {721, 760, 740},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 {761, 802, 781},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 {803, 885, 844}
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 };
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 struct tx_calchan_range tx_calchan_1900[] = {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 {512, 549, 531},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 {550, 586, 568},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 {587, 623, 605},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 {624, 697, 660},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 {698, 726, 712},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {727, 754, 740},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {755, 782, 768},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 {783, 810, 796}
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 };
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 struct txcal_band txcal_band_list[] = {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 {"850", RFPW_STD_BAND_850, 190, 5, 19, tx_calchan_850, 4},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 {"900", RFPW_STD_BAND_900, 40, 5, 19, tx_calchan_900, 1},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {"1800", RFPW_STD_BAND_1800, 700, 0, 15, tx_calchan_1800, 4},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {"1900", RFPW_STD_BAND_1900, 660, 0, 15, tx_calchan_1900, 3},
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {0, 0, 0, 0, 0, 0, 0}
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 };
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 struct txcal_band *txcal_band;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 char *txlevels_profile;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 struct tx_basis_point tx_basis[MAX_BASIS_POINTS];
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 unsigned num_basis_points;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 struct tx_level tx_levels[MAX_TX_LEVELS];
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 finish_cmdline(argc, argv)
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 char **argv;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 extern int optind;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 struct txcal_band *band;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 if (argc - optind != 2) {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 fprintf(stderr, "usage: %s band txlevels-profile\n", argv[0]);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 exit(ERROR_USAGE);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 }
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 for (band = txcal_band_list; band->name; band++)
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 if (!strcmp(band->name, argv[optind]))
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 break;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 if (!band->name) {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 fprintf(stderr, "error: \"%s\" is not a known band\n",
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 argv[optind]);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 exit(ERROR_USAGE);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 txcal_band = band;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 txlevels_profile = argv[optind+1];
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 return(0);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 }
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 main(argc, argv)
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 char **argv;
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 {
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 socket_pathname_options(argc, argv);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 finish_cmdline(argc, argv);
76
5c3574f8c8c1 fc-rfcal-txband: reading of basis & targets setting files implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 75
diff changeset
103 read_tx_cal_profile();
75
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 connect_rvinterf_socket();
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 connect_tsid_socket();
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 setlinebuf(stdout); /* to allow logging with tee */
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 printf("Preparing RF test system for %s MHz Tx calibration\n",
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 txcal_band->name);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 do_txpwr_cal_setup(txcal_band->name, txcal_band->main_arfcn);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 printf("Putting the DUT into Test Mode\n");
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 do_tms(1);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 do_rfpw(STD_BAND_FLAG, txcal_band->rfpw_std_band);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 do_rfpw(TCH_ARFCN, txcal_band->main_arfcn);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 do_rfpw(AFC_ENA_FLAG, 0);
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116
77
3f63e71b6422 fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 76
diff changeset
117 /* any previous calchan needs to be cleared out first */
80
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
118 printf("Initializing calchan table\n");
77
3f63e71b6422 fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 76
diff changeset
119 init_tx_calchan();
3f63e71b6422 fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 76
diff changeset
120 upload_tx_calchan();
80
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
121 /* run the basis measurements */
b0da2db4e36b fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 77
diff changeset
122 txcal_basis_run();
81
83b24a1dfd4a fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents: 80
diff changeset
123 /* analytical follow-up */
83b24a1dfd4a fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents: 80
diff changeset
124 txcal_basis_compute();
83
45ef4a06edfc fc-rfcal-txband: initial implementation complete, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 81
diff changeset
125 /* actual Tx levels calibration */
45ef4a06edfc fc-rfcal-txband: initial implementation complete, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 81
diff changeset
126 calibrate_tx_levels();
75
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127
106
661d122ed8e7 fc-rfcal-txband: added delay which should prevent intermittent fw crash
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
128 /*
661d122ed8e7 fc-rfcal-txband: added delay which should prevent intermittent fw crash
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
129 * We need to insert a delay between stopping Tx
661d122ed8e7 fc-rfcal-txband: added delay which should prevent intermittent fw crash
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
130 * and doing the FFS write in order to avoid
661d122ed8e7 fc-rfcal-txband: added delay which should prevent intermittent fw crash
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
131 * an intermittent fw crash on the DUT.
661d122ed8e7 fc-rfcal-txband: added delay which should prevent intermittent fw crash
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
132 */
661d122ed8e7 fc-rfcal-txband: added delay which should prevent intermittent fw crash
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
133 usleep(100000);
661d122ed8e7 fc-rfcal-txband: added delay which should prevent intermittent fw crash
Mychaela Falconia <falcon@freecalypso.org>
parents: 85
diff changeset
134
85
2bed7b024f64 fc-rfcal-txband: FFS write implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 83
diff changeset
135 printf("Saving calibrated values in FFS\n");
2bed7b024f64 fc-rfcal-txband: FFS write implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 83
diff changeset
136 misc_enable(CFG_WRITE_TX_CAL);
83
45ef4a06edfc fc-rfcal-txband: initial implementation complete, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 81
diff changeset
137 exit(0);
75
93653fe9b4ef fc-rfcal-txband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 }