aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/Source/c_input.c
diff options
context:
space:
mode:
authorJohn Hansen2011-01-21 00:44:37 +0100
committerNicolas Schodet2011-01-21 23:15:36 +0100
commit13f8dd7556fd756722cd669c1f5d5b9311a49777 (patch)
treed7b241206e7587a8697613881bf3908ace7b98a7 /AT91SAM7S256/Source/c_input.c
parentd6bd4ec76414e535a297e37aef9de066c20b7e10 (diff)
replace many array indexes with pointer access
Imported from NXT Enhanced Firmware.
Diffstat (limited to 'AT91SAM7S256/Source/c_input.c')
-rw-r--r--AT91SAM7S256/Source/c_input.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/AT91SAM7S256/Source/c_input.c b/AT91SAM7S256/Source/c_input.c
index 47ca7c0..ffd129b 100644
--- a/AT91SAM7S256/Source/c_input.c
+++ b/AT91SAM7S256/Source/c_input.c
@@ -226,8 +226,11 @@ void cInputCtrl(void)
for (Tmp = 0; Tmp < NO_OF_INPUTS; Tmp++)
{
+ UBYTE sType = IOMapInput.Inputs[Tmp].SensorType;
+ UBYTE *pType = &IOMapInput.Inputs[Tmp].SensorType;
+ UBYTE oldType = VarsInput.OldSensorType[Tmp];
- if ((IOMapInput.Inputs[Tmp].SensorType) != (VarsInput.OldSensorType[Tmp]))
+ if (sType != oldType)
{
/* Clear all variables for this sensor */
@@ -239,9 +242,10 @@ void cInputCtrl(void)
memset(&(VarsInput.VarsColor[Tmp]),0 ,sizeof(VarsInput.VarsColor[Tmp]));
/* Setup the pins for the new sensortype */
- cInputSetupType(Tmp, &(IOMapInput.Inputs[Tmp].SensorType), VarsInput.OldSensorType[Tmp]);
+ cInputSetupType(Tmp, pType, oldType);
+ sType = *pType;
IOMapInput.Inputs[Tmp].InvalidData = INVALID_DATA;
- VarsInput.OldSensorType[Tmp] = IOMapInput.Inputs[Tmp].SensorType;
+ VarsInput.OldSensorType[Tmp] = sType;
}
else
{
@@ -250,12 +254,9 @@ void cInputCtrl(void)
/* A type change has been carried out earlier - waiting for valid data */
/* The color sensor requires special startup sequence with communication */
- if (((IOMapInput.Inputs[Tmp].SensorType) == COLORFULL) ||
- ((IOMapInput.Inputs[Tmp].SensorType) == COLORRED) ||
- ((IOMapInput.Inputs[Tmp].SensorType) == COLORGREEN)||
- ((IOMapInput.Inputs[Tmp].SensorType) == COLORBLUE) ||
- ((IOMapInput.Inputs[Tmp].SensorType) == COLOREXIT) ||
- ((IOMapInput.Inputs[Tmp].SensorType) == COLORNONE))
+ if ((sType == COLORFULL) || (sType == COLORRED) ||
+ (sType == COLORGREEN)|| (sType == COLORBLUE) ||
+ (sType == COLOREXIT) || (sType == COLORNONE))
{
cInputCalcSensorValues(Tmp);
}