alonso palomino
/
ST
iot
main.cpp@0:30a995e45e2a, 2017-10-12 (annotated)
- Committer:
- alonsopg
- Date:
- Thu Oct 12 18:06:49 2017 +0000
- Revision:
- 0:30a995e45e2a
- Child:
- 1:3eec9883598a
working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alonsopg | 0:30a995e45e2a | 1 | #include "mbed.h" |
alonsopg | 0:30a995e45e2a | 2 | #include "MPU9250.h" |
alonsopg | 0:30a995e45e2a | 3 | |
alonsopg | 0:30a995e45e2a | 4 | // Serial comms |
alonsopg | 0:30a995e45e2a | 5 | Serial pc(USBTX, USBRX); |
alonsopg | 0:30a995e45e2a | 6 | |
alonsopg | 0:30a995e45e2a | 7 | // Sensor board library |
alonsopg | 0:30a995e45e2a | 8 | MPU9250 mpu = MPU9250(p26, p27); |
alonsopg | 0:30a995e45e2a | 9 | |
alonsopg | 0:30a995e45e2a | 10 | // Configuration |
alonsopg | 0:30a995e45e2a | 11 | bool test_comms = true; |
alonsopg | 0:30a995e45e2a | 12 | bool do_sensor_init = false; |
alonsopg | 0:30a995e45e2a | 13 | bool do_sensor_self_test = true; |
alonsopg | 0:30a995e45e2a | 14 | bool print_accel = true; |
alonsopg | 0:30a995e45e2a | 15 | bool print_gyro = true; |
alonsopg | 0:30a995e45e2a | 16 | |
alonsopg | 0:30a995e45e2a | 17 | int main () { |
alonsopg | 0:30a995e45e2a | 18 | float test_result[6] = {0.0,0.0,0.0,0.0,0.0,0.0}; |
alonsopg | 0:30a995e45e2a | 19 | int16_t accel[3] = {0,0,0}; |
alonsopg | 0:30a995e45e2a | 20 | int16_t gyro[3] = {0,0,0}; |
alonsopg | 0:30a995e45e2a | 21 | int16_t temp = 0; |
alonsopg | 0:30a995e45e2a | 22 | |
alonsopg | 0:30a995e45e2a | 23 | // Test MPU connection |
alonsopg | 0:30a995e45e2a | 24 | if (test_comms) { |
alonsopg | 0:30a995e45e2a | 25 | uint8_t whoami = mpu.readByte(MPU9250_ADDRESS, WHO_AM_I_MPU9250); // Read WHO_AM_I register for MPU-9250 |
alonsopg | 0:30a995e45e2a | 26 | pc.printf("I AM 0x%x\n\r", whoami); |
alonsopg | 0:30a995e45e2a | 27 | pc.printf("I SHOULD BE 0x71\n\r"); |
alonsopg | 0:30a995e45e2a | 28 | wait(1); |
alonsopg | 0:30a995e45e2a | 29 | } |
alonsopg | 0:30a995e45e2a | 30 | |
alonsopg | 0:30a995e45e2a | 31 | while(1) { |
alonsopg | 0:30a995e45e2a | 32 | pc.printf("Hi hi"); |
alonsopg | 0:30a995e45e2a | 33 | } |
alonsopg | 0:30a995e45e2a | 34 | } |