A fork of AR8000

Dependents:   Sumo_v2 Sumo_v2_Unstable Sumo_v2_RG13

Revision:
10:0c22ced44247
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RadioIn.h	Sat Apr 13 00:55:57 2013 +0000
@@ -0,0 +1,47 @@
+#pragma once
+
+//Interrupt-Callback Function
+#define RadioIn_RISE_FALL(Ch)\
+void Rise##Ch()\
+{\
+    LastRise[Ch]= Time.read_us();\
+}\
+void Fall##Ch()\
+{\
+    int dT= Time.read_us() - LastRise[Ch];\
+    if(dT > 900 && dT < 2100)\
+         dTime[Ch]= dT;\
+}
+
+
+class RadioIn
+{
+private:
+    InterruptIn ChInt0;           //Interrupt-Handler
+    InterruptIn ChInt1;
+    InterruptIn ChInt2;
+  
+    Timer Time;                     //Timer for all 3 Channels
+    volatile int LastRise[3];       //Time of the last rise
+    volatile int dTime[3];          //Pulse in us [1000...2000]
+    
+public:
+    int RawChannels[3]; //Raw Data [1000...2000]
+    
+    //Channels (0.0 - 1.0)
+    float chan1;     
+    float chan2;     
+    float chan3;     
+    
+    //Initialization
+    RadioIn();
+    void Init();
+    
+    //Interrupt-Callbacks
+    RadioIn_RISE_FALL(0);
+    RadioIn_RISE_FALL(1);
+    RadioIn_RISE_FALL(2);
+    
+    //Update Method
+    void Update();
+};
\ No newline at end of file