summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/modules/input/distance_sensor.c
diff options
context:
space:
mode:
authorsicarius <devnull@localhost>2007-02-19 21:57:03 +0100
committersicarius <devnull@localhost>2007-02-19 21:57:03 +0100
commit42a38959ff5c097463c2c95d993e5934f100d223 (patch)
tree7ad00518e3fdd85a800f5c8bf48588e7f5e1a23a /source/Concept/Framework/modules/input/distance_sensor.c
parentb3196682b1d87c40156ed1b4092a7112dd0d80df (diff)
downloadrc2007-soccer-42a38959ff5c097463c2c95d993e5934f100d223.tar
rc2007-soccer-42a38959ff5c097463c2c95d993e5934f100d223.zip
Code-stuff
Diffstat (limited to 'source/Concept/Framework/modules/input/distance_sensor.c')
-rwxr-xr-xsource/Concept/Framework/modules/input/distance_sensor.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/source/Concept/Framework/modules/input/distance_sensor.c b/source/Concept/Framework/modules/input/distance_sensor.c
index 977784f..508eeed 100755
--- a/source/Concept/Framework/modules/input/distance_sensor.c
+++ b/source/Concept/Framework/modules/input/distance_sensor.c
@@ -9,24 +9,24 @@ float Distance_Sensor::GetDistance()
*hardwareDDR |= pin;//Set pin output
*hardwarePort |= pin;//Activate port
usleep(10);//Wait for 10µs
- //*hardwarePort &= ~pin;//Deactivate port
+ *hardwarePort &= ~pin;//Deactivate port
*hardwareDDR &= ~pin;//Set pin input
- (parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print("pre 1", 4, 1);
+ //(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print("pre 1", 4, 1);
//Wait for response
- while(!(PINC & pin)){asm volatile("nop");}
+ for(int i=0;(!(PINC & pin))&&(i < 1000);i++) {asm volatile("nop");}
- (parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print("pre 2", 4, 1);
+ //(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print("pre 2", 4, 1);
//Calculate duration of response
- while(*hardwarePin & pin)
+ while((*hardwarePin & pin)&&(result < 300000))
{
result++;
asm volatile("nop");
}
- (parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print("pre 3", 4, 1);
+ //(parent->GetModule<Display>(IO_DISPLAY_MAIN))->Print("pre 3", 4, 1);
return (float(result) * DISTANCE_PER_VALUE);
}