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