![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Diff: main.cpp
- Revision:
- 3:c0d70871aa4d
- Parent:
- 2:514af7294ad0
- Child:
- 4:65f91237b687
--- a/main.cpp Mon Jun 20 20:10:37 2016 +0000 +++ b/main.cpp Tue Jun 21 18:13:49 2016 +0000 @@ -34,6 +34,7 @@ BLEDevice ble; DigitalOut led1(LED1); +DigitalOut led4(LED4); UARTService *uartServicePtr; @@ -45,12 +46,14 @@ } void onDataWritten(const GattWriteCallbackParams *params) -{ +{ if ((uartServicePtr != NULL) && (params->handle == uartServicePtr->getTXCharacteristicHandle())) { uint16_t bytesRead = params->len; uint8_t value = *(params->data); DEBUG("received %u bytes\n\r", bytesRead); DEBUG("recevied %d data\n\r", value); + + imu.reset(); // Set power mode, POWER_MODE_NORMAL(default), POWER_MODE_LOWPOWER, or POWER_MODE_SUSPEND(sleep) // By default, I2C will pull high when bus is free(pg90 of datasheet) @@ -86,6 +89,11 @@ led1 = !led1; } +// Interrupt signal +void flip() { + led4 = !led4; +} + int main(void) { led1 = 1; @@ -114,9 +122,29 @@ // setup baud rate and reset sensor pc.baud(115200); - imu.reset(); + led4 = 1; while (true) { ble.waitForEvent(); + + 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); + // Interrupt stats: This is only enabled in Low Power Mode + // 0 - no interrupt + // 64 - interrupt + // 128 - sleep + imu.get_intr(); + pc.printf("intr: %d\r\n", imu.intr); + if(imu.intr != 0) { + pc.printf(" == interrupted == \r\n"); + flip(); + } + + wait(1.0); } }