FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/fad/fad_sndp.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 : FAD_SNDP | |
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 primitives for the component | |
19 | Fax Adaptation 3.45 of the mobile station | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef FAD_SNDP_C | |
24 #define FAD_SNDP_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_SNDP | | |
59 | STATE : code ROUTINE : snd_ra_ready_ind | | |
60 +--------------------------------------------------------------------+ | |
61 | |
62 PURPOSE : Process primitive RA_READY_IND received from RA. | |
63 | |
64 */ | |
65 | |
66 GLOBAL void snd_ra_ready_ind (T_RA_READY_IND *ra_ready_ind) | |
67 { | |
68 USHORT bytes_to_send; | |
69 | |
70 #ifdef _SIMULATION_ | |
71 TRACE_FUNCTION ("snd_ra_ready_ind()"); | |
72 PACCESS (ra_ready_ind); | |
73 #endif | |
74 | |
75 if (GET_STATE(KER) EQ KER_NULL) | |
76 { | |
77 #ifdef _SIMULATION_ | |
78 PFREE (ra_ready_ind); | |
79 #endif | |
80 return; | |
81 } | |
82 | |
83 bytes_to_send = ra_ready_ind->req_frames * FRAME_SIZE; | |
84 | |
85 if ((GET_STATE (SND) NEQ SYNC_SND) AND fad_data->snd.reset) | |
86 { | |
87 snd_SendReset (bytes_to_send); | |
88 #ifdef _SIMULATION_ | |
89 PFREE (ra_ready_ind); | |
90 #endif | |
91 return; | |
92 } | |
93 | |
94 switch (GET_STATE (SND)) | |
95 { | |
96 case SYNC_SND: | |
97 sbm_free_empty_prims(); | |
98 snd_SendSequence (bytes_to_send, FR_SYNC); | |
99 break; | |
100 | |
101 case PREAM_SND: | |
102 if (!snd_SendSequence(bytes_to_send, FR_STATUS)) | |
103 { | |
104 /* | |
105 TRACE_EVENT ("BCS-REC:PREAM sent - start HDLC"); | |
106 */ | |
107 SET_STATE (SNDSUB, SUB_DATA); | |
108 #ifdef _SIMULATION_ | |
109 snd_BuildStatusFrames(fad_data->snd.fad_data_req, BCS_BUF_LEN); | |
110 #else | |
111 snd_BuildStatusFrames(fad_data->snd.fad_data_req); | |
112 #endif | |
113 SET_STATE (SND, BCS_SND); | |
114 } | |
115 break; | |
116 | |
117 case BCS_SND: | |
118 if (GET_STATE (SNDSUB) NEQ SUB_DATA) | |
119 break; | |
120 | |
121 #ifdef _SIMULATION_ | |
122 snd_SendBcsData(bytes_to_send); | |
123 #else | |
124 snd_SendBcsData(); | |
125 #endif | |
126 if (!fad_data->snd.data_to_send) | |
127 { | |
128 if (fad_data->snd.fad_data_req->sdu.l_buf) | |
129 { | |
130 #ifdef _SIMULATION_ | |
131 snd_BuildStatusFrames(fad_data->snd.fad_data_req, BCS_BUF_LEN); | |
132 #else | |
133 snd_BuildStatusFrames(fad_data->snd.fad_data_req); | |
134 #endif | |
135 } | |
136 else | |
137 { | |
138 /* | |
139 TRACE_EVENT ("BCS-REC:HDLC sent"); | |
140 */ | |
141 SET_STATE (SNDSUB, SUB_IDLE); | |
142 PFREE (fad_data->snd.fad_data_req); | |
143 fad_data->snd.fad_data_req = NULL; | |
144 sig_snd_ker_data_sent_ind (); | |
145 } | |
146 } | |
147 break; | |
148 | |
149 case TCF_SND: | |
150 if (!(snd_SendSequence(bytes_to_send, FR_T4DATA))) | |
151 { | |
152 sig_snd_ker_data_sent_ind (); | |
153 /* | |
154 TRACE_EVENT ("MSG-REC:TCF sent"); | |
155 */ | |
156 } | |
157 break; | |
158 | |
159 case TRAIN_SND: | |
160 case TRAIN_CNF_SND: | |
161 snd_SendSequence (bytes_to_send, FR_TRAIN); | |
162 break; | |
163 | |
164 case MSG_SND: | |
165 sbm_free_empty_prims(); | |
166 | |
167 if (GET_STATE (SNDSUB) EQ SUB_IDLE) /* 1st MSG block < threshold */ | |
168 { | |
169 if (!fad_data->snd.final) | |
170 if (fad_data->snd.data_to_send < fad_data->snd.threshold) | |
171 { | |
172 snd_SendSequence (bytes_to_send, FR_TRAIN); | |
173 break; | |
174 } | |
175 SET_STATE (SNDSUB, SUB_DATA); | |
176 } | |
177 if (fad_data->snd.final) | |
178 { | |
179 if (!snd_SendMsgData (ra_ready_ind->req_frames)) | |
180 { | |
181 TRACE_EVENT ("MSG-REC:DATA sent"); | |
182 SET_STATE (SNDSUB, SUB_IDLE); | |
183 sig_snd_ker_data_sent_ind (); | |
184 #ifdef _SIMULATION_ | |
185 snd_SendSequence(bytes_to_send, FR_SYNC); | |
186 #endif | |
187 } | |
188 } | |
189 else | |
190 { | |
191 /* FINAL flag not set */ | |
192 | |
193 if (!snd_SendMsgData (ra_ready_ind->req_frames)) | |
194 { | |
195 TRACE_EVENT ("MSG-REC:DATA buffer underflow"); | |
196 sig_rcv_ker_error_ind (ERR_LOCAL_DATA_MSG_UFL); | |
197 } | |
198 if ( fad_data->snd.send_ready_to_t30 | |
199 AND fad_data->snd.data_to_send < fad_data->snd.threshold) | |
200 { | |
201 sig_snd_ker_ready_ind (); | |
202 fad_data->snd.send_ready_to_t30 = FALSE; | |
203 } | |
204 } | |
205 break; | |
206 | |
207 default: | |
208 break; | |
209 } | |
210 | |
211 #ifdef _SIMULATION_ | |
212 PFREE (ra_ready_ind); | |
213 #endif | |
214 } |