Liangzhen Lai / Mbed 2 deprecated Orange_Ferrari_board_functional

Dependencies:   DDRO_Farrari mbed

Fork of DDRO_Farrari by Liangzhen Lai

Revision:
0:84a8bcfbdec9
diff -r 000000000000 -r 84a8bcfbdec9 clock.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/clock.cpp	Mon Oct 07 22:58:19 2013 +0000
@@ -0,0 +1,26 @@
+#include "clock.h"
+
+float ext_freq(DigitalIn* clk_pin)
+{
+    bool last = false;
+    unsigned int count = 0;
+    
+    Timer t;
+    t.start();
+    for(int i=0; i<100000; i++){
+        bool clkval = *clk_pin;
+        if(clkval && !last){
+            count++;
+        }
+        last = clkval;
+    }
+    float time = t.read();
+    t.stop();
+    if(count < 1000){
+        dual_printf("Clk read inaccurate");
+        pc.printf("Clk count %d\r\n", count);
+    }
+    //pc.printf("T: %f\r\nC: %i\r\n", time, count);
+    
+    return count / time;
+}
\ No newline at end of file