changeset 45:98abe6bd2042

autocal: scw implemented for Rx cal
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 05:48:04 +0000
parents 5018fd8eecce
children 751f8d9efed0
files autocal/Makefile autocal/l1meas.c autocal/rxcaldefs.h autocal/rxcommon.c
diffstat 4 files changed, 51 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/autocal/Makefile	Sat May 27 05:33:42 2017 +0000
+++ b/autocal/Makefile	Sat May 27 05:48:04 2017 +0000
@@ -3,8 +3,9 @@
 PROGS=	fc-rfcal-gmagic fc-rfcal-vcxo
 INSTBIN=/opt/freecalypso/bin
 
-GMAGIC_OBJS=	gmagicmain.o l1tmops.o rvinterf.o rxcommon.o sockopts.o \
-		tsidsock.o
+GMAGIC_OBJS=	gmagicmain.o l1meas.o l1tmops.o rvinterf.o rxcommon.o \
+		sockopts.o tsidsock.o
+
 VCXO_OBJS=	l1tmops.o rvinterf.o sockopts.o tsidsock.o vcxomain.o vcxomeas.o
 
 all:	${PROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autocal/l1meas.c	Sat May 27 05:48:04 2017 +0000
@@ -0,0 +1,41 @@
+/*
+ * In this module we are going to implement the functions for making
+ * measurements on the DUT via L1TM.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <rvinterf/pktmux.h>
+#include <rvinterf/tm3.h>
+#include <rvinterf/l1tm.h>
+#include <rvinterf/exitcodes.h>
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+do_scw(index, value)
+{
+	u_char cmdpkt[7];
+
+	cmdpkt[1] = STATS_CONFIG_WRITE;
+	cmdpkt[2] = index;
+	cmdpkt[3] = index >> 8;
+	cmdpkt[4] = value;
+	cmdpkt[5] = value >> 8;
+	l1tm_pkt_exch(cmdpkt, 5);
+	if (rvi_msg[3]) {
+		fprintf(stderr, "DUT error %u in response to scw\n",
+			rvi_msg[3]);
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg_len != 6) {
+		fprintf(stderr, "DUT error: scw response wrong length\n");
+		exit(ERROR_TARGET);
+	}
+	if (rvi_msg[4] != index) {
+		fprintf(stderr, "DUT error: scw response wrong index\n");
+		exit(ERROR_TARGET);
+	}
+	return(0);
+}
--- a/autocal/rxcaldefs.h	Sat May 27 05:33:42 2017 +0000
+++ b/autocal/rxcaldefs.h	Sat May 27 05:48:04 2017 +0000
@@ -2,3 +2,5 @@
 
 #define	RXCAL_SIGGEN_LEVEL	149	/* -74.5 dBm */
 #define	RXCAL_AGC_DB		34
+
+#define	RXCAL_LOOP_COUNT	50
--- a/autocal/rxcommon.c	Sat May 27 05:33:42 2017 +0000
+++ b/autocal/rxcommon.c	Sat May 27 05:48:04 2017 +0000
@@ -5,8 +5,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <strings.h>
 #include <rvinterf/l1tm.h>
 #include <rvinterf/exitcodes.h>
 #include "rxcaldefs.h"
@@ -16,6 +14,10 @@
 	do_rxpw(RX_AGC_ENA_FLAG, 0);
 	do_rxpw(RX_AGC_GAIN, RXCAL_AGC_DB);
 	do_rfpw(AFC_ENA_FLAG, 0);
-	/* scw settings to be added */
+	do_scw(LOOPS, RXCAL_LOOP_COUNT);
+	do_scw(AUTO_RESULT_LOOPS, RXCAL_LOOP_COUNT);
+	do_scw(AUTO_RESET_LOOPS, RXCAL_LOOP_COUNT);
+	do_scw(STAT_TYPE, ACCUMULATED_RX_STATS);
+	do_scw(STAT_BITMASK, DSP_PM);
 	return(0);
 }