comparison src/g23m-fad/fad/fad_snds.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_SNDS
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_SNDS_C
24 #define FAD_SNDS_C
25 #endif
26
27 #define ENTITY_FAD
28
29 /*==== INCLUDES ===================================================*/
30
31 #include <string.h>
32 #include "typedefs.h"
33 #include "vsi.h"
34 #include "macdef.h"
35 #include "pconst.cdg"
36 #include "custom.h"
37 #include "gsm.h"
38 #include "cnf_fad.h"
39 #include "mon_fad.h"
40 #include "prim.h"
41 #include "pei.h"
42 #include "tok.h"
43 #include "ccdapi.h"
44 #include "fad.h"
45
46 /*==== CONST =======================================================*/
47
48 /*==== TYPES =======================================================*/
49
50 /*==== VAR EXPORT ==================================================*/
51
52 /*==== VAR LOCAL ===================================================*/
53
54 /*==== FUNCTIONS ===================================================*/
55
56 /*
57 +-------------------------------------------------------------------------+
58 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
59 | STATE : code ROUTINE : sig_ker_snd_activate_req |
60 +-------------------------------------------------------------------------+
61
62 PURPOSE : Process signal ACTIVATE_REQ received from process KER
63
64 */
65
66 GLOBAL void sig_ker_snd_activate_req (T_FAD_ACTIVATE_REQ *fad_activate_req)
67 {
68 T_SND *snd = &fad_data->snd;
69
70 snd->trans_rate = fad_activate_req->trans_rate;
71 snd->frames_per_prim = fad_activate_req->frames_per_prim;
72
73 /* T.32: 5-sec. buffer */
74 #ifdef _SIMULATION_
75 snd->threshold = snd_DurationToBytes(snd->trans_rate, TIME_THRESHOLD);
76 #else
77 snd->threshold = snd_DurationToBytes(snd->trans_rate, TIME_THRESHOLD_TI);
78 #endif
79 }
80 /*
81 +-------------------------------------------------------------------------+
82 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
83 | STATE : code ROUTINE : sig_ker_snd_sync_req |
84 +-------------------------------------------------------------------------+
85
86 PURPOSE : Process signal SYNC_REQ received from process KER
87
88 */
89
90 GLOBAL void sig_ker_snd_sync_req (BOOL reset)
91 {
92 T_SND *snd = &fad_data->snd;
93 USHORT bytes_to_send;
94
95 TRACE_FUNCTION ("sig_ker_snd_sync_req()");
96
97 /*
98 TRACE_EVENT ("IDLE:send SYNCs");
99 */
100 if (reset) /* send SYNC frames following return to IDLE */
101 snd->reset = SYNC_RESET;
102
103 snd->bytes_to_send = REPEAT_FOREVER;
104 snd->seq_bufpos = 0;
105 snd->seq_buflen = 0;
106 snd_SetSequence(snd->seq_buf, &snd->seq_buflen, (UBYTE *)FR_SEQ_SYNC, LEN_SEQ_SYNC, 3);
107
108 INIT_STATE (SND, SYNC_SND);
109 INIT_STATE (SNDSUB, SUB_IDLE);
110
111 if (snd->ra_req_frames)
112 {
113 bytes_to_send = snd->ra_req_frames * FRAME_SIZE;
114 snd_SendSequence(bytes_to_send, FR_SYNC);
115 snd->ra_req_frames = 0;
116 }
117
118 }
119
120 /*
121 +-------------------------------------------------------------------------+
122 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
123 | STATE : code ROUTINE : sig_ker_snd_train_req |
124 +-------------------------------------------------------------------------+
125
126 PURPOSE : Process signal TRAIN_REQ received from process KER
127
128 */
129
130 GLOBAL void sig_ker_snd_train_req (T_FAD_DATA_REQ *fad_data_req, BOOL send_fax)
131 {
132 T_SND *snd = &fad_data->snd;
133
134 TRACE_FUNCTION ("sig_ker_snd_train_req()");
135 /*
136 TRACE_EVENT ("MSG-REC:start TRAIN");
137 */
138 if (GET_STATE (SND) EQ SYNC_SND)
139 {
140 snd->bytes_to_send = REPEAT_FOREVER;
141 snd->seq_buflen = SND_FRAME_LEN * MAX_SND_FRAMES;
142 snd->send_status = TRUE;
143 snd->seq_bufpos = 0;
144
145 SET_STATE (SNDSUB, SUB_IDLE);
146
147 if (send_fax)
148 {
149 snd->data_to_send = fad_data_req->sdu.l_buf >> 3;
150 snd_StoreMsgData (fad_data_req);
151 SET_STATE (SND, TRAIN_SND);
152 }
153 else
154 SET_STATE (SND, TRAIN_CNF_SND);
155
156 }
157 }
158
159
160 /*
161 +-------------------------------------------------------------------------+
162 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
163 | STATE : code ROUTINE : sig_ker_snd_tcf_req |
164 +-------------------------------------------------------------------------+
165
166 PURPOSE : Process signal SND_TCF_REQ received from process KER
167
168 */
169
170 GLOBAL void sig_ker_snd_tcf_req (void)
171 {
172 TRACE_FUNCTION ("sig_ker_snd_tcf_req()");
173 /*
174 TRACE_EVENT ("MSG-REC:start TCF");
175 */
176 if (GET_STATE (SND) EQ SYNC_SND)
177 {
178 fad_data->snd.seq_bufpos = 0;
179 SET_STATE (SND, TCF_SND);
180 }
181 }
182
183
184 /*
185 +-------------------------------------------------------------------------+
186 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
187 | STATE : code ROUTINE : sig_ker_snd_preamble_req |
188 +-------------------------------------------------------------------------+
189
190 PURPOSE : Process signal SND_PREAMBLE_REQ received from process KER
191 - store fad_data_req
192 - prepare preamble
193 */
194
195 GLOBAL void sig_ker_snd_preamble_req (T_FAD_DATA_REQ *fad_data_req)
196 {
197 T_SND *snd = &fad_data->snd;
198
199 TRACE_FUNCTION ("sig_ker_snd_preamble_req()");
200
201 if (GET_STATE (SND) EQ SYNC_SND)
202 {
203 snd->fad_data_req = fad_data_req;
204
205 #ifdef _SIMULATION_
206 snd->fad_data_req->sdu.l_buf >>= 3; /* set SDU byte len for */
207 snd->fad_data_req->sdu.o_buf >>= 3; /* snd_BuildStatusFrames() */
208 #endif
209
210 SET_STATE (SND, PREAM_SND);
211 }
212 }
213
214
215 /*
216 +-------------------------------------------------------------------------+
217 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
218 | STATE : code ROUTINE : sig_ker_snd_bcs_req |
219 +-------------------------------------------------------------------------+
220
221 PURPOSE : Process signal BCS_REQ received from process KER
222
223 */
224
225 GLOBAL void sig_ker_snd_bcs_req (T_FAD_DATA_REQ *fad_data_req)
226 {
227 TRACE_FUNCTION ("sig_ker_snd_bcs_req()");
228
229 if (GET_STATE (SND) EQ BCS_SND)
230 {
231 #ifdef _SIMULATION_
232 snd_BuildStatusFrames(fad_data->snd.fad_data_req, BCS_BUF_LEN);
233 #else
234 snd_BuildStatusFrames(fad_data->snd.fad_data_req);
235 #endif
236 SET_STATE (SNDSUB, SUB_DATA);
237 }
238 }
239
240 /*
241 +------------------------------------------------------------------------+
242 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
243 | STATE : code ROUTINE : sig_ker_snd_status_req |
244 +------------------------------------------------------------------------+
245
246 PURPOSE : Process signal STATUS_REQ received from process KER
247
248 */
249
250 GLOBAL void sig_ker_snd_status_req (void)
251 {
252 TRACE_FUNCTION ("sig_ker_snd_status_req()");
253
254 if (GET_STATE (SND) EQ TRAIN_SND)
255 {
256 TRACE_EVENT ("MSG-REC:start C");
257
258 SET_STATE (SND, MSG_SND);
259 SET_STATE (SNDSUB, SUB_IDLE);
260 }
261
262 }
263
264 /*
265 +-------------------------------------------------------------------------+
266 | PROJECT : GSM-F&D (8411) MODULE : FAD_SNDS |
267 | STATE : code ROUTINE : sig_ker_snd_msg_req |
268 +-------------------------------------------------------------------------+
269
270 PURPOSE : Process signal MSG_REQ received from process KER
271
272 */
273
274 GLOBAL void sig_ker_snd_msg_req (T_FAD_DATA_REQ *fad_data_req)
275 {
276 TRACE_FUNCTION ("sig_ker_snd_msg_req()");
277
278 /* T.32: 5-sec. buffer */
279 fad_data->snd.data_to_send += (fad_data_req->sdu.l_buf >> 3);
280 snd_StoreMsgData (fad_data_req);
281 }