Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BNO055 by
Revision 4:c88a12857528, committed 2015-09-15
- Comitter:
- simonscott
- Date:
- Tue Sep 15 23:37:47 2015 +0000
- Parent:
- 3:1db1628eb8b2
- Commit message:
- First commit
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 1db1628eb8b2 -r c88a12857528 BNO055.cpp --- a/BNO055.cpp Sun May 31 07:22:40 2015 +0000 +++ b/BNO055.cpp Tue Sep 15 23:37:47 2015 +0000 @@ -196,8 +196,13 @@ void BNO055::get_angles(void){ tx[0] = BNO055_EULER_H_LSB_ADDR; - _i2c.write(address,tx,1,true); - _i2c.read(address+1,rawdata,6,0); + _i2c.write(address,tx,1,true); + + char raw[22]; + _i2c.read(address+1,raw,6,0); + wait(0.01); + for(int i = 0; i < 22; i++) + rawdata[i] = raw[i]; euler.rawyaw = (rawdata[1] << 8 | rawdata[0]); euler.rawroll = (rawdata[3] << 8 | rawdata[2]); euler.rawpitch = (rawdata[5] << 8 | rawdata[4]);
diff -r 1db1628eb8b2 -r c88a12857528 BNO055.h --- a/BNO055.h Sun May 31 07:22:40 2015 +0000 +++ b/BNO055.h Tue Sep 15 23:37:47 2015 +0000 @@ -254,7 +254,8 @@ private: I2C _i2c; - char rx,tx[2],address; //I2C variables + char tx[2],address; //I2C variables + char rx; char rawdata[22]; //Temporary array for input data values char op_mode; char pwr_mode; @@ -263,8 +264,12 @@ void readchar(char location){ tx[0] = location; + char b; _i2c.write(address,tx,1,true); - _i2c.read(address,&rx,1,false); + _i2c.read(address,&b,1,false); + wait(0.01); + rx = b; + } void writechar(char location, char value){