FreeCalypso > hg > fc-rfcal-tools
annotate autocal/txbasis.c @ 94:b443d0665c1f
top README and INSTALL files added
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 17 Jul 2017 08:28:57 +0000 |
parents | 83b24a1dfd4a |
children | b0618796d28d |
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 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <rvinterf/l1tm.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <rvinterf/exitcodes.h> |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "txband.h" |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 extern double tx_power_meas(); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 extern vout_t dbm_to_vout(); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 extern struct txcal_band *txcal_band; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 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
|
16 extern unsigned num_basis_points; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 txcal_basis_run() |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 unsigned n; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 double meas; |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 printf("Performing the calibration basis run\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 do_txpw(TX_PWR_LEVEL, txcal_band->start_plnum); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 printf("Starting RF Tx on the DUT\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 do_rfe(RX_TX_TCH); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 for (n = 0; n < num_basis_points; n++) { |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 do_txpw(TX_APC_DAC, tx_basis[n].apc); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 usleep(20000); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 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
|
32 printf("APC DAC=%u: %.2f dBm\n", tx_basis[n].apc, meas); |
80
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 tx_basis[n].vout = dbm_to_vout(meas); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 printf("Stopping RF Tx on the DUT\n"); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 do_rfe(STOP_ALL); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return(0); |
b0da2db4e36b
fc-rfcal-txband: basis run implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
81
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
40 |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
41 txcal_basis_compute() |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
42 { |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
43 unsigned n; |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
44 |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
45 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
|
46 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
|
47 fprintf(stderr, |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
48 "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
|
49 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
|
50 exit(ERROR_RFTEST); |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
51 } |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
52 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
|
53 (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
|
54 } |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
55 return(0); |
83b24a1dfd4a
fc-rfcal-txband: implemented the slope computations after basis run
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
56 } |