You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2017/02/27 22:50:52 UTC
incubator-mynewt-core git commit: SensorAPI - BNO055 needs delay on
mode changes
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop d3dbe78cb -> e76365601
SensorAPI - BNO055 needs delay on mode changes
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e7636560
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e7636560
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e7636560
Branch: refs/heads/develop
Commit: e76365601d642017d207cb858847bd5b0d8c8950
Parents: d3dbe78
Author: Vipul Rahane <vi...@apache.org>
Authored: Mon Feb 27 14:46:38 2017 -0800
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Feb 27 14:50:35 2017 -0800
----------------------------------------------------------------------
apps/sensors_test/src/main.c | 4 +--
hw/drivers/sensors/bno055/src/bno055.c | 47 ++++++++++++++++++++++-------
2 files changed, 38 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e7636560/apps/sensors_test/src/main.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index d17c61a..3c5cedd 100755
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -305,8 +305,8 @@ config_sensor(void)
}
bcfg.bc_units = BNO055_ACC_UNIT_MS2 | BNO055_ANGRATE_UNIT_DPS |
- BNO055_EULER_UNIT_DEG | BNO055_TEMP_UNIT_DEGC |
- BNO055_DO_FORMAT_ANDROID;
+ BNO055_EULER_UNIT_DEG | BNO055_TEMP_UNIT_DEGC |
+ BNO055_DO_FORMAT_ANDROID;
bcfg.bc_opr_mode = BNO055_OPR_MODE_ACCONLY;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e7636560/hw/drivers/sensors/bno055/src/bno055.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/bno055/src/bno055.c b/hw/drivers/sensors/bno055/src/bno055.c
index d1043f2..1d06545 100644
--- a/hw/drivers/sensors/bno055/src/bno055.c
+++ b/hw/drivers/sensors/bno055/src/bno055.c
@@ -79,7 +79,7 @@ STATS_SECT_DECL(bno055_stat_section) g_bno055stats;
#endif
#if MYNEWT_VAL(BNO055_LOG)
-#define LOG_MODULE_BNO055 (303)
+#define LOG_MODULE_BNO055 (305)
#define BNO055_INFO(...) LOG_INFO(&_log, LOG_MODULE_BNO055, __VA_ARGS__)
#define BNO055_ERR(...) LOG_ERROR(&_log, LOG_MODULE_BNO055, __VA_ARGS__)
static struct log _log;
@@ -295,6 +295,8 @@ bno055_set_pwr_mode(uint8_t mode)
goto err;
}
+ os_time_delay((OS_TICKS_PER_SEC * 1)/1000 + 1);
+
return 0;
err:
return rc;
@@ -537,6 +539,7 @@ bno055_config(struct bno055 *bno055, struct bno055_cfg *cfg)
{
int rc;
uint8_t id;
+ uint8_t mode;
/* Check if we can read the chip address */
rc = bno055_get_chip_id(&id);
@@ -564,6 +567,8 @@ bno055_config(struct bno055 *bno055, struct bno055_cfg *cfg)
goto err;
}
+ os_time_delay(OS_TICKS_PER_SEC);
+
rc = bno055_set_opr_mode(BNO055_OPR_MODE_CONFIG);
if (rc) {
goto err;
@@ -575,13 +580,6 @@ bno055_config(struct bno055 *bno055, struct bno055_cfg *cfg)
goto err;
}
- rc = bno055_write8(BNO055_SYS_TRIGGER_ADDR, 0x0);
- if (rc) {
- goto err;
- }
-
- os_time_delay((OS_TICKS_PER_SEC * 10)/1000 + 1);
-
/**
* As per Section 5.5 in the BNO055 Datasheet,
* external crystal should be used for accurate
@@ -598,15 +596,42 @@ bno055_config(struct bno055 *bno055, struct bno055_cfg *cfg)
goto err;
}
- /* Overwrite the configuration data. */
- memcpy(&bno055->cfg, cfg, sizeof(*cfg));
-
/* Change mode to requested mode */
rc = bno055_set_opr_mode(cfg->bc_opr_mode);
if (rc) {
goto err;
}
+ os_time_delay(OS_TICKS_PER_SEC/2);
+
+ rc = bno055_get_opr_mode(&mode);
+ if (rc) {
+ goto err;
+ }
+
+ if (cfg->bc_opr_mode != mode) {
+
+ /* Trying to set operation mode again */
+ rc = bno055_set_opr_mode(cfg->bc_opr_mode);
+ if (rc) {
+ goto err;
+ }
+
+ rc = bno055_get_opr_mode(&mode);
+
+ if (rc) {
+ goto err;
+ }
+
+ if (cfg->bc_opr_mode != mode) {
+ BNO055_ERR("Config mode and read mode do not match.\n");
+ return rc;
+ }
+ }
+
+ /* Overwrite the configuration data. */
+ memcpy(&bno055->cfg, cfg, sizeof(*cfg));
+
return 0;
err:
return rc;