comparison src/g23m-aci/uart/uart_txp.c @ 162:53929b40109c

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