Access different power mode of BNO055 via nRF51-DK BLE

Dependencies:   BLE_API BNO055 mbed nRF51822 nrf51_rtc

Fork of BLE_LoopbackUART_with_LSM6DS3 by Sherry Yang

Files at this revision

API Documentation at this revision

Comitter:
5hel2l2y
Date:
Mon Jul 11 21:29:17 2016 +0000
Parent:
4:65f91237b687
Commit message:
Modified reading rate.

Changed in this revision

BNO055.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
nrf51_rtc.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 65f91237b687 -r cd414aaa44f6 BNO055.lib
--- a/BNO055.lib	Thu Jun 23 22:29:04 2016 +0000
+++ b/BNO055.lib	Mon Jul 11 21:29:17 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/5hel2l2y/code/BNO055/#303717d8776c
+https://developer.mbed.org/users/5hel2l2y/code/BNO055/#f43b1aa99e08
diff -r 65f91237b687 -r cd414aaa44f6 main.cpp
--- a/main.cpp	Thu Jun 23 22:29:04 2016 +0000
+++ b/main.cpp	Mon Jul 11 21:29:17 2016 +0000
@@ -20,6 +20,8 @@
 #include "ble/services/UARTService.h"
 #include "BNO055/BNO055.h"
 
+#include "nrf51_rtc.h"
+
 BNO055 imu(p30, p7);
 Serial pc(p9, p11);
 
@@ -66,11 +68,16 @@
                 imu.setpowermode(POWER_MODE_SUSPEND);
                 break;
             case 50:
-                DEBUG("Low power\n\r");
+                DEBUG("Accelerometer Low, Gyro Off, Magnetometer Off\r");
                 imu.setpowermode(POWER_MODE_LOWPOWER);
                 break;
             case 51:
-                DEBUG("No high power available for this sensor\n\r");
+                DEBUG("Accelerometer High, Gyro Off\n\r");
+//                imu.setpowermode(POWER_MODE_NORMAL);
+                imu.setpowermode3();
+                break;
+            case 52:
+                DEBUG("Accelerometer High, Gyro High\n\r");
                 imu.setpowermode(POWER_MODE_NORMAL);
                 break;
             default:
@@ -92,6 +99,7 @@
 
 void periodicCallback(void)
 {
+    ble.waitForEvent();
     ledAlive = !ledAlive;
 }
 
@@ -108,6 +116,8 @@
 
 int main(void)
 {
+    time_t rawtime = 0;
+    
     // turn all LED off
     ledAlive = 1;
     ledIntrG = 1;
@@ -145,15 +155,14 @@
     intrGX.rise(&flip4);
 
     while (true) {
-        ble.waitForEvent();
+        rawtime = rtc.time();
         
         imu.setmode(OPERATION_MODE_AMG);
+        
         imu.get_accel();
-        pc.printf("%2f,%2f,%2f\r\n", imu.accel.x, imu.accel.y, imu.accel.z);
         imu.get_gyro();
-        pc.printf("%2f,%2f,%2f\r\n", imu.gyro.x, imu.gyro.y, imu.gyro.z);
         imu.get_mag();
-        pc.printf("%2f,%2f,%2f\r\n", imu.mag.x, imu.mag.y, imu.mag.z);
+        pc.printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\r\n", rawtime,imu.accel.rawx,imu.accel.rawy,imu.accel.rawz,imu.gyro.rawx, imu.gyro.rawy, imu.gyro.rawz,imu.mag.rawx, imu.mag.rawy, imu.mag.rawz);
         
         // Interrupt stats: This is only enabled in Low Power Mode
         // 0 - no interrupt
@@ -167,7 +176,5 @@
 //            pc.printf("rx before: %d\r\n", imu.test3);
 //            pc.printf("rx after: %d\r\n", imu.test4);
 //        }
-        
-        wait(1.0);
     }
 }
diff -r 65f91237b687 -r cd414aaa44f6 nrf51_rtc.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nrf51_rtc.lib	Mon Jul 11 21:29:17 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/fxschumacher/code/nrf51_rtc/#3677a016109b