view autocal/rxupload.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 0bf853d1b68e
children
line wrap: on
line source

/*
 * This module contains the RF table upload code for fc-rfcal-rxband.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <endian.h>
#include <rvinterf/l1tm.h>
#include <rvinterf/exitcodes.h>
#include "rxband.h"
#include "rxtables.h"

extern struct rxcal_band *rxcal_band;
extern int Gmagic, rx_calchan_values[];

upload_gmagic()
{
	struct rx_agc_params agcparams;

	do_rftr(RX_AGC_PARAMS, &agcparams, sizeof agcparams);
	agcparams.g_magic = htole16(Gmagic);
	do_rftw(RX_AGC_PARAMS, &agcparams, sizeof agcparams);
	return(0);
}

upload_rx_calchan()
{
	unsigned n;
	struct rx_calchan_entry calchan_table[RX_CALCHAN_ENTRIES];

	for (n = 0; n < rxcal_band->num_calchan_ranges; n++) {
		calchan_table[n].upper_bound =
			htole16(rxcal_band->calchan_ranges[n].upper_bound);
		calchan_table[n].agc_calib = htole16(rx_calchan_values[n]);
	}
	for (; n < RX_CALCHAN_ENTRIES; n++) {
		calchan_table[n].upper_bound = 0;
		calchan_table[n].agc_calib = 0;
	}
	do_rftw(RX_CAL_CHAN, calchan_table, sizeof calchan_table);
	return(0);
}