FreeCalypso > hg > fc-rfcal-tools
annotate autocal/txbasis.c @ 104:7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 09 Dec 2017 07:01:13 +0000 |
parents | b0618796d28d |
children | 4c3f4231a021 |
rev | line source |
---|---|
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * The basis steps of Tx power level calibration are implemented here. |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
5 #include <math.h> |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <rvinterf/l1tm.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <rvinterf/exitcodes.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "txband.h" |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 extern double tx_power_meas(); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern vout_t dbm_to_vout(); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern struct txcal_band *txcal_band; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern struct tx_basis_point tx_basis[MAX_BASIS_POINTS]; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern unsigned num_basis_points; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 txcal_basis_run() |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 { |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 unsigned n; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 double meas; |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
23 int nanflag = 0; |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 printf("Performing the calibration basis run\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 do_txpw(TX_PWR_LEVEL, txcal_band->start_plnum); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 printf("Starting RF Tx on the DUT\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 do_rfe(RX_TX_TCH); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 for (n = 0; n < num_basis_points; n++) { |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 do_txpw(TX_APC_DAC, tx_basis[n].apc); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 usleep(20000); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 meas = tx_power_meas(); |
81
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
34 printf("APC DAC=%u: %.2f dBm\n", tx_basis[n].apc, meas); |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
35 if (isnan(meas)) |
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
36 nanflag = 1; |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 tx_basis[n].vout = dbm_to_vout(meas); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 printf("Stopping RF Tx on the DUT\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 do_rfe(STOP_ALL); |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
42 if (nanflag) { |
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
43 printf("Error: got NaN power measurement, aborting\n"); |
104
7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
44 exit(ERROR_RFFAIL); |
101
b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
45 } |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(0); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
81
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
48 |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
49 txcal_basis_compute() |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
50 { |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
51 unsigned n; |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
52 |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
53 for (n = 0; n < num_basis_points - 1; n++) { |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
54 if (tx_basis[n+1].vout <= tx_basis[n].vout) { |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
55 fprintf(stderr, |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
56 "error: Vout at APC=%u is not greater than at APC=%u\n", |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
57 tx_basis[n+1].apc, tx_basis[n].apc); |
104
7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
58 exit(ERROR_RFFAIL); |
81
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
59 } |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
60 tx_basis[n].slope = (tx_basis[n+1].vout - tx_basis[n].vout) / |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
61 (tx_basis[n+1].apc - tx_basis[n].apc); |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
62 } |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
63 return(0); |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
64 } |