FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/uart/uart_txp.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 : | |
4 | Modul : | |
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 is part of the entity UART and implements all | |
18 | functions to handles the incoming primitives as described in | |
19 | the SDL-documentation (TX-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef UART_TXP_C | |
24 #define UART_TXP_C | |
25 #endif /* !UART_TXP_C */ | |
26 | |
27 #include "config.h" | |
28 #include "fixedconf.h" | |
29 #include "condat-features.h" | |
30 | |
31 #define ENTITY_UART | |
32 | |
33 #ifndef FF_MULTI_PORT | |
34 /*==== INCLUDES =============================================================*/ | |
35 | |
36 #ifdef WIN32 | |
37 #include "nucleus.h" | |
38 #endif /* WIN32 */ | |
39 #include "typedefs.h" /* to get Condat data types */ | |
40 #include "vsi.h" /* to get a lot of macros */ | |
41 #include "macdef.h" /* to get a lot of macros */ | |
42 #include "custom.h" | |
43 #include "gsm.h" /* to get a lot of macros */ | |
44 #include "cnf_uart.h" /* to get cnf-definitions */ | |
45 #include "mon_uart.h" /* to get mon-definitions */ | |
46 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
47 #ifdef DTILIB | |
48 #include "dti.h" /* to get dti lib */ | |
49 #endif /* DTILIB */ | |
50 #include "pei.h" /* to get PEI interface */ | |
51 #ifdef _TARGET_ | |
52 #include "../../serial/serialswitch.h" | |
53 #include "../../serial/traceswitch.h" | |
54 #else /* _TARGET_ */ | |
55 #include "serial_dat.h" /* to get definitions of serial driver */ | |
56 #endif /* _TARGET_ */ | |
57 #include "uart.h" /* to get the global entity definitions */ | |
58 | |
59 #include "uart_txf.h" /* to get tx functions */ | |
60 | |
61 #include "uart_kers.h" /* to get ker signals */ | |
62 #include "uart_drxs.h" /* to get drx signals */ | |
63 | |
64 #ifdef _SIMULATION_ | |
65 #include <stdio.h> /* to get sprintf */ | |
66 #include "uart_txp.h" /* to get tx_writedata */ | |
67 #endif /* _SIMULATION_ */ | |
68 /*==== CONST ================================================================*/ | |
69 | |
70 /*==== LOCAL VARS ===========================================================*/ | |
71 | |
72 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
73 | |
74 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
75 | |
76 | |
77 | |
78 /* | |
79 +------------------------------------------------------------------------------ | |
80 | Function : tx_uart_driver_sent_ind | |
81 +------------------------------------------------------------------------------ | |
82 | Description : Handles the primitive UART_DRIVER_SENT_IND | |
83 | | |
84 | Parameters : *uart_device - affected device database | |
85 | | |
86 +------------------------------------------------------------------------------ | |
87 */ | |
88 GLOBAL void tx_uart_driver_sent_ind ( T_UART_DATA* uart_device ) | |
89 { | |
90 T_desc2* temp_desc; | |
91 T_DLC* dlc; | |
92 | |
93 TRACE_EVENT( "tx_uart_driver_sent_ind()" ); | |
94 | |
95 /* | |
96 * set affected instance | |
97 */ | |
98 uart_data = uart_device; | |
99 | |
100 switch( GET_STATE( UART_SERVICE_TX ) ) | |
101 { | |
102 case TX_READY: | |
103 /* | |
104 * send DATA_SENT signal | |
105 */ | |
106 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE]; | |
107 uart_data->tx.dlc_instance = UART_EMPTY_INSTANCE; | |
108 temp_desc = dlc->transmit_data; | |
109 dlc->transmit_data = NULL; | |
110 uart_data->drx = dlc->drx; | |
111 sig_tx_drx_data_sent_req(temp_desc, dlc->transmit_pos); | |
112 /* | |
113 * determine whether there is still data to send | |
114 */ | |
115 if(dlc->transmit_data EQ NULL) | |
116 { | |
117 /* | |
118 * no more data | |
119 */ | |
120 uart_data->tx.send_state = UART_TX_NOT_SENDING; | |
121 break; | |
122 } | |
123 /* | |
124 * inform dlc about sending | |
125 */ | |
126 uart_data->drx = dlc->drx; | |
127 sig_tx_drx_sending_req(); | |
128 /* | |
129 * transmit data | |
130 */ | |
131 if(uart_data EQ (&(uart_data_base[0]))) | |
132 { | |
133 TRACE_EVENT("UF_WriteData()"); | |
134 #ifdef _SIMULATION_ | |
135 tx_writedata(0); | |
136 #else /* _SIMULATION_ */ | |
137 UF_WriteData (uart_data->device, sm_suspend, tx_writeInFunc_0); | |
138 #endif /* else _SIMULATION_ */ | |
139 } | |
140 #ifdef FF_TWO_UART_PORTS | |
141 else if(uart_data EQ (&(uart_data_base[1]))) | |
142 { | |
143 TRACE_EVENT("UF_WriteData()"); | |
144 #ifdef _SIMULATION_ | |
145 tx_writedata(1); | |
146 #else /* _SIMULATION_ */ | |
147 UF_WriteData (uart_data->device, sm_suspend, tx_writeInFunc_1); | |
148 #endif /* else _SIMULATION_ */ | |
149 } | |
150 #endif /* FF_TWO_UART_PORTS */ | |
151 else | |
152 { | |
153 TRACE_ERROR("wrong value of uart_data"); | |
154 } | |
155 break; | |
156 | |
157 case TX_MUX: | |
158 /* | |
159 * send DATA_SENT signal | |
160 */ | |
161 if(uart_data->tx.dlc_instance EQ UART_EMPTY_INSTANCE) | |
162 { | |
163 /* | |
164 * use entry 0 for raw data | |
165 */ | |
166 dlc = &uart_data->dlc_table[UART_CONTROL_INSTANCE]; | |
167 } | |
168 else | |
169 { | |
170 dlc = &uart_data->dlc_table[uart_data->tx.dlc_instance]; | |
171 } | |
172 temp_desc = dlc->transmit_data; | |
173 dlc->transmit_data = NULL; | |
174 if(uart_data->tx.dlc_instance EQ UART_CONTROL_INSTANCE) | |
175 sig_tx_ker_data_sent_ind(temp_desc, dlc->transmit_pos); | |
176 else | |
177 { | |
178 uart_data->drx = dlc->drx; | |
179 sig_tx_drx_data_sent_req(temp_desc, dlc->transmit_pos); | |
180 } | |
181 /* | |
182 * determine next dlc allow to send | |
183 */ | |
184 tx_next_send_allowed(); | |
185 if(uart_data->tx.dlc_instance EQ UART_EMPTY_INSTANCE) | |
186 { | |
187 /* | |
188 * queue empty | |
189 */ | |
190 uart_data->tx.send_state = UART_TX_NOT_SENDING; | |
191 break; | |
192 } | |
193 /* | |
194 * inform dlc about sending | |
195 */ | |
196 dlc = &uart_data->dlc_table[uart_data->tx.dlc_instance]; | |
197 if(uart_data->tx.dlc_instance EQ UART_CONTROL_INSTANCE) | |
198 { | |
199 /* | |
200 * Control channel | |
201 */ | |
202 sig_tx_ker_sending_ind(); | |
203 } | |
204 else | |
205 { | |
206 /* | |
207 * Data channel | |
208 */ | |
209 uart_data->drx = dlc->drx; | |
210 sig_tx_drx_sending_req(); | |
211 } | |
212 /* | |
213 * transmit data | |
214 */ | |
215 #ifndef _SIMULATION_ | |
216 tx_flushUart(); | |
217 #endif /* !_SIMULATION_ */ | |
218 if(uart_data EQ (&(uart_data_base[0]))) | |
219 { | |
220 TRACE_EVENT("UF_WriteData()"); | |
221 #ifdef _SIMULATION_ | |
222 tx_writedata(0); | |
223 #else /* _SIMULATION_ */ | |
224 UF_WriteData (uart_data->device, sm_suspend, tx_writeInFunc_0); | |
225 #endif /* else _SIMULATION_ */ | |
226 } | |
227 #ifdef FF_TWO_UART_PORTS | |
228 else if(uart_data EQ (&(uart_data_base[1]))) | |
229 { | |
230 TRACE_EVENT("UF_WriteData()"); | |
231 #ifdef _SIMULATION_ | |
232 tx_writedata(1); | |
233 #else /* _SIMULATION_ */ | |
234 UF_WriteData (uart_data->device, sm_suspend, tx_writeInFunc_1); | |
235 #endif /* else _SIMULATION_ */ | |
236 } | |
237 #endif /* FF_TWO_UART_PORTS */ | |
238 else | |
239 { | |
240 TRACE_ERROR("wrong value of uart_data"); | |
241 } | |
242 break; | |
243 | |
244 default: | |
245 TRACE_ERROR( "UART_DRIVER_SENT_IND unexpected" ); | |
246 break; | |
247 } | |
248 } /* tx_uart_driver_sent_ind() */ | |
249 | |
250 | |
251 | |
252 #ifdef _SIMULATION_ | |
253 /* | |
254 +------------------------------------------------------------------------------ | |
255 | Function : tx_dti_ready_ind | |
256 +------------------------------------------------------------------------------ | |
257 | Description : Handles the primitive DTI_READY_IND | |
258 | | |
259 | Parameters : *dti_ready_ind - Ptr to primitive payload | |
260 | | |
261 +------------------------------------------------------------------------------ | |
262 */ | |
263 GLOBAL void tx_dti_ready_ind ( T_DTI2_READY_IND *dti_ready_ind ) | |
264 { | |
265 TRACE_FUNCTION( "tx_dti_ready_ind" ); | |
266 | |
267 /* | |
268 * free the received primitive | |
269 */ | |
270 PFREE(dti_ready_ind); | |
271 #ifdef DTI2 /* should combine "caller" and "read_data" */ | |
272 /* when using both devices in the test document?! */ | |
273 tx_uart_driver_sent_ind(&(uart_data_base[UART_TEST_C_ID_1])); | |
274 #else /* DTI2 */ | |
275 tx_uart_driver_sent_ind(&(uart_data_base[dti_ready_ind->c_id])); | |
276 #endif /* DTI2 */ | |
277 } /* tx_dti_ready_ind() */ | |
278 | |
279 | |
280 | |
281 /* | |
282 +------------------------------------------------------------------------------ | |
283 | Function : tx_writedata | |
284 +------------------------------------------------------------------------------ | |
285 | Description : Simulates UF_WriteData call | |
286 | | |
287 | Parameters : caller - calling UART instance | |
288 | | |
289 +------------------------------------------------------------------------------ | |
290 */ | |
291 GLOBAL void tx_writedata (UBYTE caller) | |
292 { | |
293 char buf[100]; | |
294 T_reInstMode reInstall; | |
295 USHORT size[2]; | |
296 USHORT pos; | |
297 USHORT i; | |
298 T_UART_DATA* uart_device; | |
299 | |
300 TRACE_FUNCTION( "tx_writedata" ); | |
301 | |
302 /* | |
303 * set UART instance | |
304 */ | |
305 uart_device = &(uart_data_base[caller]); | |
306 | |
307 { | |
308 /* | |
309 * calculation of SDU length: ((((frame-size + 3) * 2) + 2) * 8) | |
310 */ | |
311 PALLOC_SDU (dti_data_test_req, DTI2_DATA_TEST_REQ, 1088); | |
312 #ifdef DTI2 /* should switch for C_ID_1/2 when using both devices in the test document?! */ | |
313 dti_data_test_req->link_id = LINK_WRITEDATA_PORT_1; /* for write_data call */ | |
314 dti_data_test_req->parameters.p_id = 0; | |
315 dti_data_test_req->parameters.st_lines.st_flow = 0; | |
316 dti_data_test_req->parameters.st_lines.st_line_sa = 0; | |
317 dti_data_test_req->parameters.st_lines.st_line_sb = 0; | |
318 dti_data_test_req->parameters.st_lines.st_break_len = 0; | |
319 dti_data_test_req->sdu.o_buf = 0; | |
320 #else /* DTI2 */ | |
321 dti_data_test_req->tui = 3; /* for write_data call */ | |
322 dti_data_test_req->c_id = caller; | |
323 dti_data_test_req->p_id = 0; | |
324 dti_data_test_req->op_ack = 0; | |
325 dti_data_test_req->st_flow = 0; | |
326 dti_data_test_req->st_line_sa = 0; | |
327 dti_data_test_req->st_line_sb = 0; | |
328 dti_data_test_req->st_escape = 0; | |
329 dti_data_test_req->sdu.o_buf = 0; | |
330 #endif /* DTI2 */ | |
331 | |
332 uart_device->tx.dest[0] = dti_data_test_req->sdu.buf; | |
333 uart_device->tx.dest[1] = NULL; | |
334 size[0] = (USHORT)(1088 >> 3); | |
335 size[1] = 0; | |
336 | |
337 /* | |
338 * call actual function | |
339 */ | |
340 if(caller EQ 0) | |
341 { | |
342 tx_writeInFunc_0 (FALSE, &reInstall, 1, uart_device->tx.dest, size); | |
343 } | |
344 #ifdef FF_TWO_UART_PORTS | |
345 else if(caller EQ 1) | |
346 { | |
347 tx_writeInFunc_1 (FALSE, &reInstall, 1, uart_device->tx.dest, size); | |
348 } | |
349 #endif /* FF_TWO_UART_PORTS */ | |
350 else | |
351 { | |
352 TRACE_ERROR("wrong caller value"); | |
353 } | |
354 | |
355 /* | |
356 * set length of sdu | |
357 */ | |
358 dti_data_test_req->sdu.l_buf = ((USHORT)(1088 >> 3) - size[0]) << 3; | |
359 | |
360 /* | |
361 * trace output | |
362 */ | |
363 i = 0; | |
364 pos = 0; | |
365 while(pos < (dti_data_test_req->sdu.l_buf >> 3)) | |
366 { | |
367 i+= sprintf(&buf[i], "0x%02x, ", dti_data_test_req->sdu.buf[pos]); | |
368 pos++; | |
369 if(i > 80) | |
370 { | |
371 TRACE_FUNCTION( buf ); | |
372 i = 0; | |
373 } | |
374 else if(pos >= (dti_data_test_req->sdu.l_buf >> 3)) | |
375 { | |
376 TRACE_FUNCTION( buf ); | |
377 } | |
378 } | |
379 /* | |
380 * send primitive | |
381 */ | |
382 PSEND (hCommMMI, dti_data_test_req); | |
383 } | |
384 } /* tx_writedata() */ | |
385 #endif /* _SIMULATION_ */ | |
386 #endif /* !FF_MULTI_PORT */ |