FreeCalypso > hg > fc-magnetite
comparison src/g23m-fad/fad/fad_kers.c @ 174:90eb61ecd093
src/g23m-fad: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Oct 2016 05:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
173:bf64d785238a | 174:90eb61ecd093 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-F&D (8411) | |
4 | Modul : FAD_KERS | |
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 processing | |
18 | of incomming signals for the component | |
19 | Fax Adaptation 3.45 of the mobile station | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef FAD_KERS_C | |
24 #define FAD_KERS_C | |
25 #endif | |
26 | |
27 #define ENTITY_FAD | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "pconst.cdg" | |
34 #include "vsi.h" | |
35 #include "macdef.h" | |
36 #include "pconst.cdg" | |
37 #include "custom.h" | |
38 #include "gsm.h" | |
39 #include "cnf_fad.h" | |
40 #include "mon_fad.h" | |
41 #include "prim.h" | |
42 #include "pei.h" | |
43 #include "tok.h" | |
44 #include "ccdapi.h" | |
45 #include "fad.h" | |
46 | |
47 /*==== CONST =======================================================*/ | |
48 | |
49 /*==== TYPES =======================================================*/ | |
50 | |
51 /*==== VAR EXPORT ==================================================*/ | |
52 | |
53 /*==== VAR LOCAL ==================================================*/ | |
54 | |
55 /*==== FUNCTIONS ===================================================*/ | |
56 | |
57 /* | |
58 +-------------------------------------------------------------------------+ | |
59 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
60 | STATE : code ROUTINE : sig_snd_ker_ready_ind | | |
61 +-------------------------------------------------------------------------+ | |
62 | |
63 PURPOSE : Process signal READY_IND received from process SND | |
64 | |
65 */ | |
66 | |
67 GLOBAL void sig_snd_ker_ready_ind (void) | |
68 { | |
69 TRACE_FUNCTION ("sig_snd_ker_ready_ind()"); | |
70 | |
71 switch (GET_STATE (KER)) | |
72 { | |
73 case BCS_REC: | |
74 case MSG_REC: | |
75 { | |
76 PALLOC (fad_ready_ind, FAD_READY_IND); | |
77 PSENDX (T30, fad_ready_ind); | |
78 } | |
79 break; | |
80 default: | |
81 break; | |
82 } | |
83 | |
84 } | |
85 | |
86 /* | |
87 +-------------------------------------------------------------------------+ | |
88 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
89 | STATE : code ROUTINE : sig_snd_ker_data_sent_ind| | |
90 +-------------------------------------------------------------------------+ | |
91 | |
92 PURPOSE : Process signal DATA_SENT_IND received from process SND | |
93 | |
94 */ | |
95 | |
96 GLOBAL void sig_snd_ker_data_sent_ind (void) | |
97 { | |
98 TRACE_FUNCTION ("sig_snd_ker_data_sent_ind()"); | |
99 | |
100 switch (GET_STATE (KER)) | |
101 { | |
102 case BCS_REC: | |
103 case MSG_REC: | |
104 { | |
105 PALLOC (fad_data_cnf, FAD_DATA_CNF); | |
106 PSENDX (T30, fad_data_cnf); | |
107 SET_STATE (KER, IDLE); | |
108 sig_ker_snd_sync_req (TRUE); | |
109 } | |
110 break; | |
111 case MSG_REC_TCF: | |
112 { | |
113 PALLOC (fad_snd_tcf_cnf, FAD_SND_TCF_CNF); | |
114 PSENDX (T30, fad_snd_tcf_cnf); | |
115 SET_STATE (KER, IDLE); | |
116 sig_ker_snd_sync_req (TRUE); | |
117 } | |
118 break; | |
119 case BCS_TRA: | |
120 { | |
121 PALLOC (fad_data_cnf, FAD_DATA_CNF); | |
122 PSENDX (T30, fad_data_cnf); | |
123 /* remain in BCS-TRA state ! - don't reset sequencer ! */ | |
124 } | |
125 break; | |
126 } | |
127 } | |
128 | |
129 /* | |
130 +-------------------------------------------------------------------------+ | |
131 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
132 | STATE : code ROUTINE : sig_rcv_ker_preamble_ind | | |
133 +-------------------------------------------------------------------------+ | |
134 | |
135 PURPOSE : Process signal PREAMBLE_IND received from process RCV | |
136 | |
137 */ | |
138 | |
139 GLOBAL void sig_rcv_ker_preamble_ind (void) | |
140 { | |
141 | |
142 TRACE_FUNCTION ("sig_rcv_ker_preamble_ind()"); | |
143 | |
144 switch (GET_STATE (KER)) | |
145 { | |
146 case IDLE: | |
147 { | |
148 PALLOC (fad_mux_ind, FAD_MUX_IND); | |
149 fad_mux_ind->mode = MUX_BCS; | |
150 PSENDX (T30, fad_mux_ind); | |
151 } | |
152 SET_STATE (KER, BCS_TRA); | |
153 break; | |
154 case MSG_REC_TCF: /* non-standard: BCS data received while sending TCF */ | |
155 sig_snd_ker_data_sent_ind (); | |
156 TRACE_EVENT ("MSG-REC:BCS rec- arbt TCF"); | |
157 { | |
158 PALLOC (fad_mux_ind, FAD_MUX_IND); | |
159 fad_mux_ind->mode = MUX_BCS; | |
160 PSENDX (T30, fad_mux_ind); | |
161 } | |
162 SET_STATE (KER, BCS_TRA); | |
163 break; | |
164 default: /* discard data - reset RCV to idle */ | |
165 sig_ker_rcv_reset_req (); | |
166 } | |
167 fad_data->rcv.preamble_pending = FALSE; | |
168 } | |
169 | |
170 /* | |
171 +-------------------------------------------------------------------------+ | |
172 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
173 | STATE : code ROUTINE : sig_rcv_ker_tcf_ind | | |
174 +-------------------------------------------------------------------------+ | |
175 | |
176 PURPOSE : Process signal TCF_IND received from process RCV | |
177 | |
178 */ | |
179 | |
180 GLOBAL void sig_rcv_ker_tcf_ind(void) | |
181 { | |
182 T_RCV *rcv = &fad_data->rcv; | |
183 | |
184 USHORT err_ratio = 100 * rcv->bytes_good/rcv->bytes_rcvd; | |
185 | |
186 TRACE_FUNCTION ("sig_rcv_ker_tcf_ind()"); | |
187 | |
188 if (GET_STATE (KER) EQ MSG_TRA_TCF) | |
189 { | |
190 PALLOC (fad_rcv_tcf_cnf, FAD_RCV_TCF_CNF); | |
191 | |
192 TRACE_EVENT_P1("ratio=%d", err_ratio); | |
193 | |
194 fad_rcv_tcf_cnf->ratio = (UBYTE)err_ratio; | |
195 PSENDX (T30, fad_rcv_tcf_cnf); | |
196 SET_STATE (KER, IDLE); | |
197 sig_ker_snd_sync_req (FALSE); | |
198 } | |
199 } | |
200 | |
201 /* | |
202 +----------------------------------------------------------------------+ | |
203 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
204 | STATE : code ROUTINE : sig_rcv_ker_train_ind | | |
205 +----------------------------------------------------------------------+ | |
206 | |
207 PURPOSE : Process signal TRAIN_IND received from process RCV | |
208 | |
209 */ | |
210 | |
211 GLOBAL void sig_rcv_ker_train_ind (void) | |
212 { | |
213 TRACE_FUNCTION ("sig_rcv_ker_train_ind()"); | |
214 | |
215 if (GET_STATE (KER) EQ IDLE) | |
216 { | |
217 sig_ker_snd_train_req (0, FALSE); | |
218 { | |
219 PALLOC (fad_mux_ind, FAD_MUX_IND); | |
220 fad_mux_ind->mode = MUX_MSG; | |
221 PSENDX (T30, fad_mux_ind); | |
222 } | |
223 fad_data->ker.forward_data = TRUE; | |
224 SET_STATE (KER, MSG_TRA); | |
225 } | |
226 else /* discard data - reset RCV to idle */ | |
227 sig_ker_rcv_reset_req (); | |
228 } | |
229 | |
230 /* | |
231 +--------------------------------------------------------------------------+ | |
232 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
233 | STATE : code ROUTINE : sig_rcv_ker_train_end_ind | | |
234 +--------------------------------------------------------------------------+ | |
235 | |
236 PURPOSE : Process signal TRAIN_END_IND received from process RCV | |
237 | |
238 */ | |
239 | |
240 GLOBAL void sig_rcv_ker_train_end_ind (void) | |
241 { | |
242 | |
243 TRACE_FUNCTION ("sig_rcv_ker_train_end_ind()"); | |
244 | |
245 if (GET_STATE (KER) EQ MSG_TRA) | |
246 sig_ker_snd_sync_req (FALSE); | |
247 | |
248 } | |
249 | |
250 /* | |
251 +-------------------------------------------------------------------------+ | |
252 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
253 | STATE : code ROUTINE : sig_rcv_ker_bcs_ind | | |
254 +-------------------------------------------------------------------------+ | |
255 | |
256 PURPOSE : Process signal BCS_IND received from process RCV | |
257 | |
258 */ | |
259 | |
260 GLOBAL void sig_rcv_ker_bcs_ind (UBYTE *hdlc, USHORT hdlc_len) | |
261 { | |
262 TRACE_FUNCTION ("sig_rcv_ker_bcs_ind()"); | |
263 | |
264 if (GET_STATE (KER) EQ BCS_TRA) | |
265 { | |
266 USHORT bit_len = hdlc_len << 3; | |
267 { | |
268 PALLOC_SDU (fad_data_ind, FAD_DATA_IND, bit_len); | |
269 fad_data_ind->final = TRUE; | |
270 fad_data_ind->sdu.l_buf = bit_len; | |
271 fad_data_ind->sdu.o_buf = 0; | |
272 memcpy (fad_data_ind->sdu.buf, hdlc, hdlc_len); | |
273 if (fad_data->snd.fad_data_req) /* BCS data to send detected while receiving BCS: */ | |
274 sig_snd_ker_data_sent_ind (); /* send pseudo-CNF to T30 before forwarding data */ | |
275 | |
276 PSENDX (T30, fad_data_ind); | |
277 } | |
278 fad_data->rcv.FlagFound = 0; | |
279 SET_STATE (KER, IDLE); | |
280 sig_ker_snd_sync_req (TRUE); | |
281 if (fad_data->snd.fad_data_req) /* BCS data to send detected while receiving BCS: */ | |
282 { /* send stored BCS data */ | |
283 SET_STATE (KER, BCS_REC); | |
284 sig_ker_snd_preamble_req (fad_data->snd.fad_data_req); | |
285 } | |
286 } | |
287 fad_data->rcv.bcs_pending = FALSE; | |
288 } | |
289 | |
290 /* | |
291 +-------------------------------------------------------------------------+ | |
292 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
293 | STATE : code ROUTINE : sig_rcv_ker_msg_ind | | |
294 +-------------------------------------------------------------------------+ | |
295 | |
296 PURPOSE : Process signal MSG_IND received from process RCV | |
297 | |
298 */ | |
299 | |
300 GLOBAL void sig_rcv_ker_msg_ind (T_FAD_DATA_IND *fad_data_ind) | |
301 { | |
302 | |
303 TRACE_FUNCTION ("sig_rcv_ker_msg_ind()"); | |
304 | |
305 PACCESS (fad_data_ind); | |
306 | |
307 if (GET_STATE (KER) EQ MSG_TRA) | |
308 { | |
309 if (!fad_data_ind) | |
310 { | |
311 sig_ker_snd_sync_req (TRUE); | |
312 SET_STATE (KER, IDLE); | |
313 } | |
314 else | |
315 { | |
316 if (fad_data_ind->final) | |
317 { | |
318 sig_ker_snd_sync_req (TRUE); | |
319 SET_STATE (KER, IDLE); | |
320 } | |
321 if (fad_data->ker.forward_data) | |
322 { | |
323 PSENDX (T30, fad_data_ind); | |
324 } | |
325 else | |
326 PFREE (fad_data_ind); | |
327 } | |
328 } | |
329 | |
330 } | |
331 | |
332 /* | |
333 +-------------------------------------------------------------------------+ | |
334 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
335 | STATE : code ROUTINE : sig_rcv_ker_status_ind | | |
336 +-------------------------------------------------------------------------+ | |
337 | |
338 PURPOSE : Process signal STATUS_IND received from process RCV | |
339 | |
340 */ | |
341 | |
342 GLOBAL void sig_rcv_ker_status_ind (void ) | |
343 { | |
344 | |
345 TRACE_FUNCTION ("sig_rcv_ker_status_ind()"); | |
346 | |
347 if (GET_STATE (KER) EQ MSG_REC) | |
348 sig_ker_snd_status_req (); | |
349 | |
350 } | |
351 | |
352 /* | |
353 +-------------------------------------------------------------------------+ | |
354 | PROJECT : GSM-F&D (8411) MODULE : FAD_KERS | | |
355 | STATE : code ROUTINE : sig_rcv_ker_error_ind | | |
356 +-------------------------------------------------------------------------+ | |
357 | |
358 PURPOSE : Process signal ERROR_IND received from process RCV | |
359 | |
360 */ | |
361 | |
362 GLOBAL void sig_rcv_ker_error_ind (USHORT cause) | |
363 { | |
364 TRACE_FUNCTION ("sig_rcv_ker_error_ind()"); | |
365 | |
366 switch (GET_STATE (KER)) | |
367 { | |
368 case KER_NULL: | |
369 case IDLE: | |
370 break; | |
371 case BCS_REC: | |
372 case BCS_TRA: | |
373 case MSG_REC_TCF: | |
374 case MSG_REC: | |
375 case MSG_TRA_TCF: | |
376 case MSG_TRA: | |
377 SET_STATE (KER, IDLE); | |
378 ker_SetError (cause); | |
379 break; | |
380 default: | |
381 break; | |
382 } | |
383 } | |
384 |