annotate chipsetsw/layer1/p_cfile/l1p_ctl.c @ 321:89e6a6edf033

l1p_driv.c: l1pddsp_meas_read() reconstructed
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 04 Oct 2017 06:09:00 +0000
parents ec71c9658110
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1 /************* Revision Controle System Header *************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
2 * GSM Layer 1 software
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
3 * L1P_CTL.C
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
4 *
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
5 * Filename l1p_ctl.c
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
6 * Copyright 2003 (C) Texas Instruments
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
7 *
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
8 ************* Revision Controle System Header *************/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
9
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
10 #include "l1_macro.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
11 #include "l1_confg.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
12
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
13 #if L1_GPRS
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
14 #if (CODE_VERSION == SIMULATION)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
15 #include <string.h>
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
16 #include "l1_types.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
17 #include "sys_types.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
18 #include "l1_const.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
19 #include "l1_time.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
20 #include "l1_signa.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
21 #if TESTMODE
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
22 #include "l1tm_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
23 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
24 #if (AUDIO_TASK == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
25 #include "l1audio_const.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
26 #include "l1audio_cust.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
27 #include "l1audio_signa.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
28 #include "l1audio_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
29 #include "l1audio_msgty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
30 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
31 #if (L1_GTT == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
32 #include "l1gtt_const.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
33 #include "l1gtt_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
34 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
35 #if (L1_MP3 == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
36 #include "l1mp3_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
37 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
38 #if (L1_MIDI == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
39 #include "l1midi_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
40 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
41 #include "l1_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
42 #include "cust_os.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
43 #include "l1_msgty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
44 #include "l1_varex.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
45 #include "l1_proto.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
46 #include "l1_mftab.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
47 #include "l1_tabs.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
48 #include "l1_ver.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
49
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
50 #include "l1_ctl.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
51
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
52 #include "l1p_cons.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
53 #include "l1p_msgt.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
54 #include "l1p_deft.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
55 #include "l1p_vare.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
56 #include "l1p_sign.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
57 #if (OP_L1_STANDALONE == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
58 #ifdef _INLINE
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
59 #define INLINE static inline // Inline functions when -v option is set
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
60 #else // when the compiler is ivoked.
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
61 #define INLINE
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
62 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
63 #endif //0maps00090550
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
64 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
65 #include <string.h>
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
66 #include "l1_types.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
67 #include "sys_types.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
68 #include "l1_const.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
69 #include "l1_time.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
70 #include "l1_signa.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
71
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
72 #if (RF_FAM == 61)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
73 #include "tpudrv61.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
74 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
75
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
76 #if TESTMODE
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
77 #include "l1tm_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
78 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
79 #if (AUDIO_TASK == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
80 #include "l1audio_const.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
81 #include "l1audio_cust.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
82 #include "l1audio_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
83 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
84 #if (L1_GTT == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
85 #include "l1gtt_const.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
86 #include "l1gtt_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
87 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
88 #if (L1_MP3 == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
89 #include "l1mp3_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
90 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
91 #if (L1_MIDI == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
92 #include "l1midi_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
93 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
94 #include "l1_defty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
95 #include "cust_os.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
96 #include "l1_msgty.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
97 #include "l1_varex.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
98 #include "l1_proto.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
99
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
100 #include "l1_ctl.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
101
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
102 #include "l1p_cons.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
103 #include "l1p_msgt.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
104 #include "l1p_deft.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
105 #include "l1p_vare.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
106 #include "l1p_sign.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
107 #if (OP_L1_STANDALONE == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
108 #ifdef _INLINE
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
109 #define INLINE static inline // Inline functions when -v option is set
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
110 #else // when the compiler is ivoked.
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
111 #define INLINE
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
112 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
113 #endif //omaps00090550
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
114 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
115
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
116 #if(RF_FAM == 61)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
117 #include "l1_rf61.h"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
118 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
119
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
120
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
121 // Macro definition
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
122 //-----------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
123 #define min(value1,value2) \
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
124 value1 < value2 ? value1 : value2
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
125
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
126 // External prototypes
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
127 //--------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
128
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
129 WORD8 l1ctl_encode_delta1(UWORD16 radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
130
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
131 /*********************************************************/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
132 /* GPRS AGC Algorithms */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
133 /*********************************************************/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
134
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
135 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
136 /* l1pctl_pagc_ctrl() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
137 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
138 /* Description: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
139 /* =========== */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
140 /* Based on the same principle as the one used for PAGC */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
141 /* algorithm except that we also feed the beacon FIFO */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
142 /* with IL measured on other carriers (Pb parameter is */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
143 /* applied) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
144 /* This function is used in the control phase of PCCCH, */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
145 /* serving PBCCH and PTCCH reading tasks to determine */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
146 /* which AGC and lna_off must apply */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
147 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
148 /* WARNING: in the layer 1 code, input levels IL(l1) use */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
149 /* format 7.1: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
150 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
151 /* * IL(l1) = - 2 x IL * */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
152 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
153 /* -> Reversed sign, reversed test conditions */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
154 /* -> max replaced by min */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
155 /* ex: if IL -120 dBm, IL(l1) = 240 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
156 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
157 void l1pctl_pagc_ctrl(WORD8 *agc, UWORD8 *lna_off, UWORD16 radio_freq, UWORD8 serving_cell)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
158 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
159 UWORD8 pb;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
160 WORD16 input_level, new_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
161 WORD32 freq_index;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
162 UWORD16 beacon_frequency;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
163 UWORD8 *lna_off_ptr;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
164 UWORD8 curve_id;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
165
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
166 // We memorize the LNA state used for other serving frequencies that can be used
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
167 // in Packet idle mode
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
168 static UWORD8 lna_off_others = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
169
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
170 if (serving_cell == TRUE)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
171 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
172 beacon_frequency = l1a_l1s_com.Scell_info.radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
173 pb = l1a_l1s_com.Scell_info.pb;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
174 lna_off_ptr = &lna_off_others;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
175 curve_id = MAX_ID;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
176 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
177 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
178 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
179 beacon_frequency = l1pa_l1ps_com.pbcchn.bcch_carrier;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
180 pb = l1pa_l1ps_com.pbcchn.pb;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
181 lna_off_ptr = lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
182 curve_id = AV_ID;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
183 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
184
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
185 #if(L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
186 freq_index = beacon_frequency - l1_config.std.radio_freq_index_offset;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
187 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
188 freq_index = l1_multiband_radio_freq_convert_into_operative_radio_freq(beacon_frequency);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
189 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
190
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
191
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
192 // If the downlink channel is decoded on the beacon frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
193 if (radio_freq == beacon_frequency)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
194 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
195 // Downlink task on the serving beacon: process AGC according to the "beacon IL"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
196 input_level = l1a_l1s_com.last_input_level[freq_index].input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
197
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
198 // lna_off already processed in the read phase
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
199 *lna_off = l1a_l1s_com.last_input_level[freq_index].lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
200 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
201
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
202 // If the downlink channel is decoded on a frequency other than the beacon
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
203 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
204 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
205
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
206 // Process AGC according to "beacon IL + Pb"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
207 input_level = (WORD16) (l1a_l1s_com.last_input_level[freq_index].input_level + pb);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
208
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
209 // IL_2_AGC_xx array size
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
210 if (input_level>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
211 input_level = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
212
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
213 // lna_off must be processed in the control phase because input_level
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
214 // depends on last_input_level and Pb, and last_input_level or pb can have changed
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
215 // at any time
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
216
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
217 // New calibrated IL to reach on radio freq other than beacon
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
218 new_calibrated_IL = (WORD16) (input_level - l1ctl_encode_delta1(radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
219 - l1ctl_encode_delta2(radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
220
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
221 // IL_2_AGC_xx array size
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
222 if (new_calibrated_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
223 new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
224
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
225 // lna_off computing...
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
226 l1ctl_encode_lna((UWORD8)(new_calibrated_IL>>1),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
227 lna_off_ptr,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
228 radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
229
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
230 *lna_off = *lna_off_ptr;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
231 } // End if "radio_freq != beacon_frequency"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
232
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
233 // Process AGC to apply
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
234 *agc = Cust_get_agc_from_IL(radio_freq,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
235 input_level >> 1,
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
236 curve_id);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
237
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
238 // Store lna_off and input_level field used for current CTRL in order to be able
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
239 // to build IL from pm in READ phase.
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
240 l1a_l1s_com.Scell_used_IL.input_level = (UWORD8)input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
241 l1a_l1s_com.Scell_used_IL.lna_off = *lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
242
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
243 } // End of "l1pctl_pagc_ctrl"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
244
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
245 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
246 /* l1pctl_pagc_read() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
247 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
248 /* Description : */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
249 /* =========== */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
250 /* Based on the same principle as the one used for PAGC */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
251 /* algorithm except that we also feed the beacon FIFO */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
252 /* with IL measured on other carriers (Pb parameter is */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
253 /* applied) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
254 /* This function is used in the read phase of PCCCH and */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
255 /* serving PBCCH reading tasks to determine the IL value */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
256 /* store it in the FIFO and find the next IL to use */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
257 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
258 /* WARNING: in the layer 1 code, input levels IL(l1) use */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
259 /* format 7.1: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
260 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
261 /* * IL(l1) = - 2 x IL * */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
262 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
263 /* -> Reversed sign, reversed test conditions */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
264 /* -> max replaced by min */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
265 /* ex: if IL -120 dBm, IL(l1) = 240 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
266 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
267 UWORD8 l1pctl_pagc_read(UWORD8 pm, UWORD16 radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
268 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
269 UWORD8 i, new_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
270 WORD8 delta1_freq, delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
271 WORD16 delta_drp_gain=0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
272 UWORD16 lna_value;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
273 WORD16 used_agc, current_IL, new_calibrated_IL, current_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
274 WORD32 serving_index;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
275 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
276 UWORD16 arfcn;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
277 #endif
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
278 UWORD8 lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
279 UWORD16 dco_algo_ctl_pw_temp = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
280 UWORD8 if_ctl = 0;
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
281 #if (RF_FAM == 61) && (CODE_VERSION != SIMULATION)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
282 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GPRS;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
283 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
284
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
285 #if (L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
286 serving_index = l1a_l1s_com.Scell_info.radio_freq - l1_config.std.radio_freq_index_offset;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
287
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
288 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
289 serving_index = l1_multiband_radio_freq_convert_into_operative_radio_freq(l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
290 #endif /*if (L1_FF_MULTIBAND == 0)*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
291
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
292
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
293 // Calibration factors
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
294 delta1_freq = l1ctl_encode_delta1(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
295 delta2_freq = l1ctl_encode_delta2(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
296
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
297 // AGC used in the control phase (format F7.1)
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
298 used_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID)) << 1;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
299
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
300 // LNA attenuation
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
301 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
302
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
303 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
304 // DRP correction
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
305 #if (L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
306 arfcn = Convert_l1_radio_freq(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
307 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
308 arfcn=radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
309 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
310
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
311 #if (CODE_VERSION != SIMULATION)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
312
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
313 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID ,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
314 l1a_l1s_com.Scell_used_IL_dd.input_level,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
315 radio_freq,if_threshold);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
316 lna_off = l1a_l1s_com.Scell_used_IL_dd.lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
317 delta_drp_gain = drp_gain_correction(arfcn, lna_off, used_agc); // F7.1 format
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
318 if(if_ctl == IF_100KHZ_DSP){
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
319 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
320 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
321 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
322 delta_drp_gain += SCF_ATTENUATION_LIF_120KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
323 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
324
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
325 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
326 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
327
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
328 // current_IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
329
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
330 if (0==pm) // Check and filter illegal pm value by using last valid IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
331 {
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
332 current_IL = l1a_l1s_com.last_input_level[serving_index].input_level - lna_value;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
333 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
334 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
335 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
336 current_IL = -(pm - (used_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
337
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
338 // IL normalization to beacon (ILnorm = IL - Pb)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
339 if (radio_freq != l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
340 current_IL -= l1a_l1s_com.Scell_info.pb;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
341 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
342
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
343 // Calibrated IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
344 // NOTE: calibrated_IL is normalized to beacon. This is needed for the
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
345 // pccch_lev processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
346 current_calibrated_IL = (WORD16) (current_IL - delta1_freq - delta2_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
347
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
348 // Protect IL stores against overflow
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
349 if (current_calibrated_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
350 current_calibrated_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
351 if (current_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
352 current_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
353
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
354 // FIFO management
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
355 for (i=3;i>0;i--)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
356 l1a_l1s_com.Scell_info.buff_beacon[i] = l1a_l1s_com.Scell_info.buff_beacon[i-1];
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
357 l1a_l1s_com.Scell_info.buff_beacon[0] = (UWORD8)current_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
358
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
359 // Find min IL in FIFO
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
360 new_IL = l1ctl_find_max(l1a_l1s_com.Scell_info.buff_beacon, 4);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
361
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
362 // Input levels are always stored with lna_on
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
363 new_calibrated_IL = (WORD16) (new_IL - delta1_freq - delta2_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
364
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
365 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
366
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
367 l1ctl_encode_lna( (UWORD8)(new_calibrated_IL>>1),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
368 &(l1a_l1s_com.last_input_level[serving_index].lna_off),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
369 radio_freq );
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
370
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
371 l1a_l1s_com.last_input_level[serving_index].input_level = new_IL +
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
372 l1a_l1s_com.last_input_level[serving_index].lna_off * l1ctl_get_lna_att(radio_freq);
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
373
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
374 return((UWORD8)current_calibrated_IL);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
375 } // End of "l1pctl_pagc_read"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
376
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
377 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
378 /* l1pctl_transfer_agc_init() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
379 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
380 /* Description : */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
381 /* =========== */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
382 /* Packet transfer AGC algorithm initialization */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
383 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
384 void l1pctl_transfer_agc_init()
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
385 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
386 WORD16 calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
387 UWORD16 radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
388 WORD32 serving_index;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
389 WORD16 input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
390
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
391 #if (L1_FF_MULTIBAND ==0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
392 serving_index = l1a_l1s_com.Scell_info.radio_freq - l1_config.std.radio_freq_index_offset;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
393
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
394 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
395 serving_index = l1_multiband_radio_freq_convert_into_operative_radio_freq(l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
396 #endif /*if L1_FF_MULTIBAND*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
397
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
398
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
399 // Daughter frequencies input level initialization
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
400 //------------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
401 if (l1pa_l1ps_com.transfer.aset->dl_pwr_ctl.p0 == 255)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
402 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
403 // No power control mode AGC algorithm
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
404 input_level = (WORD16) (l1a_l1s_com.last_input_level[serving_index].input_level + l1a_l1s_com.Scell_info.pb);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
405
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
406 // Set fn_select to current_fn
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
407 l1ps.fn_select = l1s.actual_time.fn;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
408 // Initialize algorithm in "SEARCH" phase
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
409 l1ps.phase = SEARCH;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
410 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
411 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
412 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
413 // Downlink power control AGC algorithms
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
414 if (l1pa_l1ps_com.transfer.aset->dl_pwr_ctl.bts_pwr_ctl_mode == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
415 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
416 // BTS Power control mode A
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
417 input_level = (WORD16) (l1a_l1s_com.last_input_level[serving_index].input_level +
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
418 l1pa_l1ps_com.transfer.aset->dl_pwr_ctl.p0 + 10);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
419
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
420 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
421 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
422 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
423 // BTS power control mode B
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
424 input_level = (WORD16) (l1a_l1s_com.last_input_level[serving_index].input_level +
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
425 l1pa_l1ps_com.transfer.aset->dl_pwr_ctl.p0);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
426
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
427 // Initialization: PR = P0
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
428 l1ps.last_PR_good = l1pa_l1ps_com.transfer.aset->dl_pwr_ctl.p0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
429 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
430 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
431
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
432 if (input_level>INDEX_MAX) input_level = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
433 l1a_l1s_com.Scell_info.transfer_meas.input_level = (UWORD8)input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
434
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
435
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
436 // Daughter frequencies lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
437 //----------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
438
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
439 // We need to know on which frequency band we work
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
440 if (!l1pa_l1ps_com.transfer.aset->freq_param.chan_sel.h)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
441 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
442 // Single frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
443 radio_freq = l1pa_l1ps_com.transfer.aset->freq_param.chan_sel.rf_channel.single_rf.radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
444 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
445 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
446 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
447 // Frequency hopping: all frequencies of the frequency list are on the same band
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
448 // We take the first frequency of the list
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
449 radio_freq = l1pa_l1ps_com.transfer.aset->freq_param.freq_list.rf_chan_no.A[0];
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
450 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
451
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
452 calibrated_IL = (WORD16) (l1a_l1s_com.Scell_info.transfer_meas.input_level
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
453 - l1ctl_encode_delta1(radio_freq) - l1ctl_encode_delta2(radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
454 - l1a_l1s_com.last_input_level[serving_index].lna_off * l1ctl_get_lna_att(radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
455
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
456 if (calibrated_IL>INDEX_MAX) calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
457
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
458 l1ctl_encode_lna((UWORD8)(calibrated_IL>>1), &(l1a_l1s_com.Scell_info.transfer_meas.lna_off), radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
459
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
460 } // End of "l1pctl_transfer_agc_init"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
461
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
462 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
463 /* l1pctl_transfer_agc_ctrl() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
464 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
465 /* Description : */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
466 /* =========== */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
467 /* This function is used in the control phase of PDTCH/D */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
468 /* to determine which AGC and lna_off must apply */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
469 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
470 void l1pctl_transfer_agc_ctrl(WORD8 *agc, UWORD8 *lna_off, UWORD16 radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
471 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
472 T_INPUT_LEVEL *selected_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
473 #if(L1_FF_MULTIBAND == 1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
474 UWORD16 operative_radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
475 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
476
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
477
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
478 // input_level selection
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
479 if (radio_freq == l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
480 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
481 // Beacon frequency input_level used for AGC processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
482 #if(L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
483 selected_IL = &l1a_l1s_com.last_input_level[l1a_l1s_com.Scell_info.radio_freq
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
484 - l1_config.std.radio_freq_index_offset];
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
485
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
486 #else // L1_FF_MULTIBAND = 1 below
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
487
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
488 operative_radio_freq =
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
489 l1_multiband_radio_freq_convert_into_operative_radio_freq(l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
490 selected_IL = &(l1a_l1s_com.last_input_level[operative_radio_freq]);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
491
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
492
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
493 #endif // #if(L1_FF_MULTIBAND == 0) else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
494
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
495 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
496 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
497 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
498 // Daughter frequency input_level used for AGC processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
499 selected_IL = &l1a_l1s_com.Scell_info.transfer_meas;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
500 }
312
701fb3242432 l1p_ctl.c: l1pctl_transfer_agc_ctrl() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 311
diff changeset
501 *agc = Cust_get_agc_from_IL(radio_freq,selected_IL->input_level >> 1, MAX_ID);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
502 *lna_off = selected_IL->lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
503
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
504 // Store lna_off and input_level field used for current CTRL in order to be able
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
505 // to build IL from pm in READ phase.
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
506 l1a_l1s_com.Scell_used_IL.input_level = selected_IL->input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
507 l1a_l1s_com.Scell_used_IL.lna_off = *lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
508
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
509 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
510
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
511 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
512 /* l1pctl_npc_agc_read() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
513 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
514 /* Description : */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
515 /* =========== */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
516 /* AGC algorithm in packet transfer used when */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
517 /* NO POWER CONTROL is done by the BTS. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
518 /* This function is used during the read phase of PDTCH: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
519 /* 1- to determine the IL value for each timeslot in each*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
520 /* TDMA */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
521 /* 2- to find the IL value to use for the next PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
522 /* block */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
523 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
524 /* Algorithm */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
525 /* --------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
526 /* For each timeslot i used for PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
527 /* IL(i) = fct(used AGC, pm) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
528 /* if (beacon) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
529 /* ILmax_beacon = max(ILmax_beacon, IL(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
530 /* else */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
531 /* ILmax_others(i) = max(IL(i), ILmax_others(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
532 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
533 /* If (burst_nb == 3) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
534 /* If (ILmax_beacon was found during the block) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
535 /* FIFO[beacon] updated with ILmax_beacon */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
536 /* transfer_meas = max(FIFO[beacon]) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
537 /* Reset ILmax_beacon */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
538 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
539 /* For each timeslot i used for PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
540 /* if (CRC good) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
541 /* ILmax_correct = max(ILmax_correct, */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
542 /* ILmax_others(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
543 /* else */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
544 /* ILmax_not_correct = max(ILmax_not_correct, */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
545 /* ILmax_others(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
546 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
547 /* If (no ILmax_correct was found) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
548 /* ILselected = ILmax_correct */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
549 /* FNselected = current FN */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
550 /* else */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
551 /* DeltaFN = (current FN - FNselected) % MAX_FN */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
552 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
553 /* if (DeltaFN < 78) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
554 /* ILweighted = ILselected * (1 - DeltaFN/78) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
555 /* - 120 * DeltaFN /78 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
556 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
557 /* if (ILweighted < -120) ILweighted = -120 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
558 /* if (ILmax_not_correct > ILweighted) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
559 /* ILselected = ILmax_not_correct */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
560 /* FNselected = current FN */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
561 /* else */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
562 /* ILselected = -120 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
563 /* FNselected = current FN */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
564 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
565 /* Reset ILmax_others[8] */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
566 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
567 /* WARNING: in the layer 1 code, input levels IL(l1) use */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
568 /* format 7.1: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
569 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
570 /* * IL(l1) = - 2 x IL * */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
571 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
572 /* -> Reversed sign, reversed test conditions */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
573 /* -> max replaced by min */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
574 /* ex: if IL -120 dBm, IL(l1) = 240 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
575 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
576 /* Parameters */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
577 /* ---------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
578 /* "calibrated_IL[8]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
579 /* contains the IL found on timeslots */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
580 /* used for PDCH/D. These ILs can be used to process */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
581 /* RXLEV values. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
582 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
583 /* "*pdsp_db_r_ptr" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
584 /* Pointer on the DSP DB Read page, used to extract */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
585 /* pm values, burst number and timeslot allocated */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
586 /* for downlink PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
587 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
588 /* "*pdsp_ndb_ptr" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
589 /* Pointer on the DSP NDB page, used to extract the */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
590 /* CRC value for each decoded burst */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
591 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
592 /* Global parameters */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
593 /* ----------------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
594 /* "l1a_l1s_com.Scell_info.transfer_meas.input_level" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
595 /* "l1a_l1s_com.Scell_info.transfer_meas.lna_off" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
596 /* Used to store the ILselected and the associated */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
597 /* lna_off value. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
598 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
599 /* "l1a_l1s_com.Scell_info.fn_select" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
600 /* Used to store the FNselected value. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
601 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
602 /* "l1a_l1s_com.last_input_level[freq index] */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
603 /* .input_level */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
604 /* .lna_off" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
605 /* Used to store the beacon input level and */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
606 /* the associated lna_off value. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
607 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
608 /* "l1ps.transfer_beacon_buf[4]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
609 /* FIFO[beacon] */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
610 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
611 /* "l1ps.ILmin_beacon" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
612 /* "l1ps.ILmin_others[8]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
613 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
614 void l1pctl_npc_agc_read(UWORD8 calibrated_IL[8], T_DB_DSP_TO_MCU_GPRS *pdsp_db_r_ptr,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
615 T_NDB_MCU_DSP_GPRS *pdsp_ndb_ptr)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
616 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
617 UWORD8 ts;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
618 UWORD8 rx_no = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
619 UWORD8 bit_mask = 0x80;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
620 UWORD8 ILmin_correct = 255;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
621 UWORD8 ILmin_not_correct = 255;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
622 WORD8 delta1_freq, delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
623 WORD16 delta_drp_gain=0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
624 UWORD16 radio_freq, lna_value;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
625 WORD16 used_agc;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
626 WORD32 serving_index;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
627 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
628 UWORD16 arfcn;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
629 #endif
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
630 UWORD8 lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
631 UWORD16 dco_algo_ctl_pw_temp = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
632 UWORD8 if_ctl = 0;
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
633 #if (RF_FAM == 61) && (CODE_VERSION != SIMULATION)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
634 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GPRS;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
635 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
636
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
637 #if(L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
638 serving_index = l1a_l1s_com.Scell_info.radio_freq - l1_config.std.radio_freq_index_offset;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
639
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
640 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
641 serving_index = l1_multiband_radio_freq_convert_into_operative_radio_freq(l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
642 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
643
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
644
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
645 // Control phase parameters: same AGC, radio_freq, lna_off used for all PDTCH
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
646 // ***************************************************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
647
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
648 // Get radio_freq on which the downlink block was received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
649 radio_freq = l1a_l1s_com.dedic_set.radio_freq_dd;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
650
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
651 // Compute calibration factors
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
652 delta1_freq = l1ctl_encode_delta1(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
653 delta2_freq = l1ctl_encode_delta2(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
654
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
655 // AGC used in the control phase (format F7.1)
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
656 used_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID)) << 1;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
657
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
658 // LNA attenuation
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
659 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
660
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
661 // Burst 0: Reset ILmin_beacon and ILmin_others
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
662 if(pdsp_db_r_ptr->d_burst_nb_gprs == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
663 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
664 l1ps.ILmin_beacon = 255; // Not valid
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
665
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
666 for (ts = 0; ts < 8; ts++)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
667 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
668 l1ps.ILmin_others[ts] = (UWORD8) l1_config.params.il_min;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
669 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
670 } // End if "burst 0"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
671
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
672 // IL processing for each received burst
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
673 // **************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
674
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
675 // For each timeslot on which a burst was received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
676 for(ts = 0; ts < 8; ts ++)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
677 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
678 if(pdsp_db_r_ptr->d_task_d_gprs & bit_mask)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
679 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
680 WORD16 current_IL, current_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
681 UWORD8 pm;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
682
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
683 // IL = fct(pm, last_known_agc, lna_value, g_magic)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
684 //-------------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
685
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
686 pm = (UWORD8) ((pdsp_db_r_ptr->a_burst_pm_gprs[ts] & 0xffff) >> 5);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
687
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
688 // current_IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
689 if (0==pm) // Check and filter illegal pm value by using last valid IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
690 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
691 if (radio_freq == l1a_l1s_com.Scell_info.radio_freq)
313
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
692 current_IL = l1a_l1s_com.last_input_level[serving_index].input_level
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
693 - lna_value;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
694 else
313
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
695 current_IL = l1a_l1s_com.Scell_info.transfer_meas.input_level
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
696 - lna_value;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
697 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
698 else
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
699 {
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
700
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
701 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
702 // DRP correction
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
703 #if (L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
704 arfcn = Convert_l1_radio_freq(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
705 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
706 arfcn=radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
707 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
708
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
709 #if (CODE_VERSION != SIMULATION)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
710
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
711 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID ,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
712 l1a_l1s_com.Scell_used_IL_dd.input_level,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
713 radio_freq,if_threshold);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
714 lna_off = l1a_l1s_com.Scell_used_IL_dd.lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
715 delta_drp_gain = drp_gain_correction(arfcn, lna_off, used_agc); // F7.1 format
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
716 if(if_ctl == IF_100KHZ_DSP){
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
717 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
718 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
719 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
720 delta_drp_gain += SCF_ATTENUATION_LIF_120KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
721 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
722
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
723 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
724 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
725
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
726 current_IL = -(pm - (used_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq));
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
727 }
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
728
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
729 // Calibrated IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
730 current_calibrated_IL = current_IL - delta1_freq - delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
731
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
732 // Protect IL stores against overflow
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
733 if(current_calibrated_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
734 current_calibrated_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
735 if (current_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
736 current_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
737
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
738 calibrated_IL[ts] = (UWORD8)(current_calibrated_IL);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
739
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
740 // Keep ILmax
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
741 if (radio_freq == l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
742 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
743 // Beacon frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
744 l1ps.ILmin_beacon = min((UWORD8) current_IL, l1ps.ILmin_beacon);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
745 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
746 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
747 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
748 // Daughter frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
749 l1ps.ILmin_others[ts] = min((UWORD8) current_IL,l1ps.ILmin_others[ts]);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
750 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
751
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
752 // Input Level selection among ILmax found on each timeslot during the block (when burst = 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
753 // *******************************************************************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
754
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
755 if(pdsp_db_r_ptr->d_burst_nb_gprs == 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
756 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
757 // If CRC good
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
758 if (!(pdsp_ndb_ptr->a_dd_gprs[rx_no][0] & 0x0100))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
759 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
760 // Find the min found IL for blocks that were correctly received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
761 ILmin_correct = min(l1ps.ILmin_others[ts],ILmin_correct);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
762 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
763 // If CRC bad
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
764 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
765 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
766 // Find the min found IL for blocks that were not correctly received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
767 ILmin_not_correct = min(l1ps.ILmin_others[ts],ILmin_not_correct);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
768 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
769 } // End if "burst = 3"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
770
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
771 // Next downlink block
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
772 rx_no ++;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
773
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
774 } // End if "timeslot used for downlink PDCH"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
775
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
776 // Next timeslot
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
777 bit_mask >>= 1;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
778 } // End for "each timeslot...."
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
779
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
780
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
781 // IL selection for the next block if burst = 3
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
782 // **********************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
783
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
784 if(pdsp_db_r_ptr->d_burst_nb_gprs == 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
785 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
786 WORD16 new_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
787
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
788 // Beacon frequency input level updating
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
789 //--------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
790
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
791 // If a PDCH has been received on the beacon
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
792 if (l1ps.ILmin_beacon != 255)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
793 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
794 UWORD8 i, new_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
795
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
796 // FIFO management
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
797 for (i=3;i>0;i--)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
798 l1a_l1s_com.Scell_info.buff_beacon[i] = l1a_l1s_com.Scell_info.buff_beacon[i-1];
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
799 l1a_l1s_com.Scell_info.buff_beacon[0] = l1ps.ILmin_beacon;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
800
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
801 // Find min IL in FIFO
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
802 new_IL = l1ctl_find_max(l1a_l1s_com.Scell_info.buff_beacon, 4);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
803
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
804 // Input levels are always stored with lna_on
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
805
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
806 // lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
807 new_calibrated_IL = (WORD16) (new_IL - l1ctl_encode_delta1(l1a_l1s_com.Scell_info.radio_freq) - l1ctl_encode_delta2(l1a_l1s_com.Scell_info.radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
808
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
809 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
810
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
811 l1ctl_encode_lna((UWORD8)(new_calibrated_IL>>1),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
812 &(l1a_l1s_com.last_input_level[serving_index].lna_off),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
813 l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
814
313
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
815 l1a_l1s_com.last_input_level[serving_index].input_level = new_IL +
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
816 l1a_l1s_com.last_input_level[serving_index].lna_off *
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
817 l1ctl_get_lna_att(l1a_l1s_com.Scell_info.radio_freq);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
818
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
819 } // End of "beacon frequency input level updating"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
820
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
821 // Daughter frequencies input level updating
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
822 //------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
823
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
824 // If at least one block was correctly received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
825 // (Note: ILs truncated to 240 so 255 isn't valid)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
826 if (ILmin_correct != 255)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
827 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
828 // Select the min input level found on correctly received blocks
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
829 l1a_l1s_com.Scell_info.transfer_meas.input_level = ILmin_correct;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
830 l1ps.fn_select = l1s.actual_time.fn;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
831
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
832 // Algorithm switch to "TRACK" phase if it was in "SEARCH" phase
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
833 l1ps.phase = TRACK;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
834 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
835
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
836 // No block was correctly received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
837 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
838 {
313
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
839 UWORD8 input_level_ref = l1a_l1s_com.Scell_info.transfer_meas.input_level
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
840 - l1a_l1s_com.Scell_info.transfer_meas.lna_off *
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
841 l1ctl_get_lna_att(radio_freq);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
842 // SEARCH phase
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
843 if (l1ps.phase == SEARCH)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
844 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
845 // If measured level superior to currently tracket level, switch to TRACK mode
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
846 if (input_level_ref > ILmin_not_correct)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
847 l1ps.phase = TRACK;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
848
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
849 // Select the min input level found on badly received blocks
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
850 l1a_l1s_com.Scell_info.transfer_meas.input_level = ILmin_not_correct;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
851 l1ps.fn_select = l1s.actual_time.fn;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
852 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
853
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
854 // TRACK phase
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
855 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
856 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
857 // If the IL found on incorrect block is lower than current wanted IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
858 if (ILmin_not_correct < input_level_ref)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
859 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
860 // Select the new IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
861 l1a_l1s_com.Scell_info.transfer_meas.input_level = ILmin_not_correct;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
862 l1ps.fn_select = l1s.actual_time.fn;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
863 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
864
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
865 // If the IL found on incorrect block is higher than current wanted IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
866 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
867 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
868 UWORD32 delta_fn;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
869
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
870 // delta_fn processing for IL selection forgetting factor
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
871 delta_fn = l1s.actual_time.fn - l1ps.fn_select;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
872
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
873 // MAX_FN modulo management
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
874 if (l1s.actual_time.fn < l1ps.fn_select)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
875 delta_fn += MAX_FN;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
876
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
877 // If the last selected IL is more recent than 72 frames
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
878 //
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
879 // |....|R...............................C|....|
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
880 // ^ ^
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
881 // fn_selected IL reset to -120
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
882 // <-------------------------------------->
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
883 // 312
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
884 // 306 = 312 - 4 (block_size) - 1 (Read phase fn delay) - 1 (Control phase fn advance)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
885 if (delta_fn > 306)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
886 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
887 WORD16 input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
888
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
889 // IL initialized to "beacon level - Pb"
313
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
890 input_level = (WORD16)
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
891 ((l1a_l1s_com.last_input_level[serving_index].input_level +
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
892 l1a_l1s_com.Scell_info.pb) -
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
893 (l1a_l1s_com.last_input_level[serving_index].lna_off *
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
894 l1ctl_get_lna_att(l1a_l1s_com.Scell_info.radio_freq)));
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
895
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
896 if (input_level>INDEX_MAX) input_level = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
897 l1a_l1s_com.Scell_info.transfer_meas.input_level = (UWORD8)input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
898
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
899 l1ps.fn_select = l1s.actual_time.fn;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
900 // Returns to "SEARCH" phase
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
901 l1ps.phase = SEARCH;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
902 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
903 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
904 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
905 WORD16 input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
906
313
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
907 input_level = l1a_l1s_com.Scell_info.transfer_meas.input_level -
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
908 l1a_l1s_com.Scell_info.transfer_meas.lna_off *
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
909 l1ctl_get_lna_att(l1ps.read_param.radio_freq_for_lna);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
910
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
911 if (input_level>INDEX_MAX) input_level = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
912
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
913 l1a_l1s_com.Scell_info.transfer_meas.input_level = (UWORD8)input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
914 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
915 } // End if the IL found on incorrect block is higher than current wanted IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
916 } // End of "track phase"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
917 } // End if no block correctly received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
918
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
919 // lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
920 new_calibrated_IL = (WORD16) (l1a_l1s_com.Scell_info.transfer_meas.input_level - l1ctl_encode_delta1(l1ps.read_param.radio_freq_for_lna));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
921 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
922
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
923 l1ctl_encode_lna((UWORD8)(new_calibrated_IL>>1), &(l1a_l1s_com.Scell_info.transfer_meas.lna_off), l1ps.read_param.radio_freq_for_lna);
313
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
924
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
925 l1a_l1s_com.Scell_info.transfer_meas.input_level +=
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
926 l1a_l1s_com.Scell_info.transfer_meas.lna_off *
0388ecc384d6 l1p_ctl.c: l1pctl_npc_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 312
diff changeset
927 l1ctl_get_lna_att(l1ps.read_param.radio_freq_for_lna);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
928 } // End if "burst = 3"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
929
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
930 } // End of "l1pctl_npc_agc_read"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
931
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
932 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
933 /* l1pctl_dpcma_agc_read() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
934 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
935 /* Description : */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
936 /* =========== */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
937 /* AGC algorithm in packet transfer used when the BTS */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
938 /* use DOWNLINK POWER CONTROL mode A. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
939 /* This function is used during the read phase of PDTCH: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
940 /* 1- to determine the IL value for each timeslot in each*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
941 /* TDMA */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
942 /* 2- to find the IL value to use for the next PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
943 /* block */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
944 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
945 /* Algorithm */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
946 /* --------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
947 /* For each timeslot i used for PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
948 /* IL(i) = fct(used AGC, pm) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
949 /* if (beacon) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
950 /* ILmax_beacon = max(ILmax_beacon, IL(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
951 /* else */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
952 /* ILmax_others(i) = max(IL(i), ILmax_others(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
953 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
954 /* If (burst_nb == 3) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
955 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
956 /* For each timeslot i used for PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
957 /* if (CRC good) and */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
958 /* ((PR_MODE A) or (PR_MODE B and TFI good)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
959 /* ILmax = max(ILmax, ILmax_others(i) + P0 + PR(i))*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
960 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
961 /* ILmax=max(ILmax, ILmax_beacon) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
962 /* FIFO[beacon] updated with ILmax */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
963 /* last_input_level[serving beacon] = max(FIFO[beacon])*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
964 /* transfer_meas = max(FIFO[beacon]) - P0 - 5 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
965 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
966 /* Reset ILmax_others[8] and ILmax_beacon */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
967 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
968 /* WARNING: in the layer 1 code, input levels IL(l1) use */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
969 /* format 7.1: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
970 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
971 /* * IL(l1) = - 2 x IL * */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
972 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
973 /* -> Reversed sign, reversed test conditions */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
974 /* -> max replaced by min */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
975 /* ex: if IL -120 dBm, IL(l1) = 240 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
976 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
977 /* Parameters */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
978 /* ---------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
979 /* "calibrated_IL[8]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
980 /* contains the IL found on timeslots */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
981 /* used for PDCH/D. These ILs can be used to process */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
982 /* RXLEV values. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
983 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
984 /* "*pdsp_db_r_ptr" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
985 /* Pointer on the DSP DB Read page, used to extract */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
986 /* pm values, burst number and timeslot allocated */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
987 /* for downlink PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
988 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
989 /* "*pdsp_ndb_ptr" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
990 /* Pointer on the DSP NDB page, used to extract the */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
991 /* CRC value for each decoded burst */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
992 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
993 /* Global parameters */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
994 /* ----------------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
995 /* "l1a_l1s_com.Scell_info.transfer_meas.input_level" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
996 /* "l1a_l1s_com.Scell_info.transfer_meas.lna_off" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
997 /* Used to store the ILselected and the associated */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
998 /* lna_off value. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
999 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1000 /* "l1a_l1s_com.last_input_level[freq. index] */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1001 /* .input_level */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1002 /* .lna_off" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1003 /* Used to store the beacon input level and */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1004 /* the associated lna_off value. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1005 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1006 /* "l1ps.transfer_beacon_buf[4]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1007 /* FIFO[beacon] */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1008 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1009 /* "l1ps.ILmin_beacon" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1010 /* "l1ps.ILmin_others[8]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1011 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1012 void l1pctl_dpcma_agc_read(UWORD8 calibrated_IL[8], T_DB_DSP_TO_MCU_GPRS *pdsp_db_r_ptr,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1013 T_NDB_MCU_DSP_GPRS *pdsp_ndb_ptr, UWORD8 pr_table[8])
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1014 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1015 UWORD8 ts = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1016 UWORD8 rx_no = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1017 UWORD8 bit_mask = 0x80;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1018 UWORD8 IL_norm_min = 255;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1019 WORD8 delta1_freq, delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1020 WORD16 delta_drp_gain=0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1021 UWORD16 radio_freq, lna_value;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1022 WORD16 used_agc;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1023 WORD32 serving_index;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1024 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1025 UWORD16 arfcn;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1026 #endif
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1027 UWORD8 lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1028 UWORD16 dco_algo_ctl_pw_temp = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1029 UWORD8 if_ctl = 0;
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
1030 #if (RF_FAM == 61) && (CODE_VERSION != SIMULATION)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1031 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GPRS;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1032 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1033
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1034 #if(L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1035 serving_index = l1a_l1s_com.Scell_info.radio_freq - l1_config.std.radio_freq_index_offset;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1036
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1037 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1038 serving_index = l1_multiband_radio_freq_convert_into_operative_radio_freq(l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1039 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1040
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1041
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1042 // Control phase parameters: same AGC, radio_freq, lna_off used for all PDTCH
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1043 // ***************************************************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1044
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1045 // Get radio_freq on which the downlink block was received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1046 radio_freq = l1a_l1s_com.dedic_set.radio_freq_dd;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1047
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1048 // Compute calibration factors
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1049 delta1_freq = l1ctl_encode_delta1(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1050 delta2_freq = l1ctl_encode_delta2(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1051
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1052 // Last known AGC (format F7.1)
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
1053 used_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID)) << 1;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1054
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1055 // LNA attenuation
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1056 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1057
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1058 // Burst 0: Reset ILmin_beacon and ILmin_others
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1059 if(pdsp_db_r_ptr->d_burst_nb_gprs == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1060 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1061 l1ps.ILmin_beacon = 255; // Not valid
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1062
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1063 for (ts = 0; ts < 8; ts++)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1064 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1065 l1ps.ILmin_others[ts] = 255; // Not valid
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1066 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1067 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1068
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1069 // IL processing for each received burst
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1070 // **************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1071
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1072 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1073 // DRP correction
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1074 #if (L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1075 arfcn = Convert_l1_radio_freq(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1076 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1077 arfcn=radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1078 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1079
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1080 #if (CODE_VERSION != SIMULATION)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1081
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1082 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID ,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1083 l1a_l1s_com.Scell_used_IL_dd.input_level,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1084 radio_freq, if_threshold);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1085 lna_off = l1a_l1s_com.Scell_used_IL_dd.lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1086 delta_drp_gain = drp_gain_correction(arfcn, lna_off, used_agc); // F7.1 format
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1087
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1088 if(if_ctl == IF_100KHZ_DSP){
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1089 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1090 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1091 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1092 delta_drp_gain += SCF_ATTENUATION_LIF_120KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1093 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1094
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1095 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1096 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1097
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1098 // For each timeslot on which a burst was received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1099 for(ts = 0; ts < 8; ts ++)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1100 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1101 if(pdsp_db_r_ptr->d_task_d_gprs & bit_mask)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1102 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1103 WORD16 current_IL, current_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1104 UWORD8 pm;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1105
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1106 // IL = fct(pm, last_known_agc, lna_value, g_magic)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1107 //-------------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1108
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1109 pm = (UWORD8) ((pdsp_db_r_ptr->a_burst_pm_gprs[ts] & 0xffff) >> 5);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1110
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1111 // current_IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1112 if (0==pm) // Check and filter illegal pm value by using last valid IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1113 {
314
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1114 current_IL = l1a_l1s_com.last_input_level[serving_index].input_level
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1115 - lna_value;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1116
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1117 if (radio_freq != l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1118 current_IL += (l1ps.read_param.dl_pwr_ctl.p0 + 10);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1119 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1120 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1121 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1122 current_IL = -(pm - (used_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1123 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1124
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1125 // Calibrated IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1126 current_calibrated_IL = current_IL - delta1_freq - delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1127
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1128 // Protect IL stores against overflow
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1129 if(current_calibrated_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1130 current_calibrated_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1131 if (current_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1132 current_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1133
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1134 calibrated_IL[ts] = (UWORD8)(current_calibrated_IL);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1135
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1136 // Keep the minimum IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1137 if (radio_freq == l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1138 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1139 // Beacon frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1140 l1ps.ILmin_beacon = min((UWORD8) current_IL,l1ps.ILmin_beacon);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1141 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1142 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1143 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1144 // Daughter frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1145 l1ps.ILmin_others[ts] = min((UWORD8) current_IL, l1ps.ILmin_others[ts]);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1146 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1147
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1148 // Input Level selection among ILmax found on each timeslot during the block (when burst = 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1149 //-------------------------------------------------------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1150
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1151 if(pdsp_db_r_ptr->d_burst_nb_gprs == 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1152 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1153 // If CRC good
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1154 if (!(pdsp_ndb_ptr->a_dd_gprs[rx_no][0] & 0x0100))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1155 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1156 // If ((PR_MODE A and TFI good) or (PR_MODE B)) AND PR != 0 [Not usable])
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1157 if (((l1ps.read_param.dl_pwr_ctl.pr_mode != 0) || (!(pr_table[ts] & 0x80)))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1158 && ((pr_table[ts] & 0x1f) != 0))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1159 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1160 if (l1ps.ILmin_others[ts] != 255)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1161 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1162 UWORD8 IL_norm;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1163
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1164 // IL normalization to beacon (ILnorm = ILmax_others(ts) - P0 - PR)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1165 IL_norm = l1ps.ILmin_others[ts] - l1ps.read_param.dl_pwr_ctl.p0 - ((pr_table[ts] & 0x1f) << 1);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1166
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1167 // Update IL_min with the minimum found IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1168 IL_norm_min = min(IL_norm, IL_norm_min);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1169 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1170 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1171 } // End if "CRC good"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1172
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1173 } // End if "burst = 3"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1174
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1175 // Next downlink block
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1176 rx_no ++;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1177
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1178 } // End if "timeslot used for downlink PDCH"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1179
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1180 // Next timeslot
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1181 bit_mask >>= 1;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1182
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1183 } // End for "each timeslot...."
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1184
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1185
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1186 // IL selection for the next block if burst = 3
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1187 // **********************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1188
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1189 if(pdsp_db_r_ptr->d_burst_nb_gprs == 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1190 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1191 UWORD8 i, new_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1192 UWORD16 input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1193 WORD16 new_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1194
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1195 // Select the minimum IL between minimum IL found on daughter frequencies (normalized to beacon)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1196 // and minimum IL found on the beacon
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1197 IL_norm_min = min(IL_norm_min, l1ps.ILmin_beacon);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1198
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1199 // If a valid IL has been found
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1200 if (IL_norm_min != 255)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1201 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1202 // FIFO management
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1203 for (i=3;i>0;i--)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1204 l1a_l1s_com.Scell_info.buff_beacon[i] = l1a_l1s_com.Scell_info.buff_beacon[i-1];
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1205
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1206 l1a_l1s_com.Scell_info.buff_beacon[0] = IL_norm_min;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1207
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1208 // last_input_level[serving beacon] updating
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1209 //------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1210
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1211 // Find min IL in FIFO
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1212 new_IL = l1ctl_find_max(l1a_l1s_com.Scell_info.buff_beacon,4);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1213
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1214 // Input levels are always stored with lna_on
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1215
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1216 // lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1217 new_calibrated_IL = (WORD16) (new_IL - l1ctl_encode_delta1(l1a_l1s_com.Scell_info.radio_freq) - l1ctl_encode_delta2(l1a_l1s_com.Scell_info.radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1218 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1219
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1220 l1ctl_encode_lna((UWORD8)(new_calibrated_IL >> 1),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1221 &(l1a_l1s_com.last_input_level[serving_index].lna_off),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1222 l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1223
314
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1224 l1a_l1s_com.last_input_level[serving_index].input_level = new_IL +
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1225 l1a_l1s_com.last_input_level[serving_index].lna_off *
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1226 l1ctl_get_lna_att(l1a_l1s_com.Scell_info.radio_freq);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1227 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1228
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1229 // transfer_meas updating
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1230 //-----------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1231
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1232 // IL = (min IL in FIFO) + P0 + 10 (PR = 5 format 7.1)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1233 // Input levels are always stored with lna_on
314
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1234 input_level = l1a_l1s_com.last_input_level[serving_index].input_level
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1235 - l1a_l1s_com.last_input_level[serving_index].lna_off *
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1236 l1ctl_get_lna_att(l1a_l1s_com.Scell_info.radio_freq)
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1237 + l1ps.read_param.dl_pwr_ctl.p0 + 10;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1238
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1239 // IL_2_AGC_xx array size
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1240 if (input_level>INDEX_MAX) input_level = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1241
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1242 // lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1243 new_calibrated_IL = (WORD16) (input_level - l1ctl_encode_delta1(l1ps.read_param.radio_freq_for_lna));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1244
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1245 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1246
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1247 l1ctl_encode_lna((UWORD8)(new_calibrated_IL>>1), &(l1a_l1s_com.Scell_info.transfer_meas.lna_off), l1ps.read_param.radio_freq_for_lna);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1248
314
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1249 l1a_l1s_com.Scell_info.transfer_meas.input_level = input_level +
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1250 l1a_l1s_com.Scell_info.transfer_meas.lna_off *
e520acd157e2 l1p_ctl.c: l1pctl_dpcma_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 313
diff changeset
1251 l1ctl_get_lna_att(l1ps.read_param.radio_freq_for_lna);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1252 } // End if "burst = 3"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1253
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1254 } // End of "l1pctl_dpcma_agc_read"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1255
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1256 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1257 /* l1pctl_dpcmb_agc_read() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1258 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1259 /* Description : */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1260 /* =========== */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1261 /* AGC algorithm in packet transfer used when the BTS */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1262 /* use DOWNLINK POWER CONTROL mode B. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1263 /* This function is used during the read phase of PDTCH: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1264 /* 1- to determine the IL value for each timeslot in each*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1265 /* TDMA */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1266 /* 2- to find the IL value to use for the next PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1267 /* block */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1268 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1269 /* Algorithm */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1270 /* --------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1271 /* For each timeslot i used for PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1272 /* IL(i) = fct(used AGC, pm) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1273 /* if (beacon) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1274 /* ILmax_beacon = max(ILmax_beacon, IL(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1275 /* else */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1276 /* ILmax_others(i) = max(IL(i), ILmax_others(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1277 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1278 /* If (burst_nb == 3) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1279 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1280 /* For each timeslot i used for PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1281 /* if (CRC good) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1282 /* if (TFI good) last_PR_good = PR(i) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1283 /* if ((PR_MODE A) or (PR_MODE B and TFI good)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1284 /* ILmax = max(ILmax, ILmax_others(i) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1285 /* + P0 + PR(i)) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1286 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1287 /* ILmax=max(ILmax, ILmax_beacon) */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1288 /* FIFO[beacon] updated with ILmax */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1289 /* last_input_level[serving beacon] = max(FIFO[beacon])*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1290 /* transfer_meas = max(FIFO[beacon]) - last_PR_good */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1291 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1292 /* Reset ILmax_others[8] and ILmax_beacon */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1293 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1294 /* WARNING: in the layer 1 code, input levels IL(l1) use */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1295 /* format 7.1: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1296 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1297 /* * IL(l1) = - 2 x IL * */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1298 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1299 /* -> Reversed sign, reversed test conditions */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1300 /* -> max replaced by min */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1301 /* ex: if IL -120 dBm, IL(l1) = 240 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1302 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1303 /* Parameters */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1304 /* ---------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1305 /* "calibrated_IL[8]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1306 /* contains the IL found on timeslots */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1307 /* used for PDCH/D. These ILs can be used to process */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1308 /* RXLEV values. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1309 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1310 /* "*pdsp_db_r_ptr" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1311 /* Pointer on the DSP DB Read page, used to extract */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1312 /* pm values, burst number and timeslot allocated */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1313 /* for downlink PDCH */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1314 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1315 /* "*pdsp_ndb_ptr" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1316 /* Pointer on the DSP NDB page, used to extract the */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1317 /* CRC value for each decoded burst */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1318 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1319 /* Global parameters */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1320 /* ----------------- */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1321 /* "l1a_l1s_com.Scell_info.transfer_meas.input_level" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1322 /* "l1a_l1s_com.Scell_info.transfer_meas.lna_off" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1323 /* Used to store the ILselected and the associated */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1324 /* lna_off value. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1325 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1326 /* "l1a_l1s_com.last_input_level[freq. index] */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1327 /* .input_level */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1328 /* .lna_off" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1329 /* Used to store the beacon input level and */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1330 /* the associated lna_off value. */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1331 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1332 /* "l1ps.transfer_beacon_buf[4]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1333 /* FIFO[beacon] */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1334 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1335 /* "l1ps.ILmin_beacon" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1336 /* "l1ps.ILmin_others[8]" */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1337 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1338 void l1pctl_dpcmb_agc_read(UWORD8 calibrated_IL[8], T_DB_DSP_TO_MCU_GPRS *pdsp_db_r_ptr,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1339 T_NDB_MCU_DSP_GPRS *pdsp_ndb_ptr, UWORD8 pr_table[8])
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1340 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1341 UWORD8 ts = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1342 UWORD8 rx_no = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1343 UWORD8 bit_mask = 0x80;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1344 UWORD8 IL_norm_min = 255;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1345 WORD8 delta1_freq, delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1346 WORD16 delta_drp_gain=0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1347 UWORD16 radio_freq, lna_value;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1348 WORD16 used_agc;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1349 WORD32 serving_index;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1350 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1351 UWORD16 arfcn;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1352 #endif
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1353 UWORD8 lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1354 UWORD16 dco_algo_ctl_pw_temp = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1355 UWORD8 if_ctl = 0;
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
1356 #if (RF_FAM == 61) && (CODE_VERSION != SIMULATION)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1357 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GPRS;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1358 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1359
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1360 #if(L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1361 serving_index = l1a_l1s_com.Scell_info.radio_freq - l1_config.std.radio_freq_index_offset;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1362 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1363 serving_index = l1_multiband_radio_freq_convert_into_operative_radio_freq(l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1364 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1365
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1366
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1367 // Control phase parameters: same AGC, radio_freq, lna_off used for all PDTCH
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1368 // ***************************************************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1369
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1370 // Get radio_freq on which the downlink block was received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1371 radio_freq = l1a_l1s_com.dedic_set.radio_freq_dd;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1372
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1373 // Compute calibration factors
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1374 delta1_freq = l1ctl_encode_delta1(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1375 delta2_freq = l1ctl_encode_delta2(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1376
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1377 // Last known AGC (format F7.1)
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
1378 used_agc = (Cust_get_agc_from_IL(radio_freq, l1a_l1s_com.Scell_used_IL_dd.input_level >> 1, MAX_ID)) << 1;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1379
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1380 // LNA attenuation
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1381 lna_value = l1a_l1s_com.Scell_used_IL_dd.lna_off * l1ctl_get_lna_att(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1382
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1383 // Burst 0: Reset ILmin_beacon and ILmin_others
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1384 if(pdsp_db_r_ptr->d_burst_nb_gprs == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1385 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1386 l1ps.ILmin_beacon = 255; // Not valid
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1387
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1388 for (ts = 0; ts < 8; ts++)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1389 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1390 l1ps.ILmin_others[ts] = 255; // Not valid
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1391 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1392 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1393
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1394 // IL processing for each received burst
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1395 // **************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1396
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1397 // For each timeslot on which a burst was received
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1398 for(ts = 0; ts < 8; ts ++)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1399 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1400 if(pdsp_db_r_ptr->d_task_d_gprs & bit_mask)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1401 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1402 WORD16 current_IL, current_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1403 UWORD8 pm;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1404
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1405 // IL = fct(pm, last_known_agc, lna_value, g_magic)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1406 //-------------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1407
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1408 pm = (UWORD8) ((pdsp_db_r_ptr->a_burst_pm_gprs[ts] & 0xffff) >> 5);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1409
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1410 // current_IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1411 if (0==pm) // Check and filter illegal pm value by using last valid IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1412 {
315
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1413 current_IL = l1a_l1s_com.last_input_level[serving_index].input_level
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1414 - lna_value;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1415
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1416 if (radio_freq != l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1417 current_IL += (l1ps.last_PR_good);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1418 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1419 else
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1420 {
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1421
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1422 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1423 // DRP correction
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1424 #if (L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1425 arfcn = Convert_l1_radio_freq(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1426 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1427 arfcn=radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1428 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1429
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1430 #if (CODE_VERSION != SIMULATION)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1431
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1432
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1433 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID ,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1434 l1a_l1s_com.Scell_used_IL_dd.input_level,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1435 radio_freq, if_threshold);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1436 lna_off = l1a_l1s_com.Scell_used_IL_dd.lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1437 delta_drp_gain = drp_gain_correction(arfcn, lna_off, used_agc); // F7.1 format
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1438
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1439 if(if_ctl == IF_100KHZ_DSP){
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1440 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1441 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1442 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1443 delta_drp_gain += SCF_ATTENUATION_LIF_120KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1444 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1445
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1446
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1447 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1448 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1449
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1450 current_IL = -(pm - ( used_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq));
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1451 }
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1452
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1453 // Calibrated IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1454 current_calibrated_IL = current_IL - delta1_freq - delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1455
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1456 // Protect IL stores against overflow
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1457 if(current_calibrated_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1458 current_calibrated_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1459 if (current_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1460 current_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1461
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1462 calibrated_IL[ts] = (UWORD8)(current_calibrated_IL);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1463
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1464 // Keep the minimum IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1465 if (radio_freq == l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1466 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1467 // Beacon frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1468 l1ps.ILmin_beacon = min((UWORD8) current_IL,l1ps.ILmin_beacon);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1469 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1470 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1471 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1472 // Daughter frequency
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1473 l1ps.ILmin_others[ts] = min((UWORD8) current_IL, l1ps.ILmin_others[ts]);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1474 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1475
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1476 // Input Level selection among ILmax found on each timeslot during the block (when burst = 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1477 //-------------------------------------------------------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1478
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1479 if(pdsp_db_r_ptr->d_burst_nb_gprs == 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1480 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1481 // If CRC good
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1482 if (!(pdsp_ndb_ptr->a_dd_gprs[rx_no][0] & 0x0100))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1483 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1484 // If ((PR_MODE A and TFI good) or (PR_MODE B))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1485 if ((l1ps.read_param.dl_pwr_ctl.pr_mode != 0) || (!(pr_table[ts] & 0x80)))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1486 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1487
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1488 // If TFI good
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1489 if (!(pr_table[ts] & 0x80))
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1490 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1491 // Memorize decoded PR
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1492 l1ps.last_PR_good = ((pr_table[ts] & 0x1f) << 1);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1493 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1494
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1495 if (l1ps.ILmin_others[ts] != 255)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1496 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1497 UWORD8 IL_norm;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1498
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1499 // IL normalization to beacon (ILnorm = ILmax_others(ts) - PR)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1500 IL_norm = l1ps.ILmin_others[ts] - ((pr_table[ts] & 0x1f) << 1);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1501
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1502 // Update IL_min with the minimum found IL
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1503 IL_norm_min = min(IL_norm, IL_norm_min);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1504 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1505 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1506 } // End if "CRC good"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1507
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1508 } // End if "burst = 3"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1509
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1510 // Next downlink block
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1511 rx_no ++;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1512
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1513 } // End if "timeslot used for downlink PDCH"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1514
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1515 // Next timeslot
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1516 bit_mask >>= 1;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1517
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1518 } // End for "each timeslot...."
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1519
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1520
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1521 // IL selection for the next block if burst = 3
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1522 // **********************************************
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1523
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1524 if(pdsp_db_r_ptr->d_burst_nb_gprs == 3)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1525 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1526 UWORD8 i, new_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1527 UWORD16 input_level;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1528 WORD16 new_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1529
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1530 // Select the minimum IL between minimum IL found on daughter frequencies (normalized to beacon)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1531 // and minimum IL found on the beacon
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1532 IL_norm_min = min(IL_norm_min, l1ps.ILmin_beacon);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1533
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1534 // If a valid IL has been found
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1535 if (IL_norm_min != 255)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1536 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1537 // FIFO management
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1538 for (i=3;i>0;i--)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1539 l1a_l1s_com.Scell_info.buff_beacon[i] = l1a_l1s_com.Scell_info.buff_beacon[i-1];
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1540
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1541 l1a_l1s_com.Scell_info.buff_beacon[0] = IL_norm_min;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1542
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1543 // last_input_level[serving beacon] updating
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1544 //------------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1545
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1546 // Find min IL in FIFO
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1547 new_IL = l1ctl_find_max(l1a_l1s_com.Scell_info.buff_beacon,4);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1548
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1549 // Input levels are always stored with lna_on
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1550
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1551 // lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1552 new_calibrated_IL = (WORD16) (new_IL - l1ctl_encode_delta1(l1a_l1s_com.Scell_info.radio_freq) - l1ctl_encode_delta2(l1a_l1s_com.Scell_info.radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1553
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1554 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1555
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1556 l1ctl_encode_lna((UWORD8)(new_calibrated_IL >> 1),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1557 &(l1a_l1s_com.last_input_level[serving_index].lna_off),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1558 l1a_l1s_com.Scell_info.radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1559
315
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1560 l1a_l1s_com.last_input_level[serving_index].input_level = new_IL +
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1561 l1a_l1s_com.last_input_level[serving_index].lna_off *
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1562 l1ctl_get_lna_att(l1a_l1s_com.Scell_info.radio_freq);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1563 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1564
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1565 // transfer_meas updating
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1566 //-----------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1567
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1568 // IL = (min IL in FIFO) + PR (Middle of the range specified by the last decoded PR with CRC and TFI good)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1569 // Input levels are always stored with lna_on
315
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1570 input_level = l1a_l1s_com.last_input_level[serving_index].input_level
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1571 - l1a_l1s_com.last_input_level[serving_index].lna_off *
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1572 l1ctl_get_lna_att(l1a_l1s_com.Scell_info.radio_freq)
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1573 + l1ps.last_PR_good;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1574
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1575 // IL_2_AGC_xx array size
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1576 if (input_level>INDEX_MAX) input_level = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1577
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1578 // lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1579 new_calibrated_IL = (WORD16) (input_level - l1ctl_encode_delta1(l1ps.read_param.radio_freq_for_lna));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1580
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1581 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1582
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1583 l1ctl_encode_lna((UWORD8)(new_calibrated_IL>>1), &(l1a_l1s_com.Scell_info.transfer_meas.lna_off), l1ps.read_param.radio_freq_for_lna);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1584
315
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1585 l1a_l1s_com.Scell_info.transfer_meas.input_level = input_level +
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1586 l1a_l1s_com.Scell_info.transfer_meas.lna_off *
27a933036b4f l1p_ctl.c: l1pctl_dpcmb_agc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
1587 l1ctl_get_lna_att(l1ps.read_param.radio_freq_for_lna);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1588
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1589 } // End if "burst = 3"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1590
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1591 } // End of "l1pctl_dpcmb_agc_read"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1592
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1593 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1594 /* l1pctl_pgc() */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1595 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1596 /* Description : */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1597 /* ============= */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1598 /* This function is used in packet transfer mode for the*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1599 /* Read phase of power measurements. It permits to: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1600 /* - Process the IL value in function of the Pm and AGC */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1601 /* used */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1602 /* - Update the FIFO[beacon] used in packet transfer AGC*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1603 /* algorithms */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1604 /* - Update last_input_level */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1605 /* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1606 /* WARNING: in the layer 1 code, input levels IL(l1) use */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1607 /* format 7.1: */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1608 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1609 /* * IL(l1) = - 2 x IL * */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1610 /* ********************* */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1611 /* -> Reversed sign, reversed test conditions */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1612 /* -> max replaced by min */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1613 /* ex: if IL -120 dBm, IL(l1) = 240 */
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1614 /*-------------------------------------------------------*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1615 UWORD8 l1pctl_pgc(UWORD8 pm, UWORD8 last_known_il, UWORD8 lna_off, UWORD16 radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1616 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1617 UWORD8 i, new_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1618 WORD8 delta1_freq, delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1619 WORD16 delta_drp_gain=0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1620 UWORD16 lna_value;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1621 WORD16 used_agc, current_IL, current_calibrated_IL, new_calibrated_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1622 WORD32 index;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1623 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1624 UWORD16 arfcn;
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1625 #endif
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1626 UWORD16 dco_algo_ctl_pw_temp = 0;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1627 UWORD8 if_ctl = 0;
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
1628 #if (RF_FAM == 61) && (CODE_VERSION != SIMULATION)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1629 UWORD8 if_threshold = C_IF_ZERO_LOW_THRESHOLD_GPRS;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1630 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1631
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1632 // Calibration factors
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1633 delta1_freq = l1ctl_encode_delta1(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1634 delta2_freq = l1ctl_encode_delta2(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1635
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1636 // initialize index
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1637 #if(L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1638 index = radio_freq - l1_config.std.radio_freq_index_offset;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1639
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1640 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1641 index = l1_multiband_radio_freq_convert_into_operative_radio_freq(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1642 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1643
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1644
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1645 // LNA attenuation
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1646 lna_value = lna_off * l1ctl_get_lna_att(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1647
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1648 // Used AGC in the control phase (format F7.1)
310
cd2507a8ec57 l1p_ctl.c: passes compilation
Mychaela Falconia <falcon@freecalypso.org>
parents: 309
diff changeset
1649 used_agc = (Cust_get_agc_from_IL(radio_freq, last_known_il >> 1, PWR_ID)) << 1;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1650
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1651
311
5f8ab159aa76 l1p_ctl.c: l1pctl_pagc_read() reconstructed
Mychaela Falconia <falcon@freecalypso.org>
parents: 310
diff changeset
1652 #if (RF_FAM == 61)
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1653 // DRP correction
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1654 #if (L1_FF_MULTIBAND == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1655 arfcn = Convert_l1_radio_freq(radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1656 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1657 arfcn=radio_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1658 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1659
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1660 #if (CODE_VERSION != SIMULATION)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1661
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1662
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1663 #if (PWMEAS_IF_MODE_FORCE == 0)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1664 cust_get_if_dco_ctl_algo(&dco_algo_ctl_pw_temp, &if_ctl, (UWORD8) L1_IL_VALID ,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1665 last_known_il,
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1666 radio_freq, if_threshold);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1667 #else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1668 if_ctl = IF_120KHZ_DSP;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1669 dco_algo_ctl_pw_temp = DCO_IF_0KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1670 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1671
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1672 lna_off = l1a_l1s_com.Scell_used_IL_dd.lna_off;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1673 delta_drp_gain = drp_gain_correction(arfcn, lna_off, used_agc); // F7.1 format
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1674
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1675 if(if_ctl == IF_100KHZ_DSP){
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1676 delta_drp_gain += SCF_ATTENUATION_LIF_100KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1677 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1678 else{ /* i.e. if_ctl = IF_120KHZ_DSP*/
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1679 delta_drp_gain += SCF_ATTENUATION_LIF_120KHZ;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1680 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1681
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1682
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1683 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1684 #endif
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1685
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1686 if (0==pm) // Check and filter illegal pm value by using last valid IL
316
ec71c9658110 l1p_ctl.c: reconstruction complete, perfect match to original TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 315
diff changeset
1687 current_IL = l1a_l1s_com.last_input_level[index].input_level - lna_value;
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1688 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1689 current_IL = -(pm - (used_agc - delta_drp_gain) + lna_value - l1ctl_get_g_magic(radio_freq));
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1690
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1691 // Calibrated IL processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1692 current_calibrated_IL = current_IL - delta1_freq - delta2_freq;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1693
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1694 // Protect IL stores against overflow
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1695 if (current_calibrated_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1696 current_calibrated_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1697 if (current_IL>INDEX_MAX)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1698 current_IL=INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1699
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1700 // if radio freq is the serving beacon
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1701 //------------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1702 if (radio_freq == l1a_l1s_com.Scell_info.radio_freq)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1703 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1704 // FIFO management
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1705 for (i=3;i>0;i--)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1706 l1a_l1s_com.Scell_info.buff_beacon[i] = l1a_l1s_com.Scell_info.buff_beacon[i-1];
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1707 l1a_l1s_com.Scell_info.buff_beacon[0] = (UWORD8) current_IL;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1708
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1709 // Find min IL in FIFO
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1710 new_IL = l1ctl_find_max(l1a_l1s_com.Scell_info.buff_beacon,4);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1711
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1712 // lna_off processing
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1713 new_calibrated_IL = (WORD16) (new_IL - delta1_freq - delta2_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1714 if (new_calibrated_IL>INDEX_MAX) new_calibrated_IL = INDEX_MAX;
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1715
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1716 l1ctl_encode_lna((UWORD8)(new_calibrated_IL>>1),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1717 &(l1a_l1s_com.last_input_level[index].lna_off),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1718 radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1719
316
ec71c9658110 l1p_ctl.c: reconstruction complete, perfect match to original TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 315
diff changeset
1720 l1a_l1s_com.last_input_level[index].input_level = new_IL +
ec71c9658110 l1p_ctl.c: reconstruction complete, perfect match to original TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 315
diff changeset
1721 l1a_l1s_com.last_input_level[index].lna_off *
ec71c9658110 l1p_ctl.c: reconstruction complete, perfect match to original TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 315
diff changeset
1722 l1ctl_get_lna_att(radio_freq);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1723 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1724
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1725 // if radio freq is a neighbor beacon
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1726 //-----------------------------------
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1727 else
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1728 {
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1729 // Update last_input_level (IL with LNA ON)
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1730 l1ctl_encode_lna((UWORD8)(current_calibrated_IL>>1),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1731 &(l1a_l1s_com.last_input_level[index].lna_off),
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1732 radio_freq);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1733
316
ec71c9658110 l1p_ctl.c: reconstruction complete, perfect match to original TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 315
diff changeset
1734 l1a_l1s_com.last_input_level[index].input_level = current_IL +
ec71c9658110 l1p_ctl.c: reconstruction complete, perfect match to original TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 315
diff changeset
1735 l1a_l1s_com.last_input_level[index].lna_off *
ec71c9658110 l1p_ctl.c: reconstruction complete, perfect match to original TCS211 object
Mychaela Falconia <falcon@freecalypso.org>
parents: 315
diff changeset
1736 l1ctl_get_lna_att(radio_freq);
309
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1737 }
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1738
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1739 return((UWORD8)current_calibrated_IL);
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1740
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1741 } // End of "l1pctl_pgc"
871cf4253768 l1p_ctl.c: initial import from LoCosto source
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
1742 #endif