Code-stuff

This commit is contained in:
sicarius 2007-02-19 20:57:03 +00:00
parent b3196682b1
commit 42a38959ff
12 changed files with 474 additions and 55 deletions

View file

@ -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);
}

View file

@ -42,9 +42,9 @@ public:
this->pinSCK = (1 << 6);
this->registerConfig = 0x00;
this->registerPixelData = 0x08;
this->registerSqual = 0x4;
this->registerDeltaX = 0x3;
this->registerDeltaY = 0x2;
this->registerSqual = 0x04;
this->registerDeltaX = 0x03;
this->registerDeltaY = 0x02;
this->configReset = 0x80;
this->configAwake = 0x01;
break;
@ -52,13 +52,13 @@ public:
this->hardwarePort = &PORTC;
this->hardwareDDR = &DDRC;
this->hardwarePin = &PINC;
this->pinSDA = (1 << 5);
this->pinSCK = (1 << 7);
this->pinSDA = (1 << 7);
this->pinSCK = (1 << 5);
this->registerConfig = 0x00;
this->registerPixelData = 0x08;
this->registerSqual = 0x4;
this->registerDeltaX = 0x3;
this->registerDeltaY = 0x2;
this->registerSqual = 0x04;
this->registerDeltaX = 0x03;
this->registerDeltaY = 0x02;
this->configReset = 0x80;
this->configAwake = 0x01;
break;