author | William Roberts <williamr@symbian.org> |
Fri, 01 Oct 2010 11:40:18 +0100 | |
changeset 2 | 048b58430d46 |
parent 0 | 5de814552237 |
permissions | -rw-r--r-- |
0
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
1 |
/* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
8 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
11 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
13 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
15 |
* naviengine_assp\gpio.cpp |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
16 |
* NaviEngine implementation of the MHA GPIO class |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
17 |
* |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
18 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
19 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
20 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
21 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
22 |
#include <naviengine_priv.h> |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
23 |
#include <gpio.h> |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
24 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
25 |
const TInt32 KHwGpioPinMax = 31; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
26 |
const TInt32 KHwGpioEdgeRising = 0x0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
27 |
const TInt32 KHwGpioEdgeFalling = 0x1; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
28 |
const TInt32 KHwGpioEdgeBoth = 0x2; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
29 |
const TInt32 KHwGpioLevelLow = 0x3; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
30 |
const TInt32 KHwGpioLevelHigh = 0x4; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
31 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
32 |
const TInt32 KGpioDebounceInterval = 1; // (in ticks) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
33 |
const TInt32 KGpioMaxRetries = 8; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
34 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
35 |
class GpioPin |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
36 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
37 |
public: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
38 |
GPIO::TGpioMode iMode; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
39 |
TGpioIsr iIsr; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
40 |
TAny * iPtr; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
41 |
TInt iDebounce; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
42 |
}; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
43 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
44 |
static GpioPin GpioPins[KHwGpioPinMax+1]; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
45 |
static TInt32 GpioInterruptId; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
46 |
#ifdef __SMP__ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
47 |
const TInt32 KGpioLockOrder = TSpinLock::EOrderGenericIrqLow2; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
48 |
static TSpinLock GpioSpinLock(KGpioLockOrder); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
49 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
50 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
51 |
inline TInt GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
52 |
inline void GpioUnlock(TInt irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
53 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
54 |
/** |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
55 |
Calculate 16-bit device pin Id from 32-bit pin Id. Use DeviceId() to |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
56 |
get device Id. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
57 |
@param aId 32-bit pin Id |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
58 |
@return 16-bit device specific pin Id |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
59 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
60 |
static inline TUint16 DevicePinId(TInt aId) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
61 |
{return static_cast<TUint16>(aId & 0x0000FFFF);} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
62 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
63 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
64 |
//Commented out to satisfy compiler(as method is not used in the code) but can |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
65 |
//be usefull later |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
66 |
/** |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
67 |
Calculate and return GPIO device Id(either SOC or one of the extenders) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
68 |
defined in TGpioBaseId from the 32-bit pin Id |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
69 |
@param aId 32-bit pin Id |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
70 |
@return |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
71 |
- EInternalId SOC GPIO |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
72 |
- EExtender0-15 GPIO extenders from 0-15 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
73 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
74 |
static inline GPIO::TGpioBaseId ExtenderId(TInt aId) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
75 |
{return static_cast<GPIO::TGpioBaseId>((aId & 0xFFFF0000));} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
76 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
77 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
78 |
//Commented out to satisfy compiler(as method is not used in the code) but can |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
79 |
//be usefull later |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
80 |
/** |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
81 |
Generate 32-bit pin Id from the device Id and device specific 16-bit |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
82 |
pin Id. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
83 |
@param aExtenderId Device Id is defined in TGpioBaseId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
84 |
@param aPinId 16-bit device pin Id |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
85 |
return 32-bit pin Id |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
86 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
87 |
static inline TInt Id(GPIO::TGpioBaseId aExtenderId, TUint16 aPinId) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
88 |
{return static_cast<TInt>(aExtenderId |aPinId);} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
89 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
90 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
91 |
//Commented out to satisfy compiler(as method is not used in the code) but can |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
92 |
//be usefull later |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
93 |
/** |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
94 |
Find index in extender GPIO device table. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
95 |
@param aExtenderId Extender Id is defined in TGpioBaseId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
96 |
@return singned 32-bit integer index device, possible value |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
97 |
from 0 to 15 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
98 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
99 |
static TInt DeviceIndex(GPIO::TGpioBaseId aExtenderId) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
100 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
101 |
TUint16 val = (TUint16)((aExtenderId & 0xFFFF0000) >> 16); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
102 |
if(val == 0) return GPIO::EInternalId; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
103 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
104 |
//The algorithm steps througth the value until first non-zero bit is |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
105 |
//found. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
106 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
107 |
TInt index = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
108 |
if(val & 0xFF00) {index = 8; val = val >> 8;} // 2 x 8-bits |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
109 |
if(val & 0x00F0) {index += 4; val = val >> 4;} // 2 x 4-bits |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
110 |
if(val & 0x000C) {index += 2; val = val >> 2;} // 2 x 2 bits |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
111 |
if(val & 0x0002) {index += 1; val = val >> 1;} // 2 x 1 bits |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
112 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
113 |
return index; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
114 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
115 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
116 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
117 |
//Commented out to satisfy compiler(as method is not used in the code) but can |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
118 |
//be usefull later |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
119 |
/** |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
120 |
Find index in extender GPIO device table. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
121 |
@param aId 32-bit GPIO pin Id |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
122 |
@return singned 32-bit integer index device, possible value |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
123 |
from 0 to 15 |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
124 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
125 |
static TInt DeviceIndex(TInt aId){return DeviceIndex(ExtenderId(aId));} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
126 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
127 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
128 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
129 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
130 |
/** |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
131 |
GPIO interrupt handler |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
132 |
Takes a generic argument (TAny*) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
133 |
*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
134 |
void GpioIsrDispatch(TAny *aPtr) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
135 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
136 |
GpioPin *pins = (GpioPin *)aPtr; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
137 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
138 |
TUint32 interrupt = AsspRegister::Read32(KHwRwGpio_Int); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
139 |
TUint32 enabled = AsspRegister::Read32(KHwRwGpio_Int_Enable); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
140 |
TUint32 masked = interrupt & enabled; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
141 |
for (TInt i = 0; i <= KHwGpioPinMax; i++) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
142 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
143 |
if ((masked & 0x1) && (pins[i].iIsr != NULL)) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
144 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
145 |
(*pins[i].iIsr)(pins[i].iPtr); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
146 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
147 |
masked >>= 1; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
148 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
149 |
Interrupt::Clear(GpioInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
150 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
151 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
152 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
153 |
#include "gpio.inl" |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
154 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
155 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
156 |
// work out debounced state |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
157 |
// |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
158 |
TInt GetDebouncedState(TInt aId, TUint32 &aVal) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
159 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
160 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
161 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
162 |
TInt debounceCount = GpioPins[pinId].iDebounce/KGpioDebounceInterval; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
163 |
TInt count = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
164 |
TInt retries = debounceCount*KGpioMaxRetries; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
165 |
TUint lastState = AsspRegister::Read32(KHwRoGpio_Port_Value); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
166 |
TUint state = lastState; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
167 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
168 |
for (count = 0; count < debounceCount && retries > 0; count ++) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
169 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
170 |
NKern::Sleep(KGpioDebounceInterval); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
171 |
state = AsspRegister::Read32(KHwRoGpio_Port_Value); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
172 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
173 |
if ((state & 1<<pinId) != (lastState & 1<<pinId)) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
174 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
175 |
// state has changed so reset count and lastState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
176 |
lastState = AsspRegister::Read32(KHwRoGpio_Port_Value); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
177 |
count = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
178 |
retries--; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
179 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
180 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
181 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
182 |
if (retries == 0) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
183 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
184 |
// too many retries |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
185 |
return KErrTimedOut; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
186 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
187 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
188 |
aVal = state; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
189 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
190 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
191 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
192 |
EXPORT_C TInt GPIO::SetPinMode |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
193 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
194 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
195 |
TGpioMode aMode |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
196 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
197 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
198 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
199 |
// the chip doesn't support modes, so just store it |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
200 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
201 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
202 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
203 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
204 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
205 |
__e32_atomic_store_rel32(&GpioPins[pinId].iMode, aMode); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
206 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
207 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
208 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
209 |
EXPORT_C TInt GPIO::GetPinMode |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
210 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
211 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
212 |
TGpioMode & aMode |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
213 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
214 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
215 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
216 |
// the chip doesn't support modes, so just return what we stored earlier |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
217 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
218 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
219 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
220 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
221 |
aMode = (TGpioMode) __e32_atomic_load_acq32(&GpioPins[pinId].iMode); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
222 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
223 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
224 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
225 |
EXPORT_C TInt GPIO::SetPinDirection |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
226 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
227 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
228 |
TGpioDirection aDirection |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
229 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
230 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
231 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
232 |
// tristate not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
233 |
if (pinId > KHwGpioPinMax || aDirection == ETriStated) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
234 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
235 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
236 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
237 |
// port enabled means output, disabled means input |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
238 |
if (aDirection == EInput) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
239 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
240 |
AsspRegister::Write32(KHwWoGpio_Port_Control_Disable, 1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
241 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
242 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
243 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
244 |
AsspRegister::Write32(KHwRwGpio_Port_Control_Enable, 1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
245 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
246 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
247 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
248 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
249 |
EXPORT_C TInt GPIO::GetPinDirection |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
250 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
251 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
252 |
TGpioDirection & aDirection |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
253 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
254 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
255 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
256 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
257 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
258 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
259 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
260 |
// port enabled means output, disabled means input |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
261 |
TUint enabled = AsspRegister::Read32(KHwRwGpio_Port_Control_Enable); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
262 |
if (enabled & 1<<pinId) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
263 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
264 |
aDirection = EOutput; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
265 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
266 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
267 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
268 |
aDirection = EInput; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
269 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
270 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
271 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
272 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
273 |
EXPORT_C TInt GPIO::SetPinBias |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
274 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
275 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
276 |
TGpioBias /*aBias*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
277 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
278 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
279 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
280 |
// pin bias not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
281 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
282 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
283 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
284 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
285 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
286 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
287 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
288 |
EXPORT_C TInt GPIO::GetPinBias |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
289 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
290 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
291 |
TGpioBias& /*aBias*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
292 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
293 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
294 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
295 |
// pin bias not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
296 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
297 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
298 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
299 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
300 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
301 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
302 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
303 |
EXPORT_C TInt GPIO::SetPinIdleConfigurationAndState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
304 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
305 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
306 |
TInt /*aConf*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
307 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
308 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
309 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
310 |
// pin idle configuration and state not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
311 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
312 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
313 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
314 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
315 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
316 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
317 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
318 |
EXPORT_C TInt GPIO::GetPinIdleConfigurationAndState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
319 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
320 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
321 |
TInt & /*aBias*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
322 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
323 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
324 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
325 |
// pin idle configuration and state not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
326 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
327 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
328 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
329 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
330 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
331 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
332 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
333 |
EXPORT_C TInt GPIO::BindInterrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
334 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
335 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
336 |
TGpioIsr aIsr, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
337 |
TAny * aPtr |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
338 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
339 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
340 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
341 |
if (pinId > KHwGpioPinMax || aIsr == NULL) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
342 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
343 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
344 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
345 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
346 |
if (GpioPins[pinId].iIsr != NULL) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
347 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
348 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
349 |
// already bound |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
350 |
return KErrInUse; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
351 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
352 |
GpioPins[pinId].iIsr = aIsr; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
353 |
GpioPins[pinId].iPtr = aPtr; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
354 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
355 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
356 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
357 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
358 |
EXPORT_C TInt GPIO::UnbindInterrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
359 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
360 |
TInt aId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
361 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
362 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
363 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
364 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
365 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
366 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
367 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
368 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
369 |
if (GpioPins[pinId].iIsr == NULL) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
370 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
371 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
372 |
// nothing bound |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
373 |
return KErrGeneral; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
374 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
375 |
GpioPins[pinId].iIsr = NULL; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
376 |
GpioPins[pinId].iPtr = NULL; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
377 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
378 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
379 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
380 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
381 |
EXPORT_C TInt GPIO::EnableInterrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
382 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
383 |
TInt aId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
384 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
385 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
386 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
387 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
388 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
389 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
390 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
391 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
392 |
if (GpioPins[pinId].iIsr == NULL) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
393 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
394 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
395 |
// nothing bound |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
396 |
return KErrGeneral; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
397 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
398 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
399 |
// hold value so it can be read after triggering |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
400 |
TUint32 held = AsspRegister::Read32(KHwRwGpio_Int_Hold); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
401 |
AsspRegister::Write32(KHwRwGpio_Int_Hold, held | 1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
402 |
// enable interrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
403 |
AsspRegister::Write32(KHwRwGpio_Int_Enable, 1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
404 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
405 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
406 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
407 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
408 |
EXPORT_C TInt GPIO::DisableInterrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
409 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
410 |
TInt aId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
411 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
412 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
413 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
414 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
415 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
416 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
417 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
418 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
419 |
if (GpioPins[pinId].iIsr == NULL) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
420 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
421 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
422 |
// nothing bound |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
423 |
return KErrGeneral; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
424 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
425 |
// disable interrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
426 |
AsspRegister::Write32(KHwWoGpio_Int_Disable, 1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
427 |
// disable hold |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
428 |
TUint32 held = AsspRegister::Read32(KHwRwGpio_Int_Hold); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
429 |
AsspRegister::Write32(KHwRwGpio_Int_Hold, held & !(1<<pinId)); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
430 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
431 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
432 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
433 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
434 |
EXPORT_C TInt GPIO::IsInterruptEnabled |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
435 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
436 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
437 |
TBool & aEnable |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
438 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
439 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
440 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
441 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
442 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
443 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
444 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
445 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
446 |
if (GpioPins[pinId].iIsr == NULL) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
447 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
448 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
449 |
// nothing bound |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
450 |
return KErrGeneral; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
451 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
452 |
aEnable = AsspRegister::Read32(KHwRwGpio_Int_Enable) & (1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
453 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
454 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
455 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
456 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
457 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
458 |
EXPORT_C TInt GPIO::ClearInterrupt |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
459 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
460 |
TInt aId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
461 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
462 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
463 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
464 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
465 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
466 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
467 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
468 |
// clear pin interrupt status |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
469 |
AsspRegister::Write32(KHwRwGpio_Int, 1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
470 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
471 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
472 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
473 |
EXPORT_C TInt GPIO::GetMaskedInterruptState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
474 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
475 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
476 |
TBool & aActive |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
477 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
478 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
479 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
480 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
481 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
482 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
483 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
484 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
485 |
aActive = AsspRegister::Read32(KHwRwGpio_Int_Enable) & AsspRegister::Read32(KHwRwGpio_Int) & (1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
486 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
487 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
488 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
489 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
490 |
EXPORT_C TInt GPIO::GetRawInterruptState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
491 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
492 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
493 |
TBool & aActive |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
494 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
495 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
496 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
497 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
498 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
499 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
500 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
501 |
aActive = AsspRegister::Read32(KHwRwGpio_Int) & (1<<pinId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
502 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
503 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
504 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
505 |
EXPORT_C TInt GPIO::SetInterruptTrigger |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
506 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
507 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
508 |
TGpioDetectionTrigger aTrigger |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
509 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
510 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
511 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
512 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
513 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
514 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
515 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
516 |
TUint modeRegister = KHwRwGpio_Int_Mode0 + ((pinId >> 3) << 2); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
517 |
TUint modeShift = pinId & 0x7; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
518 |
TUint mode; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
519 |
switch (aTrigger) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
520 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
521 |
case ELevelLow: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
522 |
mode = KHwGpioLevelLow; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
523 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
524 |
case ELevelHigh: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
525 |
mode = KHwGpioLevelHigh; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
526 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
527 |
case EEdgeFalling: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
528 |
mode = KHwGpioEdgeFalling; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
529 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
530 |
case EEdgeRising: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
531 |
mode = KHwGpioEdgeRising; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
532 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
533 |
case EEdgeBoth: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
534 |
mode = KHwGpioEdgeBoth; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
535 |
break; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
536 |
default: |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
537 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
538 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
539 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
540 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
541 |
TUint currentMode = AsspRegister::Read32(modeRegister) & !(0xf << modeShift); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
542 |
AsspRegister::Write32(modeRegister, (mode << modeShift) | currentMode); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
543 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
544 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
545 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
546 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
547 |
EXPORT_C TInt GPIO::EnableWakeup |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
548 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
549 |
TInt aId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
550 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
551 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
552 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
553 |
// wakeup not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
554 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
555 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
556 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
557 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
558 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
559 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
560 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
561 |
EXPORT_C TInt GPIO::DisableWakeup |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
562 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
563 |
TInt aId |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
564 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
565 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
566 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
567 |
// wakeup not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
568 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
569 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
570 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
571 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
572 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
573 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
574 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
575 |
EXPORT_C TInt GPIO::IsWakeupEnabled |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
576 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
577 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
578 |
TBool & /*aEnable*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
579 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
580 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
581 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
582 |
// wakeup not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
583 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
584 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
585 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
586 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
587 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
588 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
589 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
590 |
EXPORT_C TInt GPIO::SetWakeupTrigger |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
591 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
592 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
593 |
TGpioDetectionTrigger /*aTrigger*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
594 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
595 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
596 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
597 |
// wakeup not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
598 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
599 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
600 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
601 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
602 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
603 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
604 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
605 |
EXPORT_C TInt GPIO::SetDebounceTime |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
606 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
607 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
608 |
TInt aTime |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
609 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
610 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
611 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
612 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
613 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
614 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
615 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
616 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
617 |
GpioPins[pinId].iDebounce = NKern::TimerTicks(aTime/1000); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
618 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
619 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
620 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
621 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
622 |
EXPORT_C TInt GPIO::GetDebounceTime |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
623 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
624 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
625 |
TInt & aTime |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
626 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
627 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
628 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
629 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
630 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
631 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
632 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
633 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
634 |
aTime = (GpioPins[pinId].iDebounce*1000)/NKern::TimerTicks(1); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
635 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
636 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
637 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
638 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
639 |
EXPORT_C TInt GPIO::GetInputState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
640 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
641 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
642 |
TGpioState & aState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
643 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
644 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
645 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
646 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
647 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
648 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
649 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
650 |
// check it is enabled and is an input port |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
651 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
652 |
if (GpioPins[pinId].iMode != EEnabled || (AsspRegister::Read32(KHwRwGpio_Port_Control_Enable) & 1<<pinId)) // reg will have 0 for input 1 for output |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
653 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
654 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
655 |
return KErrGeneral; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
656 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
657 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
658 |
TUint32 state; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
659 |
if (GpioPins[pinId].iDebounce == 0) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
660 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
661 |
// just read it if we are not debouncing |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
662 |
state = AsspRegister::Read32(KHwRoGpio_Port_Value); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
663 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
664 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
665 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
666 |
// work out debounced state |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
667 |
TInt err = GetDebouncedState(aId, state); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
668 |
if (err != KErrNone) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
669 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
670 |
return err; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
671 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
672 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
673 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
674 |
if (state & (1<<pinId)) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
675 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
676 |
aState = EHigh; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
677 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
678 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
679 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
680 |
aState = ELow; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
681 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
682 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
683 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
684 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
685 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
686 |
EXPORT_C TInt GPIO::SetOutputState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
687 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
688 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
689 |
TGpioState aState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
690 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
691 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
692 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
693 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
694 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
695 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
696 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
697 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
698 |
if (GpioPins[pinId].iMode != EEnabled) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
699 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
700 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
701 |
return KErrGeneral; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
702 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
703 |
TUint outputReg, value; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
704 |
if (pinId >= 16) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
705 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
706 |
outputReg = KHwWoGpio_Port_Set_Clear_Hi; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
707 |
pinId = pinId - 16; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
708 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
709 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
710 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
711 |
outputReg = KHwWoGpio_Port_Set_Clear_Lo; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
712 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
713 |
if (aState == EHigh) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
714 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
715 |
value = 1 << pinId; // LSW - set.. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
716 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
717 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
718 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
719 |
value = 1 << (pinId + 16); // MSW - clear.. |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
720 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
721 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
722 |
AsspRegister::Write32(outputReg, value); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
723 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
724 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
725 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
726 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
727 |
EXPORT_C TInt GPIO::GetOutputState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
728 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
729 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
730 |
TGpioState & aState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
731 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
732 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
733 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
734 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
735 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
736 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
737 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
738 |
// atomic - no lock required |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
739 |
TUint32 state = AsspRegister::Read32(KHwRoGpio_Port_Value); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
740 |
if(state & (1<<pinId)) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
741 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
742 |
aState = EHigh; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
743 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
744 |
else |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
745 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
746 |
aState = ELow; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
747 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
748 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
749 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
750 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
751 |
EXPORT_C TInt GPIO::GetInputState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
752 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
753 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
754 |
TGpioCallback * /*aCb*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
755 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
756 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
757 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
758 |
// asynch calls not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
759 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
760 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
761 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
762 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
763 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
764 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
765 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
766 |
EXPORT_C TInt GPIO::SetOutputState |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
767 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
768 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
769 |
TGpioState /*aState*/, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
770 |
TGpioCallback * /*aCb*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
771 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
772 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
773 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
774 |
// asynch calls not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
775 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
776 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
777 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
778 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
779 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
780 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
781 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
782 |
#ifndef __USE_GPIO_STATIC_EXTENSION__ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
783 |
EXPORT_C TInt GPIO::StaticExtension |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
784 |
( |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
785 |
TInt aId, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
786 |
TInt /*aCmd*/, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
787 |
TAny * /*aArg1*/, |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
788 |
TAny * /*aArg2*/ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
789 |
) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
790 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
791 |
TUint16 pinId = DevicePinId(aId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
792 |
// static extensions not supported |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
793 |
if (pinId > KHwGpioPinMax) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
794 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
795 |
return KErrArgument; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
796 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
797 |
return KErrNotSupported; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
798 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
799 |
#endif |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
800 |
|
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
801 |
DECLARE_STANDARD_EXTENSION() |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
802 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
803 |
TInt irq = GpioLock(); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
804 |
// initialise GPIO pins array |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
805 |
for (TInt32 i = 0; i <= KHwGpioPinMax; i++) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
806 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
807 |
GpioPins[i].iMode = GPIO::EIdle; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
808 |
GpioPins[i].iIsr = NULL; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
809 |
GpioPins[i].iPtr = NULL; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
810 |
GpioPins[i].iDebounce = 0; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
811 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
812 |
GpioUnlock(irq); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
813 |
TInt r = Interrupt::Bind(KIntIdGpio, GpioIsrDispatch, &GpioPins[0]); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
814 |
if (r < 0) |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
815 |
{ |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
816 |
return r; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
817 |
} |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
818 |
GpioInterruptId = r; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
819 |
Interrupt::Clear(GpioInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
820 |
Interrupt::Enable(GpioInterruptId); |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
821 |
return KErrNone; |
5de814552237
Initial contribution supporting NaviEngine 1
Ryan Harkin <ryan.harkin@nokia.com>
parents:
diff
changeset
|
822 |
} |