view autocal/txcalchan.c @ 106:661d122ed8e7

fc-rfcal-txband: added delay which should prevent intermittent fw crash
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Dec 2017 16:06:07 +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);
}