FreeCalypso > hg > fc-rfcal-tools
view autocal/rxbandmain.c @ 124:9f09a7c3607a
fc-rfcal-txband: level error tolerance tightened to 0.75 dB
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 12 Jan 2019 20:15:17 +0000 |
parents | d388732c2f73 |
children |
line wrap: on
line source
/* * This module contains the main() function for fc-rfcal-rxband. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <rvinterf/l1tm.h> #include <rvinterf/exitcodes.h> #include "rxband.h" #include "rxcaldefs.h" #include "stdband.h" struct rx_calchan_range rx_calchan_850[] = { {128, 138, 128}, {139, 157, 148}, {158, 178, 168}, {179, 199, 189}, {200, 217, 208}, {218, 239, 228}, {240, 251, 251} }; struct rx_calchan_range rx_calchan_900[] = { { 0, 10, 1}, { 11, 30, 20}, { 31, 51, 37}, { 52, 71, 62}, { 72, 90, 80}, { 91, 112, 100}, { 113, 124, 124}, { 975, 991, 975}, { 992, 1009, 1000}, {1010, 1023, 1017} }; struct rx_calchan_range rx_calchan_1800[] = { {512, 548, 512}, {549, 622, 585}, {623, 680, 660}, {681, 745, 698}, {746, 812, 790}, {813, 860, 835}, {861, 885, 885} }; struct rx_calchan_range rx_calchan_1900[] = { {512, 548, 512}, {549, 622, 585}, {623, 680, 661}, {681, 745, 700}, {746, 795, 790}, {796, 810, 805} }; struct rxcal_band rxcal_band_list[] = { {"850", RFPW_STD_BAND_850, 189, rx_calchan_850, sizeof(rx_calchan_850) / sizeof(struct rx_calchan_range)}, {"900", RFPW_STD_BAND_900, 37, rx_calchan_900, sizeof(rx_calchan_900) / sizeof(struct rx_calchan_range)}, {"1800", RFPW_STD_BAND_1800, 698, rx_calchan_1800, sizeof(rx_calchan_1800) / sizeof(struct rx_calchan_range)}, {"1900", RFPW_STD_BAND_1900, 661, rx_calchan_1900, sizeof(rx_calchan_1900) / sizeof(struct rx_calchan_range)}, {0, 0, 0, 0, 0} }; struct rxcal_band *rxcal_band; int Gmagic, rx_calchan_values[10]; finish_cmdline(argc, argv) char **argv; { extern int optind; struct rxcal_band *band; if (argc - optind != 1) { fprintf(stderr, "usage: %s band\n", argv[0]); exit(ERROR_USAGE); } for (band = rxcal_band_list; band->name; band++) if (!strcmp(band->name, argv[optind])) break; if (!band->name) { fprintf(stderr, "error: \"%s\" is not a known band\n", argv[optind]); exit(ERROR_USAGE); } rxcal_band = band; return(0); } prepare_rf_test_system() { char cmd[80]; printf("Preparing RF test system for %s MHz Rx calibration\n", rxcal_band->name); sprintf(cmd, "signal-gen-setup %s\n", rxcal_band->name); tsid_command(cmd); return(0); } main(argc, argv) char **argv; { socket_pathname_options(argc, argv); finish_cmdline(argc, argv); connect_rvinterf_socket(); connect_tsid_socket(); setlinebuf(stdout); /* to allow logging with tee */ prepare_rf_test_system(); printf("Putting the DUT into Test Mode\n"); do_tms(1); do_rfpw(STD_BAND_FLAG, rxcal_band->rfpw_std_band); l1tm_setup_for_rxcal(); do_gmagic(); do_rx_calchan(); printf("Saving calibrated values in FFS\n"); misc_enable(CFG_WRITE_RX_CAL); exit(0); } do_gmagic() { int pm; char Gmagic_db[64]; printf("Calibrating GMagic\n"); pm = rx_measure(rxcal_band->main_arfcn); Gmagic = pm - RXCAL_SIGGEN_LEVEL - RXCAL_AGC_DB * 2; halfdb_to_string(Gmagic, Gmagic_db); printf("GMagic=%d (%s dB)\n", Gmagic, Gmagic_db); upload_gmagic(); return(0); } do_rx_calchan() { unsigned n; int pm; printf("Calibrating RSSI channel compensation\n"); for (n = 0; n < rxcal_band->num_calchan_ranges; n++) { pm = rx_measure(rxcal_band->calchan_ranges[n].test_arfcn); rx_calchan_values[n] = RXCAL_SIGGEN_LEVEL - pm + RXCAL_AGC_DB * 2 + Gmagic; } for (n = 0; n < rxcal_band->num_calchan_ranges; n++) printf("ARFCN %u-%u: correction=%d\n", rxcal_band->calchan_ranges[n].lower_bound, rxcal_band->calchan_ranges[n].upper_bound, rx_calchan_values[n]); upload_rx_calchan(); return(0); }