comparison gpf/tst_drv/ser_sd.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_sd.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_SD_C__
21 #define __SER_SD_C__
22 #endif
23
24 #include "typedefs.h"
25 #include "stack1_serial.h"
26 #include "gdi.h"
27 #include "tstheader.h"
28
29 /*==== TYPES ======================================================*/
30
31 typedef struct
32 {
33 USHORT Handle;
34 USHORT EnabledSignalType;
35 T_DRV_CB_FUNC Callback;
36 char Connected;
37 } T_SER_SD_DATA;
38
39 /*==== CONSTANTS ==================================================*/
40
41 #define ALLOWED_SER_SD_SIGNALS (DRV_SIGTYPE_READ|DRV_SIGTYPE_CONNECT)
42
43 /*==== EXTERNALS ==================================================*/
44
45
46 /*==== VARIABLES ==================================================*/
47
48 T_SER_SD_DATA SER_SD_Data;
49 static T_DRV_SIGNAL Signal;
50
51 /*==== FUNCTIONS ==================================================*/
52
53 /*
54 +--------------------------------------------------------------------+
55 | PROJECT : GSM-Frame (8415) MODULE : SER |
56 | STATE : code ROUTINE : Callback |
57 +--------------------------------------------------------------------+
58
59 PURPOSE : callback function of the driver
60
61 */
62 void Callback ( void )
63 {
64 if ( SER_SD_Data.EnabledSignalType & DRV_SIGTYPE_READ )
65 {
66 Signal.SignalType = DRV_SIGTYPE_READ;
67 Signal.DrvHandle = SER_SD_Data.Handle;
68
69 (SER_SD_Data.Callback)( &Signal );
70 }
71 }
72
73 /*
74 +--------------------------------------------------------------------+
75 | PROJECT : GSM-Frame (8415) MODULE : SER |
76 | STATE : code ROUTINE : SER_SD_Exit |
77 +--------------------------------------------------------------------+
78
79 PURPOSE : exit a driver
80
81 */
82 void SER_SD_Exit ( void )
83 {
84 }
85
86 /*
87 +--------------------------------------------------------------------+
88 | PROJECT : GSM-Frame (8415) MODULE : SER |
89 | STATE : code ROUTINE : SER_SD_Read |
90 +--------------------------------------------------------------------+
91
92 PURPOSE : read data from driver
93
94 */
95 USHORT SER_SD_Read ( void *Buffer, ULONG *BytesToRead )
96 {
97 *BytesToRead = stack1_Serial_receiveData ( (unsigned char*)Buffer, *BytesToRead );
98 return DRV_OK;
99 }
100
101
102 /*
103 +--------------------------------------------------------------------+
104 | PROJECT : GSM-Frame (8415) MODULE : SER |
105 | STATE : code ROUTINE : SER_SD_Write |
106 +--------------------------------------------------------------------+
107
108 PURPOSE : write data to driver
109
110 */
111 USHORT SER_SD_Write ( void *Buffer, ULONG *BytesToWrite )
112 {
113 ULONG ToWrite = *BytesToWrite & ~PRIM_FLAG_MASK;
114
115 /* stack1_Serial_sendData() returns TRUE/FALSE but not the number of written bytes */
116 stack1_Serial_sendData( (unsigned char*)Buffer, ToWrite );
117 return ( DRV_OK );
118 }
119 /*
120 +--------------------------------------------------------------------+
121 | PROJECT : GSM-Frame (8415) MODULE : SER |
122 | STATE : code ROUTINE : SER_SD_SetSignal |
123 +--------------------------------------------------------------------+
124
125 PURPOSE : enable signal for the driver
126
127 */
128 USHORT SER_SD_SetSignal ( USHORT SignalType )
129 {
130 if ( !(SignalType & ALLOWED_SER_SD_SIGNALS) )
131 return DRV_INVALID_PARAMS;
132 else
133 SER_SD_Data.EnabledSignalType |= SignalType;
134
135 return DRV_OK;
136 }
137
138 /*
139 +--------------------------------------------------------------------+
140 | PROJECT : GSM-Frame (8415) MODULE : SER |
141 | STATE : code ROUTINE : SER_SD_ResetSignal |
142 +--------------------------------------------------------------------+
143
144 PURPOSE : disable signal for the driver
145
146 */
147 USHORT SER_SD_ResetSignal ( USHORT SignalType )
148 {
149 if ( !(SignalType & ALLOWED_SER_SD_SIGNALS) )
150 return DRV_INVALID_PARAMS;
151 else
152 SER_SD_Data.EnabledSignalType &= ~SignalType;
153
154 return DRV_OK;
155 }
156
157 /*
158 +--------------------------------------------------------------------+
159 | PROJECT : GSM-Frame (8415) MODULE : SER |
160 | STATE : code ROUTINE : SER_SD_SetConfig |
161 +--------------------------------------------------------------------+
162
163 PURPOSE : set configuration for the driver
164
165 */
166 USHORT SER_SD_SetConfig ( char *Buffer )
167 {
168
169 if ( !SER_SD_Data.Connected )
170 {
171 Signal.SignalType = DRV_SIGTYPE_CONNECT;
172 Signal.DrvHandle = SER_SD_Data.Handle;
173 Signal.UserData = NULL;
174 (SER_SD_Data.Callback)( &Signal );
175 SER_SD_Data.Connected = TRUE;
176 return DRV_OK;
177 }
178 return DRV_OK;
179 }
180
181
182 /*
183 +--------------------------------------------------------------------+
184 | PROJECT : GSM-Frame (8415) MODULE : SER |
185 | STATE : code ROUTINE : SER_SD_Init |
186 +--------------------------------------------------------------------+
187
188 PURPOSE : initialize driver
189
190 */
191 USHORT SER_SD_Init ( USHORT DrvHandle, T_DRV_CB_FUNC CallbackFunc, T_DRV_EXPORT const **DrvInfo )
192 {
193 static const T_DRV_EXPORT SER_SD_Info =
194 {
195 "SER",
196 CALLED_FROM_ISR,
197 {
198 #ifdef _TOOLS_
199 SER_SD_Init,
200 #endif
201 SER_SD_Exit,
202 SER_SD_Read,
203 SER_SD_Write,
204 NULL,
205 NULL,
206 NULL,
207 SER_SD_SetSignal,
208 SER_SD_ResetSignal,
209 SER_SD_SetConfig,
210 NULL,
211 NULL,
212 }
213 };
214
215 SER_SD_Data.Handle = DrvHandle;
216 SER_SD_Data.EnabledSignalType = 0;
217 SER_SD_Data.Callback = CallbackFunc;
218 SER_SD_Data.Connected = FALSE;
219
220 stack1_Serial_PowerUp ( Callback );
221
222 *DrvInfo = &SER_SD_Info;
223
224 return DRV_OK;
225 }
226