A Simple program that simplifies development of SPI devices. It alows you to read and write to registers using a PC serial terminal in real time.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
martin
Date:
Mon May 31 18:20:25 2010 +0000
Commit message:

Changed in this revision

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 4568a8086f47 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 31 18:20:25 2010 +0000
@@ -0,0 +1,45 @@
+// Writes hex over SPI from pc input
+
+#include "mbed.h"
+
+SPI spi(p5, p6, p7); // mosi, miso, sclk
+DigitalOut cs(p10);
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main() {
+    spi.format(8,3);
+    spi.frequency(1000000);
+    wait(0.1);
+
+while(1){
+
+
+int n;
+pc.printf("hex: ");
+pc.scanf("%xx", &n);
+pc.printf("%xx", n);
+
+    int o;
+    
+pc.printf("hex2: ");
+pc.scanf("%xx", &o);
+pc.printf("%xx", o);
+
+    // Select the device
+    cs=0;
+    int dataA = spi.write(n);
+    //wait(0.01);
+        int dataB = spi.write(o);
+     cs=1;
+    pc.printf("Data out = 0x%X\n", dataA);
+
+   
+    pc.printf("data out = 0x%X\n", dataB);
+    wait(0.1);
+    
+
+
+}    
+
+}
\ No newline at end of file
diff -r 000000000000 -r 4568a8086f47 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 31 18:20:25 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0