annotate autocal/txbasis.c @ 70:e35da125c937

fc-cmu200d: CMU200 external att setting implemented in RF analyzer mode
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 Jul 2017 05:03:10 +0000
parents df827df6db82
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the main() function for fc-rfcal-txbasis.
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/l1tm.h>
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/exitcodes.h>
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "stdband.h"
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern char *rvif_socket_pathname, *tsid_socket_pathname;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern double tx_power_meas();
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static struct band {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 char *name;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 unsigned rfpw_std_band;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned default_arfcn;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 } bands[] = {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {"850", RFPW_STD_BAND_850, 190},
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {"900", RFPW_STD_BAND_900, 40},
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 {"1800", RFPW_STD_BAND_1800, 700},
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {"1900", RFPW_STD_BAND_1900, 660},
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 {0, 0, 0}
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 };
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 static struct band *selected_band;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 static unsigned arfcn, arfcn_set;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 cmdline_options(argc, argv)
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 char **argv;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 extern char *optarg;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 int c;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 while ((c = getopt(argc, argv, "a:s:t:")) != EOF) {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 switch (c) {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 case 'a':
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 arfcn = atoi(optarg);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 arfcn_set = 1;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 continue;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 case 's':
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 rvif_socket_pathname = optarg;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 continue;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 case 't':
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 tsid_socket_pathname = optarg;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 continue;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 case '?':
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 default:
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /* error msg already printed */
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 exit(ERROR_USAGE);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 }
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 return(0);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 select_band(bandname)
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 char *bandname;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 struct band *band;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 for (band = bands; band->name; band++)
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 if (!strcmp(band->name, bandname))
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 break;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 if (!band->name) {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 fprintf(stderr, "error: \"%s\" is not a known band\n",
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 bandname);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 exit(ERROR_USAGE);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 selected_band = band;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (!arfcn_set)
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 arfcn = band->default_arfcn;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 return(0);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 main(argc, argv)
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 char **argv;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 extern int optind;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 int apc;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 double meas;
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 cmdline_options(argc, argv);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 if (argc - optind < 2) {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 fprintf(stderr, "usage: %s band apc...\n", argv[0]);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 exit(ERROR_USAGE);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 select_band(argv[optind++]);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 connect_rvinterf_socket();
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 connect_tsid_socket();
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 setlinebuf(stdout); /* to allow logging with tee */
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 printf("Preparing RF test system for %s MHz Tx calibration\n",
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 selected_band->name);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 do_txpwr_cal_setup(selected_band->name, arfcn);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 printf("Putting the DUT into Test Mode\n");
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 do_tms(1);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 do_rfpw(TCH_ARFCN, arfcn);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 do_rfpw(AFC_ENA_FLAG, 0);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 printf("Starting RF Tx on the DUT\n");
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 do_rfe(RX_TX_TCH);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 for (; optind < argc; optind++) {
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 apc = atoi(argv[optind]);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 do_txpw(TX_APC_DAC, apc);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 usleep(20000);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 meas = tx_power_meas();
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 printf("APC DAC=%d: %.2f dBm\n", apc, meas);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 }
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 printf("Stopping RF Tx on the DUT\n");
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 do_rfe(STOP_ALL);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 exit(0);
df827df6db82 fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 }