Simple test for MPU connectivity

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
smigielski
Date:
Thu Jan 29 21:44:33 2015 +0000
Commit message:
initial version of mputest

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 7c2bb0b8ea73 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 29 21:44:33 2015 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+
+SPI spi(P0_28, P0_24, P0_29); // mosi, miso, sclk
+DigitalOut cs(P0_18);
+
+#define MPU9250_WHOAMI 0x75
+#define MPU9250_READ_FLAG 0x80
+
+//Test that spi is working with mpu9250
+int main() {
+    cs=1;
+    while(1) {
+        cs = 0;        
+        spi.write(MPU9250_WHOAMI| MPU9250_READ_FLAG);
+        uint8_t val = spi.write(0x00);
+        //Device id is 0x71
+        cs = 1;        
+        wait(1.0);   
+    }
+}
diff -r 000000000000 -r 7c2bb0b8ea73 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 29 21:44:33 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file