SonicMEMS@Cornell / Mbed 2 deprecated SPI_MCP3201

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
pc445
Date:
Mon Nov 10 17:20:14 2014 +0000
Commit message:
MCP3201_exampleCode

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 10 17:20:14 2014 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+SPI spi(p5, p6, p7); // mosi, miso, sclk
+DigitalOut cs(p8);
+ 
+int main() {
+    // Chip must be deselected
+    
+    cs = 1;
+    spi.format(16,0);
+    spi.frequency(1000000);
+
+    // Setup the spi for 8 bit data, high steady state clock,
+    // second edge capture, with a 1MHz clock rate
+    while(1){
+    // Select the device by seting chip select low
+    cs = 0;
+ 
+    // Send 0x8f, the command to read the WHOAMI register
+    //spi.write(0x8F);
+ 
+    // Send a dummy byte to receive the contents of the WHOAMI register
+    unsigned int whoami = spi.write(0x00);
+    whoami = (whoami>>1)&0x0FFF;
+    printf("WHOAMI register = %d\n\r", whoami);
+ 
+    // Deselect the device
+    cs = 1;
+    //wait(0.001);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 10 17:20:14 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file