)))

Dependencies:   mbed

Revision:
0:69fc4661515e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 25 12:13:12 2019 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+ 
+SPI spi(D11, D12, D13);
+DigitalOut cs(D9);
+AnalogOut my_output(PA_4);
+int SIZE;
+ 
+int main() {
+    while(1)
+    {
+    // Chip must be deselected
+    cs = 1;
+ 
+    // Setup the spi for 8 bit data, high steady state clock,
+    // second edge capture, with a 1MHz clock rate
+    spi.format(8,0);
+    spi.frequency(1000000);
+ 
+    // Select the device by seting chip select low
+    cs = 0;
+ 
+    // Send 0x8f, the command to read the WHOAMI register
+    spi.write(0x03);
+    spi.write(0x00);
+    spi.write(0x00);
+    spi.write(0x00);
+     
+    // Send a dummy byte to receive the contents of the WHOAMI register
+    SIZE = 600000;
+    for(int i=0; i<SIZE; i++)
+    {
+    uint16_t sample = spi.write(0x01);
+   // my_output.write_u16(sample);
+    //wait_us(125);
+    }
+    // Deselect the device
+    cs = 1;
+    }
+    }
\ No newline at end of file