FreeCalypso > hg > fc-rfcal-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
81:83b24a1dfd4a | 82:a094db1453b1 |
---|---|
1 /* | |
2 * The calibration of Tx power levels is implemented here. | |
3 */ | |
4 | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <rvinterf/l1tm.h> | |
8 #include <rvinterf/exitcodes.h> | |
9 #include "txband.h" | |
10 | |
11 extern double tx_power_meas(); | |
12 extern vout_t dbm_to_vout(); | |
13 | |
14 extern struct txcal_band *txcal_band; | |
15 extern struct tx_basis_point tx_basis[MAX_BASIS_POINTS]; | |
16 extern unsigned num_basis_points; | |
17 extern struct tx_level tx_levels[MAX_TX_LEVELS]; | |
18 | |
19 unsigned | |
20 find_apc_for_target(target_dbm) | |
21 double target_dbm; | |
22 { | |
23 vout_t target_vout; | |
24 unsigned n; | |
25 int apc_delta; | |
26 | |
27 target_vout = dbm_to_vout(target_dbm); | |
28 for (n = 0; n < num_basis_points - 1; n++) | |
29 if (target_vout < tx_basis[n+1].vout) | |
30 break; | |
31 apc_delta = (target_vout - tx_basis[n].vout) / tx_basis[n].slope; | |
32 return tx_basis[n].apc + apc_delta; | |
33 } |