author | hgs |
Mon, 12 Jul 2010 14:24:01 +0100 | |
changeset 202 | 9aca3be14c27 |
parent 90 | 947f0dc9f7a8 |
child 252 | 0a40b8675b23 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32\include\drivers\gpio.h |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#ifndef __GPIO_H__ |
|
19 |
#define __GPIO_H__ |
|
20 |
||
21 |
class TGpioCallback; //forward declaration |
|
22 |
||
23 |
/** |
|
24 |
@publishedPartner |
|
25 |
@prototype 9.6 |
|
26 |
||
27 |
GPIO interrupt handler |
|
28 |
Takes a generic argument (TAny*) |
|
29 |
*/ |
|
30 |
typedef void (*TGpioIsr)(TAny*); |
|
31 |
||
32 |
/** |
|
33 |
@publishedPartner |
|
34 |
@prototype 9.6 |
|
35 |
||
36 |
GPIO class handler |
|
37 |
*/ |
|
38 |
class GPIO |
|
39 |
{ |
|
40 |
public: |
|
41 |
/** |
|
42 |
GPIO pin modes (to be requested on any pin): |
|
43 |
- enabled, |
|
44 |
- disabled, |
|
45 |
- idling |
|
46 |
*/ |
|
47 |
enum TGpioMode |
|
48 |
{ |
|
49 |
EEnabled, |
|
50 |
EDisabled, |
|
51 |
EIdle |
|
52 |
}; |
|
53 |
||
54 |
/** |
|
55 |
GPIO pin directions (to be requested on any pin): |
|
56 |
- input, |
|
57 |
- output, |
|
58 |
- tristated |
|
59 |
*/ |
|
60 |
enum TGpioDirection |
|
61 |
{ |
|
62 |
EInput, |
|
63 |
EOutput, |
|
64 |
ETriStated |
|
65 |
}; |
|
66 |
||
67 |
/** |
|
68 |
GPIO pin states (to be set on an output or read from an input or output): |
|
69 |
- electrical Low, |
|
70 |
- electrical High, |
|
71 |
- state compatible with idling the pin (module) |
|
72 |
*/ |
|
73 |
enum TGpioState |
|
74 |
{ |
|
75 |
ELow, |
|
76 |
EHigh, |
|
77 |
EIdleState |
|
78 |
}; |
|
79 |
||
80 |
/** |
|
81 |
GPIO programmable bias: |
|
82 |
- no drive, |
|
83 |
- pulled down (Low), |
|
84 |
- pulled up (High) |
|
85 |
*/ |
|
86 |
enum TGpioBias |
|
87 |
{ |
|
88 |
ENoDrive, |
|
89 |
EPullDown, |
|
90 |
EPullUp |
|
91 |
}; |
|
92 |
||
93 |
/** |
|
94 |
GPIO interrupt and/or wakeup triger configuration (to be requested on an input |
|
95 |
that supports interrupts or wakeup function): |
|
96 |
- Level triggered, low level, |
|
97 |
- Level triggered, high level, |
|
98 |
- Edge triggered, falling edge, |
|
99 |
- Edge triggered, rising edge, |
|
100 |
- Edge triggered, both edges, |
|
101 |
*/ |
|
102 |
enum TGpioDetectionTrigger |
|
103 |
{ |
|
104 |
ELevelLow, |
|
105 |
ELevelHigh, |
|
106 |
EEdgeFalling, |
|
107 |
EEdgeRising, |
|
108 |
EEdgeBoth |
|
109 |
}; |
|
110 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
Enumeration TGpioBaseId defines the highest 16 bits of 32 bit GPIO Id |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
to identify the GPIO hardware block: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
- EInternalId - The SOC GPIO hardware block (and any extender that is |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
covered by the vendor supplied implementation) supports |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
pin ids from 0-65535 |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
- EExtender0-15 - Up to 16 3rd party extenders (each supporting up |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
to 65536 pins) can be used. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
enum TGpioBaseId |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
EInternalId = 0x00000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
EExtender0 = 0x00010000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
EExtender1 = 0x00020000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
EExtender2 = 0x00040000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
EExtender3 = 0x00080000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
EExtender4 = 0x00100000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
EExtender5 = 0x00200000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
EExtender6 = 0x00400000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
EExtender7 = 0x00800000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
EExtender8 = 0x01000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
EExtender9 = 0x02000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
EExtender10 = 0x04000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
EExtender11 = 0x08000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
EExtender12 = 0x10000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
EExtender13 = 0x20000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
EExtender14 = 0x40000000, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
EExtender15 = 0x80000000 |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
}; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
141 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
|
0 | 143 |
/** |
144 |
Sets the pin mode. |
|
145 |
||
146 |
@param aId The pin Id. |
|
147 |
@param aMode The pin mode. |
|
148 |
||
149 |
@return KErrNone, if successful; KErrArgument, if aId is invalid; |
|
150 |
KErrNotReady, when a pin that has requested to be Idle is not ready to do |
|
151 |
so; |
|
152 |
KErrNotSupported, if a pin cannot be used as a GPIO because it has been |
|
153 |
assigned an alternative function. |
|
154 |
||
155 |
When disabling a pin, the module which the pin is a part of may not be disabled, |
|
156 |
but KErrNone is still returned. |
|
157 |
*/ |
|
158 |
IMPORT_C static TInt SetPinMode(TInt aId, TGpioMode aMode); |
|
159 |
||
160 |
/** |
|
161 |
Reads the pin mode. |
|
162 |
||
163 |
@param aId The pin Id. |
|
164 |
@param aMode On return contains the pin mode. |
|
165 |
||
166 |
@return KErrNone, if successful; KErrArgument, if aId is invalid; |
|
167 |
KErrNotSupported, if reading the pin mode is not supported. |
|
168 |
*/ |
|
169 |
IMPORT_C static TInt GetPinMode(TInt aId, TGpioMode& aMode); |
|
170 |
||
171 |
/** |
|
172 |
Sets the pin direction. |
|
173 |
||
174 |
@param aId The pin Id. |
|
175 |
@param aDirection The pin direction. |
|
176 |
||
177 |
@return KErrNone, if successful; KErrArgument, if aId is invalid; |
|
178 |
KErrNotSupported, if a pin cannot operate in the direction specified. |
|
179 |
*/ |
|
180 |
IMPORT_C static TInt SetPinDirection(TInt aId, TGpioDirection aDirection); |
|
181 |
||
182 |
/** |
|
183 |
Reads the pin direction. |
|
184 |
||
185 |
@param aId The pin Id. |
|
186 |
@param aDirection On return contains the pin direction. |
|
187 |
||
188 |
@return KErrNone, if successful; KErrArgument, if aId is invalid; |
|
189 |
KErrNotSupported, if reading the pin direction is not supported. |
|
190 |
*/ |
|
191 |
IMPORT_C static TInt GetPinDirection(TInt aId, TGpioDirection& aDirection); |
|
192 |
||
193 |
/** |
|
194 |
Sets the bias on a pin. |
|
195 |
||
196 |
@param aId The pin Id. |
|
197 |
@param aBias The drive on the pin. |
|
198 |
||
199 |
@return KErrNone, if successful; KErrArgument, if aId is invalid; |
|
200 |
KErrNotSupported, if a pin does not support setting the drive. |
|
201 |
*/ |
|
202 |
IMPORT_C static TInt SetPinBias(TInt aId, TGpioBias aBias); |
|
203 |
||
204 |
/** |
|
205 |
Reads the bias on a pin. |
|
206 |
||
207 |
@param aId The pin Id. |
|
208 |
@param aBias On return contains the bias previoulsy set on the pin (or the |
|
209 |
default bias if first time). |
|
210 |
||
211 |
@return KErrNone, if successful; |
|
212 |
KErrArgument, if aId is invalid; |
|
213 |
KErrNotSupported, if reading the pin bias is not supported. |
|
214 |
*/ |
|
215 |
IMPORT_C static TInt GetPinBias(TInt aId, TGpioBias& aBias); |
|
216 |
||
217 |
/** |
|
218 |
Sets the idle configuration and state. The pin configuration is the |
|
219 |
same that the pin should have when setting the mode to EIdle and the |
|
220 |
state same it should present when setting the output state to EIdleState. |
|
221 |
||
222 |
@param aId The pin Id. |
|
223 |
@param aConf An implementation specific token specifying the idle |
|
224 |
configration and state. |
|
225 |
||
226 |
@return KErrNone, if successful; |
|
227 |
KErrArgument, if aId is invalid; |
|
228 |
KErrNotSupported, if setting the pin idle configuration and state |
|
229 |
are not supported. |
|
230 |
*/ |
|
231 |
IMPORT_C static TInt SetPinIdleConfigurationAndState(TInt aId, TInt aConf); |
|
232 |
||
233 |
/** |
|
234 |
Reads the pin idle configuration and state. |
|
235 |
||
236 |
@param aId The pin Id. |
|
237 |
@param aConf On return contains the idle configuration and state previoulsy |
|
238 |
set on the pin. |
|
239 |
||
240 |
@return KErrNone, if successful; |
|
241 |
KErrArgument, if aId is invalid; |
|
242 |
KErrNotSupported, if reading the pin idle configuration and state |
|
243 |
is not supported. |
|
244 |
*/ |
|
245 |
IMPORT_C static TInt GetPinIdleConfigurationAndState(TInt aId, TInt& aConf); |
|
246 |
||
247 |
/** |
|
248 |
Associates the specified interrupt service routine (ISR) function with the |
|
249 |
specified interrupt Id. |
|
250 |
||
251 |
@param aId The pin Id. |
|
252 |
@param anIsr The address of the ISR function. |
|
253 |
@param aPtr 32-bit value that is passed to the ISR. |
|
254 |
This is designated a TAny* type as it is usually a pointer to the |
|
255 |
owning class or data to be used in the ISR, although it can be any |
|
256 |
32-bit value. |
|
257 |
||
258 |
@return KErrNone, if successful; |
|
259 |
KErrArgument, if aId is invalid; |
|
260 |
KErrNotSupported if pin does not support interrupts; |
|
261 |
KErrInUse, if an ISR is already bound to this interrupt. |
|
262 |
*/ |
|
263 |
IMPORT_C static TInt BindInterrupt(TInt aId, TGpioIsr aIsr, TAny* aPtr); |
|
264 |
||
265 |
/** |
|
266 |
Unbinds the interrupt service routine (ISR) function from the specified interrupt |
|
267 |
id. |
|
268 |
||
269 |
@param aId The pin Id. |
|
270 |
||
271 |
@return KErrNone, if successful; |
|
272 |
KErrArgument, if aId is invalid; |
|
273 |
KErrNotSupported if pin does not support interrupts; |
|
274 |
KErrGeneral, if there is no ISR bound to this interrupt. |
|
275 |
*/ |
|
276 |
IMPORT_C static TInt UnbindInterrupt(TInt aId); |
|
277 |
||
278 |
/** |
|
279 |
Enables the interrupt on specified pin. |
|
280 |
||
281 |
@param aId The pin Id. |
|
282 |
||
283 |
@return KErrNone, if successful; |
|
284 |
KErrArgument, if aId is invalid; |
|
285 |
KErrNotSupported if pin does not support interrupts; |
|
286 |
KErrGeneral, if there is no ISR bound to this interrupt. |
|
287 |
*/ |
|
288 |
IMPORT_C static TInt EnableInterrupt(TInt aId); |
|
289 |
||
290 |
/** |
|
291 |
Disables the interrupt on specified pin. |
|
292 |
||
293 |
@param aId The pin Id. |
|
294 |
||
295 |
@return KErrNone, if successful; |
|
296 |
KErrArgument, if aId is invalid; |
|
297 |
KErrNotSupported if pin does not support interrupts; |
|
298 |
KErrGeneral, if there is no ISR bound to this interrupt. |
|
299 |
*/ |
|
300 |
IMPORT_C static TInt DisableInterrupt(TInt aId); |
|
301 |
||
302 |
/** |
|
303 |
Checks if interrupt is enabled on pin. |
|
304 |
||
305 |
@param aId The pin Id. |
|
306 |
@param aEnable On return contains the enable/disable state of interrupt |
|
307 |
(TRUE=enabled). |
|
308 |
||
309 |
@return KErrNone, if successful; |
|
310 |
KErrArgument, if aId is invalid; |
|
311 |
KErrNotSupported if pin does not support interrupts; |
|
312 |
KErrGeneral, if there is no ISR bound to this interrupt. |
|
313 |
*/ |
|
314 |
IMPORT_C static TInt IsInterruptEnabled(TInt aId, TBool& aEnable); |
|
315 |
||
316 |
/** |
|
317 |
Clears any pending interrupt on the specified pin. |
|
318 |
||
319 |
@param aId The pin Id. |
|
320 |
||
321 |
@return KErrNone, if successful; |
|
322 |
KErrArgument, if aId is invalid; |
|
323 |
KErrNotSupported if clearing interrupt signal is not supported on this |
|
324 |
pin; |
|
325 |
KErrGeneral, if there is no ISR bound to this interrupt. |
|
326 |
*/ |
|
327 |
IMPORT_C static TInt ClearInterrupt(TInt aId); |
|
328 |
||
329 |
/** |
|
330 |
Reads the interrupt state as output by the GPIO interrupt controller. |
|
331 |
||
332 |
@param aId The pin Id. |
|
333 |
@param aActive On return contains the state of the interrupt signal as output by |
|
334 |
GPIO interrupt controller (TRUE=active). |
|
335 |
||
336 |
@return KErrNone, if successful; |
|
337 |
KErrArgument, if aId is invalid; |
|
338 |
KErrNotSupported if reading interrupt state is not supported; |
|
339 |
KErrGeneral, if there is no ISR bound to this interrupt. |
|
340 |
*/ |
|
341 |
IMPORT_C static TInt GetMaskedInterruptState(TInt aId, TBool& aActive); |
|
342 |
||
343 |
/** |
|
344 |
Reads the interrupt state on the specified pin before any masking. |
|
345 |
||
346 |
@param aId The pin Id. |
|
347 |
@param aActive On return contains state of the interrupt signal on the pin |
|
348 |
(TRUE=active). |
|
349 |
||
350 |
@return KErrNone, if successful; |
|
351 |
KErrArgument, if aId is invalid; |
|
352 |
KErrNotSupported if reading raw interrupt state is not supported; |
|
353 |
KErrGeneral, if there is no ISR bound to this interrupt. |
|
354 |
*/ |
|
355 |
IMPORT_C static TInt GetRawInterruptState(TInt aId, TBool& aActive); |
|
356 |
||
357 |
/** |
|
358 |
Sets the interrupt trigger on the specified pin. |
|
359 |
||
360 |
@param aId The pin Id. |
|
361 |
@param aTrigger The trigger type. |
|
362 |
||
363 |
@return KErrNone, if successful; |
|
364 |
KErrArgument, if aId is invalid; |
|
365 |
KErrNotSupported if pin does not support interrupts. |
|
366 |
*/ |
|
367 |
IMPORT_C static TInt SetInterruptTrigger(TInt aId, TGpioDetectionTrigger aTrigger); |
|
368 |
||
369 |
/** |
|
370 |
Enables the wakeup on specified pin. |
|
371 |
||
372 |
@param aId The pin Id. |
|
373 |
||
374 |
@return KErrNone, if successful; |
|
375 |
KErrArgument, if aId is invalid; |
|
376 |
KErrNotSupported if pin does not support wakeup. |
|
377 |
*/ |
|
378 |
IMPORT_C static TInt EnableWakeup(TInt aId); |
|
379 |
||
380 |
/** |
|
381 |
Disables the wakeup on specified pin. |
|
382 |
||
383 |
@param aId The pin Id. |
|
384 |
||
385 |
@return KErrNone, if successful; |
|
386 |
KErrArgument, if aId is invalid; |
|
387 |
KErrNotSupported if pin does not support wakeup. |
|
388 |
*/ |
|
389 |
IMPORT_C static TInt DisableWakeup(TInt aId); |
|
390 |
||
391 |
/** |
|
392 |
Checks if wakeup is enabled on pin. |
|
393 |
||
394 |
@param aId The pin Id. |
|
395 |
@param aEnable On return contains the enable/disable state of wakeup |
|
396 |
(TRUE=enabled). |
|
397 |
||
398 |
@return KErrNone, if successful; |
|
399 |
KErrArgument, if aId is invalid; |
|
400 |
KErrNotSupported if pin does not support wakeups; |
|
401 |
*/ |
|
402 |
IMPORT_C static TInt IsWakeupEnabled(TInt aId, TBool& aEnable); |
|
403 |
||
404 |
/** |
|
405 |
Sets the wakeup trigger on the specified pin. |
|
406 |
||
407 |
@param aId The pin Id. |
|
408 |
@param aTrigger The trigger type. |
|
409 |
||
410 |
@return KErrNone, if successful; |
|
411 |
KErrArgument, if aId is invalid; |
|
412 |
KErrNotSupported if pin does not support wakeup. |
|
413 |
*/ |
|
414 |
IMPORT_C static TInt SetWakeupTrigger(TInt aId, TGpioDetectionTrigger aTrigger); |
|
415 |
||
416 |
/** |
|
417 |
Sets the debouncing time on the specified pin. |
|
418 |
||
419 |
@param aId The pin Id. |
|
420 |
@param aTime The debouncing time in microseconds. |
|
421 |
||
422 |
@return KErrNone, if the time is succesfully changed or no change is needed (see |
|
423 |
below); |
|
424 |
KErrArgument, if aId is invalid; |
|
425 |
KErrNotSupported if pin does not support debouncing. |
|
426 |
||
427 |
If the requested time is greater than the common value for the module, the latter |
|
428 |
is increased to the value requested. |
|
429 |
If the requested time is lesser than the common value for the module then the |
|
430 |
common value is unchanged, unless it is set to the value requested on this pin. |
|
431 |
*/ |
|
432 |
IMPORT_C static TInt SetDebounceTime(TInt aId, TInt aTime); |
|
433 |
||
434 |
/** |
|
435 |
Reads the debouncing time on the specified pin. |
|
436 |
||
437 |
@param aId The pin Id. |
|
438 |
@param aTime On return contains the debouncing time in microseconds. |
|
439 |
||
440 |
@return KErrNone, if successful; |
|
441 |
KErrArgument, if aId is invalid; |
|
442 |
KErrNotSupported if pin does not support debouncing. |
|
443 |
*/ |
|
444 |
IMPORT_C static TInt GetDebounceTime(TInt aId, TInt& aTime); |
|
445 |
||
446 |
/** |
|
447 |
Reads the state of an input (synchronously). |
|
448 |
||
449 |
@param aId The pin Id. |
|
450 |
@param aState On return contains the pin state. |
|
451 |
||
452 |
@return KErrNone, if successful; |
|
453 |
KErrArgument, if aId is invalid. |
|
454 |
KErrNotSupported, if reading the state synchronously is not supported. |
|
455 |
*/ |
|
456 |
IMPORT_C static TInt GetInputState(TInt aId, TGpioState& aState); |
|
457 |
||
458 |
/** |
|
459 |
Sets the output pin to one of the supported states (synchronously). |
|
460 |
||
461 |
@param aId The pin Id. |
|
462 |
@param aState The pin state. |
|
463 |
||
464 |
@return KErrNone, if successful; |
|
465 |
KErrArgument, if aId is invalid; |
|
466 |
KErrNotSupported, if the state is not supported or if setting its state synchronously is not supported. |
|
467 |
*/ |
|
468 |
IMPORT_C static TInt SetOutputState(TInt aId, TGpioState aState); |
|
469 |
||
470 |
/** |
|
471 |
Reads the output pin states (synchronously). |
|
472 |
||
473 |
@param aId The pin Id. |
|
474 |
@param aState On return contains the pin state. On systems where the state of an |
|
475 |
ouptut pin cannot be read directly from hardware, or takes a non |
|
476 |
negligible time to be retrieved, the implementation must cache it. |
|
477 |
||
478 |
@return KErrNone, if successful; |
|
479 |
KErrArgument, if aId is invalid. |
|
480 |
*/ |
|
481 |
IMPORT_C static TInt GetOutputState(TInt aId, TGpioState& aState); |
|
482 |
||
483 |
/** |
|
484 |
Reads the state of an input (asynchronously). |
|
485 |
||
486 |
@param aId The pin Id. |
|
487 |
@param aCb A pointer to a GPIO callback object. |
|
488 |
||
489 |
@return KErrNone, if accepted; |
|
490 |
KErrArgument, if aId is invalid. |
|
491 |
KErrNotSupported, if reading the state asynchronously is not supported. |
|
492 |
||
493 |
The result of the read operation and the state of the input pin will be passed as an argument to the callback function; |
|
494 |
*/ |
|
495 |
IMPORT_C static TInt GetInputState(TInt aId, TGpioCallback* aCb); |
|
496 |
||
497 |
/** |
|
498 |
Sets the output pin to one of the supported states (asynchronously). |
|
499 |
||
500 |
@param aId The pin Id. |
|
501 |
@param aState The pin state. |
|
502 |
@param aCb A pointer to a GPIO callback object. |
|
503 |
||
504 |
@return KErrNone, if accepted; |
|
505 |
KErrArgument, if aId is invalid; |
|
506 |
KErrNotSupported, if setting its state asynchronously is not supported. |
|
507 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
508 |
|
0 | 509 |
The result of the set operation will be passed as an argument to the callback function; |
510 |
*/ |
|
511 |
IMPORT_C static TInt SetOutputState(TInt aId, TGpioState aState, TGpioCallback* aCb); |
|
512 |
||
513 |
/** |
|
514 |
Allows the platform specific implementation to extend the API. |
|
515 |
||
516 |
@param aId The pin Id. |
|
517 |
@param aCmd A PSL extension function id. |
|
518 |
@param aArg1 An argument to be passed to the PSL extension function. |
|
519 |
@param aArg2 An argument to be passed to the PSL extension function. |
|
520 |
||
521 |
@return KErrNone, if accepted; |
|
522 |
KErrArgument, if aId is invalid; |
|
523 |
KErrNotSupported, if static extensions are not supported. |
|
524 |
Any other system wide error code. |
|
525 |
*/ |
|
526 |
IMPORT_C static TInt StaticExtension(TInt aId, TInt aCmd, TAny* aArg1, TAny* aArg2); |
|
527 |
}; |
|
528 |
||
529 |
/** |
|
530 |
@publishedPartner |
|
531 |
@prototype 9.6 |
|
532 |
||
533 |
GPIO asynchronous callback function |
|
534 |
*/ |
|
535 |
typedef void (*TGpioCbFn)(TInt /*aPinId*/, |
|
536 |
GPIO::TGpioState /*aState*/, |
|
537 |
TInt /*aResult*/, |
|
538 |
TAny* /*aParam*/); |
|
539 |
/** |
|
540 |
@publishedPartner |
|
541 |
@prototype 9.6 |
|
542 |
||
543 |
GPIO asynchronous callback DFC |
|
544 |
The client must create one of these to be passed to each asynchronous call to GetInputState and SetOutputState |
|
545 |
The callback function is called in the context supplied by the client when creating an object of this kind (aQue) |
|
546 |
The callback function takes as arguments the pin id and the state, so it can be common to all TGpioCallback |
|
547 |
*/ |
|
548 |
class TGpioCallback : public TDfc |
|
549 |
{ |
|
550 |
public: |
|
551 |
inline TGpioCallback(TGpioCbFn aFn, TAny* aPtr, TDfcQue* aQue, TInt aPriority) : TDfc(DfcFunc, this, aQue, aPriority), iParam(aPtr), iCallback(aFn) |
|
552 |
{} |
|
553 |
private: |
|
554 |
inline static void DfcFunc(TAny* aPtr) |
|
555 |
{ |
|
556 |
TGpioCallback* pCb = (TGpioCallback*) aPtr; |
|
557 |
pCb->iCallback(pCb->iPinId, pCb->iState, pCb->iResult, pCb->iParam); |
|
558 |
} |
|
559 |
public: |
|
560 |
TInt iPinId; // the Id of the pin on which the asynchronous operation is performed |
|
561 |
GPIO::TGpioState iState; // either the state the output pin should be moved to or the state the input pin is at |
|
562 |
TInt iResult; // the result of this transaction as a system wide error |
|
563 |
TAny* iParam; |
|
564 |
TGpioCbFn iCallback; |
|
565 |
}; |
|
566 |
||
567 |
#endif /*__GPIO_H__*/ |
|
568 |