diff autocal/vcxomain.c @ 28:ba4b6877e227

fc-rfcal-vcxo: afcparams computation implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 22 May 2017 23:36:14 +0000
parents 841dd03d5c85
children 4cd55371d3e4
line wrap: on
line diff
--- a/autocal/vcxomain.c	Mon May 22 23:10:34 2017 +0000
+++ b/autocal/vcxomain.c	Mon May 22 23:36:14 2017 +0000
@@ -4,9 +4,11 @@
 
 #include <math.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <rvinterf/l1tm.h>
 #include <rvinterf/exitcodes.h>
+#include "afcparams.h"
 #include "stdband.h"
 
 #define	VCXOCAL_BAND		900
@@ -23,6 +25,8 @@
 static int dac_init_int;
 static float Psi_sta, Psi_st;
 
+struct afcparams afcparams_host, afcparams_arm;
+
 prepare_rf_test_system()
 {
 	char cmd[80];
@@ -97,7 +101,27 @@
 	Psi_sta = 2.0f * (float)M_PI * lin_a / 270833.0f;
 	Psi_st = Psi_sta * 0.8f;
 
-	/* afcparams output TBD */
+	/* compute and fill afcparams */
+	afcparams_host.psi_sta_inv = (unsigned)(1.0f / Psi_sta);
+	afcparams_host.psi_st = (unsigned)(Psi_st * 65536.0f);
+	afcparams_host.psi_st_32 = (unsigned)(Psi_st * 65536.0f * 65536.0f);
+	afcparams_host.psi_st_inv = (unsigned)(1.0f / Psi_st);
+	afcparams_host.dac_center = (int)(dac_init * 8.0f);
+	afcparams_host.dac_min = (int)(dac_min * 8.0f);
+	afcparams_host.dac_max = (int)(dac_max * 8.0f);
+	afcparams_host.snr_thr = 2560;
+
+	/* print them out */
+	printf("afcparams Psi_sta_inv: %u\n", afcparams_host.psi_sta_inv);
+	printf("afcparams Psi_st: %u\n", afcparams_host.psi_st);
+	printf("afcparams Psi_st_32: %u\n", afcparams_host.psi_st_32);
+	printf("afcparams Psi_st_inv: %u\n", afcparams_host.psi_st_inv);
+	printf("afcparams DAC_INIT*8: %d\n", afcparams_host.dac_center);
+	printf("afcparams DAC_MIN*8: %d\n", afcparams_host.dac_min);
+	printf("afcparams DAC_MAX*8: %d\n", afcparams_host.dac_max);
+	printf("afcparams snr_thr: %d\n", afcparams_host.snr_thr);
+
+	/* conversion to LE and sending to L1 remain to be implemented */
 
 	exit(0);
 }