FreeCalypso > hg > fc-rfcal-tools
view autocal/rxband.c @ 59:c87067884da7
autocal/l1tmops.c: do_rftr() added
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 23:23:35 +0000 |
parents | 46c72323182a |
children | 81e8f7e99d89 |
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; 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(); exit(0); } do_gmagic() { int pm, Gmagic; 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); return(0); }