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.
Dependents: BNO055_test BNO055-ELEC3810 1BNO055 DEMO3 ... more
Revision 5:cf33bcfe976c, committed 2017-08-22
- Comitter:
- kenjiArai
- Date:
- Tue Aug 22 10:13:30 2017 +0000
- Parent:
- 4:9e6fead1e93e
- Child:
- 6:07d01bf36ad0
- Commit message:
- countermeasure for NonCopyable
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 |
--- a/BNO055.cpp Thu Apr 16 10:47:40 2015 +0000
+++ b/BNO055.cpp Tue Aug 22 10:13:30 2017 +0000
@@ -3,24 +3,27 @@
* BNO055 Intelligent 9-axis absolute orientation sensor
* by Bosch Sensortec
*
- * Copyright (c) 2015 Kenji Arai / JH1PJL
+ * Copyright (c) 2015,'17 Kenji Arai / JH1PJL
* http://www.page.sannet.ne.jp/kenjia/index.html
* http://mbed.org/users/kenjiArai/
* Created: March 30th, 2015
- * Revised: April 16th, 2015
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Revised: September 21st, 2017
*/
#include "mbed.h"
#include "BNO055.h"
+
+#if MBED_MAJOR_VERSION == 2
+#define WAIT_MS(x) wait_ms(x)
+#elif MBED_MAJOR_VERSION == 5
+#define WAIT_MS(x) Thread::wait(x)
+#else
+#error "Running on Unknown OS"
+#endif
+
BNO055::BNO055 (PinName p_sda, PinName p_scl, PinName p_reset, uint8_t addr, uint8_t mode):
- _i2c(p_sda, p_scl), _res(p_reset)
+ _i2c_p(new I2C(p_sda, p_scl)), _i2c(*_i2c_p), _res(p_reset)
{
chip_addr = addr;
chip_mode = mode;
@@ -28,7 +31,7 @@
}
BNO055::BNO055 (PinName p_sda, PinName p_scl, PinName p_reset) :
- _i2c(p_sda, p_scl), _res(p_reset)
+ _i2c_p(new I2C(p_sda, p_scl)), _i2c(*_i2c_p), _res(p_reset)
{
chip_addr = BNO055_G_CHIP_ADDR;
chip_mode = MODE_NDOF;
@@ -173,7 +176,7 @@
dt[0] = BNO055_TEMP_SOURCE;
dt[1] = 0;
_i2c.write(chip_addr, dt, 2, false);
- wait_ms(1); // Do I need to wait?
+ WAIT_MS(1); // Do I need to wait?
dt[0] = BNO055_TEMP;
_i2c.write(chip_addr, dt, 1, true);
_i2c.read(chip_addr, dt, 1, false);
@@ -185,7 +188,7 @@
dt[0] = BNO055_TEMP_SOURCE;
dt[1] = 1;
_i2c.write(chip_addr, dt, 2, false);
- wait_ms(1); // Do I need to wait?
+ WAIT_MS(1); // Do I need to wait?
dt[0] = BNO055_TEMP;
_i2c.write(chip_addr, dt, 1, true);
_i2c.read(chip_addr, dt, 1, false);
@@ -245,9 +248,9 @@
uint8_t BNO055::reset(void)
{
_res = 0;
- wait_ms(1); // Reset 1mS
+ WAIT_MS(1); // Reset 1mS
_res = 1;
- wait(0.7); // Need to wait at least 650mS
+ WAIT_MS(700); // Need to wait at least 650mS
#if defined(TARGET_STM32L152RE)
_i2c.frequency(400000);
#else
@@ -343,7 +346,7 @@
dt[0] = BNO055_OPR_MODE;
dt[1] = mode;
_i2c.write(chip_addr, dt, 2, false);
- wait_ms(19); // wait 19mS
+ WAIT_MS(19); // wait 19mS
break;
case MODE_IMU:
case MODE_COMPASS:
@@ -354,12 +357,12 @@
dt[0] = BNO055_OPR_MODE;
dt[1] = CONFIGMODE;
_i2c.write(chip_addr, dt, 2, false);
- wait_ms(19); // wait 19mS
+ WAIT_MS(19); // wait 19mS
}
dt[0] = BNO055_OPR_MODE;
dt[1] = mode;
_i2c.write(chip_addr, dt, 2, false);
- wait_ms(7); // wait 7mS
+ WAIT_MS(7); // wait 7mS
break;
default:
break;
@@ -481,3 +484,4 @@
change_fusion_mode(current_mode);
return d;
}
+
--- a/BNO055.h Thu Apr 16 10:47:40 2015 +0000
+++ b/BNO055.h Tue Aug 22 10:13:30 2017 +0000
@@ -3,17 +3,11 @@
* BNO055 Intelligent 9-axis absolute orientation sensor
* by Bosch Sensortec
*
- * Copyright (c) 2015 Kenji Arai / JH1PJL
+ * Copyright (c) 2015,'17 Kenji Arai / JH1PJL
* http://www.page.sannet.ne.jp/kenjia/index.html
* http://mbed.org/users/kenjiArai/
* Created: March 30th, 2015
- * Revised: April 16th, 2015
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Revised: September 21st, 2017
*/
/*
*---------------- REFERENCE ----------------------------------------------------------------------
@@ -267,7 +261,8 @@
uint8_t check_operating_mode(void);
uint8_t select_page(uint8_t page);
- I2C _i2c;
+ I2C *_i2c_p;
+ I2C &_i2c;
DigitalOut _res;
private: