changeset 77:3f63e71b6422

fc-rfcal-txband: implemented initial calchan clearing
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 15 Jul 2017 20:25:31 +0000
parents 5c3574f8c8c1
children 1d3dd589a857
files autocal/Makefile autocal/txbandmain.c autocal/txcalchan.c
diffstat 3 files changed, 48 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/autocal/Makefile	Sat Jul 15 20:08:55 2017 +0000
+++ b/autocal/Makefile	Sat Jul 15 20:25:31 2017 +0000
@@ -11,7 +11,7 @@
 		rxupload.o sockopts.o tsidsock.o
 
 TXBAND_OBJS=	l1tmops.o rvinterf.o sockopts.o tsidsock.o txbandmain.o \
-		txcalconf.o txpwrmeas.o
+		txcalchan.o txcalconf.o txpwrmeas.o
 
 TXBASIS_OBJS=	l1tmops.o rvinterf.o tsidsock.o txpwrmeas.o txstandbas.o
 
--- a/autocal/txbandmain.c	Sat Jul 15 20:08:55 2017 +0000
+++ b/autocal/txbandmain.c	Sat Jul 15 20:25:31 2017 +0000
@@ -114,5 +114,9 @@
 	do_rfpw(TCH_ARFCN, txcal_band->main_arfcn);
 	do_rfpw(AFC_ENA_FLAG, 0);
 
+	/* any previous calchan needs to be cleared out first */
+	init_tx_calchan();
+	upload_tx_calchan();
+
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autocal/txcalchan.c	Sat Jul 15 20:25:31 2017 +0000
@@ -0,0 +1,43 @@
+/*
+ * 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);
+}