FreeCalypso > hg > fc-rfcal-tools
changeset 57:2588f9eed11a
fc-rfcal-rxband started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 23:05:28 +0000 |
parents | df827df6db82 |
children | 46c72323182a |
files | .hgignore autocal/Makefile autocal/rxband.c autocal/rxband.h autocal/rxtables.h |
diffstat | 5 files changed, 166 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sat May 27 20:02:10 2017 +0000 +++ b/.hgignore Sat May 27 23:05:28 2017 +0000 @@ -3,6 +3,7 @@ \.[oa]$ ^autocal/fc-rfcal-gmagic$ +^autocal/fc-rfcal-rxband$ ^autocal/fc-rfcal-txbasis$ ^autocal/fc-rfcal-txcheck$ ^autocal/fc-rfcal-vcxo$
--- a/autocal/Makefile Sat May 27 20:02:10 2017 +0000 +++ b/autocal/Makefile Sat May 27 23:05:28 2017 +0000 @@ -1,11 +1,15 @@ CC= gcc CFLAGS= -O2 -I/opt/freecalypso/include -PROGS= fc-rfcal-gmagic fc-rfcal-txbasis fc-rfcal-txcheck fc-rfcal-vcxo +PROGS= fc-rfcal-gmagic fc-rfcal-rxband fc-rfcal-txbasis fc-rfcal-txcheck \ + fc-rfcal-vcxo INSTBIN=/opt/freecalypso/bin GMAGIC_OBJS= gmagicmain.o l1meas.o l1tmops.o rvinterf.o rxcommon.o \ sockopts.o tsidsock.o +RXBAND_OBJS= l1meas.o l1tmops.o rvinterf.o rxband.o rxcommon.o sockopts.o \ + tsidsock.o + TXBASIS_OBJS= l1tmops.o rvinterf.o tsidsock.o txbasis.o txpwrmeas.o TXCHECK_OBJS= l1tmops.o rvinterf.o sockopts.o tsidsock.o txchkmain.o \ @@ -18,6 +22,9 @@ fc-rfcal-gmagic: ${GMAGIC_OBJS} ${CC} -o $@ ${GMAGIC_OBJS} +fc-rfcal-rxband: ${RXBAND_OBJS} + ${CC} -o $@ ${RXBAND_OBJS} + fc-rfcal-txbasis: ${TXBASIS_OBJS} ${CC} -o $@ ${TXBASIS_OBJS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocal/rxband.c Sat May 27 23:05:28 2017 +0000 @@ -0,0 +1,127 @@ +/* + * 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; +{ + int pm, Gmagic; + char Gmagic_db[64]; + + 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(); + + 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); + exit(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocal/rxband.h Sat May 27 23:05:28 2017 +0000 @@ -0,0 +1,15 @@ +/* internal structures for fc-rfcal-rxband */ + +struct rx_calchan_range { + unsigned lower_bound; + unsigned upper_bound; + unsigned test_arfcn; +}; + +struct rxcal_band { + char *name; + unsigned rfpw_std_band; + unsigned main_arfcn; + struct rx_calchan_range *calchan_ranges; + unsigned num_calchan_ranges; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocal/rxtables.h Sat May 27 23:05:28 2017 +0000 @@ -0,0 +1,15 @@ +/* definitions of the L1 Rx table structures we need */ + +struct rx_agc_params { + uint16_t g_magic; + uint16_t lna_att; + uint16_t lna_switch_thr_low; + uint16_t lna_switch_thr_high; +}; + +#define RX_CALCHAN_ENTRIES 10 + +struct rx_calchan_entry { + uint16_t upper_bound; + int16_t agc_calib; +};