annotate autocal/txlevels.c @ 82:a094db1453b1

fc-rfcal-txband: implemented computation of APC from basis
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 15 Jul 2017 22:48:29 +0000
parents
children 45ef4a06edfc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
82
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The calibration of Tx power levels is implemented here.
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <rvinterf/l1tm.h>
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <rvinterf/exitcodes.h>
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "txband.h"
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 extern double tx_power_meas();
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 extern vout_t dbm_to_vout();
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern struct txcal_band *txcal_band;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern struct tx_basis_point tx_basis[MAX_BASIS_POINTS];
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern unsigned num_basis_points;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern struct tx_level tx_levels[MAX_TX_LEVELS];
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 unsigned
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 find_apc_for_target(target_dbm)
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 double target_dbm;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 vout_t target_vout;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 unsigned n;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 int apc_delta;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 target_vout = dbm_to_vout(target_dbm);
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 for (n = 0; n < num_basis_points - 1; n++)
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (target_vout < tx_basis[n+1].vout)
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 break;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 apc_delta = (target_vout - tx_basis[n].vout) / tx_basis[n].slope;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 return tx_basis[n].apc + apc_delta;
a094db1453b1 fc-rfcal-txband: implemented computation of APC from basis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }