STM issues

Dependencies:   MPU6050 mbed

Fork of mpu6050_test by Simon Garfieldsg

Committer:
chris1seto
Date:
Tue Jul 01 23:29:27 2014 +0000
Revision:
1:09d785823d44
Parent:
0:84dda456d02c
STM issues

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garfieldsg 0:84dda456d02c 1 #include "mbed.h"
garfieldsg 0:84dda456d02c 2 #include "MPU6050.h"
chris1seto 1:09d785823d44 3 #include "shared.h"
garfieldsg 0:84dda456d02c 4
garfieldsg 0:84dda456d02c 5 DigitalOut myled(LED1);
garfieldsg 0:84dda456d02c 6 MPU6050 mpu;
garfieldsg 0:84dda456d02c 7
garfieldsg 0:84dda456d02c 8 int16_t ax, ay, az;
garfieldsg 0:84dda456d02c 9 int16_t gx, gy, gz;
garfieldsg 0:84dda456d02c 10
garfieldsg 0:84dda456d02c 11 int main()
garfieldsg 0:84dda456d02c 12 {
chris1seto 1:09d785823d44 13 pc.baud(115200);
chris1seto 1:09d785823d44 14 pc.printf("MPU6050 test\r\n");
chris1seto 1:09d785823d44 15 pc.printf("MPU6050 initialize \r\n");
garfieldsg 0:84dda456d02c 16
garfieldsg 0:84dda456d02c 17 mpu.initialize();
chris1seto 1:09d785823d44 18 pc.printf("MPU6050 testConnection \r\n");
garfieldsg 0:84dda456d02c 19
garfieldsg 0:84dda456d02c 20 bool mpu6050TestResult = mpu.testConnection();
garfieldsg 0:84dda456d02c 21 if(mpu6050TestResult) {
chris1seto 1:09d785823d44 22 pc.printf("MPU6050 test passed \r\n");
garfieldsg 0:84dda456d02c 23 } else {
chris1seto 1:09d785823d44 24 pc.printf("MPU6050 test failed \r\n");
garfieldsg 0:84dda456d02c 25 }
garfieldsg 0:84dda456d02c 26
garfieldsg 0:84dda456d02c 27 while(1) {
garfieldsg 0:84dda456d02c 28 wait(1);
garfieldsg 0:84dda456d02c 29 mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
garfieldsg 0:84dda456d02c 30 //writing current accelerometer and gyro position
chris1seto 1:09d785823d44 31 pc.printf("%d;%d;%d;%d;%d;%d\r\n",ax,ay,az,gx,gy,gz);
garfieldsg 0:84dda456d02c 32 }
garfieldsg 0:84dda456d02c 33 }