annotate autocal/vcxomain.c @ 24:0b6881281d86

fc-rfcal-vcxo ready for first test
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 22 May 2017 22:00:36 +0000
parents 9a9fd9ebe799
children a2e4da9d85cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the main() function for fc-rfcal-vcxo.
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <rvinterf/l1tm.h>
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <rvinterf/exitcodes.h>
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "stdband.h"
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #define VCXOCAL_BAND 900
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #define VCXOCAL_BAND_RFPW RFPW_STD_BAND(6, 0)
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #define VCXOCAL_ARFCN 40
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
24
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
15 extern float vcxo_freq_meas();
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
16
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
17 static float freq_max_neg, freq_max_pos;
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
18 static float lin_a, lin_b, lin_a2, lin_b2;
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
19 static int center_search_start;
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
20
23
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
21 prepare_rf_test_system()
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
22 {
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
23 char cmd[80];
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
24
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
25 printf("Preparing RF test system for VCXO calibration\n");
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
26 sprintf(cmd, "vcxo-cal-setup %d %d\n", VCXOCAL_BAND, VCXOCAL_ARFCN);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
27 tsid_command(cmd);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
28 return(0);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
29 }
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
30
21
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 main(argc, argv)
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 char **argv;
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 socket_pathname_options(argc, argv);
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 connect_rvinterf_socket();
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 connect_tsid_socket();
23
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
37 prepare_rf_test_system();
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
38
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
39 printf("Putting the DUT into Test Mode\n");
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
40 do_tms(1);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
41 do_rfpw(STD_BAND_FLAG, VCXOCAL_BAND_RFPW);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
42 do_rfpw(TCH_ARFCN, VCXOCAL_ARFCN);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
43 do_rfpw(AFC_ENA_FLAG, 0);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
44 do_txpw(TX_PWR_LEVEL, 12);
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
45 printf("Starting RF Tx on the DUT\n");
9a9fd9ebe799 autocal/vcxomain.c: coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
46 do_rfe(RX_TX_TCH);
21
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
24
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
48 /* initial measurements at the DAC extremes */
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
49 freq_max_neg = vcxo_freq_meas(-2048, "max-neg");
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
50 freq_max_pos = vcxo_freq_meas(2048, "max-pos");
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
51 lin_a = (freq_max_pos - freq_max_neg) / 4096.0f;
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
52 lin_b = freq_max_pos - lin_a * 2048.0f;
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
53 center_search_start = -lin_b / lin_a;
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
54 printf("Center search start DAC value: %d\n", center_search_start);
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
55 vcxo_freq_meas(center_search_start, "center");
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
56 vcxo_freq_meas(center_search_start - 100, "center-delta");
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
57 vcxo_freq_meas(center_search_start + 100, "center+delta");
21
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
24
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
59 printf("Stopping RF Tx on the DUT\n");
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
60 do_rfe(STOP_ALL);
0b6881281d86 fc-rfcal-vcxo ready for first test
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
61 exit(0);
21
a3f48378658d autocal: beginning of fc-rfcal-vcxo
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }