Combine AS7000 into BNO055

Fork of BNO055 by Sog Yang

Committer:
tsungta
Date:
Mon May 22 08:03:56 2017 +0000
Revision:
10:1914e07be563
Parent:
9:f04b0a4c8057
Combine AS7000 into BNO055 to reduce the usage of I2C LLD

Who changed what in which revision?

UserRevisionLine numberNew contents of line
StressedDave 0:24f23c36dd24 1 #include "BNO055.h"
StressedDave 0:24f23c36dd24 2 #include "mbed.h"
StressedDave 0:24f23c36dd24 3
tsungta 10:1914e07be563 4 DigitalOut AS7000_GPIO8(p5); //NNN50-P5 map to GPIO-8 for AS7000 on/off
tsungta 10:1914e07be563 5 DigitalInOut AS7000_INT(p4); //NNN50-P4 GPIO-5 for AS7000 INT
tsungta 10:1914e07be563 6
StressedDave 0:24f23c36dd24 7 BNO055::BNO055(PinName SDA, PinName SCL) : _i2c(SDA,SCL){
StressedDave 0:24f23c36dd24 8 //Set I2C fast and bring reset line high
sog_yang 9:f04b0a4c8057 9 _i2c.frequency(400000);
StressedDave 0:24f23c36dd24 10 address = BNOAddress;
StressedDave 6:1f722ffec323 11 accel_scale = 0.001f;
StressedDave 0:24f23c36dd24 12 rate_scale = 1.0f/16.0f;
StressedDave 0:24f23c36dd24 13 angle_scale = 1.0f/16.0f;
StressedDave 1:2c3322a8d417 14 temp_scale = 1;
tsungta 10:1914e07be563 15
tsungta 10:1914e07be563 16 //Set I2C fast and bring reset line high
tsungta 10:1914e07be563 17 //_i2c.frequency(400000);
tsungta 10:1914e07be563 18 //address = AS7000Address;
tsungta 10:1914e07be563 19
tsungta 10:1914e07be563 20 AS7000_INT.mode(PullNone);
tsungta 10:1914e07be563 21
tsungta 10:1914e07be563 22 AS7000_INT.output();
tsungta 10:1914e07be563 23
tsungta 10:1914e07be563 24 AS7000_GPIO8.write(1); // Power OFF AS7000
tsungta 10:1914e07be563 25 AS7000_INT.write(1); // AS7000 GPIO OUTPUT LOW
tsungta 10:1914e07be563 26 AS7000_INT.input();
tsungta 10:1914e07be563 27 wait_ms(100);
StressedDave 0:24f23c36dd24 28 }
StressedDave 0:24f23c36dd24 29
StressedDave 0:24f23c36dd24 30 void BNO055::reset(){
StressedDave 0:24f23c36dd24 31 //Perform a power-on-reset
StressedDave 0:24f23c36dd24 32 readchar(BNO055_SYS_TRIGGER_ADDR);
StressedDave 0:24f23c36dd24 33 rx = rx | 0x20;
StressedDave 0:24f23c36dd24 34 writechar(BNO055_SYS_TRIGGER_ADDR,rx);
StressedDave 0:24f23c36dd24 35 //Wait for the system to come back up again (datasheet says 650ms)
StressedDave 0:24f23c36dd24 36 wait_ms(675);
StressedDave 0:24f23c36dd24 37 }
StressedDave 0:24f23c36dd24 38
StressedDave 0:24f23c36dd24 39 bool BNO055::check(){
StressedDave 0:24f23c36dd24 40 //Check we have communication link with the chip
StressedDave 0:24f23c36dd24 41 readchar(BNO055_CHIP_ID_ADDR);
StressedDave 0:24f23c36dd24 42 if (rx != 0xA0) return false;
StressedDave 0:24f23c36dd24 43 //Grab the chip ID and software versions
StressedDave 0:24f23c36dd24 44 tx[0] = BNO055_CHIP_ID_ADDR;
StressedDave 0:24f23c36dd24 45 _i2c.write(address,tx,1,true);
StressedDave 0:24f23c36dd24 46 _i2c.read(address+1,rawdata,7,false);
StressedDave 0:24f23c36dd24 47 ID.id = rawdata[0];
StressedDave 0:24f23c36dd24 48 ID.accel = rawdata[1];
StressedDave 0:24f23c36dd24 49 ID.mag = rawdata[2];
StressedDave 0:24f23c36dd24 50 ID.gyro = rawdata[3];
StressedDave 0:24f23c36dd24 51 ID.sw[0] = rawdata[4];
StressedDave 0:24f23c36dd24 52 ID.sw[1] = rawdata[5];
StressedDave 0:24f23c36dd24 53 ID.bootload = rawdata[6];
StressedDave 0:24f23c36dd24 54 setpage(1);
StressedDave 0:24f23c36dd24 55 tx[0] = BNO055_UNIQUE_ID_ADDR;
StressedDave 0:24f23c36dd24 56 _i2c.write(address,tx,1,true);
StressedDave 0:24f23c36dd24 57 _i2c.read(address+1,ID.serial,16,false);
StressedDave 0:24f23c36dd24 58 setpage(0);
StressedDave 0:24f23c36dd24 59 return true;
StressedDave 0:24f23c36dd24 60 }
StressedDave 0:24f23c36dd24 61
StressedDave 0:24f23c36dd24 62 void BNO055::SetExternalCrystal(bool yn){
StressedDave 0:24f23c36dd24 63 // Read the current status from the device
StressedDave 0:24f23c36dd24 64 readchar(BNO055_SYS_TRIGGER_ADDR);
StressedDave 0:24f23c36dd24 65 if (yn) rx = rx | 0x80;
StressedDave 0:24f23c36dd24 66 else rx = rx & 0x7F;
StressedDave 0:24f23c36dd24 67 writechar(BNO055_SYS_TRIGGER_ADDR,rx);
StressedDave 0:24f23c36dd24 68 }
StressedDave 0:24f23c36dd24 69
StressedDave 0:24f23c36dd24 70 void BNO055::set_accel_units(char units){
StressedDave 0:24f23c36dd24 71 readchar(BNO055_UNIT_SEL_ADDR);
StressedDave 0:24f23c36dd24 72 if(units == MPERSPERS){
StressedDave 0:24f23c36dd24 73 rx = rx & 0xFE;
StressedDave 0:24f23c36dd24 74 accel_scale = 0.01f;
StressedDave 0:24f23c36dd24 75 }
StressedDave 0:24f23c36dd24 76 else {
StressedDave 0:24f23c36dd24 77 rx = rx | units;
StressedDave 6:1f722ffec323 78 accel_scale = 0.001f;
StressedDave 0:24f23c36dd24 79 }
StressedDave 0:24f23c36dd24 80 writechar(BNO055_UNIT_SEL_ADDR,rx);
StressedDave 0:24f23c36dd24 81 }
StressedDave 0:24f23c36dd24 82
StressedDave 0:24f23c36dd24 83 void BNO055::set_anglerate_units(char units){
StressedDave 0:24f23c36dd24 84 readchar(BNO055_UNIT_SEL_ADDR);
StressedDave 0:24f23c36dd24 85 if (units == DEG_PER_SEC){
StressedDave 0:24f23c36dd24 86 rx = rx & 0xFD;
StressedDave 0:24f23c36dd24 87 rate_scale = 1.0f/16.0f;
StressedDave 0:24f23c36dd24 88 }
StressedDave 0:24f23c36dd24 89 else {
StressedDave 0:24f23c36dd24 90 rx = rx | units;
StressedDave 0:24f23c36dd24 91 rate_scale = 1.0f/900.0f;
StressedDave 0:24f23c36dd24 92 }
StressedDave 0:24f23c36dd24 93 writechar(BNO055_UNIT_SEL_ADDR,rx);
StressedDave 0:24f23c36dd24 94 }
StressedDave 0:24f23c36dd24 95
StressedDave 0:24f23c36dd24 96 void BNO055::set_angle_units(char units){
StressedDave 0:24f23c36dd24 97 readchar(BNO055_UNIT_SEL_ADDR);
StressedDave 0:24f23c36dd24 98 if (units == DEGREES){
StressedDave 0:24f23c36dd24 99 rx = rx & 0xFB;
StressedDave 0:24f23c36dd24 100 angle_scale = 1.0f/16.0f;
StressedDave 0:24f23c36dd24 101 }
StressedDave 0:24f23c36dd24 102 else {
StressedDave 0:24f23c36dd24 103 rx = rx | units;
StressedDave 0:24f23c36dd24 104 rate_scale = 1.0f/900.0f;
StressedDave 0:24f23c36dd24 105 }
StressedDave 0:24f23c36dd24 106 writechar(BNO055_UNIT_SEL_ADDR,rx);
StressedDave 0:24f23c36dd24 107 }
StressedDave 0:24f23c36dd24 108
StressedDave 0:24f23c36dd24 109 void BNO055::set_temp_units(char units){
StressedDave 0:24f23c36dd24 110 readchar(BNO055_UNIT_SEL_ADDR);
StressedDave 0:24f23c36dd24 111 if (units == CENTIGRADE){
StressedDave 1:2c3322a8d417 112 rx = rx & 0xEF;
StressedDave 1:2c3322a8d417 113 temp_scale = 1;
StressedDave 0:24f23c36dd24 114 }
StressedDave 0:24f23c36dd24 115 else {
StressedDave 0:24f23c36dd24 116 rx = rx | units;
StressedDave 1:2c3322a8d417 117 temp_scale = 2;
StressedDave 0:24f23c36dd24 118 }
StressedDave 0:24f23c36dd24 119 writechar(BNO055_UNIT_SEL_ADDR,rx);
StressedDave 0:24f23c36dd24 120 }
StressedDave 0:24f23c36dd24 121
StressedDave 1:2c3322a8d417 122 void BNO055::set_orientation(char units){
StressedDave 1:2c3322a8d417 123 readchar(BNO055_UNIT_SEL_ADDR);
StressedDave 1:2c3322a8d417 124 if (units == WINDOWS) rx = rx &0x7F;
StressedDave 1:2c3322a8d417 125 else rx = rx | units;
StressedDave 1:2c3322a8d417 126 writechar(BNO055_UNIT_SEL_ADDR,rx);
StressedDave 1:2c3322a8d417 127 }
StressedDave 1:2c3322a8d417 128
StressedDave 0:24f23c36dd24 129 void BNO055::setmode(char omode){
StressedDave 0:24f23c36dd24 130 writechar(BNO055_OPR_MODE_ADDR,omode);
StressedDave 0:24f23c36dd24 131 op_mode = omode;
StressedDave 0:24f23c36dd24 132 }
StressedDave 0:24f23c36dd24 133
StressedDave 0:24f23c36dd24 134 void BNO055::setpowermode(char pmode){
StressedDave 0:24f23c36dd24 135 writechar(BNO055_PWR_MODE_ADDR,pmode);
StressedDave 0:24f23c36dd24 136 pwr_mode = pmode;
StressedDave 0:24f23c36dd24 137 }
StressedDave 0:24f23c36dd24 138
StressedDave 0:24f23c36dd24 139 void BNO055::get_accel(void){
StressedDave 0:24f23c36dd24 140 tx[0] = BNO055_ACCEL_DATA_X_LSB_ADDR;
StressedDave 0:24f23c36dd24 141 _i2c.write(address,tx,1,true);
StressedDave 0:24f23c36dd24 142 _i2c.read(address+1,rawdata,6,0);
StressedDave 0:24f23c36dd24 143 accel.rawx = (rawdata[1] << 8 | rawdata[0]);
StressedDave 0:24f23c36dd24 144 accel.rawy = (rawdata[3] << 8 | rawdata[2]);
StressedDave 0:24f23c36dd24 145 accel.rawz = (rawdata[5] << 8 | rawdata[4]);
StressedDave 0:24f23c36dd24 146 accel.x = float(accel.rawx)*accel_scale;
StressedDave 0:24f23c36dd24 147 accel.y = float(accel.rawy)*accel_scale;
StressedDave 0:24f23c36dd24 148 accel.z = float(accel.rawz)*accel_scale;
StressedDave 0:24f23c36dd24 149 }
StressedDave 0:24f23c36dd24 150
StressedDave 0:24f23c36dd24 151 void BNO055::get_gyro(void){
StressedDave 0:24f23c36dd24 152 tx[0] = BNO055_GYRO_DATA_X_LSB_ADDR;
StressedDave 0:24f23c36dd24 153 _i2c.write(address,tx,1,true);
StressedDave 0:24f23c36dd24 154 _i2c.read(address+1,rawdata,6,0);
StressedDave 0:24f23c36dd24 155 gyro.rawx = (rawdata[1] << 8 | rawdata[0]);
StressedDave 0:24f23c36dd24 156 gyro.rawy = (rawdata[3] << 8 | rawdata[2]);
StressedDave 0:24f23c36dd24 157 gyro.rawz = (rawdata[5] << 8 | rawdata[4]);
StressedDave 0:24f23c36dd24 158 gyro.x = float(gyro.rawx)*rate_scale;
StressedDave 0:24f23c36dd24 159 gyro.y = float(gyro.rawy)*rate_scale;
StressedDave 0:24f23c36dd24 160 gyro.z = float(gyro.rawz)*rate_scale;
StressedDave 0:24f23c36dd24 161 }
StressedDave 0:24f23c36dd24 162
StressedDave 0:24f23c36dd24 163 void BNO055::get_mag(void){
StressedDave 0:24f23c36dd24 164 tx[0] = BNO055_MAG_DATA_X_LSB_ADDR;
StressedDave 0:24f23c36dd24 165 _i2c.write(address,tx,1,true);
StressedDave 0:24f23c36dd24 166 _i2c.read(address+1,rawdata,6,0);
StressedDave 0:24f23c36dd24 167 mag.rawx = (rawdata[1] << 8 | rawdata[0]);
StressedDave 0:24f23c36dd24 168 mag.rawy = (rawdata[3] << 8 | rawdata[2]);
StressedDave 0:24f23c36dd24 169 mag.rawz = (rawdata[5] << 8 | rawdata[4]);
StressedDave 0:24f23c36dd24 170 mag.x = float(mag.rawx);
StressedDave 0:24f23c36dd24 171 mag.y = float(mag.rawy);
StressedDave 0:24f23c36dd24 172 mag.z = float(mag.rawz);
StressedDave 0:24f23c36dd24 173 }
StressedDave 0:24f23c36dd24 174
StressedDave 0:24f23c36dd24 175 void BNO055::get_lia(void){
StressedDave 0:24f23c36dd24 176 tx[0] = BNO055_LINEAR_ACCEL_DATA_X_LSB_ADDR;
StressedDave 0:24f23c36dd24 177 _i2c.write(address,tx,1,true);
StressedDave 0:24f23c36dd24 178 _i2c.read(address+1,rawdata,6,0);
StressedDave 0:24f23c36dd24 179 lia.rawx = (rawdata[1] << 8 | rawdata[0]);
StressedDave 0:24f23c36dd24 180 lia.rawy = (rawdata[3] << 8 | rawdata[2]);
StressedDave 0:24f23c36dd24 181 lia.rawz = (rawdata[5] << 8 | rawdata[4]);
StressedDave 0:24f23c36dd24 182 lia.x = float(lia.rawx)*accel_scale;
StressedDave 0:24f23c36dd24 183 lia.y = float(lia.rawy)*accel_scale;
StressedDave 0:24f23c36dd24 184 lia.z = float(lia.rawz)*accel_scale;
StressedDave 0:24f23c36dd24 185 }
StressedDave 0:24f23c36dd24 186
StressedDave 0:24f23c36dd24 187 void BNO055::get_grv(void){
StressedDave 0:24f23c36dd24 188 tx[0] = BNO055_GRAVITY_DATA_X_LSB_ADDR;
StressedDave 0:24f23c36dd24 189 _i2c.write(address,tx,1,true);
StressedDave 0:24f23c36dd24 190 _i2c.read(address+1,rawdata,6,0);
StressedDave 0:24f23c36dd24 191 gravity.rawx = (rawdata[1] << 8 | rawdata[0]);
StressedDave 0:24f23c36dd24 192 gravity.rawy = (rawdata[3] << 8 | rawdata[2]);
StressedDave 0:24f23c36dd24 193 gravity.rawz = (rawdata[5] << 8 | rawdata[4]);
StressedDave 0:24f23c36dd24 194 gravity.x = float(gravity.rawx)*accel_scale;
StressedDave 0:24f23c36dd24 195 gravity.y = float(gravity.rawy)*accel_scale;
StressedDave 0:24f23c36dd24 196 gravity.z = float(gravity.rawz)*accel_scale;
StressedDave 0:24f23c36dd24 197 }
StressedDave 0:24f23c36dd24 198
StressedDave 1:2c3322a8d417 199 void BNO055::get_quat(void){
StressedDave 1:2c3322a8d417 200 tx[0] = BNO055_QUATERNION_DATA_W_LSB_ADDR;
StressedDave 1:2c3322a8d417 201 _i2c.write(address,tx,1,true);
StressedDave 1:2c3322a8d417 202 _i2c.read(address+1,rawdata,8,0);
StressedDave 1:2c3322a8d417 203 quat.raww = (rawdata[1] << 8 | rawdata[0]);
StressedDave 1:2c3322a8d417 204 quat.rawx = (rawdata[3] << 8 | rawdata[2]);
StressedDave 1:2c3322a8d417 205 quat.rawy = (rawdata[5] << 8 | rawdata[4]);
StressedDave 1:2c3322a8d417 206 quat.rawz = (rawdata[7] << 8 | rawdata[6]);
StressedDave 1:2c3322a8d417 207 quat.w = float(quat.raww)/16384.0f;
StressedDave 1:2c3322a8d417 208 quat.x = float(quat.rawx)/16384.0f;
StressedDave 1:2c3322a8d417 209 quat.y = float(quat.rawy)/16384.0f;
StressedDave 1:2c3322a8d417 210 quat.z = float(quat.rawz)/16384.0f;
StressedDave 1:2c3322a8d417 211 }
StressedDave 1:2c3322a8d417 212
StressedDave 2:695c6e5d239a 213 void BNO055::get_angles(void){
StressedDave 2:695c6e5d239a 214 tx[0] = BNO055_EULER_H_LSB_ADDR;
StressedDave 2:695c6e5d239a 215 _i2c.write(address,tx,1,true);
StressedDave 2:695c6e5d239a 216 _i2c.read(address+1,rawdata,6,0);
StressedDave 3:1db1628eb8b2 217 euler.rawyaw = (rawdata[1] << 8 | rawdata[0]);
StressedDave 3:1db1628eb8b2 218 euler.rawroll = (rawdata[3] << 8 | rawdata[2]);
StressedDave 3:1db1628eb8b2 219 euler.rawpitch = (rawdata[5] << 8 | rawdata[4]);
StressedDave 3:1db1628eb8b2 220 euler.yaw = float(euler.rawyaw)*angle_scale;
StressedDave 3:1db1628eb8b2 221 euler.roll = float(euler.rawroll)*angle_scale;
StressedDave 3:1db1628eb8b2 222 euler.pitch = float(euler.rawpitch)*angle_scale;
StressedDave 2:695c6e5d239a 223 }
StressedDave 2:695c6e5d239a 224
StressedDave 2:695c6e5d239a 225
StressedDave 1:2c3322a8d417 226 void BNO055::get_temp(void){
StressedDave 1:2c3322a8d417 227 readchar(BNO055_TEMP_ADDR);
StressedDave 1:2c3322a8d417 228 temperature = rx / temp_scale;
StressedDave 1:2c3322a8d417 229 }
StressedDave 1:2c3322a8d417 230
StressedDave 0:24f23c36dd24 231 void BNO055::get_calib(void){
StressedDave 0:24f23c36dd24 232 readchar(BNO055_CALIB_STAT_ADDR);
StressedDave 0:24f23c36dd24 233 calib = rx;
StressedDave 1:2c3322a8d417 234 }
StressedDave 1:2c3322a8d417 235
StressedDave 1:2c3322a8d417 236 void BNO055::read_calibration_data(void){
StressedDave 1:2c3322a8d417 237 char tempmode = op_mode;
StressedDave 1:2c3322a8d417 238 setmode(OPERATION_MODE_CONFIG);
StressedDave 1:2c3322a8d417 239 wait_ms(20);
StressedDave 1:2c3322a8d417 240 tx[0] = ACCEL_OFFSET_X_LSB_ADDR;
StressedDave 1:2c3322a8d417 241 _i2c.write(address,tx,1,true);
StressedDave 1:2c3322a8d417 242 _i2c.read(address,calibration,22,false);
StressedDave 1:2c3322a8d417 243 setmode(tempmode);
StressedDave 1:2c3322a8d417 244 wait_ms(10);
StressedDave 1:2c3322a8d417 245 }
StressedDave 1:2c3322a8d417 246
StressedDave 1:2c3322a8d417 247 void BNO055::write_calibration_data(void){
StressedDave 1:2c3322a8d417 248 char tempmode = op_mode;
StressedDave 1:2c3322a8d417 249 setmode(OPERATION_MODE_CONFIG);
StressedDave 1:2c3322a8d417 250 wait_ms(20);
StressedDave 1:2c3322a8d417 251 tx[0] = ACCEL_OFFSET_X_LSB_ADDR;
StressedDave 1:2c3322a8d417 252 _i2c.write(address,tx,1,true);
StressedDave 1:2c3322a8d417 253 _i2c.write(address,calibration,22,false);
StressedDave 1:2c3322a8d417 254 setmode(tempmode);
StressedDave 1:2c3322a8d417 255 wait_ms(10);
StressedDave 1:2c3322a8d417 256 }
StressedDave 1:2c3322a8d417 257
StressedDave 1:2c3322a8d417 258 void BNO055::set_mapping(char orient){
StressedDave 1:2c3322a8d417 259 switch (orient){
StressedDave 1:2c3322a8d417 260 case 0:
StressedDave 1:2c3322a8d417 261 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x21);
StressedDave 1:2c3322a8d417 262 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x04);
StressedDave 1:2c3322a8d417 263 break;
StressedDave 1:2c3322a8d417 264 case 1:
StressedDave 1:2c3322a8d417 265 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x24);
StressedDave 1:2c3322a8d417 266 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x00);
StressedDave 1:2c3322a8d417 267 break;
StressedDave 1:2c3322a8d417 268 case 2:
StressedDave 1:2c3322a8d417 269 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x24);
StressedDave 1:2c3322a8d417 270 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x00);
StressedDave 1:2c3322a8d417 271 break;
StressedDave 1:2c3322a8d417 272 case 3:
StressedDave 1:2c3322a8d417 273 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x21);
StressedDave 1:2c3322a8d417 274 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x02);
StressedDave 1:2c3322a8d417 275 break;
StressedDave 1:2c3322a8d417 276 case 4:
StressedDave 1:2c3322a8d417 277 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x24);
StressedDave 1:2c3322a8d417 278 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x03);
StressedDave 1:2c3322a8d417 279 break;
StressedDave 1:2c3322a8d417 280 case 5:
StressedDave 1:2c3322a8d417 281 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x21);
StressedDave 1:2c3322a8d417 282 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x01);
StressedDave 1:2c3322a8d417 283 break;
StressedDave 1:2c3322a8d417 284 case 6:
StressedDave 1:2c3322a8d417 285 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x21);
StressedDave 1:2c3322a8d417 286 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x07);
StressedDave 1:2c3322a8d417 287 break;
StressedDave 1:2c3322a8d417 288 case 7:
StressedDave 1:2c3322a8d417 289 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x24);
StressedDave 1:2c3322a8d417 290 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x05);
StressedDave 1:2c3322a8d417 291 break;
StressedDave 1:2c3322a8d417 292 default:
StressedDave 1:2c3322a8d417 293 writechar(BNO055_AXIS_MAP_CONFIG_ADDR,0x24);
StressedDave 1:2c3322a8d417 294 writechar(BNO055_AXIS_MAP_SIGN_ADDR,0x00);
StressedDave 1:2c3322a8d417 295 }
tsungta 10:1914e07be563 296 }
tsungta 10:1914e07be563 297
tsungta 10:1914e07be563 298 //AS7000::AS7000(PinName SDA, PinName SCL) : _i2c(SDA,SCL){
tsungta 10:1914e07be563 299 //
tsungta 10:1914e07be563 300 //}
tsungta 10:1914e07be563 301
tsungta 10:1914e07be563 302 void BNO055::enable(void){
tsungta 10:1914e07be563 303 char cmd[2];
tsungta 10:1914e07be563 304
tsungta 10:1914e07be563 305 AS7000_GPIO8.write(0); //Power ON AS7000
tsungta 10:1914e07be563 306 wait_ms(280); //Wait for > 250ms for booting
tsungta 10:1914e07be563 307
tsungta 10:1914e07be563 308 cmd[0] = AS7000_STARTUP; //0x04;
tsungta 10:1914e07be563 309 cmd[1] = 0x02;
tsungta 10:1914e07be563 310 _i2c.write(AS7000Address, cmd, 2);
tsungta 10:1914e07be563 311 wait_ms(35);
tsungta 10:1914e07be563 312
tsungta 10:1914e07be563 313 }
tsungta 10:1914e07be563 314
tsungta 10:1914e07be563 315 void BNO055::update(void){
tsungta 10:1914e07be563 316
tsungta 10:1914e07be563 317 }
tsungta 10:1914e07be563 318
tsungta 10:1914e07be563 319 void BNO055::hr_only(void){
tsungta 10:1914e07be563 320 char cmd[2];
tsungta 10:1914e07be563 321 cmd[0] = HR_ONLY;
tsungta 10:1914e07be563 322 if(AS7000_INT == 0) {
tsungta 10:1914e07be563 323 _i2c.write(AS7000Address, cmd, 1);
tsungta 10:1914e07be563 324 _i2c.read(AS7000Address, rawdata, 7, false);
tsungta 10:1914e07be563 325 wait_ms(10);
tsungta 10:1914e07be563 326 //update();
tsungta 10:1914e07be563 327 hrm.transaction_id = rawdata[0];
tsungta 10:1914e07be563 328 hrm.status = rawdata[1];
tsungta 10:1914e07be563 329 hrm.hreat_rate = rawdata[2];
tsungta 10:1914e07be563 330 hrm.signal_QA = rawdata[3];
tsungta 10:1914e07be563 331 hrm.LED_current = ((rawdata[4]<<8)+rawdata[5]);
tsungta 10:1914e07be563 332 hrm.SYNC = rawdata[6];
tsungta 10:1914e07be563 333 }
StressedDave 0:24f23c36dd24 334 }