comparison src/g23m-fad/ra/ra_dll.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : RA_DLL
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This Modul defines the L1 scheduler interface functions
18 | for the component RA of the mobile station
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef RA_DLL_C
23 #define RA_DLL_C
24 #endif
25
26 #define ENTITY_RA
27
28 /*==== INCLUDES ===================================================*/
29
30 #include <string.h>
31 #include "typedefs.h"
32 #include "vsi.h"
33 #include "pconst.cdg"
34 #include "custom.h"
35 #include "gsm.h"
36 #include "cnf_ra.h"
37 #include "prim.h"
38 #include "pei.h"
39 #include "tok.h"
40 #include "ccdapi.h"
41 #include "ra.h"
42
43 /*==== CONST ======================================================*/
44 /*==== TYPES ======================================================*/
45 /*==== VARIABLES ==================================================*/
46
47 GLOBAL T_RA_DATA ra_data_base[1];
48
49 /*
50 * state-controlled jump tables for each communication model
51 */
52
53 LOCAL const T_VOID_FUNC tra_uplink_func[TRA_STATES] =
54 {
55 tra_ul_null, // TRA_NULL
56 tra_ul_init_l1, // TRA_INIT_L1
57 tra_idle, // TRA_SYNCH_TCH_START
58 tra_ul_sync_tch_found, // TRA_SYNCH_TCH_FOUND
59 tra_idle, // TRA_WAIT_SYNC_LOST
60 tra_idle, // TRA_DATA_TRANS_PRE1
61 tra_idle, // TRA_DATA_TRANS_PRE2
62 tra_idle, // TRA_DATA_TRANS_PRE3
63 tra_ul_data_trans // TRA_DATA_TRANS
64 };
65
66 LOCAL const T_VOID_FUNC tra_downlink_func[TRA_STATES] =
67 {
68 tra_idle, // TRA_NULL
69 tra_idle, // TRA_INIT_L1
70 tra_dl_sync_tch_start, // TRA_SYNCH_TCH_START
71 tra_idle, // TRA_SYNCH_TCH_FOUND
72 tra_dl_wait_sync_lost, // TRA_WAIT_SYNC_LOST
73 tra_dl_wait_for_connect, // TRA_DATA_TRANS_PRE1
74 tra_dl_wait_for_uart, // TRA_DATA_TRANS_PRE2
75 tra_dl_got_uart, // TRA_DATA_TRANS_PRE3
76 tra_dl_data_trans // TRA_DATA_TRANS
77 };
78
79 #ifdef FF_FAX
80
81 LOCAL const T_VOID_FUNC fax_uplink_func[FAX_STATES] =
82 {
83 fax_ul_null, // FAX_NULL
84 fax_ul_init_l1, // FAX_INIT_L1
85 fax_idle, // FAX_SYNCH_TCH_START
86 fax_ul_sync_tch_found, // FAX_SYNCH_TCH_FOUND
87 fax_idle, // FAX_WAIT_SYNC_LOST
88 fax_idle, // FAX_DATA_TRANS_PRE
89 fax_ul_data_trans, // FAX_DATA_TRANS
90 fax_ul_modify // FAX_MODIFY
91 };
92
93 LOCAL const T_VOID_FUNC fax_downlink_func[FAX_STATES] =
94 {
95 fax_idle, // FAX_NULL
96 fax_idle, // FAX_INIT_L1
97 fax_dl_sync_tch_start, // FAX_SYNCH_TCH_START
98 fax_idle, // FAX_SYNCH_TCH_FOUND
99 fax_dl_wait_sync_lost, // FAX_WAIT_SYNC_LOST
100 fax_idle, // FAX_DATA_TRANS_PRE
101 fax_dl_data_trans, // FAX_DATA_TRANS
102 fax_idle // FAX_MODIFY
103 };
104
105 #endif /* FF_FAX */
106
107 LOCAL const T_VOID_FUNC rlp_uplink_func[RLP_STATES] =
108 {
109 rlp_ul_null, // RLP_NULL
110 rlp_ul_init_l1, // RLP_INIT_L1
111 rlp_ul_data_trans // RLP_DATA_TRANS
112 };
113
114 LOCAL const T_VOID_FUNC rlp_downlink_func[RLP_STATES] =
115 {
116 rlp_idle, // RLP_NULL
117 rlp_idle, // RLP_INIT_L1
118 rlp_dl_data_trans // RLP_DATA_TRANS
119 };
120
121 /*==== FUNCTIONS ==================================================*/
122
123 /*
124 +--------------------------------------------------------------------+
125 | PROJECT : GSM-F&D (8411) MODULE : RA_DLL |
126 | STATE : code ROUTINE : TimeOut |
127 +--------------------------------------------------------------------+
128
129 PURPOSE :
130 */
131
132 GLOBAL BOOL TimeOut(USHORT *timer)
133 {
134 if (*timer NEQ 0) /* timer running */
135 {
136 if (*timer > ra_data->cycle_time)
137 *timer -= ra_data->cycle_time;
138 else
139 *timer = 0;
140
141 #ifdef _SIMULATION_
142 TRACE_EVENT_P1("RA_TIMER=%d", *timer);
143 #endif
144
145 if (*timer EQ 0)
146 return TRUE; /* timer expired */
147 else
148 return FALSE; /* timer running */
149 }
150 return FALSE; /* timer not running */
151 }
152
153 /*
154 +--------------------------------------------------------------------+
155 | PROJECT : GSM-F&D (8411) MODULE : RA_DLL |
156 | STATE : code ROUTINE : dll_init |
157 +--------------------------------------------------------------------+
158
159 PURPOSE : This function is called from the L2/3 in case of
160 activation/deactivation of data services.
161 */
162
163 GLOBAL void dll_init(void)
164 {
165 ra_data = &ra_data_base[0];
166 memset (ra_data, 0, sizeof(T_RA_DATA));
167 memset ((char *)ra_data->shm.shm_addr, 0, sizeof (ra_data->shm.shm_addr));
168 }
169
170 /*
171 +--------------------------------------------------------------------+
172 | PROJECT : GSM-F&D (8411) MODULE : RA_DLL |
173 | STATE : code ROUTINE : dll_data_ul |
174 +--------------------------------------------------------------------+
175
176 PURPOSE : This function is called from the L1 scheduler every 20ms.
177 This function writes the control words
178 and/or the uplink data into the shared memory area
179 which is the interface between the DSP layer1
180 and the MCU layer2. This function is used for all kind
181 of data transmission (FAX/TRANSPARENTDATA/RLP)
182 */
183
184 GLOBAL void dll_data_ul
185 (
186 USHORT *_ul_buffer_address,
187 USHORT *_d_ra_conf,
188 USHORT *_d_ra_act,
189 USHORT *_d_ra_test,
190 USHORT *_d_ra_statu,
191 USHORT *_d_fax
192 )
193 {
194 if (ra_data->activated EQ FALSE)
195 {
196 return;
197 }
198
199 switch (ra_data->model)
200 {
201 case MODEL_RLP:
202 if (ra_data->shm.shm_addr[a_ntu] EQ NULL)
203 {
204 ra_data->shm.shm_addr[a_ntu] = _ul_buffer_address;
205 ra_data->shm.shm_addr[d_ra_conf] = _d_ra_conf;
206 ra_data->shm.shm_addr[d_ra_act] = _d_ra_act;
207 }
208 rlp_uplink_func[ra_data->ker.state]();
209 break;
210
211 case MODEL_TRANS:
212 if (ra_data->shm.shm_addr[a_rau] EQ NULL)
213 {
214 ra_data->shm.shm_addr[a_rau] = _ul_buffer_address;
215 ra_data->shm.shm_addr[d_ra_conf] = _d_ra_conf;
216 ra_data->shm.shm_addr[d_ra_act] = _d_ra_act;
217 ra_data->shm.shm_addr[d_ra_statu] = _d_ra_statu;
218 ra_data->shm.shm_addr[d_ra_test] = _d_ra_test;
219 }
220 tra_uplink_func[ra_data->ker.state]();
221 break;
222
223 #ifdef FF_FAX
224 case MODEL_FAX:
225 if (ra_data->shm.shm_addr[a_faxu] EQ NULL)
226 {
227 ra_data->shm.shm_addr[a_faxu] = _ul_buffer_address;
228 ra_data->shm.shm_addr[d_ra_conf] = _d_ra_conf;
229 ra_data->shm.shm_addr[d_ra_act] = _d_ra_act;
230 ra_data->shm.shm_addr[d_ra_statu] = _d_ra_statu;
231 ra_data->shm.shm_addr[d_fax] = _d_fax;
232 }
233 fax_uplink_func[ra_data->ker.state]();
234 break;
235 #endif /* FF_FAX */
236
237 default:
238 return;
239 }
240 }
241
242 /*
243 +--------------------------------------------------------------------+
244 | PROJECT : GSM-F&D (8411) MODULE : RA_DLL |
245 | STATE : code ROUTINE : dll_data_dl |
246 +--------------------------------------------------------------------+
247
248 PURPOSE : This function is called from the L1 scheduler every 20ms
249 (in TCH/9.6F). This function should read out the
250 indiaction words and/or the downlink data from the shared
251 memory area which is the interface between the DSP layer1
252 and the MCU layer2 and send a primitive to the entity
253 which is active in the selected data mode.
254 This function is used for all kind
255 of data transmission (FAX/TRANSPARENTDATA/RLP)
256 */
257
258 GLOBAL void dll_data_dl(USHORT *_dl_buffer_address, USHORT *_d_ra_act, USHORT *_d_ra_statd)
259 {
260 if (ra_data->activated EQ FALSE)
261 {
262 return;
263 }
264
265 switch (ra_data->model)
266 {
267 case MODEL_RLP:
268 if (ra_data->shm.shm_addr[a_ntd] EQ NULL)
269 {
270 ra_data->shm.shm_addr[a_ntd] = _dl_buffer_address;
271 ra_data->shm.shm_addr[d_ra_act] = _d_ra_act;
272 }
273 rlp_downlink_func[ra_data->ker.state]();
274 break;
275
276 case MODEL_TRANS:
277 if (ra_data->shm.shm_addr[a_rad] EQ NULL)
278 {
279 ra_data->shm.shm_addr[a_rad] = _dl_buffer_address;
280 ra_data->shm.shm_addr[d_ra_act] = _d_ra_act;
281 ra_data->shm.shm_addr[d_ra_statd] = _d_ra_statd;
282 }
283 tra_downlink_func[ra_data->ker.state]();
284 break;
285
286 #ifdef FF_FAX
287 case MODEL_FAX:
288 if (ra_data->shm.shm_addr[a_faxd] EQ NULL)
289 {
290 ra_data->shm.shm_addr[a_faxd] = _dl_buffer_address;
291 ra_data->shm.shm_addr[d_ra_act] = _d_ra_act;
292 ra_data->shm.shm_addr[d_ra_statd] = _d_ra_statd;
293 }
294 fax_downlink_func[ra_data->ker.state]();
295 break;
296 #endif /* FF_FAX */
297
298 default:
299 return;
300 }
301 }
302