1 sensor using RTOS Timer, another 2 over RTOS Semaphore

Dependents:   Autonomous_quadcopter

Fork of HCSR04 by Antoniolinux B.

Revision:
12:6f6469b2f016
Parent:
11:49a0feca5d71
Child:
13:e9b99635aa2d
--- a/hcsr04.cpp	Sun Mar 04 15:17:12 2018 +0000
+++ b/hcsr04.cpp	Tue May 15 10:32:08 2018 +0000
@@ -5,7 +5,7 @@
 /*
 *HCSR04.cpp
 */
-HCSR04::HCSR04(PinName t1, PinName e1, PinName t2, PinName e2) : trig1(t1), echo1(e1), trig2(t2), echo2(e2) {
+HCSR04::HCSR04(PinName t1, PinName e1) : trig1(t1), echo1(e1){
     
     int rate = (1.0 / FLIGHT_CONTROLLER_FREQUENCY) * 1000; //ms
     
@@ -53,46 +53,9 @@
         //printf("end\n\r");
 }
 
-void HCSR04::threadWorker2(void const *p)
-{
-    HCSR04* self = (HCSR04*)p;
-    
-        self->trig2=1;   //  trigger high
-        wait_us(10);
-        self->trig2=0;  // trigger low
-        // start pulseIN
-        self->timer2.reset();
-        self->timer2.start();
-        while(!self->echo2){
-            if(self->timer2.read_us() > self->limit){
-                //printf("moc1\n\r");
-                // if no response from distance sensor -> let the quadcopter fall
-                //self->distan2 = 500;
-                break;
-            }    
-        }
-        if(self->timer2.read_us() < self->limit){
-            self->timer2.stop();
-            self->timer2.reset();  //reset timer
-            self->timer2.start();
-            while(self->echo2){
-                if(self->timer2.read_us() > self->limit){
-                    //printf("moc2\n\r");
-                    // if no response from distance sensor -> let the quadcopter fall
-                    //self->distan2 = 500;
-                    break;
-                }
-            }
-            self->timer2.stop();
-            self->distan2 = self->timer2.read_us() / 58;
-        }
-}
 
 float HCSR04::getDistan1(){
     return distan1;    
 }
 
-uint16_t HCSR04::getDistan2(){
-    return distan2;    
-}