YMFC-AL implementation in mbed.

Dependencies:   mbed

Revision:
1:411d267f9d32
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPM.cpp	Fri Oct 04 17:04:41 2019 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "PPM.h"
+ 
+PPM::PPM(PinName pin): ppm(pin)
+{
+    for (int i = 0; i < NUM_CHANNELS; i++)
+        channels[i] = 1500;
+    currentChannel = 0;    
+    timer.start();
+    ppm.rise( callback(this, &PPM::rise) );
+}
+            
+void PPM::rise()
+{
+    uint16_t time = timer.read_us();
+    timer.reset();
+    
+    if ( time > 2500 )
+    {
+       currentChannel = 0;
+    }
+    else if ( currentChannel < NUM_CHANNELS )
+    {
+        channels[currentChannel] = time;
+        currentChannel++;
+    }
+}
\ No newline at end of file