--- a/bsptemplate/asspandvariant/template_assp/gpio.cpp Tue Aug 31 16:34:26 2010 +0300
+++ b/bsptemplate/asspandvariant/template_assp/gpio.cpp Wed Sep 01 12:34:56 2010 +0100
@@ -39,87 +39,6 @@
static TInt32 GpioInterruptId; // place to store interrupt handle returned from Interrupt::Bind()
-
-/**
-Calculate 16-bit device pin Id from 32-bit pin Id. Use DeviceId() to
-get device Id.
-@param aId 32-bit pin Id
-@return 16-bit device specific pin Id
- */
-static inline TUint16 DevicePinId(TInt aId)
- {return static_cast<TUint16>(aId & 0x0000FFFF);}
-
-
-//Commented out to satisfy compiler(as method is not used in the code) but can
-//be usefull later
-/**
-Calculate and return GPIO device Id(either SOC or one of the extenders)
-defined in TGpioBaseId from the 32-bit pin Id
-@param aId 32-bit pin Id
-@return
- - EInternalId SOC GPIO
- - EExtender0-15 GPIO extenders from 0-15
-
-static inline GPIO::TGpioBaseId ExtenderId(TInt aId)
- {return static_cast<GPIO::TGpioBaseId>((aId & 0xFFFF0000));}
-*/
-
-//Commented out to satisfy compiler(as method is not used in the code) but can
-//be usefull later
-/**
-Generate 32-bit pin Id from the device Id and device specific 16-bit
-pin Id.
-@param aExtenderId Device Id is defined in TGpioBaseId
-@param aPinId 16-bit device pin Id
-return 32-bit pin Id
-
-static inline TInt Id(GPIO::TGpioBaseId aExtenderId, TUint16 aPinId)
- {return static_cast<TInt>(aExtenderId |aPinId);}
-*/
-
-//Commented out to satisfy compiler(as method is not used in the code) but can
-//be usefull later
-/**
-Find index in extender GPIO device table.
-@param aExtenderId Extender Id is defined in TGpioBaseId
-@return singned 32-bit integer index device, possible value
- from 0 to 15
-
-static TInt DeviceIndex(GPIO::TGpioBaseId aExtenderId)
- {
- TUint16 val = (TUint16)((aExtenderId & 0xFFFF0000) >> 16);
- if(val == 0) return GPIO::EInternalId;
-
- //The algorithm steps througth the value until first non-zero bit is
- //found.
- //
- TInt index = 0;
- if(val & 0xFF00) {index = 8; val = val >> 8;} // 2 x 8-bits
- if(val & 0x00F0) {index += 4; val = val >> 4;} // 2 x 4-bits
- if(val & 0x000C) {index += 2; val = val >> 2;} // 2 x 2 bits
- if(val & 0x0002) {index += 1; val = val >> 1;} // 2 x 1 bits
-
- return index;
- }
-*/
-
-
-//Commented out to satisfy compiler(as method is not used in the code) but can
-//be usefull later
-/**
-Find index in extender GPIO device table.
-@param aId 32-bit GPIO pin Id
-@return singned 32-bit integer index device, possible value
- from 0 to 15
-
-static TInt DeviceIndex(TInt aId){return DeviceIndex(ExtenderId(aId));}
-*/
-
-
-
-
-
-
/**
GPIO interrupt handler
generic argument (TAny*) is a pointer to the GpioPins array
@@ -153,8 +72,7 @@
TGpioMode aMode
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -168,8 +86,7 @@
TGpioMode & aMode
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -183,8 +100,7 @@
TGpioDirection aDirection
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax || aDirection == ETriStated)
+ if (aId < 0 || aId > KHwGpioPinMax || aDirection == ETriStated)
{
return KErrArgument;
}
@@ -198,8 +114,7 @@
TGpioDirection & aDirection
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -213,8 +128,7 @@
TGpioBias aBias
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -228,8 +142,7 @@
TGpioBias & aBias
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -243,8 +156,7 @@
TInt /*aConf*/
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -258,8 +170,7 @@
TInt & aBias
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -274,19 +185,18 @@
TAny * aPtr
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax || aIsr == NULL)
+ if (aId < 0 || aId > KHwGpioPinMax || aIsr == NULL)
{
return KErrArgument;
}
- if (GpioPins[pinId].iIsr != NULL)
+ if (GpioPins[aId].iIsr != NULL)
{
// already bound
return KErrInUse;
}
// record isr and arg bound to this pin
- GpioPins[pinId].iIsr = aIsr;
- GpioPins[pinId].iPtr = aPtr;
+ GpioPins[aId].iIsr = aIsr;
+ GpioPins[aId].iPtr = aPtr;
return KErrNone;
}
@@ -295,19 +205,18 @@
TInt aId
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
- if (GpioPins[pinId].iIsr == NULL)
+ if (GpioPins[aId].iIsr == NULL)
{
// nothing bound
return KErrGeneral;
}
// NULL isr bound to this pin
- GpioPins[pinId].iIsr = NULL;
- GpioPins[pinId].iPtr = NULL;
+ GpioPins[aId].iIsr = NULL;
+ GpioPins[aId].iPtr = NULL;
return KErrNone;
}
@@ -316,12 +225,11 @@
TInt aId
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
- if (GpioPins[pinId].iIsr == NULL)
+ if (GpioPins[aId].iIsr == NULL)
{
// nothing bound
return KErrGeneral;
@@ -335,12 +243,11 @@
TInt aId
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
- if (GpioPins[pinId].iIsr == NULL)
+ if (GpioPins[aId].iIsr == NULL)
{
// nothing bound
return KErrGeneral;
@@ -355,12 +262,11 @@
TBool & aEnable
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
- if (GpioPins[pinId].iIsr == NULL)
+ if (GpioPins[aId].iIsr == NULL)
{
// nothing bound
return KErrGeneral;
@@ -374,12 +280,11 @@
TInt aId
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
- if (GpioPins[pinId].iIsr == NULL)
+ if (GpioPins[aId].iIsr == NULL)
{
// nothing bound
return KErrGeneral;
@@ -394,8 +299,7 @@
TBool & aActive
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -409,8 +313,7 @@
TBool & aActive
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -424,8 +327,7 @@
TGpioDetectionTrigger aTrigger
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -438,8 +340,7 @@
TInt aId
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -452,8 +353,7 @@
TInt aId
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -467,8 +367,7 @@
TBool & aEnable
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -482,8 +381,7 @@
TGpioDetectionTrigger aTrigger
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -497,8 +395,7 @@
TInt aTime
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -513,8 +410,7 @@
TInt & aTime
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -528,8 +424,7 @@
TGpioState & aState
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -547,8 +442,7 @@
TGpioState aState
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -562,8 +456,7 @@
TGpioState & aState
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -577,8 +470,7 @@
TGpioCallback * aCb
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -593,8 +485,7 @@
TGpioCallback * aCb
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}
@@ -610,8 +501,7 @@
TAny * aArg2
)
{
- TUint16 pinId = DevicePinId(aId);
- if (pinId > KHwGpioPinMax)
+ if (aId < 0 || aId > KHwGpioPinMax)
{
return KErrArgument;
}