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 2019/10/17 00:04:02 UTC

[mynewt-core] branch master updated: bmp388: Fix 2 bugs in bmp3_set_op_mode - Don't write device to set mode if the device is already in the request mode - Don't delay unless device mode was actually changed

This is an automated email from the ASF dual-hosted git repository.

vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 1400dfe  bmp388: Fix 2 bugs in bmp3_set_op_mode - Don't write device to set mode if the device is already in the request mode - Don't delay unless device mode was actually changed
     new 588cf53  Merge pull request #2043 from JuulLabs/fix/bmp388-poll-read
1400dfe is described below

commit 1400dfebb4809dbdefb95b8e8e2fb20bed583111
Author: Ben McCrea <bm...@juul.com>
AuthorDate: Wed Oct 16 17:03:39 2019 +0800

    bmp388: Fix 2 bugs in bmp3_set_op_mode
    - Don't write device to set mode if the device is already in the request mode
    - Don't delay unless device mode was actually changed
---
 hw/drivers/sensors/bmp388/src/bmp388.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/drivers/sensors/bmp388/src/bmp388.c b/hw/drivers/sensors/bmp388/src/bmp388.c
index 763e94c..faa06fa 100644
--- a/hw/drivers/sensors/bmp388/src/bmp388.c
+++ b/hw/drivers/sensors/bmp388/src/bmp388.c
@@ -1041,6 +1041,12 @@ bmp3_set_op_mode(struct bmp3_dev *dev)
 
     if (rslt == BMP3_OK) {
         rslt = bmp3_get_op_mode(&last_set_mode, dev);
+
+        /* quit if sensor is already in the requested mode */
+        if (last_set_mode == curr_mode) {
+            return BMP3_OK;
+        }
+
         /* If the sensor is not in sleep mode put the device to sleep mode */
         if (last_set_mode != BMP3_SLEEP_MODE) {
             /* Device should be put to sleep before transiting to
@@ -1054,12 +1060,12 @@ bmp3_set_op_mode(struct bmp3_dev *dev)
             if (curr_mode == BMP3_NORMAL_MODE) {
                 /* Set normal mode and validate necessary settings */
                 rslt = set_normal_mode(dev);
+                delay_msec(5);
             } else if (curr_mode == BMP3_FORCED_MODE) {
                 /* Set forced mode */
                 rslt = write_power_mode(dev);
+                delay_msec(5);
             }
-            /* Give some time for device to change mode */
-            delay_msec(5);
         }
     }