BNO055 Library with interrupt
Dependents: BLE_LoopbackUART_with_BNO055
Fork of BNO055 by
Diff: BNO055.cpp
- Revision:
- 8:303717d8776c
- Parent:
- 7:cd181d3f2858
- Child:
- 9:f43b1aa99e08
--- a/BNO055.cpp Tue Jun 21 18:12:29 2016 +0000 +++ b/BNO055.cpp Thu Jun 23 22:28:41 2016 +0000 @@ -279,7 +279,37 @@ } } -void BNO055::get_intr(void){ +void BNO055::resetIntr(){ + readchar(BNO055_SYS_TRIGGER_ADDR); + rx |= 0x40; + writechar(BNO055_SYS_TRIGGER_ADDR, rx); +} + +void BNO055::initIntr() { + uint16_t thresholdG = 500; + uint8_t slopeG = 0; + uint8_t durationG = 1; + + setmode(OPERATION_MODE_CONFIG); + wait_ms(20); + setpage(1); + // 1a. Set gyroscope interrupt on X, Y, and Z (any motion) + writechar(0x17, 0x47); + // 1b. Set gyroscope interrupt threshold + writechar(0x1E, ((0 & ~(0x7F)) | ((thresholdG << 0) & 0x7F))); + // 1c. Set gyroscope interrupt slope samples + writechar(0x1F, ((0 & ~(0x03)) | ((slopeG << 0) & 0x03))); + // 1d. Set gyroscope interrupt awake duration + writechar(0x1F, ((0 & ~(0x0C)) | ((durationG << 2) & 0x0C))); + + // 2. Set gyroscope interrupt mask + writechar(0x0F, ((0 & ~(0x04)) | ((0x01 << 2) & 0x04))); + + // 3. Set gyroscope interrupt + writechar(0x10, ((0 & ~(0x04)) | ((0x01 << 2) & 0x04))); + + // 4. Read gyroscope interrupt status + setpage(0); readchar(BNO055_INTR_STAT_ADDR); intr = rx; } \ No newline at end of file