1 sensor using RTOS Timer, another 2 over RTOS Semaphore

Dependents:   Autonomous_quadcopter

Fork of HCSR04 by Antoniolinux B.

Revision:
5:02948ae78be7
Parent:
3:81512ca9a13c
Child:
6:7f98f258e8ef
--- a/hcsr04.cpp	Sat Jan 20 11:44:21 2018 +0000
+++ b/hcsr04.cpp	Sun Feb 04 15:20:37 2018 +0000
@@ -1,4 +1,5 @@
 #include "hcsr04.h"
+#include "definitions.h"
 #include "mbed.h"
 #include "rtos.h"
 /*
@@ -7,7 +8,8 @@
 HCSR04::HCSR04(PinName t, PinName e) : trig(t), echo(e) {
     //thread = new Thread(threadWorker, this);
     threadUpdateTimer = new RtosTimer(threadWorker, osTimerPeriodic, this);
-    threadUpdateTimer->start(5);
+    int rate = (1.0 / FLIGHT_CONTROLLER_FREQUENCY) * 1000;
+    threadUpdateTimer->start(rate);
 }
 
 void HCSR04::threadWorker(void const *p)