FreeCalypso > hg > fc-rfcal-tools
comparison autocal/rxcommon.c @ 49:1a0dbc746d57
autocal: Rx cal main engine implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 07:23:20 +0000 |
parents | 751f8d9efed0 |
children |
comparison
equal
deleted
inserted
replaced
48:201f27bd8dca | 49:1a0dbc746d57 |
---|---|
3 * fc-rfcal-gmagic and fc-rfcal-rxband. | 3 * fc-rfcal-gmagic and fc-rfcal-rxband. |
4 */ | 4 */ |
5 | 5 |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <unistd.h> | |
8 #include <rvinterf/l1tm.h> | 9 #include <rvinterf/l1tm.h> |
9 #include <rvinterf/exitcodes.h> | 10 #include <rvinterf/exitcodes.h> |
11 #include "l1stats.h" | |
10 #include "rxcaldefs.h" | 12 #include "rxcaldefs.h" |
11 | 13 |
12 l1tm_setup_for_rxcal() | 14 l1tm_setup_for_rxcal() |
13 { | 15 { |
14 do_rxpw(RX_AGC_ENA_FLAG, 0); | 16 do_rxpw(RX_AGC_ENA_FLAG, 0); |
36 sprintf(strbuf, "%s%d.%c", sign ? "-" : "", halfdb >> 1, | 38 sprintf(strbuf, "%s%d.%c", sign ? "-" : "", halfdb >> 1, |
37 halfdb & 1 ? '5' : '0'); | 39 halfdb & 1 ? '5' : '0'); |
38 return(0); | 40 return(0); |
39 } | 41 } |
40 | 42 |
43 static unsigned | |
41 rx_single_offset_meas(arfcn, offset) | 44 rx_single_offset_meas(arfcn, offset) |
42 unsigned arfcn; | 45 unsigned arfcn; |
43 char *offset; | 46 char *offset; |
44 { | 47 { |
45 char dbm[64], tsid_cmd[128]; | 48 char dbm[64], tsid_cmd[128]; |
49 struct l1stats l1st; | |
50 unsigned pm; | |
46 | 51 |
47 halfdb_to_string(RXCAL_SIGGEN_LEVEL, dbm); | 52 halfdb_to_string(RXCAL_SIGGEN_LEVEL, dbm); |
48 printf("Rx meas at ARFCN %u offset %s kHz, TL=%s dBm, AGC=%d dB\n", | 53 printf("Rx meas at ARFCN %u offset %s kHz, TL=%s dBm, AGC=%d dB\n", |
49 arfcn, offset, dbm, RXCAL_AGC_DB); | 54 arfcn, offset, dbm, RXCAL_AGC_DB); |
50 sprintf(tsid_cmd, "signal-gen-sine %u %s %s\n", arfcn, offset, dbm); | 55 sprintf(tsid_cmd, "signal-gen-sine %u %s %s\n", arfcn, offset, dbm); |
51 tsid_command(tsid_cmd); | 56 tsid_command(tsid_cmd); |
57 usleep(20000); | |
58 do_rfe(RX_TCH); | |
59 collect_auto_stats(&l1st); | |
60 collect_rfe_completion(); | |
61 if (!(l1st.bitmask & DSP_PM)) { | |
62 fprintf(stderr, "DUT error: no DSP_PM in auto-stats msg\n"); | |
63 exit(ERROR_TARGET); | |
64 } | |
65 pm = l1st.dsp_pm; | |
66 printf("DSP_PM=0x%04X, %u half-dBm\n", pm, (pm + 16) >> 5); | |
67 return(pm); | |
68 } | |
52 | 69 |
70 unsigned | |
71 rx_measure(arfcn) | |
72 unsigned arfcn; | |
73 { | |
74 unsigned pm1, pm2; | |
53 | 75 |
76 do_rfpw(TCH_ARFCN, arfcn); | |
77 pm1 = rx_single_offset_meas(arfcn, "+67"); | |
78 pm2 = rx_single_offset_meas(arfcn, "-67"); | |
79 return (pm1 + pm2 + 32) >> 6; | |
54 } | 80 } |