FreeCalypso > hg > freecalypso-citrine
comparison gpf/tst_drv/ser_tr.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 | File: ser_tr.c | |
4 +------------------------------------------------------------------------------ | |
5 | Copyright 2004 Texas Instruments Deutschland, AG | |
6 | All rights reserved. | |
7 | | |
8 | This file is confidential and a trade secret of Texas | |
9 | Instruments Berlin, AG | |
10 | The receipt of or possession of this file does not convey | |
11 | any rights to reproduce or disclose its contents or to | |
12 | manufacture, use, or sell anything it may describe, in | |
13 | whole, or in part, without the specific written consent of | |
14 | Texas Instruments Deutschland, AG. | |
15 +----------------------------------------------------------------------------- | |
16 | Purpose : This Modul contains the serial driver adaptation | |
17 +----------------------------------------------------------------------------- | |
18 */ | |
19 | |
20 #ifndef __SER_TR_C__ | |
21 #define __SER_TR_C__ | |
22 #endif | |
23 | |
24 #include "gpfconf.h" | |
25 #include "typedefs.h" | |
26 #include "../../serial/traceswitch.h" | |
27 #include "../../serial/serialswitch.h" | |
28 #include "gdi.h" | |
29 #include "tstheader.h" | |
30 | |
31 /*==== TYPES ======================================================*/ | |
32 | |
33 typedef struct | |
34 { | |
35 USHORT Handle; | |
36 USHORT EnabledSignalType; | |
37 T_DRV_CB_FUNC Callback; | |
38 char Connected; | |
39 } T_SER_TR_DATA; | |
40 | |
41 /*==== CONSTANTS ==================================================*/ | |
42 | |
43 #define ALLOWED_SER_TR_SIGNALS (DRV_SIGTYPE_READ|DRV_SIGTYPE_CONNECT) | |
44 | |
45 /*==== EXTERNALS ==================================================*/ | |
46 | |
47 #ifdef RUN_FLASH | |
48 USHORT SER_TR_Write ( void *Buffer, ULONG *BytesToWrite ); | |
49 #endif | |
50 | |
51 /*==== VARIABLES ==================================================*/ | |
52 | |
53 #ifndef RUN_INT_RAM | |
54 T_SER_TR_DATA SER_TR_Data; | |
55 #endif | |
56 static T_DRV_SIGNAL Signal; | |
57 | |
58 /*==== FUNCTIONS ==================================================*/ | |
59 | |
60 #ifndef RUN_INT_RAM | |
61 /* | |
62 +--------------------------------------------------------------------+ | |
63 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
64 | STATE : code ROUTINE : Callback | | |
65 +--------------------------------------------------------------------+ | |
66 | |
67 PURPOSE : callback function of the driver | |
68 | |
69 */ | |
70 void Callback ( void ) | |
71 { | |
72 if ( SER_TR_Data.EnabledSignalType & DRV_SIGTYPE_READ ) | |
73 { | |
74 Signal.SignalType = DRV_SIGTYPE_READ; | |
75 Signal.DrvHandle = SER_TR_Data.Handle; | |
76 | |
77 (SER_TR_Data.Callback)( &Signal ); | |
78 } | |
79 } | |
80 #endif | |
81 | |
82 #ifndef RUN_INT_RAM | |
83 /* | |
84 +--------------------------------------------------------------------+ | |
85 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
86 | STATE : code ROUTINE : SER_TR_Exit | | |
87 +--------------------------------------------------------------------+ | |
88 | |
89 PURPOSE : exit a driver | |
90 | |
91 */ | |
92 void SER_TR_Exit ( void ) | |
93 { | |
94 } | |
95 #endif | |
96 | |
97 #ifndef RUN_INT_RAM | |
98 /* | |
99 +--------------------------------------------------------------------+ | |
100 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
101 | STATE : code ROUTINE : SER_TR_Read | | |
102 +--------------------------------------------------------------------+ | |
103 | |
104 PURPOSE : read data from driver | |
105 | |
106 */ | |
107 USHORT SER_TR_Read ( void *Buffer, ULONG *BytesToRead ) | |
108 { | |
109 *BytesToRead = (USHORT)SER_tr_ReadNChars ( SER_LAYER_1, Buffer, *BytesToRead ); | |
110 return DRV_OK; | |
111 } | |
112 #endif | |
113 | |
114 | |
115 #ifndef RUN_FLASH | |
116 /* | |
117 +--------------------------------------------------------------------+ | |
118 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
119 | STATE : code ROUTINE : SER_TR_Write | | |
120 +--------------------------------------------------------------------+ | |
121 | |
122 PURPOSE : write data to driver | |
123 | |
124 */ | |
125 USHORT SER_TR_Write ( void *Buffer, ULONG *BytesToWrite ) | |
126 { | |
127 ULONG ToWrite = *BytesToWrite & ~PRIM_FLAG_MASK; | |
128 ULONG BytesWritten; | |
129 char *ptr = (char*)Buffer; | |
130 | |
131 ptr--; | |
132 *ptr = 0x13; | |
133 ToWrite += 1; | |
134 BytesWritten = (ULONG)SER_tr_WriteNBytes (SER_LAYER_1, (SYS_UWORD8*)ptr, (SYS_UWORD32)ToWrite); | |
135 *BytesToWrite = BytesWritten; | |
136 | |
137 return ( DRV_OK ); | |
138 } | |
139 #endif | |
140 | |
141 #ifndef RUN_INT_RAM | |
142 /* | |
143 +--------------------------------------------------------------------+ | |
144 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
145 | STATE : code ROUTINE : SER_TR_SetSignal | | |
146 +--------------------------------------------------------------------+ | |
147 | |
148 PURPOSE : enable signal for the driver | |
149 | |
150 */ | |
151 USHORT SER_TR_SetSignal ( USHORT SignalType ) | |
152 { | |
153 if ( !(SignalType & ALLOWED_SER_TR_SIGNALS) ) | |
154 return DRV_INVALID_PARAMS; | |
155 else | |
156 SER_TR_Data.EnabledSignalType |= SignalType; | |
157 | |
158 return DRV_OK; | |
159 } | |
160 #endif | |
161 | |
162 #ifndef RUN_INT_RAM | |
163 /* | |
164 +--------------------------------------------------------------------+ | |
165 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
166 | STATE : code ROUTINE : SER_TR_ResetSignal | | |
167 +--------------------------------------------------------------------+ | |
168 | |
169 PURPOSE : disable signal for the driver | |
170 | |
171 */ | |
172 USHORT SER_TR_ResetSignal ( USHORT SignalType ) | |
173 { | |
174 if ( !(SignalType & ALLOWED_SER_TR_SIGNALS) ) | |
175 return DRV_INVALID_PARAMS; | |
176 else | |
177 SER_TR_Data.EnabledSignalType &= ~SignalType; | |
178 | |
179 return DRV_OK; | |
180 } | |
181 #endif | |
182 | |
183 #ifndef RUN_INT_RAM | |
184 /* | |
185 +--------------------------------------------------------------------+ | |
186 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
187 | STATE : code ROUTINE : SER_TR_SetConfig | | |
188 +--------------------------------------------------------------------+ | |
189 | |
190 PURPOSE : set configuration for the driver | |
191 | |
192 */ | |
193 USHORT SER_TR_SetConfig ( char *Buffer ) | |
194 { | |
195 | |
196 if ( !SER_TR_Data.Connected ) | |
197 { | |
198 Signal.SignalType = DRV_SIGTYPE_CONNECT; | |
199 Signal.DrvHandle = SER_TR_Data.Handle; | |
200 Signal.UserData = NULL; | |
201 (SER_TR_Data.Callback)( &Signal ); | |
202 SER_TR_Data.Connected = TRUE; | |
203 return DRV_OK; | |
204 } | |
205 return DRV_OK; | |
206 } | |
207 #endif | |
208 | |
209 | |
210 #ifndef RUN_INT_RAM | |
211 /* | |
212 +--------------------------------------------------------------------+ | |
213 | PROJECT : GSM-Frame (8415) MODULE : SER | | |
214 | STATE : code ROUTINE : SER_TR_Init | | |
215 +--------------------------------------------------------------------+ | |
216 | |
217 PURPOSE : initialize driver | |
218 | |
219 */ | |
220 USHORT SER_TR_Init ( USHORT DrvHandle, T_DRV_CB_FUNC CallbackFunc, T_DRV_EXPORT const **DrvInfo ) | |
221 { | |
222 static const T_DRV_EXPORT SER_TR_Info = | |
223 { | |
224 "SER", | |
225 CALLED_FROM_ISR, | |
226 { | |
227 #ifdef _TOOLS_ | |
228 SER_TR_TR_Init, | |
229 #endif | |
230 SER_TR_Exit, | |
231 SER_TR_Read, | |
232 SER_TR_Write, | |
233 NULL, | |
234 NULL, | |
235 NULL, | |
236 SER_TR_SetSignal, | |
237 SER_TR_ResetSignal, | |
238 SER_TR_SetConfig, | |
239 NULL, | |
240 NULL, | |
241 } | |
242 }; | |
243 | |
244 SER_TR_Data.Handle = DrvHandle; | |
245 SER_TR_Data.EnabledSignalType = 0; | |
246 SER_TR_Data.Callback = CallbackFunc; | |
247 SER_TR_Data.Connected = FALSE; | |
248 | |
249 SER_tr_Init ( SER_LAYER_1, TR_BAUD_115200, Callback ); | |
250 *DrvInfo = &SER_TR_Info; | |
251 | |
252 return DRV_OK; | |
253 } | |
254 #endif |