bno055

Dependents:   LPC1768-GPS-FUSION-17102018-1

Fork of BNO055 by Dave Turner

Revision:
4:fe45288757f6
Parent:
3:1db1628eb8b2
--- a/BNO055.cpp	Sun May 31 07:22:40 2015 +0000
+++ b/BNO055.cpp	Wed Oct 17 11:35:39 2018 +0000
@@ -10,21 +10,22 @@
     angle_scale = 1.0f/16.0f;
     temp_scale = 1;
     }
+ 
     
 void BNO055::reset(){
-//Perform a power-on-reset
+    //Perform a power-on-reset
     readchar(BNO055_SYS_TRIGGER_ADDR);
     rx = rx | 0x20;
     writechar(BNO055_SYS_TRIGGER_ADDR,rx);
-//Wait for the system to come back up again (datasheet says 650ms)
+    //Wait for the system to come back up again (datasheet says 650ms)
     wait_ms(675);
-}
+    }
     
 bool BNO055::check(){
-//Check we have communication link with the chip
+    //Check we have communication link with the chip
     readchar(BNO055_CHIP_ID_ADDR);
     if (rx != 0xA0) return false;
-//Grab the chip ID and software versions
+    //Grab the chip ID and software versions
     tx[0] = BNO055_CHIP_ID_ADDR;
     _i2c.write(address,tx,1,true);  
     _i2c.read(address+1,rawdata,7,false); 
@@ -43,13 +44,15 @@
     return true;
     }
     
+    
 void BNO055::SetExternalCrystal(bool yn){
-// Read the current status from the device
+    // Read the current status from the device
     readchar(BNO055_SYS_TRIGGER_ADDR); 
     if (yn) rx = rx | 0x80;
     else rx = rx & 0x7F;
     writechar(BNO055_SYS_TRIGGER_ADDR,rx); 
-}
+    }
+
 
 void BNO055::set_accel_units(char units){
     readchar(BNO055_UNIT_SEL_ADDR);
@@ -62,7 +65,8 @@
         accel_scale = 1.0f;
         }
     writechar(BNO055_UNIT_SEL_ADDR,rx);
-}
+    }
+
 
 void BNO055::set_anglerate_units(char units){
     readchar(BNO055_UNIT_SEL_ADDR);
@@ -75,7 +79,8 @@
         rate_scale = 1.0f/900.0f;
         }
     writechar(BNO055_UNIT_SEL_ADDR,rx);
-}    
+    }    
+
 
 void BNO055::set_angle_units(char units){
     readchar(BNO055_UNIT_SEL_ADDR);
@@ -88,7 +93,9 @@
         rate_scale = 1.0f/900.0f;
         }
     writechar(BNO055_UNIT_SEL_ADDR,rx);
-}    
+    }    
+    
+    
 
 void BNO055::set_temp_units(char units){
     readchar(BNO055_UNIT_SEL_ADDR);
@@ -101,7 +108,9 @@
         temp_scale = 2;
         }
     writechar(BNO055_UNIT_SEL_ADDR,rx);
-}    
+    }   
+    
+     
 
 void BNO055::set_orientation(char units){
     readchar(BNO055_UNIT_SEL_ADDR);
@@ -113,12 +122,14 @@
 void BNO055::setmode(char omode){
     writechar(BNO055_OPR_MODE_ADDR,omode);
     op_mode = omode;
-}
+    }
+
 
 void BNO055::setpowermode(char pmode){
     writechar(BNO055_PWR_MODE_ADDR,pmode);
     pwr_mode = pmode;
-}
+    }
+
 
 void BNO055::get_accel(void){
     tx[0] = BNO055_ACCEL_DATA_X_LSB_ADDR;
@@ -130,7 +141,8 @@
     accel.x = float(accel.rawx)*accel_scale;
     accel.y = float(accel.rawy)*accel_scale;
     accel.z = float(accel.rawz)*accel_scale;
-}
+    }
+    
     
 void BNO055::get_gyro(void){
     tx[0] = BNO055_GYRO_DATA_X_LSB_ADDR;
@@ -142,7 +154,8 @@
     gyro.x = float(gyro.rawx)*rate_scale;
     gyro.y = float(gyro.rawy)*rate_scale;
     gyro.z = float(gyro.rawz)*rate_scale;
-}
+    }
+    
 
 void BNO055::get_mag(void){
     tx[0] = BNO055_MAG_DATA_X_LSB_ADDR;
@@ -154,7 +167,8 @@
     mag.x = float(mag.rawx);
     mag.y = float(mag.rawy);
     mag.z = float(mag.rawz);
-}
+    }
+    
 
 void BNO055::get_lia(void){
     tx[0] = BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR;
@@ -166,7 +180,8 @@
     lia.x = float(lia.rawx)*accel_scale;
     lia.y = float(lia.rawy)*accel_scale;
     lia.z = float(lia.rawz)*accel_scale;
-}
+    }
+
 
 void BNO055::get_grv(void){
     tx[0] = BNO055_GRAVITY_DATA_X_LSB_ADDR;
@@ -178,7 +193,8 @@
     gravity.x = float(gravity.rawx)*accel_scale;
     gravity.y = float(gravity.rawy)*accel_scale;
     gravity.z = float(gravity.rawz)*accel_scale;
-}
+    }
+    
 
 void BNO055::get_quat(void){
     tx[0] = BNO055_QUATERNION_DATA_W_LSB_ADDR;
@@ -192,7 +208,8 @@
     quat.x = float(quat.rawx)/16384.0f;
     quat.y = float(quat.rawy)/16384.0f;
     quat.z = float(quat.rawz)/16384.0f;
-}
+    }
+    
 
 void BNO055::get_angles(void){
     tx[0] = BNO055_EULER_H_LSB_ADDR;
@@ -204,18 +221,20 @@
     euler.yaw = float(euler.rawyaw)*angle_scale;
     euler.roll = float(euler.rawroll)*angle_scale;
     euler.pitch = float(euler.rawpitch)*angle_scale;
-}
+    }
 
 
 void BNO055::get_temp(void){
     readchar(BNO055_TEMP_ADDR);
     temperature = rx / temp_scale;
-}
+    }
+
 
 void BNO055::get_calib(void){
      readchar(BNO055_CALIB_STAT_ADDR);
      calib = rx;
-}
+    }
+
 
 void BNO055::read_calibration_data(void){
     char tempmode = op_mode;
@@ -226,7 +245,8 @@
     _i2c.read(address,calibration,22,false); 
     setmode(tempmode);
     wait_ms(10);
-}
+    }
+    
 
 void BNO055::write_calibration_data(void){
     char tempmode = op_mode;
@@ -237,7 +257,8 @@
     _i2c.write(address,calibration,22,false); 
     setmode(tempmode);
     wait_ms(10);
-}
+    }
+
 
 void BNO055::set_mapping(char orient){
     switch (orient){
@@ -277,4 +298,4 @@
             writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x24);
             writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x00);
         }
-}
\ No newline at end of file
+    }
\ No newline at end of file