![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my new gear...
BNO055.h@0:1456b6f84c75, 2022-02-25 (annotated)
- Committer:
- yootee
- Date:
- Fri Feb 25 05:20:11 2022 +0000
- Revision:
- 0:1456b6f84c75
my_custom
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yootee | 0:1456b6f84c75 | 1 | #ifndef BNO055_H |
yootee | 0:1456b6f84c75 | 2 | #define BNO055_H |
yootee | 0:1456b6f84c75 | 3 | |
yootee | 0:1456b6f84c75 | 4 | #include "mbed.h" |
yootee | 0:1456b6f84c75 | 5 | // |
yootee | 0:1456b6f84c75 | 6 | #define BNOAddress (0x28 << 1) |
yootee | 0:1456b6f84c75 | 7 | //Register definitions |
yootee | 0:1456b6f84c75 | 8 | /* Page id register definition */ |
yootee | 0:1456b6f84c75 | 9 | #define BNO055_PAGE_ID_ADDR 0x07 |
yootee | 0:1456b6f84c75 | 10 | /* PAGE0 REGISTER DEFINITION START*/ |
yootee | 0:1456b6f84c75 | 11 | #define BNO055_CHIP_ID_ADDR 0x00 |
yootee | 0:1456b6f84c75 | 12 | #define BNO055_ACCEL_REV_ID_ADDR 0x01 |
yootee | 0:1456b6f84c75 | 13 | #define BNO055_MAG_REV_ID_ADDR 0x02 |
yootee | 0:1456b6f84c75 | 14 | #define BNO055_GYRO_REV_ID_ADDR 0x03 |
yootee | 0:1456b6f84c75 | 15 | #define BNO055_SW_REV_ID_LSB_ADDR 0x04 |
yootee | 0:1456b6f84c75 | 16 | #define BNO055_SW_REV_ID_MSB_ADDR 0x05 |
yootee | 0:1456b6f84c75 | 17 | #define BNO055_BL_REV_ID_ADDR 0x06 |
yootee | 0:1456b6f84c75 | 18 | /* Accel data register */ |
yootee | 0:1456b6f84c75 | 19 | #define BNO055_ACCEL_DATA_X_LSB_ADDR 0x08 |
yootee | 0:1456b6f84c75 | 20 | #define BNO055_ACCEL_DATA_X_MSB_ADDR 0x09 |
yootee | 0:1456b6f84c75 | 21 | #define BNO055_ACCEL_DATA_Y_LSB_ADDR 0x0A |
yootee | 0:1456b6f84c75 | 22 | #define BNO055_ACCEL_DATA_Y_MSB_ADDR 0x0B |
yootee | 0:1456b6f84c75 | 23 | #define BNO055_ACCEL_DATA_Z_LSB_ADDR 0x0C |
yootee | 0:1456b6f84c75 | 24 | #define BNO055_ACCEL_DATA_Z_MSB_ADDR 0x0D |
yootee | 0:1456b6f84c75 | 25 | /* Mag data register */ |
yootee | 0:1456b6f84c75 | 26 | #define BNO055_MAG_DATA_X_LSB_ADDR 0x0E |
yootee | 0:1456b6f84c75 | 27 | #define BNO055_MAG_DATA_X_MSB_ADDR 0x0F |
yootee | 0:1456b6f84c75 | 28 | #define BNO055_MAG_DATA_Y_LSB_ADDR 0x10 |
yootee | 0:1456b6f84c75 | 29 | #define BNO055_MAG_DATA_Y_MSB_ADDR 0x11 |
yootee | 0:1456b6f84c75 | 30 | #define BNO055_MAG_DATA_Z_LSB_ADDR 0x12 |
yootee | 0:1456b6f84c75 | 31 | #define BNO055_MAG_DATA_Z_MSB_ADDR 0x13 |
yootee | 0:1456b6f84c75 | 32 | /* Gyro data registers */ |
yootee | 0:1456b6f84c75 | 33 | #define BNO055_GYRO_DATA_X_LSB_ADDR 0x14 |
yootee | 0:1456b6f84c75 | 34 | #define BNO055_GYRO_DATA_X_MSB_ADDR 0x15 |
yootee | 0:1456b6f84c75 | 35 | #define BNO055_GYRO_DATA_Y_LSB_ADDR 0x16 |
yootee | 0:1456b6f84c75 | 36 | #define BNO055_GYRO_DATA_Y_MSB_ADDR 0x17 |
yootee | 0:1456b6f84c75 | 37 | #define BNO055_GYRO_DATA_Z_LSB_ADDR 0x18 |
yootee | 0:1456b6f84c75 | 38 | #define BNO055_GYRO_DATA_Z_MSB_ADDR 0x19 |
yootee | 0:1456b6f84c75 | 39 | /* Euler data registers */ |
yootee | 0:1456b6f84c75 | 40 | #define BNO055_EULER_H_LSB_ADDR 0x1A |
yootee | 0:1456b6f84c75 | 41 | #define BNO055_EULER_H_MSB_ADDR 0x1B |
yootee | 0:1456b6f84c75 | 42 | #define BNO055_EULER_R_LSB_ADDR 0x1C |
yootee | 0:1456b6f84c75 | 43 | #define BNO055_EULER_R_MSB_ADDR 0x1D |
yootee | 0:1456b6f84c75 | 44 | #define BNO055_EULER_P_LSB_ADDR 0x1E |
yootee | 0:1456b6f84c75 | 45 | #define BNO055_EULER_P_MSB_ADDR 0x1F |
yootee | 0:1456b6f84c75 | 46 | /* Quaternion data registers */ |
yootee | 0:1456b6f84c75 | 47 | #define BNO055_QUATERNION_DATA_W_LSB_ADDR 0x20 |
yootee | 0:1456b6f84c75 | 48 | #define BNO055_QUATERNION_DATA_W_MSB_ADDR 0x21 |
yootee | 0:1456b6f84c75 | 49 | #define BNO055_QUATERNION_DATA_X_LSB_ADDR 0x22 |
yootee | 0:1456b6f84c75 | 50 | #define BNO055_QUATERNION_DATA_X_MSB_ADDR 0x23 |
yootee | 0:1456b6f84c75 | 51 | #define BNO055_QUATERNION_DATA_Y_LSB_ADDR 0x24 |
yootee | 0:1456b6f84c75 | 52 | #define BNO055_QUATERNION_DATA_Y_MSB_ADDR 0x25 |
yootee | 0:1456b6f84c75 | 53 | #define BNO055_QUATERNION_DATA_Z_LSB_ADDR 0x26 |
yootee | 0:1456b6f84c75 | 54 | #define BNO055_QUATERNION_DATA_Z_MSB_ADDR 0x27 |
yootee | 0:1456b6f84c75 | 55 | /* Linear acceleration data registers */ |
yootee | 0:1456b6f84c75 | 56 | #define BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR 0x28 |
yootee | 0:1456b6f84c75 | 57 | #define BNO055_LINEAR_ACCEL_DATA_X_MSB_ADDR 0x29 |
yootee | 0:1456b6f84c75 | 58 | #define BNO055_LINEAR_ACCEL_DATA_Y_LSB_ADDR 0x2A |
yootee | 0:1456b6f84c75 | 59 | #define BNO055_LINEAR_ACCEL_DATA_Y_MSB_ADDR 0x2B |
yootee | 0:1456b6f84c75 | 60 | #define BNO055_LINEAR_ACCEL_DATA_Z_LSB_ADDR 0x2C |
yootee | 0:1456b6f84c75 | 61 | #define BNO055_LINEAR_ACCEL_DATA_Z_MSB_ADDR 0x2D |
yootee | 0:1456b6f84c75 | 62 | /* Gravity data registers */ |
yootee | 0:1456b6f84c75 | 63 | #define BNO055_GRAVITY_DATA_X_LSB_ADDR 0x2E |
yootee | 0:1456b6f84c75 | 64 | #define BNO055_GRAVITY_DATA_X_MSB_ADDR 0x2F |
yootee | 0:1456b6f84c75 | 65 | #define BNO055_GRAVITY_DATA_Y_LSB_ADDR 0x30 |
yootee | 0:1456b6f84c75 | 66 | #define BNO055_GRAVITY_DATA_Y_MSB_ADDR 0x31 |
yootee | 0:1456b6f84c75 | 67 | #define BNO055_GRAVITY_DATA_Z_LSB_ADDR 0x32 |
yootee | 0:1456b6f84c75 | 68 | #define BNO055_GRAVITY_DATA_Z_MSB_ADDR 0x33 |
yootee | 0:1456b6f84c75 | 69 | /* Temperature data register */ |
yootee | 0:1456b6f84c75 | 70 | #define BNO055_TEMP_ADDR 0x34 |
yootee | 0:1456b6f84c75 | 71 | /* Status registers */ |
yootee | 0:1456b6f84c75 | 72 | #define BNO055_CALIB_STAT_ADDR 0x35 |
yootee | 0:1456b6f84c75 | 73 | #define BNO055_SELFTEST_RESULT_ADDR 0x36 |
yootee | 0:1456b6f84c75 | 74 | #define BNO055_INTR_STAT_ADDR 0x37 |
yootee | 0:1456b6f84c75 | 75 | #define BNO055_SYS_CLK_STAT_ADDR 0x38 |
yootee | 0:1456b6f84c75 | 76 | #define BNO055_SYS_STAT_ADDR 0x39 |
yootee | 0:1456b6f84c75 | 77 | #define BNO055_SYS_ERR_ADDR 0x3A |
yootee | 0:1456b6f84c75 | 78 | /* Unit selection register */ |
yootee | 0:1456b6f84c75 | 79 | #define BNO055_UNIT_SEL_ADDR 0x3B |
yootee | 0:1456b6f84c75 | 80 | #define BNO055_DATA_SELECT_ADDR 0x3C |
yootee | 0:1456b6f84c75 | 81 | /* Mode registers */ |
yootee | 0:1456b6f84c75 | 82 | #define BNO055_OPR_MODE_ADDR 0x3D |
yootee | 0:1456b6f84c75 | 83 | #define BNO055_PWR_MODE_ADDR 0x3E |
yootee | 0:1456b6f84c75 | 84 | #define BNO055_SYS_TRIGGER_ADDR 0x3F |
yootee | 0:1456b6f84c75 | 85 | #define BNO055_TEMP_SOURCE_ADDR 0x40 |
yootee | 0:1456b6f84c75 | 86 | /* Axis remap registers */ |
yootee | 0:1456b6f84c75 | 87 | #define BNO055_AXIS_MAP_CONFIG_ADDR 0x41 |
yootee | 0:1456b6f84c75 | 88 | #define BNO055_AXIS_MAP_SIGN_ADDR 0x42 |
yootee | 0:1456b6f84c75 | 89 | /* Accelerometer Offset registers */ |
yootee | 0:1456b6f84c75 | 90 | #define ACCEL_OFFSET_X_LSB_ADDR 0x55 |
yootee | 0:1456b6f84c75 | 91 | #define ACCEL_OFFSET_X_MSB_ADDR 0x56 |
yootee | 0:1456b6f84c75 | 92 | #define ACCEL_OFFSET_Y_LSB_ADDR 0x57 |
yootee | 0:1456b6f84c75 | 93 | #define ACCEL_OFFSET_Y_MSB_ADDR 0x58 |
yootee | 0:1456b6f84c75 | 94 | #define ACCEL_OFFSET_Z_LSB_ADDR 0x59 |
yootee | 0:1456b6f84c75 | 95 | #define ACCEL_OFFSET_Z_MSB_ADDR 0x5A |
yootee | 0:1456b6f84c75 | 96 | /* Magnetometer Offset registers */ |
yootee | 0:1456b6f84c75 | 97 | #define MAG_OFFSET_X_LSB_ADDR 0x5B |
yootee | 0:1456b6f84c75 | 98 | #define MAG_OFFSET_X_MSB_ADDR 0x5C |
yootee | 0:1456b6f84c75 | 99 | #define MAG_OFFSET_Y_LSB_ADDR 0x5D |
yootee | 0:1456b6f84c75 | 100 | #define MAG_OFFSET_Y_MSB_ADDR 0x5E |
yootee | 0:1456b6f84c75 | 101 | #define MAG_OFFSET_Z_LSB_ADDR 0x5F |
yootee | 0:1456b6f84c75 | 102 | #define MAG_OFFSET_Z_MSB_ADDR 0x60 |
yootee | 0:1456b6f84c75 | 103 | /* Gyroscope Offset registers*/ |
yootee | 0:1456b6f84c75 | 104 | #define GYRO_OFFSET_X_LSB_ADDR 0x61 |
yootee | 0:1456b6f84c75 | 105 | #define GYRO_OFFSET_X_MSB_ADDR 0x62 |
yootee | 0:1456b6f84c75 | 106 | #define GYRO_OFFSET_Y_LSB_ADDR 0x63 |
yootee | 0:1456b6f84c75 | 107 | #define GYRO_OFFSET_Y_MSB_ADDR 0x64 |
yootee | 0:1456b6f84c75 | 108 | #define GYRO_OFFSET_Z_LSB_ADDR 0x65 |
yootee | 0:1456b6f84c75 | 109 | #define GYRO_OFFSET_Z_MSB_ADDR 0x66 |
yootee | 0:1456b6f84c75 | 110 | /* Radius registers */ |
yootee | 0:1456b6f84c75 | 111 | #define ACCEL_RADIUS_LSB_ADDR 0x67 |
yootee | 0:1456b6f84c75 | 112 | #define ACCEL_RADIUS_MSB_ADDR 0x68 |
yootee | 0:1456b6f84c75 | 113 | #define MAG_RADIUS_LSB_ADDR 0x69 |
yootee | 0:1456b6f84c75 | 114 | #define MAG_RADIUS_MSB_ADDR 0x6A |
yootee | 0:1456b6f84c75 | 115 | |
yootee | 0:1456b6f84c75 | 116 | /* Page 1 registers */ |
yootee | 0:1456b6f84c75 | 117 | #define BNO055_UNIQUE_ID_ADDR 0x50 |
yootee | 0:1456b6f84c75 | 118 | |
yootee | 0:1456b6f84c75 | 119 | //Definitions for unit selection |
yootee | 0:1456b6f84c75 | 120 | #define MPERSPERS 0x00 |
yootee | 0:1456b6f84c75 | 121 | #define MILLIG 0x01 |
yootee | 0:1456b6f84c75 | 122 | #define DEG_PER_SEC 0x00 |
yootee | 0:1456b6f84c75 | 123 | #define RAD_PER_SEC 0x02 |
yootee | 0:1456b6f84c75 | 124 | #define DEGREES 0x00 |
yootee | 0:1456b6f84c75 | 125 | #define RADIANS 0x04 |
yootee | 0:1456b6f84c75 | 126 | #define CENTIGRADE 0x00 |
yootee | 0:1456b6f84c75 | 127 | #define FAHRENHEIT 0x10 |
yootee | 0:1456b6f84c75 | 128 | #define WINDOWS 0x00 |
yootee | 0:1456b6f84c75 | 129 | #define ANDROID 0x80 |
yootee | 0:1456b6f84c75 | 130 | |
yootee | 0:1456b6f84c75 | 131 | //Definitions for power mode |
yootee | 0:1456b6f84c75 | 132 | #define POWER_MODE_NORMAL 0x00 |
yootee | 0:1456b6f84c75 | 133 | #define POWER_MODE_LOWPOWER 0x01 |
yootee | 0:1456b6f84c75 | 134 | #define POWER_MODE_SUSPEND 0x02 |
yootee | 0:1456b6f84c75 | 135 | |
yootee | 0:1456b6f84c75 | 136 | //Definitions for operating mode |
yootee | 0:1456b6f84c75 | 137 | #define OPERATION_MODE_CONFIG 0x00 |
yootee | 0:1456b6f84c75 | 138 | #define OPERATION_MODE_ACCONLY 0x01 |
yootee | 0:1456b6f84c75 | 139 | #define OPERATION_MODE_MAGONLY 0x02 |
yootee | 0:1456b6f84c75 | 140 | #define OPERATION_MODE_GYRONLY 0x03 |
yootee | 0:1456b6f84c75 | 141 | #define OPERATION_MODE_ACCMAG 0x04 |
yootee | 0:1456b6f84c75 | 142 | #define OPERATION_MODE_ACCGYRO 0x05 |
yootee | 0:1456b6f84c75 | 143 | #define OPERATION_MODE_MAGGYRO 0x06 |
yootee | 0:1456b6f84c75 | 144 | #define OPERATION_MODE_AMG 0x07 |
yootee | 0:1456b6f84c75 | 145 | #define OPERATION_MODE_IMUPLUS 0x08 |
yootee | 0:1456b6f84c75 | 146 | #define OPERATION_MODE_COMPASS 0x09 |
yootee | 0:1456b6f84c75 | 147 | #define OPERATION_MODE_M4G 0x0A |
yootee | 0:1456b6f84c75 | 148 | #define OPERATION_MODE_NDOF_FMC_OFF 0x0B |
yootee | 0:1456b6f84c75 | 149 | #define OPERATION_MODE_NDOF 0x0C |
yootee | 0:1456b6f84c75 | 150 | |
yootee | 0:1456b6f84c75 | 151 | typedef struct values{ |
yootee | 0:1456b6f84c75 | 152 | int16_t rawx,rawy,rawz; |
yootee | 0:1456b6f84c75 | 153 | float x,y,z; |
yootee | 0:1456b6f84c75 | 154 | }values; |
yootee | 0:1456b6f84c75 | 155 | |
yootee | 0:1456b6f84c75 | 156 | typedef struct angles{ |
yootee | 0:1456b6f84c75 | 157 | int16_t rawroll,rawpitch,rawyaw; |
yootee | 0:1456b6f84c75 | 158 | float roll, pitch, yaw; |
yootee | 0:1456b6f84c75 | 159 | } angles; |
yootee | 0:1456b6f84c75 | 160 | |
yootee | 0:1456b6f84c75 | 161 | typedef struct quaternion{ |
yootee | 0:1456b6f84c75 | 162 | int16_t raww,rawx,rawy,rawz; |
yootee | 0:1456b6f84c75 | 163 | float w,x,y,z; |
yootee | 0:1456b6f84c75 | 164 | }quaternion; |
yootee | 0:1456b6f84c75 | 165 | |
yootee | 0:1456b6f84c75 | 166 | typedef struct chip{ |
yootee | 0:1456b6f84c75 | 167 | char id; |
yootee | 0:1456b6f84c75 | 168 | char accel; |
yootee | 0:1456b6f84c75 | 169 | char gyro; |
yootee | 0:1456b6f84c75 | 170 | char mag; |
yootee | 0:1456b6f84c75 | 171 | char sw[2]; |
yootee | 0:1456b6f84c75 | 172 | char bootload; |
yootee | 0:1456b6f84c75 | 173 | char serial[16]; |
yootee | 0:1456b6f84c75 | 174 | }chip; |
yootee | 0:1456b6f84c75 | 175 | |
yootee | 0:1456b6f84c75 | 176 | /** Class for operating Bosch BNO055 sensor over I2C **/ |
yootee | 0:1456b6f84c75 | 177 | class BNO055 |
yootee | 0:1456b6f84c75 | 178 | { |
yootee | 0:1456b6f84c75 | 179 | public: |
yootee | 0:1456b6f84c75 | 180 | |
yootee | 0:1456b6f84c75 | 181 | /** Create BNO055 instance **/ |
yootee | 0:1456b6f84c75 | 182 | BNO055(PinName SDA, PinName SCL); |
yootee | 0:1456b6f84c75 | 183 | |
yootee | 0:1456b6f84c75 | 184 | /** Perform a power-on reset of the BNO055 **/ |
yootee | 0:1456b6f84c75 | 185 | void reset(); |
yootee | 0:1456b6f84c75 | 186 | /** Check that the BNO055 is connected and download the software details |
yootee | 0:1456b6f84c75 | 187 | and serial number of chip and store in ID structure **/ |
yootee | 0:1456b6f84c75 | 188 | bool check(); |
yootee | 0:1456b6f84c75 | 189 | /** Turn the external timing crystal on/off **/ |
yootee | 0:1456b6f84c75 | 190 | void SetExternalCrystal(bool yn); |
yootee | 0:1456b6f84c75 | 191 | /** Set the operation mode of the sensor **/ |
yootee | 0:1456b6f84c75 | 192 | void setmode(char mode); |
yootee | 0:1456b6f84c75 | 193 | /** Set the power mode of the sensor **/ |
yootee | 0:1456b6f84c75 | 194 | void setpowermode(char mode); |
yootee | 0:1456b6f84c75 | 195 | |
yootee | 0:1456b6f84c75 | 196 | /** Set the output units from the accelerometer, either MPERSPERS or MILLIG **/ |
yootee | 0:1456b6f84c75 | 197 | void set_accel_units(char units); |
yootee | 0:1456b6f84c75 | 198 | /** Set the output units from the gyroscope, either DEG_PER_SEC or RAD_PER_SEC **/ |
yootee | 0:1456b6f84c75 | 199 | void set_anglerate_units(char units); |
yootee | 0:1456b6f84c75 | 200 | /** Set the output units from the IMU, either DEGREES or RADIANS **/ |
yootee | 0:1456b6f84c75 | 201 | void set_angle_units(char units); |
yootee | 0:1456b6f84c75 | 202 | /** Set the output units from the temperature sensor, either CENTIGRADE or FAHRENHEIT **/ |
yootee | 0:1456b6f84c75 | 203 | void set_temp_units(char units); |
yootee | 0:1456b6f84c75 | 204 | /** Set the data output format to either WINDOWS or ANDROID **/ |
yootee | 0:1456b6f84c75 | 205 | void set_orientation(char units); |
yootee | 0:1456b6f84c75 | 206 | /** Set the mapping of the exes/directions as per page 25 of datasheet |
yootee | 0:1456b6f84c75 | 207 | range 0-7, any value outside this will set the orientation to P1 (default at power up) **/ |
yootee | 0:1456b6f84c75 | 208 | void set_mapping(char orient); |
yootee | 0:1456b6f84c75 | 209 | |
yootee | 0:1456b6f84c75 | 210 | /** Get the current values from the accelerometer **/ |
yootee | 0:1456b6f84c75 | 211 | void get_accel(void); |
yootee | 0:1456b6f84c75 | 212 | /** Get the current values from the gyroscope **/ |
yootee | 0:1456b6f84c75 | 213 | void get_gyro(void); |
yootee | 0:1456b6f84c75 | 214 | /** Get the current values from the magnetometer **/ |
yootee | 0:1456b6f84c75 | 215 | void get_mag(void); |
yootee | 0:1456b6f84c75 | 216 | /** Get the corrected linear acceleration **/ |
yootee | 0:1456b6f84c75 | 217 | void get_lia(void); |
yootee | 0:1456b6f84c75 | 218 | /** Get the current gravity vector **/ |
yootee | 0:1456b6f84c75 | 219 | void get_grv(void); |
yootee | 0:1456b6f84c75 | 220 | /** Get the output quaternion **/ |
yootee | 0:1456b6f84c75 | 221 | void get_quat(void); |
yootee | 0:1456b6f84c75 | 222 | /** Get the current Euler angles **/ |
yootee | 0:1456b6f84c75 | 223 | void get_angles(void); |
yootee | 0:1456b6f84c75 | 224 | /** Get the current temperature **/ |
yootee | 0:1456b6f84c75 | 225 | void get_temp(void); |
yootee | 0:1456b6f84c75 | 226 | |
yootee | 0:1456b6f84c75 | 227 | /** Read the calibration status register and store the result in the calib variable **/ |
yootee | 0:1456b6f84c75 | 228 | void get_calib(void); |
yootee | 0:1456b6f84c75 | 229 | /** Read the offset and radius values into the calibration array**/ |
yootee | 0:1456b6f84c75 | 230 | void read_calibration_data(void); |
yootee | 0:1456b6f84c75 | 231 | /** Write the contents of the calibration array into the registers **/ |
yootee | 0:1456b6f84c75 | 232 | void write_calibration_data(void); |
yootee | 0:1456b6f84c75 | 233 | |
yootee | 0:1456b6f84c75 | 234 | /** Structures containing 3-axis data for acceleration, rate of turn and magnetic field. |
yootee | 0:1456b6f84c75 | 235 | x,y,z are the scale floating point values and |
yootee | 0:1456b6f84c75 | 236 | rawx, rawy, rawz are the int16_t values read from the sensors **/ |
yootee | 0:1456b6f84c75 | 237 | values accel,gyro,mag,lia,gravity; |
yootee | 0:1456b6f84c75 | 238 | /** Stucture containing the Euler angles as yaw, pitch, roll as scaled floating point |
yootee | 0:1456b6f84c75 | 239 | and rawyaw, rawroll & rollpitch as the int16_t values loaded from the registers **/ |
yootee | 0:1456b6f84c75 | 240 | angles euler; |
yootee | 0:1456b6f84c75 | 241 | /** Quaternion values as w,x,y,z (scaled floating point) and raww etc... as int16_t loaded from the |
yootee | 0:1456b6f84c75 | 242 | registers **/ |
yootee | 0:1456b6f84c75 | 243 | quaternion quat; |
yootee | 0:1456b6f84c75 | 244 | |
yootee | 0:1456b6f84c75 | 245 | /** Current contents of calibration status register **/ |
yootee | 0:1456b6f84c75 | 246 | char calib; |
yootee | 0:1456b6f84c75 | 247 | /** Contents of the 22 registers containing offset and radius values used as calibration by the sensor **/ |
yootee | 0:1456b6f84c75 | 248 | char calibration[22]; |
yootee | 0:1456b6f84c75 | 249 | /** Structure containing sensor numbers, software version and chip UID **/ |
yootee | 0:1456b6f84c75 | 250 | chip ID; |
yootee | 0:1456b6f84c75 | 251 | /** Current temperature **/ |
yootee | 0:1456b6f84c75 | 252 | int temperature; |
yootee | 0:1456b6f84c75 | 253 | |
yootee | 0:1456b6f84c75 | 254 | private: |
yootee | 0:1456b6f84c75 | 255 | |
yootee | 0:1456b6f84c75 | 256 | I2C _i2c; |
yootee | 0:1456b6f84c75 | 257 | char rx,tx[2],address; //I2C variables |
yootee | 0:1456b6f84c75 | 258 | char rawdata[22]; //Temporary array for input data values |
yootee | 0:1456b6f84c75 | 259 | char op_mode; |
yootee | 0:1456b6f84c75 | 260 | char pwr_mode; |
yootee | 0:1456b6f84c75 | 261 | float accel_scale,rate_scale,angle_scale; |
yootee | 0:1456b6f84c75 | 262 | int temp_scale; |
yootee | 0:1456b6f84c75 | 263 | |
yootee | 0:1456b6f84c75 | 264 | void readchar(char location){ |
yootee | 0:1456b6f84c75 | 265 | tx[0] = location; |
yootee | 0:1456b6f84c75 | 266 | _i2c.write(address,tx,1,true); |
yootee | 0:1456b6f84c75 | 267 | _i2c.read(address,&rx,1,false); |
yootee | 0:1456b6f84c75 | 268 | } |
yootee | 0:1456b6f84c75 | 269 | |
yootee | 0:1456b6f84c75 | 270 | void writechar(char location, char value){ |
yootee | 0:1456b6f84c75 | 271 | tx[0] = location; |
yootee | 0:1456b6f84c75 | 272 | tx[1] = value; |
yootee | 0:1456b6f84c75 | 273 | _i2c.write(address,tx,2); |
yootee | 0:1456b6f84c75 | 274 | } |
yootee | 0:1456b6f84c75 | 275 | |
yootee | 0:1456b6f84c75 | 276 | void setpage(char value){ |
yootee | 0:1456b6f84c75 | 277 | writechar(BNO055_PAGE_ID_ADDR,value); |
yootee | 0:1456b6f84c75 | 278 | } |
yootee | 0:1456b6f84c75 | 279 | }; |
yootee | 0:1456b6f84c75 | 280 | #endif |