view autocal/txcalchan.c @ 102:80281b67511f

fc-rfcal-txband: fixed bug in the corner case when the target power level is above the highest basis point
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 12 Aug 2017 08:47:09 +0000
parents 3f63e71b6422
children 4ce87a30383f
line wrap: on
line source

/*
 * This module contains the code for handling Tx calchan tables.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <endian.h>
#include <rvinterf/l1tm.h>
#include <rvinterf/exitcodes.h>
#include "txband.h"
#include "txcalchan.h"

extern struct txcal_band *txcal_band;

unsigned tx_calchan_values[TX_CALCHAN_TABLES][TX_CALCHAN_ENTRIES];

init_tx_calchan()
{
	unsigned i, j;

	for (i = 0; i < TX_CALCHAN_TABLES; i++)
		for (j = 0; j < TX_CALCHAN_ENTRIES; j++)
			tx_calchan_values[i][j] = 128;
	return(0);
}

upload_tx_calchan()
{
	unsigned i, j;
	struct tx_calchan_entry l1_table[TX_CALCHAN_TABLES][TX_CALCHAN_ENTRIES];

	for (i = 0; i < TX_CALCHAN_TABLES; i++) {
		for (j = 0; j < TX_CALCHAN_ENTRIES; j++) {
			l1_table[i][j].arfcn_limit =
			    htole16(txcal_band->calchan_ranges[j].upper_bound);
			l1_table[i][j].chan_cal =
				htole16(tx_calchan_values[i][j]);
		}
	}
	do_rftw(TX_CAL_CHAN, l1_table, sizeof l1_table);
	return(0);
}