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