FreeCalypso > hg > fc-rfcal-tools
annotate autocal/txcalchan.c @ 127:fd856f729618
scripts: fc-rfcal-tri850 added
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 24 Dec 2019 07:08:27 +0000 |
| parents | 4c3f4231a021 |
| children |
| rev | line source |
|---|---|
|
77
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the code for handling Tx calchan tables. |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdint.h> |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <endian.h> |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <rvinterf/l1tm.h> |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <rvinterf/exitcodes.h> |
|
117
4c3f4231a021
autocal: vout_t definition factored out of txband.h into txvout.h
Mychaela Falconia <falcon@freecalypso.org>
parents:
116
diff
changeset
|
11 #include "txvout.h" |
|
77
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "txband.h" |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "txcalchan.h" |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
|
116
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
15 extern double tx_power_meas(); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
16 extern vout_t dbm_to_vout(); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
17 |
|
77
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern struct txcal_band *txcal_band; |
|
116
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
19 extern struct tx_level tx_levels[MAX_TX_LEVELS]; |
|
77
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 unsigned tx_calchan_values[TX_CALCHAN_TABLES][TX_CALCHAN_ENTRIES]; |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 init_tx_calchan() |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 unsigned i, j; |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 for (i = 0; i < TX_CALCHAN_TABLES; i++) |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 for (j = 0; j < TX_CALCHAN_ENTRIES; j++) |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 tx_calchan_values[i][j] = 128; |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 return(0); |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
|
116
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
33 tx_calchan_one_table(tblnum) |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
34 unsigned tblnum; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
35 { |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
36 vout_t vout[TX_CALCHAN_ENTRIES]; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
37 char cmd[80]; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
38 unsigned n, arfcn, plidx; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
39 double meas; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
40 int nanflag = 0; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
41 int apc_delta; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
42 unsigned apc_wanted; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
43 |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
44 printf("Calibrating Tx channel correction table %u (PL #%u)\n", tblnum, |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
45 txcal_band->calchan_plnum[tblnum]); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
46 do_txpw(TX_PWR_LEVEL, txcal_band->calchan_plnum[tblnum]); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
47 plidx = txcal_band->calchan_plnum[tblnum] - txcal_band->start_plnum; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
48 printf("Starting RF Tx on the DUT\n"); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
49 do_rfe(RX_TX_TCH); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
50 for (n = 0; n < TX_CALCHAN_ENTRIES; n++) { |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
51 arfcn = txcal_band->calchan_ranges[n].test_arfcn; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
52 sprintf(cmd, "txpwr-cal-channel %u\n", arfcn); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
53 tsid_command(cmd); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
54 do_rfpw(TCH_ARFCN, arfcn); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
55 usleep(20000); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
56 meas = tx_power_meas(); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
57 printf("ARFCN=%u: %.2f dBm\n", arfcn, meas); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
58 if (isnan(meas)) |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
59 nanflag = 1; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
60 vout[n] = dbm_to_vout(meas); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
61 } |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
62 printf("Stopping RF Tx on the DUT\n"); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
63 do_rfe(STOP_ALL); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
64 if (nanflag) { |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
65 printf("Error: got NaN power measurement, aborting\n"); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
66 exit(ERROR_RFFAIL); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
67 } |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
68 |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
69 for (n = 0; n < TX_CALCHAN_ENTRIES; n++) { |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
70 apc_delta = (vout[txcal_band->ref_subband] - vout[n]) / |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
71 tx_levels[plidx].slope; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
72 apc_wanted = tx_levels[plidx].apc + apc_delta; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
73 tx_calchan_values[tblnum][n] = (apc_wanted * 128) / |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
74 tx_levels[plidx].apc; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
75 printf("ARFCN %u-%u: correction=%u\n", |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
76 txcal_band->calchan_ranges[n].lower_bound, |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
77 txcal_band->calchan_ranges[n].upper_bound, |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
78 tx_calchan_values[tblnum][n]); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
79 } |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
80 } |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
81 |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
82 calibrate_tx_calchan() |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
83 { |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
84 unsigned tblnum; |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
85 |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
86 for (tblnum = 0; tblnum < TX_CALCHAN_TABLES; tblnum++) |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
87 tx_calchan_one_table(tblnum); |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
88 } |
|
4ce87a30383f
fc-rfcal-txband: channel calibration implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
77
diff
changeset
|
89 |
|
77
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 upload_tx_calchan() |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 { |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 unsigned i, j; |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 struct tx_calchan_entry l1_table[TX_CALCHAN_TABLES][TX_CALCHAN_ENTRIES]; |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 for (i = 0; i < TX_CALCHAN_TABLES; i++) { |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 for (j = 0; j < TX_CALCHAN_ENTRIES; j++) { |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 l1_table[i][j].arfcn_limit = |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 htole16(txcal_band->calchan_ranges[j].upper_bound); |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 l1_table[i][j].chan_cal = |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 htole16(tx_calchan_values[i][j]); |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 } |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 do_rftw(TX_CAL_CHAN, l1_table, sizeof l1_table); |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 return(0); |
|
3f63e71b6422
fc-rfcal-txband: implemented initial calchan clearing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
