FreeCalypso > hg > fc-rfcal-tools
view autocal/txbasis.c @ 113:01bae2629ffd
doc/Test-system-interface: txpwr-cal-channel addition documented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Feb 2018 04:39:33 +0000 |
parents | 7ad0495991ed |
children | 4c3f4231a021 |
line wrap: on
line source
/* * The basis steps of Tx power level calibration are implemented here. */ #include <math.h> #include <stdio.h> #include <stdlib.h> #include <rvinterf/l1tm.h> #include <rvinterf/exitcodes.h> #include "txband.h" extern double tx_power_meas(); extern vout_t dbm_to_vout(); extern struct txcal_band *txcal_band; extern struct tx_basis_point tx_basis[MAX_BASIS_POINTS]; extern unsigned num_basis_points; txcal_basis_run() { unsigned n; double meas; int nanflag = 0; printf("Performing the calibration basis run\n"); do_txpw(TX_PWR_LEVEL, txcal_band->start_plnum); printf("Starting RF Tx on the DUT\n"); do_rfe(RX_TX_TCH); for (n = 0; n < num_basis_points; n++) { do_txpw(TX_APC_DAC, tx_basis[n].apc); usleep(20000); meas = tx_power_meas(); printf("APC DAC=%u: %.2f dBm\n", tx_basis[n].apc, meas); if (isnan(meas)) nanflag = 1; tx_basis[n].vout = dbm_to_vout(meas); } printf("Stopping RF Tx on the DUT\n"); do_rfe(STOP_ALL); if (nanflag) { printf("Error: got NaN power measurement, aborting\n"); exit(ERROR_RFFAIL); } return(0); } txcal_basis_compute() { unsigned n; for (n = 0; n < num_basis_points - 1; n++) { if (tx_basis[n+1].vout <= tx_basis[n].vout) { fprintf(stderr, "error: Vout at APC=%u is not greater than at APC=%u\n", tx_basis[n+1].apc, tx_basis[n].apc); exit(ERROR_RFFAIL); } tx_basis[n].slope = (tx_basis[n+1].vout - tx_basis[n].vout) / (tx_basis[n+1].apc - tx_basis[n].apc); } return(0); }