Code for one-to-one connectivity testing

Dependencies:   USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
fil
Date:
Mon Nov 03 16:56:02 2014 +0000
Commit message:
one to one connectivity test.

Changed in this revision

USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 60658097abea USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Mon Nov 03 16:56:02 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
diff -r 000000000000 -r 60658097abea main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 03 16:56:02 2014 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#include "USBKeyboard.h"
+
+SPI spi(PTD2, PTD3, PTD1); // mosi, miso, sclk
+DigitalOut csADC(PTD0); // chip select for the ADC
+DigitalOut csDAC(PTD5); // chip select for the DAC
+AnalogOut test_out(PTE30); // analog out
+AnalogIn test_in(PTB0); // analog in
+USBKeyboard keyboard;
+
+PwmOut rled(LED_RED);
+//PwmOut gled(LED_GREEN);
+//PwmOut bled(LED_BLUE);
+
+int main() {
+
+    rled = 1.0;
+    //spi.format(8,0);
+    //spi.frequency(1000000);
+
+    csADC = 1;
+    csDAC = 1;
+    test_sig = 0.1;
+    wait(0.1);
+    csDAC = 0;
+    int intermediary = spi.write(0xFF);
+    wait(0.01);
+    csDAC = 1;
+    csADC = 0;
+    int out = spi.write(0x00);
+    csADC = 1;
+    test_out.write(0.01);
+    
+    while(1) {
+        //test_out.write(0.01);
+        //keyboard.printf("%f ",test_in.read());
+        //keyboard.printf("%f \n",test_out.read());
+        float th_low = test_out.read()*0.8;
+        float th_high = test_out.read()*1.2;
+        if ((test_in.read() > th_low) && (test_in.read() < th_high))
+                rled = 0.0;
+        else
+            rled = 1.0;
+        //keyboard.printf("%f ", th_low); keyboard.printf("%f ", test_in.read()); keyboard.printf("%f \n", th_high);
+        wait(0.5);
+    }    
+}
\ No newline at end of file
diff -r 000000000000 -r 60658097abea mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 03 16:56:02 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file