Simple test for MPU connectivity
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:7c2bb0b8ea73
--- /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); + } +}