1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: spia interface declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 7 % |
|
20 */ |
|
21 |
|
22 #ifndef WLANSPIA_H |
|
23 #define WLANSPIA_H |
|
24 |
|
25 class MWlanSpiaClient; |
|
26 class MWlanOsaExt; |
|
27 |
|
28 #include <wlanspiatypes.h> |
|
29 |
|
30 /** |
|
31 * spia interface declaration |
|
32 * |
|
33 * |
|
34 * @lib wlanpdd.pdd |
|
35 * @since S60 v3.2 |
|
36 */ |
|
37 class WlanSpia |
|
38 { |
|
39 |
|
40 public: |
|
41 |
|
42 typedef TInt TRequestId; |
|
43 |
|
44 /* SPI transfer clock speed. The closest one is selected if the |
|
45 * exact clock frequency cannot be achieved. |
|
46 * The closest is always less than the requested frequency.*/ |
|
47 enum TClockSpeed |
|
48 { |
|
49 EClk1_5MHz = 0, |
|
50 EClk3MHz, |
|
51 EClk6MHz, |
|
52 EClk12MHz, |
|
53 EClk24MHz, |
|
54 EClk48MHz, |
|
55 EClk96MHz |
|
56 }; |
|
57 |
|
58 /* SPI clock modes used for transfer. |
|
59 Next picture shows what different configuration values means. |
|
60 |
|
61 ,--> Sampling |
|
62 | ,> Shift out |
|
63 | | |
|
64 high/rising ______|¯|_|¯|_|¯|_ (mode 0) |
|
65 |
|
66 high/falling ____|¯|_|¯|_|¯|_|¯ (mode 1) |
|
67 |
|
68 low/falling ¯¯¯¯¯¯|_|¯|_|¯|_|¯ (mode 2) |
|
69 |
|
70 low/rising ¯¯¯¯|_|¯|_|¯|_|¯|_ (mode 3) |
|
71 */ |
|
72 enum TClockMode |
|
73 { |
|
74 /* SPI clock active high, sampling occurs on the rising edge */ |
|
75 EPolarityHighRisingEdge = 0, |
|
76 /* SPI clock active high, sampling occurs on the falling edge */ |
|
77 EPolarityHighFallingEdge, |
|
78 /* SPI clock active low, sampling occurs on the falling edge */ |
|
79 EPolarityLowFallingEdge, |
|
80 /* SPI clock active low, sampling occurs on the rising edge */ |
|
81 EPolarityLowRisingEdge |
|
82 }; |
|
83 |
|
84 /* SPI slave select signal polarity used for transfer */ |
|
85 enum TSsPolarity |
|
86 { |
|
87 /** SS is held \e high during the active state */ |
|
88 ESsPolarityHigh = 0, |
|
89 /** SS is held \e low during the active state */ |
|
90 ESsPolarityLow |
|
91 }; |
|
92 |
|
93 /* SPI read mode, used when reading is done */ |
|
94 enum TReadMode |
|
95 { |
|
96 /* normal read from SPI slave device |
|
97 * (i.e no write involved for this call) */ |
|
98 ENormalRead = 0, |
|
99 /* write buffer is written completely |
|
100 * before the read operation is done */ |
|
101 EWriteB4Read, |
|
102 /* full duplex mode |
|
103 * Tx and Rx are done at same time |
|
104 * NOTE: Tx and Rx buffers must not overlap and must be of equal size */ |
|
105 ECombinedWriteRead |
|
106 }; |
|
107 |
|
108 struct TConfig |
|
109 { |
|
110 /* SPI clock mode */ |
|
111 TClockMode iSpiaClockMode; |
|
112 /* SPI slave select signal polarity */ |
|
113 TSsPolarity iSpiaSsPolarity; |
|
114 /* number of bytes per frame in tx */ |
|
115 TUint8 iTxBytesPerFrame; |
|
116 /* number of bytes per frame in rx */ |
|
117 TUint8 iRxBytsPerFrame; |
|
118 }; |
|
119 |
|
120 /* SPI slave select mode */ |
|
121 enum TSsMode |
|
122 { |
|
123 /* slave select is active during the whole SPI request operation */ |
|
124 EForcedActive = 0, |
|
125 /* slave select is toggled on SPI frame basis during the whole SPI request */ |
|
126 EFrameControlled |
|
127 }; |
|
128 |
|
129 struct TCapabilities |
|
130 { |
|
131 /* bit 0 - memory config support: |
|
132 * bit clear non cached memory supported, bit set cached memory supported |
|
133 * default value is cleared |
|
134 * bit 1 - ENormalRead support in TReadMode: bit set when supported |
|
135 * bit 2 - EWriteB4Read support in TReadMode: bit set when supported |
|
136 * bit 3 - ECombinedWriteRead support in TReadMode: bit set when supported |
|
137 * bit 4 - EForcedActive support in TSsMode: bit set when supported |
|
138 * bit 5 - EFrameControlled in TSsMode: bit set when supported */ |
|
139 TUint32 iCapability; |
|
140 /* Length of the memory cache line in bytes (needed for buffer alignment) */ |
|
141 TUint32 iCacheLineLength; |
|
142 /* DMA threshold for SPI operations */ |
|
143 TUint32 iDMAThreshold; |
|
144 }; |
|
145 |
|
146 /* SPIA request structure */ |
|
147 struct TRequest |
|
148 { |
|
149 /* tx buffer. Buffer length must be multiple of sizeof(TInt) */ |
|
150 const TUint8* iTxBuffer; |
|
151 /* amount of data to transmit in the tx buffer in bytes */ |
|
152 TUint iTxBufferSize; |
|
153 /* rx buffer. Buffer length must be multiple of sizeof(TInt) */ |
|
154 TUint8* iRxBuffer; |
|
155 /* amount of data to read to the rx buffer in bytes */ |
|
156 TUint iRxBufferSize; |
|
157 /* read operation type */ |
|
158 TReadMode iReadMode; |
|
159 /* complete callback method client to be called after |
|
160 * the request has completed */ |
|
161 MWlanSpiaClient* iRequestClient; |
|
162 /* unique request ID passed back to client as |
|
163 * is in SPIA request callback */ |
|
164 TRequestId iRequestId; |
|
165 /* SPI transfer clock speed. |
|
166 * The closest one is selected if exact clock frequency |
|
167 * can not be achieved. The closest is always less |
|
168 * than the requested frequency. */ |
|
169 TClockSpeed iSpiaClockSpeed; |
|
170 /* last request or not for a while, a hint for power management |
|
171 * ETrue upon last request, any other not */ |
|
172 TBool iLastRequest; |
|
173 /* SPI slave select mode used */ |
|
174 TSsMode iSsMode; |
|
175 }; |
|
176 |
|
177 /** |
|
178 * Destructor. |
|
179 * |
|
180 * @since S60 v3.2 |
|
181 */ |
|
182 virtual ~WlanSpia() {}; |
|
183 |
|
184 /** |
|
185 * Create spia layer object |
|
186 * |
|
187 * @since S60 v3.2 |
|
188 * @param aOsaExt osa extension object |
|
189 * @return spia layer object, NULL upon failure |
|
190 * @deprecated Create() and Attach( MWlanOsaExt& ) should be used instead |
|
191 */ |
|
192 static WlanSpia* Create( MWlanOsaExt& aOsaExt ); |
|
193 |
|
194 /** |
|
195 * Create spia layer object |
|
196 * |
|
197 * @since S60 v3.2 |
|
198 * @return spia layer object, NULL upon failure |
|
199 */ |
|
200 static WlanSpia* Create(); |
|
201 |
|
202 /** |
|
203 * Attach the OSA extension object |
|
204 * |
|
205 * @since S60 v3.2 |
|
206 * @param aOsaExt osa extension object |
|
207 */ |
|
208 void Attach( MWlanOsaExt& aOsaExt ); |
|
209 |
|
210 /** |
|
211 * Destroy spia layer object |
|
212 * |
|
213 * @since S60 v3.2 |
|
214 * @param aWlanSpia spia layer object |
|
215 */ |
|
216 static void Destroy( WlanSpia* aWlanSpia ); |
|
217 |
|
218 /** |
|
219 * Extract module capabilities |
|
220 * |
|
221 * @since S60 v3.2 |
|
222 * @param aCapabilities capabilities of the module |
|
223 */ |
|
224 virtual void Capability( TCapabilities& aCapabilities ) { aCapabilities.iCapability = 0; } |
|
225 |
|
226 /** |
|
227 * Configures the SPI HW block |
|
228 * |
|
229 * @since S60 v3.2 |
|
230 * @param aConfig SPI configuration data |
|
231 */ |
|
232 virtual void Configure( const TConfig& aConfig ) = 0; |
|
233 |
|
234 /** |
|
235 * Issues SPIA request |
|
236 * |
|
237 * NOTE: the request must remain valid until operation completes |
|
238 * (either synchronously or asynchronously by completion callback). |
|
239 * It is guaranteed by the system that no SPIA request complete callback |
|
240 * gets called during this call |
|
241 * |
|
242 * @since S60 v3.2 |
|
243 * @param aRequest request to execute |
|
244 * @return status of the operation |
|
245 * ESuccess - request was accepted for asynchronous |
|
246 * excecution and will complete at a later time. |
|
247 * Request completion is notified by |
|
248 * SPIA request complete callback. |
|
249 * SPIA user is allowed to issue additional |
|
250 * requests |
|
251 * |
|
252 * EFailure - request was not accepted as it failed due |
|
253 * unspecified reason. |
|
254 * SPIA request complete callback is not called |
|
255 * |
|
256 * ESuccessXfer - request was accepted and completed |
|
257 * synchronously inside the SPIA. |
|
258 * SPIA request complete callback is not called. |
|
259 * SPIA user is allowed to issue additional |
|
260 * requests |
|
261 * |
|
262 * EPending - request was accepted for asynchronous |
|
263 * excecution and will complete at later time. |
|
264 * Request completion is notified by |
|
265 * SPIA request complete callback. |
|
266 * SPIA user is NOT allowed to issue additional |
|
267 * requests until SPIA request complete callback is called |
|
268 */ |
|
269 virtual SPIA::TStatus Request( const TRequest& aRequest ) = 0; |
|
270 |
|
271 /** |
|
272 * Cancels a pending SPIA request. Either succeeds or has no effect |
|
273 * |
|
274 * NOTE: it is guaranteed by the system that no SPIA request complete callback |
|
275 * gets called during this call |
|
276 * |
|
277 * @since S60 v3.2 |
|
278 * @param aRequestId request ID that identifies the SPIA request to cancel |
|
279 * @return status of the operation |
|
280 * ESuccess - operation success. |
|
281 * SPIA request was cancelled and no SPIA request |
|
282 * complete callback gets executed for the request |
|
283 * that was cancelled |
|
284 * |
|
285 * |
|
286 * EFailure - the request is in use and can not be cancelled. |
|
287 */ |
|
288 virtual SPIA::TStatus Cancel( TRequestId aRequestId ) = 0; |
|
289 |
|
290 protected: |
|
291 |
|
292 /** |
|
293 * Constructor |
|
294 * |
|
295 * @since S60 v3.2 |
|
296 */ |
|
297 explicit WlanSpia() : iOsaExt( NULL ) {} |
|
298 |
|
299 /** |
|
300 * Constructor |
|
301 * |
|
302 * @since S60 v3.2 |
|
303 * @param aOsaExt osa extension object |
|
304 */ |
|
305 explicit WlanSpia( MWlanOsaExt& aOsaExt ) : iOsaExt( &aOsaExt ) {} |
|
306 |
|
307 /** |
|
308 * Extract osa extension |
|
309 * |
|
310 * @since S60 v3.2 |
|
311 * @return osa extension |
|
312 */ |
|
313 inline MWlanOsaExt& OsaExtCb(); |
|
314 |
|
315 private: |
|
316 |
|
317 /** |
|
318 * osa extension |
|
319 */ |
|
320 MWlanOsaExt* iOsaExt; |
|
321 |
|
322 }; |
|
323 |
|
324 #include <wlanspia.inl> |
|
325 |
|
326 #endif // WLANSPIA_H |
|