FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/ra/ra_tra.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_TRA | |
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 functions for the transparent data model | |
18 | for the component RA of the mobile station | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef RA_TRA_C | |
23 #define RA_TRA_C | |
24 #endif | |
25 | |
26 #define ENTITY_RA | |
27 | |
28 /*==== INCLUDES ===================================================*/ | |
29 | |
30 #include "typedefs.h" | |
31 #include "vsi.h" | |
32 #include "macdef.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 /*==== FUNCTIONS ==================================================*/ | |
47 | |
48 /* | |
49 +--------------------------------------------------------------------+ | |
50 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
51 | STATE : code ROUTINE : tra_init | | |
52 +--------------------------------------------------------------------+ | |
53 | |
54 PURPOSE : initialize the transparent mode data | |
55 */ | |
56 | |
57 GLOBAL void tra_init (UBYTE tra_rate) | |
58 { | |
59 T_TRA *dtra = ra_data->tra; | |
60 | |
61 TRACE_FUNCTION("tra_init()"); | |
62 | |
63 dtra->ul_data_pending = FALSE; | |
64 dtra->ul_signals_pending = FALSE; | |
65 dtra->ul_break_pending = FALSE; | |
66 | |
67 dtra->break_pos = 0; | |
68 dtra->break_len = 0; | |
69 dtra->overspeed = 0; | |
70 dtra->ul_status = 0; | |
71 dtra->ul_sa = 0; | |
72 dtra->ul_sb = 0; | |
73 dtra->ul_x = 0; | |
74 | |
75 dtra->dl_sa.pos = ST_SA; /* DSR */ | |
76 dtra->dl_sa.last = 0xFF; | |
77 dtra->dl_sa.timer = 0L; | |
78 | |
79 #ifdef _SIMULATION_ /* according to GSM-TS07.01 */ | |
80 | |
81 dtra->dl_sa.delay_OFF_ON = 0L; | |
82 dtra->dl_sa.delay_ON_OFF = 0L; | |
83 | |
84 #else /* to avoid spurious data at the beginning of the call */ | |
85 | |
86 dtra->dl_sa.delay_OFF_ON = 5000L; | |
87 dtra->dl_sa.delay_ON_OFF = 1000L; | |
88 | |
89 #endif | |
90 | |
91 dtra->dl_sb.pos = ST_SB; /* DCD */ | |
92 dtra->dl_sb.last = 0xFF; | |
93 dtra->dl_sb.timer = 0L; | |
94 dtra->dl_sb.delay_OFF_ON = 200L; | |
95 dtra->dl_sb.delay_ON_OFF = 5000L; | |
96 | |
97 dtra->dl_x.pos = ST_X; /* CTS */ | |
98 dtra->dl_x.last = 0xFF; | |
99 dtra->dl_x.timer = 0L; | |
100 dtra->dl_x.delay_OFF_ON = 1000L; | |
101 dtra->dl_x.delay_ON_OFF = 1000L; | |
102 | |
103 ra_data->ra_data_ind.status = ST_SA + ST_SB + ST_X; | |
104 | |
105 ra_data->ra_data_ind.fr_type = FR_TRANS; | |
106 ra_data->ra_data_ind.sdu.o_buf = 0; | |
107 ra_data->ra_data_ind.sdu.l_buf = 0; | |
108 | |
109 ra_data->ra_ready_ind[0].req_frames = 0; /* used, if not all data sent yet */ | |
110 dtra->ready_ind_idx = 1; | |
111 | |
112 switch (tra_rate) | |
113 { | |
114 case TRA_FULLRATE_14400: | |
115 ra_data->ra_ready_ind[1].req_frames = RAU_DATA_14400; | |
116 break; | |
117 case TRA_FULLRATE_4800: | |
118 ra_data->ra_ready_ind[1].req_frames = RAU_DATA_4800; | |
119 break; | |
120 case TRA_HALFRATE_4800: | |
121 case TRA_FULLRATE_2400: | |
122 ra_data->ra_ready_ind[1].req_frames = RAU_DATA_2400; | |
123 break; | |
124 case TRA_HALFRATE_2400: | |
125 ra_data->ra_ready_ind[1].req_frames = RAU_DATA_1200; | |
126 break; | |
127 default: | |
128 ra_data->ra_ready_ind[1].req_frames = RAU_DATA_9600; | |
129 break; | |
130 } | |
131 | |
132 cl_set_frame_desc_0(&dtra->ul_frame_desc, NULL, 0); | |
133 | |
134 hCommMMI = vsi_c_open ( VSI_CALLER ACI_NAME ); | |
135 hCommTRA = vsi_c_open ( VSI_CALLER TRA_NAME ); | |
136 } | |
137 | |
138 /* | |
139 +--------------------------------------------------------------------+ | |
140 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
141 | STATE : code ROUTINE : tra_idle | | |
142 +--------------------------------------------------------------------+ | |
143 | |
144 PURPOSE : IDLE processing fpr uplink and downlink transparent mode | |
145 | |
146 | |
147 */ | |
148 | |
149 GLOBAL void tra_idle(void) | |
150 { | |
151 TRACE_FUNCTION("tra_idle()"); | |
152 } | |
153 | |
154 /* | |
155 +--------------------------------------------------------------------+ | |
156 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
157 | STATE : code ROUTINE : tra_ul_null | | |
158 +--------------------------------------------------------------------+ | |
159 | |
160 PURPOSE : | |
161 | |
162 */ | |
163 | |
164 GLOBAL void tra_ul_null(void) | |
165 { | |
166 TRACE_FUNCTION("tra_ul_null()"); | |
167 | |
168 if (ra_data->activated) | |
169 { | |
170 /* | |
171 * setup the communication parameters | |
172 */ | |
173 shm_set_dsp_value (conf_b_itc, V_ITC_DATA); | |
174 shm_set_dsp_value (test_b_t_dl_debug, 0); | |
175 | |
176 switch (ra_data->nsb) | |
177 { | |
178 case 1: | |
179 shm_set_dsp_value (conf_b_nsb, V_NSB_ONE_STOP); | |
180 break; | |
181 | |
182 case 2: | |
183 shm_set_dsp_value (conf_b_nsb, V_NSB_TWO_STOP); | |
184 break; | |
185 | |
186 default: | |
187 break; | |
188 } | |
189 | |
190 switch (ra_data->ndb) | |
191 { | |
192 case 7: | |
193 shm_set_dsp_value (conf_b_ndb, V_NDMSK_B_7_DBITS); | |
194 break; | |
195 | |
196 case 8: | |
197 shm_set_dsp_value (conf_b_ndb, V_NDMSK_B_8_DBITS); | |
198 break; | |
199 | |
200 default: | |
201 break; | |
202 } | |
203 | |
204 switch (ra_data->user_rate) | |
205 { | |
206 case URA_300: | |
207 shm_set_dsp_value (conf_b_ur, V_UR_300); | |
208 break; | |
209 | |
210 case URA_1200: | |
211 shm_set_dsp_value (conf_b_ur, V_UR_1200); | |
212 break; | |
213 | |
214 case URA_2400: | |
215 shm_set_dsp_value (conf_b_ur, V_UR_2400); | |
216 break; | |
217 | |
218 case URA_4800: | |
219 shm_set_dsp_value (conf_b_ur, V_UR_4800); | |
220 break; | |
221 | |
222 case URA_9600: | |
223 /* hack for 14400: */ | |
224 if (ra_data->tra_rate EQ TRA_FULLRATE_14400) | |
225 { | |
226 shm_set_dsp_value (conf_b_ur, V_UR_14400); | |
227 } | |
228 else | |
229 { | |
230 shm_set_dsp_value (conf_b_ur, V_UR_9600); | |
231 } | |
232 break; | |
233 | |
234 case URA_1200_75: | |
235 shm_set_dsp_value (conf_b_ur, V_UR_1200_75); | |
236 break; | |
237 | |
238 case URA_14400: | |
239 shm_set_dsp_value (conf_b_ur, V_UR_14400); | |
240 break; | |
241 | |
242 default: | |
243 break; | |
244 } | |
245 | |
246 shm_set_dsp_value (conf_b_ce, V_CE_TRANSP); | |
247 | |
248 switch (ra_data->tra_rate) | |
249 { | |
250 case TRA_FULLRATE_14400: | |
251 case TRA_FULLRATE_9600: | |
252 case TRA_FULLRATE_4800: | |
253 case TRA_FULLRATE_2400: | |
254 shm_set_dsp_value (conf_b_ct, V_CT_FR); | |
255 ra_data->cycle_time = 20; | |
256 break; | |
257 | |
258 case TRA_HALFRATE_4800: | |
259 case TRA_HALFRATE_2400: | |
260 shm_set_dsp_value (conf_b_ct, V_CT_HR); | |
261 ra_data->cycle_time = 40; | |
262 break; | |
263 | |
264 default: | |
265 break; | |
266 } | |
267 | |
268 /* | |
269 * set uplink buffer empty to empty values and no break | |
270 */ | |
271 shm_set_dsp_value (rau_byte_cnt, 2); | |
272 shm_set_dsp_value (rau_break_len, 0); | |
273 shm_set_dsp_value (rau_break_pos, 0); | |
274 | |
275 /* | |
276 * start initialisation process in F&D L1 | |
277 */ | |
278 shm_set_dsp_value (act_b_init, 1); | |
279 shm_set_dsp_value (act_b_syncul, 1); | |
280 shm_set_dsp_value (act_b_syncdl, 1); | |
281 | |
282 INIT_STATE (KER, TRA_INIT_L1); | |
283 | |
284 #ifdef HO_WORKAROUND /* tra_ul_null */ | |
285 _act_d_ra_conf = *ra_data->shm.shm_addr[d_ra_conf]; | |
286 TRACE_EVENT("d_ra_conf saved"); | |
287 #endif | |
288 | |
289 } | |
290 } | |
291 | |
292 /* | |
293 +--------------------------------------------------------------------+ | |
294 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
295 | STATE : code ROUTINE : tra_ul_init_l1 | | |
296 +--------------------------------------------------------------------+ | |
297 | |
298 PURPOSE : | |
299 | |
300 | |
301 */ | |
302 | |
303 GLOBAL void tra_ul_init_l1(void) | |
304 { | |
305 TRACE_FUNCTION("tra_ul_init_l1()"); | |
306 | |
307 if (shm_get_dsp_value (act_b_init) EQ 0) | |
308 { | |
309 /* | |
310 * L1 F&D initialzed | |
311 * start ul/dl synchronisation | |
312 */ | |
313 | |
314 SET_STATE (KER, TRA_SYNCH_TCH_START); | |
315 } | |
316 } | |
317 | |
318 /* | |
319 +--------------------------------------------------------------------+ | |
320 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
321 | STATE : code ROUTINE : tra_dl_sync_tch_start | | |
322 +--------------------------------------------------------------------+ | |
323 | |
324 PURPOSE : | |
325 */ | |
326 | |
327 GLOBAL void tra_dl_sync_tch_start(void) | |
328 { | |
329 TRACE_FUNCTION("tra_dl_sync_tch_start()"); | |
330 | |
331 if (shm_get_dsp_value (statd_b_syncdet) EQ 1) | |
332 { | |
333 /* | |
334 * Start a pseudo timer with 500 ms. | |
335 * The value is decremented by cycle_time | |
336 * each time the L1 calls the dll_data_ul function. | |
337 */ | |
338 TRACE_EVENT("SYNC_TIMER: start"); | |
339 ra_data->sync_timer = 500L; | |
340 shm_set_dsp_value (rad_byte_cnt, 2); | |
341 SET_STATE (KER, TRA_SYNCH_TCH_FOUND); | |
342 } | |
343 } | |
344 | |
345 LOCAL void set_ul_status(T_TRA *tra) | |
346 { | |
347 shm_set_dsp_value (statu_b_sa, tra->ul_sa); | |
348 shm_set_dsp_value (statu_b_sb, tra->ul_sb); | |
349 shm_set_dsp_value (statu_b_x, tra->ul_x); | |
350 } | |
351 | |
352 /* | |
353 +--------------------------------------------------------------------+ | |
354 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
355 | STATE : code ROUTINE : tra_ul_sync_tch_found | | |
356 +--------------------------------------------------------------------+ | |
357 | |
358 PURPOSE : | |
359 */ | |
360 | |
361 GLOBAL void tra_ul_sync_tch_found(void) | |
362 { | |
363 TRACE_FUNCTION("tra_ul_sync_tch_found()"); | |
364 | |
365 if (TimeOut(&ra_data->sync_timer) NEQ TRUE) | |
366 return; | |
367 | |
368 /* | |
369 * timeout of the sync timer - reset the sync-detection flags | |
370 */ | |
371 TRACE_EVENT("SYNC_TIMER: time out"); | |
372 | |
373 shm_set_dsp_value (act_b_syncul, 0); | |
374 shm_set_dsp_value (act_b_syncdl, 0); | |
375 | |
376 if (ra_data->tra_rate NEQ TRA_FULLRATE_14400) | |
377 { | |
378 ra_data->sync_timer = 10000L; /* 10 secs timeout */ | |
379 SET_STATE (KER, TRA_WAIT_SYNC_LOST); | |
380 } | |
381 else | |
382 { | |
383 SET_STATE (KER, TRA_DATA_TRANS_PRE1); | |
384 | |
385 #ifdef HO_WORKAROUND /* tra_ul_sync_tch_found */ | |
386 if (*ra_data->shm.shm_addr[d_ra_conf] NEQ _act_d_ra_conf) | |
387 { | |
388 *ra_data->shm.shm_addr[d_ra_conf] = _act_d_ra_conf; /* tra_dl_data_trans */ | |
389 TRACE_EVENT("HO_REFRESH tra_ul_sync_tch_found"); | |
390 } | |
391 #endif | |
392 | |
393 } | |
394 } | |
395 | |
396 /* | |
397 +--------------------------------------------------------------------+ | |
398 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
399 | STATE : code ROUTINE : tra_dl_wait_sync_lost | | |
400 +--------------------------------------------------------------------+ | |
401 | |
402 PURPOSE : | |
403 */ | |
404 | |
405 GLOBAL void tra_dl_wait_sync_lost(void) | |
406 { | |
407 BOOL timeout; | |
408 | |
409 TRACE_FUNCTION("tra_dl_wait_sync_lost()"); | |
410 | |
411 timeout = TimeOut(&ra_data->sync_timer); | |
412 | |
413 if (timeout EQ TRUE) | |
414 { | |
415 TRACE_EVENT("SYNC_TIMER: statd_b_syncdet remains HIGH"); | |
416 } | |
417 | |
418 if (shm_get_dsp_value (statd_b_syncdet) EQ 0 OR timeout EQ TRUE) | |
419 { | |
420 /* | |
421 * sync detection finished -> enter the data transmission state | |
422 * send ra_activate_cnf -> ACI | |
423 */ | |
424 SET_STATE (KER, TRA_DATA_TRANS_PRE1); | |
425 set_ul_status(ra_data->tra); | |
426 | |
427 #ifdef HO_WORKAROUND /* tra_dl_wait_sync_lost */ | |
428 if (*ra_data->shm.shm_addr[d_ra_conf] NEQ _act_d_ra_conf) | |
429 { | |
430 *ra_data->shm.shm_addr[d_ra_conf] = _act_d_ra_conf; /* tra_dl_data_trans */ | |
431 TRACE_EVENT("HO_REFRESH tra_dl_wait_sync_lost"); | |
432 } | |
433 #endif | |
434 | |
435 } | |
436 } | |
437 | |
438 /* | |
439 +--------------------------------------------------------------------+ | |
440 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
441 | STATE : code ROUTINE : tra_ul_data_trans | | |
442 +--------------------------------------------------------------------+ | |
443 | |
444 PURPOSE : | |
445 */ | |
446 | |
447 GLOBAL void tra_ul_data_trans(void) | |
448 { | |
449 T_TRA *dtra = ra_data->tra; | |
450 | |
451 TRACE_FUNCTION("tra_ul_data_trans()"); | |
452 | |
453 if (dtra->ul_signals_pending) | |
454 { | |
455 /* | |
456 * handle sa, sb, x signals | |
457 */ | |
458 set_ul_status(dtra); | |
459 | |
460 shm_set_dsp_value (act_b_ovspul, dtra->overspeed); | |
461 } | |
462 | |
463 if (dtra->ul_data_pending) | |
464 { | |
465 USHORT offs, new_offs; | |
466 | |
467 offs = shm_get_dsp_value (rau_byte_cnt); | |
468 | |
469 if (offs > 0) | |
470 { | |
471 offs -= 2; | |
472 | |
473 if (dtra->ul_break_pending) | |
474 { | |
475 shm_set_dsp_value (rau_break_pos, dtra->break_pos); | |
476 shm_set_dsp_value (rau_break_len, dtra->break_len); | |
477 } | |
478 else | |
479 { | |
480 shm_set_dsp_value (rau_break_pos, 0); | |
481 shm_set_dsp_value (rau_break_len, 0); | |
482 } | |
483 | |
484 new_offs = shm_set_dsp_buffer(&dtra->ul_frame_desc, | |
485 ra_data->shm.shm_addr[adr_rau_data]+wof_rau_data, | |
486 offs, | |
487 (USHORT)(ra_data->ra_ready_ind[1].req_frames - offs)); | |
488 if (new_offs NEQ offs) | |
489 { | |
490 shm_set_dsp_value (rau_byte_cnt, (USHORT)(new_offs+2)); | |
491 } | |
492 | |
493 if (dtra->ul_frame_desc.Len[0] EQ 0) | |
494 { | |
495 dtra->ul_data_pending = FALSE; | |
496 dtra->ready_ind_idx = 1; | |
497 } | |
498 else | |
499 { | |
500 dtra->ul_frame_desc.Adr[0] += (new_offs-offs); | |
501 } | |
502 } | |
503 } | |
504 if (!dtra->ul_data_pending OR dtra->ul_signals_pending) | |
505 { | |
506 if (dtra->ul_signals_pending AND !dtra->ul_data_pending) | |
507 { | |
508 dtra->ready_ind_idx = 1; | |
509 } | |
510 if (dtra->data_req_rec) /* send only if RA_DATA_REQ received */ | |
511 { | |
512 l1i_ra_ready_ind(hCommTRA, dtra->ready_ind_idx); | |
513 dtra->data_req_rec = FALSE; | |
514 dtra->ready_ind_idx = 0; | |
515 dtra->ul_signals_pending = FALSE; | |
516 } | |
517 } | |
518 } | |
519 | |
520 LOCAL UBYTE check_status_bit(T_STATUS_BIT *status) | |
521 { | |
522 if (status->last NEQ status->current) | |
523 { | |
524 status->last = status->current; | |
525 | |
526 if (status->current) /* current status bit is OFF */ | |
527 { | |
528 if (status->delay_ON_OFF) | |
529 { | |
530 status->timer = status->delay_ON_OFF; /* start ON to OFF timer */ | |
531 return 2+1; | |
532 } | |
533 else | |
534 { | |
535 ra_data->ra_data_ind.status |= status->pos; /* status bit OFF */ | |
536 return 4+1; | |
537 } | |
538 } | |
539 else /* current status bit is ON */ | |
540 { | |
541 if (status->delay_OFF_ON) | |
542 { | |
543 status->timer = status->delay_OFF_ON; /* start OFF to ON timer */ | |
544 return 2+0; | |
545 } | |
546 else | |
547 { | |
548 ra_data->ra_data_ind.status &= ~status->pos; /* status bit ON */ | |
549 return 4+0; | |
550 } | |
551 } | |
552 } | |
553 else /* status->last EQ status->current */ | |
554 { | |
555 if (TimeOut(&status->timer) EQ TRUE) | |
556 { | |
557 if (status->current) /* current status bit is OFF */ | |
558 { | |
559 ra_data->ra_data_ind.status |= status->pos; /* filtered status bit OFF */ | |
560 return 4+1; | |
561 } | |
562 else | |
563 { | |
564 ra_data->ra_data_ind.status &= ~status->pos; /* filtered status bit ON */ | |
565 return 4+0; | |
566 } | |
567 } | |
568 } | |
569 return 0; | |
570 } | |
571 | |
572 LOCAL BOOL get_dl_status_bits(void) | |
573 { | |
574 T_TRA *dtra = ra_data->tra; | |
575 BOOL dl_status_changed = FALSE; | |
576 UBYTE ret; | |
577 | |
578 /*** status bit SA ***/ | |
579 | |
580 dtra->dl_sa.current = (UBYTE)shm_get_dsp_value(statd_b_sa); | |
581 ret = check_status_bit(&dtra->dl_sa); | |
582 if (ret > 3) | |
583 dl_status_changed = TRUE; | |
584 | |
585 #ifdef TRACE_RA_TRA_STATUS | |
586 switch (ret) | |
587 { | |
588 case 2: TRACE_EVENT("SA bit timer started 1 -> 0"); break; | |
589 case 3: TRACE_EVENT("SA bit timer started 0 -> 1"); break; | |
590 case 4: TRACE_EVENT("CT107-DSR=ON"); break; | |
591 case 5: TRACE_EVENT("CT107-DSR=OFF"); break; | |
592 } | |
593 #endif | |
594 | |
595 if (!(ra_data->ra_data_ind.status & ST_SA)) /* DSR EQ ON */ | |
596 { | |
597 /*** perform filtering of status bit SB ***/ | |
598 | |
599 dtra->dl_sb.current = (UBYTE)shm_get_dsp_value(statd_b_sb); | |
600 ret = check_status_bit(&dtra->dl_sb); | |
601 if (ret > 3) | |
602 dl_status_changed = TRUE; | |
603 | |
604 #ifdef TRACE_RA_TRA_STATUS | |
605 switch (ret) | |
606 { | |
607 case 2: TRACE_EVENT("SB bit timer started 1 -> 0"); break; | |
608 case 3: TRACE_EVENT("SB bit timer started 0 -> 1"); break; | |
609 case 4: TRACE_EVENT("CT109-DCD=ON"); break; | |
610 case 5: TRACE_EVENT("CT109-DCD=OFF"); break; | |
611 } | |
612 #endif | |
613 | |
614 /*** perform filtering of status bit X ***/ | |
615 | |
616 dtra->dl_x.current = (UBYTE)shm_get_dsp_value(statd_b_x); | |
617 ret = check_status_bit(&dtra->dl_x); | |
618 if (ret > 3) | |
619 dl_status_changed = TRUE; | |
620 | |
621 #ifdef TRACE_RA_TRA_STATUS | |
622 switch (ret) | |
623 { | |
624 case 2: TRACE_EVENT("X bit timer started 1 -> 0"); break; | |
625 case 3: TRACE_EVENT("X bit timer started 0 -> 1"); break; | |
626 case 4: TRACE_EVENT("CT106-CTS=ON"); break; | |
627 case 5: TRACE_EVENT("CT106-CTS=OFF"); break; | |
628 } | |
629 #endif | |
630 | |
631 } | |
632 else if (dl_status_changed EQ TRUE) /* DSR EQ OFF */ | |
633 { | |
634 ra_data->ra_data_ind.status |= ST_SB + ST_X; | |
635 dtra->dl_sb.last = 0xFF; | |
636 dtra->dl_x.last = 0xFF; | |
637 | |
638 #ifdef TRACE_RA_TRA_STATUS | |
639 TRACE_EVENT("CT106-CTS=OFF"); | |
640 TRACE_EVENT("CT109-DCD=OFF"); | |
641 #endif | |
642 } | |
643 | |
644 /* | |
645 * overwrite the downlink CTS bit; | |
646 * allows UART the reception of escape sequence always; | |
647 * no matter what the current call state may be | |
648 ra_data->ra_data_ind.status &= ~ST_X; | |
649 */ | |
650 return dl_status_changed; | |
651 } | |
652 | |
653 LOCAL U8 get_frame_descriptor(U8 bytes_to_read) | |
654 { | |
655 T_TRA *dtra = ra_data->tra; | |
656 | |
657 #ifdef _SIMULATION_ | |
658 dtra->dl_pFD = cl_ribu_get_new_frame_desc(ra_data->dl_ribu); | |
659 #else | |
660 dtra->dl_pFD = tra_get_next_FrameDesc(); | |
661 #endif | |
662 | |
663 | |
664 if (NULL EQ dtra->dl_pFD) | |
665 { | |
666 /*Race condition where there is a data from L1 and call is released parallely*/ | |
667 TRACE_EVENT("Call is Released when data arrived or Ribu write index is invalid"); | |
668 | |
669 /*return as if no data is read from L1.*/ | |
670 return 0; | |
671 } | |
672 | |
673 | |
674 if (bytes_to_read) | |
675 { | |
676 dtra->dl_pFD->len = MAX_TRANS_BUFFER; | |
677 return (shm_get_dsp_buffer_new(ra_data->shm.shm_addr[adr_rad_data]+wof_rad_data, bytes_to_read, dtra->dl_pFD)); | |
678 } | |
679 else | |
680 { | |
681 dtra->dl_pFD->len = 0; | |
682 return 0; | |
683 } | |
684 } | |
685 | |
686 /* | |
687 +--------------------------------------------------------------------+ | |
688 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
689 | STATE : code ROUTINE : tra_dl_wait_for_connect | | |
690 +--------------------------------------------------------------------+ | |
691 | |
692 PURPOSE : wait for all filtered status bits set to 0 | |
693 */ | |
694 | |
695 GLOBAL void tra_dl_wait_for_connect(void) | |
696 { | |
697 TRACE_FUNCTION("tra_dl_wait_for_connect()"); | |
698 | |
699 #ifdef HO_WORKAROUND /* tra_dl_wait_for_connect */ | |
700 if (*ra_data->shm.shm_addr[d_ra_conf] NEQ _act_d_ra_conf) | |
701 { | |
702 *ra_data->shm.shm_addr[d_ra_conf] = _act_d_ra_conf; /* tra_dl_data_trans */ | |
703 TRACE_EVENT("HO_REFRESH tra_dl_data_trans"); | |
704 } | |
705 #endif | |
706 | |
707 get_dl_status_bits(); | |
708 if ((UBYTE)(ra_data->ra_data_ind.status AND (ST_SA + ST_SB + ST_X)) EQ 0) | |
709 { | |
710 l1i_ra_activate_cnf(); | |
711 SET_STATE (KER, TRA_DATA_TRANS_PRE2); | |
712 } | |
713 } | |
714 | |
715 /* | |
716 +--------------------------------------------------------------------+ | |
717 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
718 | STATE : code ROUTINE : tra_dl_wait_for_uart | | |
719 +--------------------------------------------------------------------+ | |
720 | |
721 PURPOSE : wait for DTI connection to UART | |
722 */ | |
723 | |
724 GLOBAL void tra_dl_wait_for_uart(void) | |
725 { | |
726 TRACE_FUNCTION("tra_dl_wait_for_uart()"); | |
727 | |
728 get_dl_status_bits(); | |
729 } | |
730 | |
731 /* | |
732 +--------------------------------------------------------------------+ | |
733 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
734 | STATE : code ROUTINE : tra_dl_got_uart | | |
735 +--------------------------------------------------------------------+ | |
736 | |
737 PURPOSE : send the current downlink status bits to UART | |
738 */ | |
739 | |
740 GLOBAL void tra_dl_got_uart(void) | |
741 { | |
742 TRACE_FUNCTION("tra_dl_got_uart()"); | |
743 | |
744 get_dl_status_bits(); | |
745 get_frame_descriptor(0); | |
746 l1i_ra_data_ind(hCommTRA); | |
747 SET_STATE (KER, TRA_DATA_TRANS); | |
748 } | |
749 | |
750 LOCAL void get_dl_bytes(UBYTE bytes_to_read) | |
751 { | |
752 T_TRA *dtra = ra_data->tra; | |
753 | |
754 UBYTE bytes_read; | |
755 | |
756 bytes_read = get_frame_descriptor(bytes_to_read); | |
757 shm_set_dsp_value (rad_byte_cnt, 2); /* confirm read operation */ | |
758 | |
759 if ( bytes_read EQ 0 ){ | |
760 /*We couldn't read the data, in get_frame_descriptor() there is a possibiliy | |
761 we get NULL frame description (race condition) hence no data is read. In this case we should not | |
762 access dtra->dl_pFD pointer and as well donot indicate ra_data_ind, hence return. | |
763 */ | |
764 return; | |
765 } | |
766 | |
767 | |
768 if (ra_data->ra_data_ind.status & ST_SA OR ra_data->ra_data_ind.status & ST_SB) | |
769 { | |
770 /* | |
771 DSR is OFF OR DCD is OFF | |
772 */ | |
773 dtra->dl_pFD->len = 0; | |
774 #ifdef TRACE_RA_TRA_DATA | |
775 TRACE_EVENT_P1("DATA_IND - len=0:%c", *dtra->dl_pFD->buf); | |
776 #endif | |
777 } | |
778 else | |
779 { | |
780 dtra->dl_pFD->len = bytes_read; | |
781 #ifdef TRACE_RA_TRA_DATA | |
782 TRACE_EVENT_P2("DATA_IND - len=%d:%c", bytes_read, *dtra->dl_pFD->buf); | |
783 #endif | |
784 } | |
785 l1i_ra_data_ind(hCommTRA); | |
786 } | |
787 | |
788 LOCAL BOOL dl_break_detected(BOOL *dl_status_changed, UBYTE *bytes_to_read) /* BREAK handling */ | |
789 { | |
790 T_TRA *dtra = ra_data->tra; | |
791 | |
792 UBYTE brklen; | |
793 UBYTE brkpos; | |
794 UBYTE bytes_read; | |
795 | |
796 if ((brklen = (UBYTE)shm_get_dsp_value(rad_break_len)) > 0) | |
797 { | |
798 TRACE_EVENT_P1("RA_BREAK_IND-brklen=%d", brklen); | |
799 | |
800 /*** handling of 0xff break over multiple frames not implemented yet ***/ | |
801 | |
802 if ((brkpos = (UBYTE)shm_get_dsp_value(rad_break_pos)) > 0) | |
803 { | |
804 TRACE_EVENT_P1("brkpos=%d", brkpos); | |
805 /* | |
806 * If the position > 0 read out the data until the break occurs. | |
807 */ | |
808 if (*bytes_to_read > 0) | |
809 { | |
810 TRACE_EVENT_P1("bytes_to_read=%d", *bytes_to_read); | |
811 | |
812 bytes_read = get_frame_descriptor(brkpos); | |
813 bytes_to_read -= bytes_read; | |
814 dtra->dl_pFD->len = bytes_read; | |
815 | |
816 TRACE_EVENT ("DATA_IND - break handling"); | |
817 dtra->dl_pFD->len = 0; | |
818 l1i_ra_data_ind(hCommTRA); | |
819 } | |
820 } | |
821 | |
822 shm_set_dsp_value (rad_byte_cnt, 2); /* confirm read operation */ | |
823 | |
824 #ifdef HO_WORKAROUND /* tra_dl_data_trans - "BREAK" */ | |
825 | |
826 /* | |
827 enforce new DSR status bit filtering time | |
828 */ | |
829 dtra->dl_sa.delay_OFF_ON = 1000L; | |
830 dtra->dl_sa.delay_ON_OFF = 0L; | |
831 | |
832 dtra->dl_sa.last = 0xFF; | |
833 dtra->dl_sb.last = 0xFF; | |
834 dtra->dl_x.last = 0xFF; | |
835 | |
836 ra_data->ra_data_ind.status = ST_SA + ST_SB + ST_X; | |
837 | |
838 *dl_status_changed = TRUE; | |
839 | |
840 #else | |
841 | |
842 dtra->ra_break_ind.break_len = brklen; | |
843 l1i_ra_break_ind(); | |
844 | |
845 #endif | |
846 | |
847 if (*dl_status_changed EQ TRUE) | |
848 { | |
849 get_frame_descriptor(0); | |
850 l1i_ra_data_ind(hCommTRA); | |
851 } | |
852 | |
853 return TRUE; | |
854 } /* brklen > 0 */ | |
855 | |
856 return FALSE; | |
857 } | |
858 | |
859 /* | |
860 +--------------------------------------------------------------------+ | |
861 | PROJECT : GSM-F&D (8411) MODULE : RA_TRA | | |
862 | STATE : code ROUTINE : tra_dl_data_trans | | |
863 +--------------------------------------------------------------------+ | |
864 | |
865 PURPOSE : | |
866 */ | |
867 | |
868 GLOBAL void tra_dl_data_trans(void) | |
869 { | |
870 UBYTE bytes_to_read; | |
871 BOOL dl_status_changed; | |
872 | |
873 TRACE_FUNCTION("tra_dl_data_trans()"); | |
874 | |
875 #ifdef HO_WORKAROUND /* tra_dl_data_trans */ | |
876 if (*ra_data->shm.shm_addr[d_ra_conf] NEQ _act_d_ra_conf) | |
877 { | |
878 *ra_data->shm.shm_addr[d_ra_conf] = _act_d_ra_conf; /* tra_dl_data_trans */ | |
879 TRACE_EVENT("HO_REFRESH tra_dl_data_trans"); | |
880 } | |
881 #endif | |
882 | |
883 dl_status_changed = get_dl_status_bits(); | |
884 | |
885 /*** read out the received downlink data ***/ | |
886 | |
887 bytes_to_read = shm_get_dsp_value (rad_byte_cnt); | |
888 | |
889 if (bytes_to_read > 0) | |
890 { | |
891 bytes_to_read -= 2; /* ignore header */ | |
892 | |
893 if (dl_break_detected(&dl_status_changed, &bytes_to_read)) | |
894 return; | |
895 | |
896 if (bytes_to_read > 0 AND bytes_to_read <= MAX_TRANS_BUFFER) | |
897 { | |
898 get_dl_bytes(bytes_to_read); | |
899 } | |
900 else /* NO bytes_to_read */ | |
901 { | |
902 if (dl_status_changed EQ TRUE) | |
903 { | |
904 get_frame_descriptor(0); | |
905 l1i_ra_data_ind(hCommTRA); | |
906 } | |
907 } | |
908 } | |
909 else /* NO bytes_to_read -- will never happen */ | |
910 { | |
911 if (dl_status_changed EQ TRUE) | |
912 { | |
913 get_frame_descriptor(0); | |
914 l1i_ra_data_ind(hCommTRA); | |
915 } | |
916 } | |
917 } |