FreeCalypso > hg > tcs211-fcmodem
comparison g23m/condat/ms/src/aci/ati_src_uart.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : ATI_SRC_UARTC | |
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 : . | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 #ifdef UART | |
22 | |
23 #ifndef ATI_SRC_UART_C | |
24 #define ATI_SRC_UART_C | |
25 #endif | |
26 | |
27 #include "aci_all.h" | |
28 /*==== INCLUDES ===================================================*/ | |
29 #include "aci_cmh.h" | |
30 #include "ati_cmd.h" | |
31 #include "aci_cmd.h" | |
32 #include "dti.h" /* functionality of the dti library */ | |
33 | |
34 #include "aci_lst.h" | |
35 #include "dti_conn_mng.h" | |
36 #include "dti_cntrl_mng.h" | |
37 | |
38 #ifdef UART | |
39 #include "psa_uart.h" | |
40 #include "cmh_uart.h" | |
41 #endif | |
42 | |
43 #include "aci_io.h" | |
44 | |
45 #ifdef UART | |
46 #include "ati_src_uart.h" | |
47 #endif | |
48 | |
49 #include "aci_mem.h" | |
50 #include "aci.h" | |
51 #include "psa.h" | |
52 #include "cmh.h" | |
53 #include "pcm.h" | |
54 | |
55 /*==== CONSTANTS ==================================================*/ | |
56 | |
57 /*==== TYPES ======================================================*/ | |
58 | |
59 /*==== EXPORT =====================================================*/ | |
60 | |
61 EXTERN T_ACI_LIST *uart_src_params; | |
62 #ifdef _SIMULATION_ | |
63 EXTERN T_ACI_LIST *ati_src_list; | |
64 #endif /* _SIMULATION_ */ | |
65 | |
66 /*==== VARIABLES ==================================================*/ | |
67 | |
68 /*==== FUNCTIONS ==================================================*/ | |
69 | |
70 /* | |
71 +-------------------------------------------------------------------+ | |
72 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIR | | |
73 | ROUTINE : uart_new_source | | |
74 +-------------------------------------------------------------------+ | |
75 | |
76 PURPOSE : Create a new source for ATI with the corresponding struct. | |
77 */ | |
78 | |
79 #ifdef UART | |
80 GLOBAL void uart_InitCmdStruct( T_ACI_DTI_PRC *cmd_struct ) | |
81 { | |
82 cmd_struct->device = 0; | |
83 cmd_struct->dlci = NOT_PRESENT_8BIT; | |
84 cmd_struct->RecState = NOT_INITIALIZED; | |
85 cmd_struct->LineState = LINE_CONNECTING; | |
86 cmd_struct->run_cmd = FALSE; | |
87 cmd_struct->first_output = FALSE; | |
88 cmd_struct->data_cntr = 0; | |
89 cmd_struct->MuxParms = NULL; | |
90 cmd_struct->large_type = FALSE; | |
91 cmd_struct->data_buffer.data_list = NULL; | |
92 cmd_struct->data_buffer.max_buffer_size = 0; | |
93 cmd_struct->data_buffer.create_time = 0; | |
94 cmd_struct->device_type = DEVICE_TYPE_UNKNOWN; | |
95 } | |
96 #endif | |
97 | |
98 GLOBAL UBYTE uart_new_source( UBYTE device, UBYTE dlci ) | |
99 { | |
100 T_ACI_DTI_PRC *cmd_struct; | |
101 UBYTE src_id; | |
102 | |
103 TRACE_FUNCTION("uart_new_source"); | |
104 | |
105 src_id = ati_init(ATI_SRC_TYPE_UART, uart_src_result_cb, uart_src_line_state_cb); | |
106 | |
107 TRACE_EVENT_P1 ("uart_new_source: srcId=%d", src_id); | |
108 | |
109 ACI_MALLOC (cmd_struct, sizeof(T_ACI_DTI_PRC)); | |
110 | |
111 #ifdef UART | |
112 uart_InitCmdStruct( cmd_struct ); | |
113 #endif | |
114 | |
115 cmd_struct->srcId = src_id; | |
116 cmd_struct->device = device; | |
117 cmd_struct->dlci = dlci; | |
118 | |
119 /* | |
120 * Determine the mode of the command source based on the | |
121 * source ID. | |
122 */ | |
123 if (src_id<CMD_SRC_MAX) | |
124 { | |
125 if (src_id==CMD_SRC_LCL) | |
126 { | |
127 aci_cmd_src_mode_set(src_id,CMD_MODE_ACI); | |
128 } | |
129 else | |
130 { | |
131 #ifdef FF_ATI_BAT | |
132 aci_cmd_src_mode_set(src_id,CMD_MODE_BAT); | |
133 #else | |
134 aci_cmd_src_mode_set(src_id,CMD_MODE_ATI); | |
135 #endif | |
136 } | |
137 } | |
138 | |
139 insert_list (uart_src_params, cmd_struct); | |
140 cmhUART_AddDeviceToComParameter( device ); | |
141 | |
142 return(src_id); | |
143 } | |
144 | |
145 #ifdef _SIMULATION_ | |
146 GLOBAL void uart_new_source_for_aci_src_tst( UBYTE src_id, UBYTE device, UBYTE dlci ) | |
147 { | |
148 T_ACI_DTI_PRC *cmd_struct; | |
149 | |
150 TRACE_FUNCTION("uart_new_source_for_aci_src_tst"); | |
151 | |
152 ACI_MALLOC (cmd_struct, sizeof(T_ACI_DTI_PRC)); | |
153 | |
154 #ifdef UART | |
155 uart_InitCmdStruct( cmd_struct ); | |
156 #endif | |
157 | |
158 cmd_struct->srcId = src_id; | |
159 cmd_struct->device = device; | |
160 cmd_struct->dlci = dlci; | |
161 | |
162 /* | |
163 * Determine the mode of the command source based on the | |
164 * source ID. | |
165 */ | |
166 if (src_id<CMD_SRC_MAX) | |
167 { | |
168 if (src_id==CMD_SRC_LCL) | |
169 { | |
170 aci_cmd_src_mode_set(src_id,CMD_MODE_ACI); | |
171 } | |
172 else | |
173 { | |
174 #ifdef FF_ATI_BAT | |
175 aci_cmd_src_mode_set(src_id,CMD_MODE_BAT); | |
176 #else | |
177 aci_cmd_src_mode_set(src_id,CMD_MODE_ATI); | |
178 #endif | |
179 } | |
180 } | |
181 | |
182 insert_list (uart_src_params, cmd_struct); | |
183 cmhUART_AddDeviceToComParameter( device ); | |
184 } | |
185 #endif | |
186 /* | |
187 +-------------------------------------------------------------------+ | |
188 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIR | | |
189 | ROUTINE : uart_erase_source | | |
190 +-------------------------------------------------------------------+ | |
191 | |
192 PURPOSE : erase an entry element from the uart_src_params list. | |
193 */ | |
194 #ifdef DTI | |
195 EXTERN void dti_cntrl_erase_entry(UBYTE dti_id); | |
196 #endif | |
197 | |
198 GLOBAL void uart_erase_source( UBYTE srcId ) | |
199 { | |
200 #ifdef DTI | |
201 T_DTI_CNTRL info; | |
202 #endif | |
203 | |
204 TRACE_FUNCTION("uart_erase_source"); | |
205 | |
206 ati_finit (srcId); | |
207 #ifdef DTI | |
208 dti_cntrl_get_info_from_src_id (srcId, &info); | |
209 | |
210 dti_cntrl_erase_entry( info.dti_id ); | |
211 | |
212 dti_cntrl_clear_conn_parms( info.dti_id ); | |
213 #endif | |
214 TRACE_EVENT_P1("Source nb %d deleted", srcId); | |
215 | |
216 } | |
217 #ifdef DTI | |
218 /* | |
219 +-------------------------------------------------------------------+ | |
220 | PROJECT : GSM-PS (6147) MODULE : PSA_UART | | |
221 | ROUTINE : atiUART_dti_callback | | |
222 +-------------------------------------------------------------------+ | |
223 | |
224 PURPOSE : callback for dti manager. | |
225 | |
226 */ | |
227 GLOBAL BOOL atiUART_dti_cb( UBYTE dti_id, T_DTI_CONN_STATE result_type ) | |
228 { | |
229 #ifdef _SIMULATION_ | |
230 T_ATI_SRC_PARAMS *src_params; | |
231 #endif /* _SIMULATION_ */ | |
232 | |
233 T_ACI_DTI_PRC *srcInfos = NULL; | |
234 UBYTE saveState; | |
235 BOOL is_uart_src = TRUE; /* for simulation */ | |
236 T_DTI_CNTRL info; | |
237 | |
238 TRACE_FUNCTION("atiUART_dti_cb"); | |
239 | |
240 | |
241 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE) | |
242 { | |
243 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id); | |
244 return FALSE; | |
245 } | |
246 | |
247 srcInfos = find_element (uart_src_params, info.src_id, cmhUARTtest_srcId); | |
248 if (srcInfos EQ NULL) | |
249 { | |
250 TRACE_EVENT_P1 ("[ERR] atiUART_dti_cb: srcId=%d not found", info.src_id) ; | |
251 return FALSE ; | |
252 } | |
253 | |
254 saveState = srcInfos->LineState; | |
255 | |
256 #ifdef _SIMULATION_ | |
257 src_params = find_element (ati_src_list, info.src_id, search_ati_src_id); | |
258 if (src_params EQ NULL) | |
259 { | |
260 TRACE_EVENT ("[ERR] SIMULATION: atiUART_dti_cb: source ID not found"); | |
261 return FALSE; | |
262 } | |
263 if (src_params->src_type EQ ATI_SRC_TYPE_TST) | |
264 { | |
265 is_uart_src = FALSE; | |
266 } | |
267 #endif /* _SIMULATION_ */ | |
268 | |
269 | |
270 | |
271 | |
272 switch(result_type) | |
273 { | |
274 /* UART and ACI connected */ | |
275 /* UART and ACI connected */ | |
276 case(DTI_CONN_STATE_CONNECTED): | |
277 #ifdef RMV_01_04_03 | |
278 #ifdef FF_TWO_UART_PORTS | |
279 if (srcInfos->srcId EQ UART_DATA_CHANNEL) | |
280 { | |
281 srcInfos->LineState = LINE_CONNECTED; | |
282 return (TRUE); | |
283 } | |
284 #endif /* FF_MULTI_PORT */ | |
285 #endif | |
286 | |
287 /* first set the line state, then care for DCD */ | |
288 srcInfos->LineState = LINE_CONNECTED; | |
289 | |
290 ati_switch_mode(info.src_id, ATI_CMD_MODE); | |
291 | |
292 if (saveState EQ LINE_CONNECTING) | |
293 { | |
294 | |
295 if (is_uart_src) | |
296 { | |
297 /* creation of a new connection: set DCD */ | |
298 io_setDCD (info.src_id, IO_DCD_OFF); | |
299 } | |
300 | |
301 #ifndef _SIMULATION_ | |
302 /* AV2-Plattform: Inform the user about the cause for the last stack crash. | |
303 /* not (yet) enabled since this could cause problems with other customers. | |
304 setatPercentDAR("", srcInfos->srcId); | |
305 */ | |
306 #ifdef FF_BAT | |
307 if (aci_cmd_src_mode_get(info.src_id)!=CMD_MODE_BAT) | |
308 #endif | |
309 { | |
310 io_sendMessage (srcInfos->srcId, "AT-Command Interpreter ready", | |
311 ATI_NORMAL_OUTPUT); | |
312 } | |
313 #endif /* _SIMULATION_ */ | |
314 } | |
315 | |
316 if (is_uart_src) | |
317 { | |
318 /* tells UART that ACI is ready to get some data */ | |
319 cmhUART_getdata (srcInfos->srcId); | |
320 } | |
321 break; | |
322 /* UART and data entity temporary disconnected */ | |
323 case(DTI_CONN_STATE_CONNECTING): | |
324 break; | |
325 | |
326 case(DTI_CONN_STATE_DISCONNECTING): | |
327 srcInfos->LineState = LINE_TMP_DISCONNECTING; | |
328 ati_switch_mode(info.src_id, ATI_DATA_MODE); | |
329 break; | |
330 | |
331 case(DTI_CONN_STATE_DISCONNECTED): | |
332 srcInfos->LineState = LINE_TMP_DISCONNECTED; | |
333 #ifdef DTI | |
334 dti_cntrl_clear_conn_parms( dti_id ); | |
335 #endif /* DTI */ | |
336 break; | |
337 | |
338 case(DTI_CONN_STATE_ERROR): | |
339 #ifdef DTI | |
340 dti_cntrl_close_dpath_from_dti_id( dti_id ); | |
341 #endif /* DTI */ | |
342 break; | |
343 default: | |
344 break; | |
345 } | |
346 | |
347 /* Maybe drop call if DTR is asserted */ | |
348 if (uartShrdPrm.dtr_clearcall EQ TRUE) | |
349 { | |
350 T_ACI_RETURN l_ret; | |
351 | |
352 l_ret = sAT_H(info.src_id); | |
353 if (l_ret NEQ AT_EXCT AND l_ret NEQ AT_CMPL) | |
354 { | |
355 uartShrdPrm.dtr_clearcall = FALSE; | |
356 TRACE_ERROR("DTR-Drop sAT_H() error"); | |
357 } | |
358 } | |
359 | |
360 return TRUE; | |
361 } | |
362 #endif /* DTI */ | |
363 | |
364 /* | |
365 +-------------------------------------------------------------------+ | |
366 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIR | | |
367 | ROUTINE : uart_src_proc_chars | | |
368 +-------------------------------------------------------------------+ | |
369 | |
370 PURPOSE : Check if characters received are ok, and pack them into the command line. | |
371 return TRUE if ACI allows more data from DTI. | |
372 */ | |
373 | |
374 GLOBAL BOOL uart_src_proc_chars ( UBYTE *chars, | |
375 USHORT len, | |
376 T_ACI_DTI_PRC *elem ) | |
377 { | |
378 if (len >= MAX_CMD_LEN) | |
379 { | |
380 TRACE_ERROR ("[ERR] [ATI]: command line too long"); | |
381 return (TRUE); | |
382 } | |
383 if (elem->run_cmd) | |
384 { | |
385 ati_abort (elem->srcId); | |
386 } | |
387 else | |
388 { | |
389 ati_execute (elem->srcId, chars, len); | |
390 } | |
391 return (TRUE); | |
392 } | |
393 | |
394 #endif /* UART */ |