added extra functions to test irq
Fork of BNO055_fusion by
Revision 6:58a48f7c0faa, committed 2017-02-13
- Comitter:
- mrcrsch
- Date:
- Mon Feb 13 14:25:57 2017 +0000
- Parent:
- 5:6a08a4c5b1e1
- Commit message:
- init;
Changed in this revision
BNO055.cpp | Show annotated file Show diff for this revision Revisions of this file |
BNO055.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6a08a4c5b1e1 -r 58a48f7c0faa BNO055.cpp --- a/BNO055.cpp Mon Jan 16 16:51:39 2017 +0000 +++ b/BNO055.cpp Mon Feb 13 14:25:57 2017 +0000 @@ -426,6 +426,9 @@ change_fusion_mode(current_mode); } + + + /////////////// I2C Freq. ///////////////////////////////// void BNO055::frequency(int hz) { @@ -532,4 +535,44 @@ la->x=Quat[0]*tempQuat[1] -Quat[1]*tempQuat[0] +Quat[2]*tempQuat[3] -Quat[3]*tempQuat[2]; la->y=Quat[0]*tempQuat[2] +Quat[1]*tempQuat[3] -Quat[2]*tempQuat[0] +Quat[3]*tempQuat[1]; la->z=Quat[0]*tempQuat[3] +Quat[1]*tempQuat[2] -Quat[2]*tempQuat[1] -Quat[3]*tempQuat[0]; -} \ No newline at end of file +} + +void BNO055::initIntr() { + uint16_t thresholdG = 500; + uint8_t slopeG = 0; + uint8_t durationG = 1; + + change_fusion_mode(CONFIGMODE); + wait_ms(20); + select_page(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 + select_page(0); + readchar(BNO055_INTR_STAT); + intr = rx; +} + +void BNO055::resetIntr(){ + readchar(BNO055_SYS_TRIGGER); + rx |= 0x40; + writechar(BNO055_SYS_TRIGGER, rx); +} + +void BNO055::setpowermode(char pmode){ + writechar(BNO055_PWR_MODE,pmode); + pwr_mode = pmode; +}
diff -r 6a08a4c5b1e1 -r 58a48f7c0faa BNO055.h --- a/BNO055.h Mon Jan 16 16:51:39 2017 +0000 +++ b/BNO055.h Mon Feb 13 14:25:57 2017 +0000 @@ -285,6 +285,9 @@ void get_quaternion_float(float *Q); void configure_accelerometer_range(uint8_t range); + void initIntr(); + void resetIntr(); + void setpowermode(char pmode); protected: void initialize(void); @@ -303,6 +306,7 @@ uint8_t chip_mode; uint8_t ready_flag; uint8_t page_flag; + uint8_t pwr_mode; uint8_t chip_id; uint8_t acc_id; @@ -311,10 +315,30 @@ uint8_t bootldr_rev_id; uint16_t sw_rev_id; + char intr; + char rx,tx[2]; + + + + +void readchar(char location){ + tx[0] = location; + _i2c.write(chip_addr,tx,1,true); + _i2c.read(chip_addr,&rx,1,false); +} + +void writechar(char location, char value){ + tx[0] = location; + tx[1] = value; + _i2c.write(chip_addr,tx,2); +} }; + + + //--------------------------------------------------------- //----- Register's definition ----------------------------- //---------------------------------------------------------