summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/modules/input/distance_sensor.c
diff options
context:
space:
mode:
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);
}