You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2018/12/12 13:09:38 UTC

[mynewt-core] branch master updated (f5769ec -> 7a7e6cf)

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

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


    from f5769ec  Use syscfg settings for sysinit stage numbers
     new 3ade5d2  bmp280/bme280: Update syscfg description
     new 2bcc631  bmp280/bme280: Cleanup temperature and pressure reading function
     new 57c46c8  bmp280/bme280: Fix pressure, humidity readout
     new 7e05db3  hw/drivers/bme280: Fix integer calculation compilation
     new 901dd08  hw/drivers/bmp280: Fix build for bus driver
     new 7a7e6cf  bmp280/bme280: Fix dependency for bus driver

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 hw/drivers/sensors/bme280/pkg.yml                 |  3 +
 hw/drivers/sensors/bme280/src/bme280.c            | 73 ++++++++++-------------
 hw/drivers/sensors/bme280/syscfg.yml              |  4 +-
 hw/drivers/sensors/bmp280/include/bmp280/bmp280.h |  7 +++
 hw/drivers/sensors/bmp280/pkg.yml                 |  4 +-
 hw/drivers/sensors/bmp280/src/bmp280.c            | 56 +++++++----------
 hw/drivers/sensors/bmp280/syscfg.yml              |  4 +-
 7 files changed, 72 insertions(+), 79 deletions(-)


[mynewt-core] 06/06: bmp280/bme280: Fix dependency for bus driver

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7a7e6cfe3692443e93c1c6ac4589294f89b778ae
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Dec 7 12:56:12 2018 +0100

    bmp280/bme280: Fix dependency for bus driver
    
    dependency to i2cn is not needed when bus driver is used.
---
 hw/drivers/sensors/bme280/pkg.yml | 3 +++
 hw/drivers/sensors/bmp280/pkg.yml | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/drivers/sensors/bme280/pkg.yml b/hw/drivers/sensors/bme280/pkg.yml
index 8f9780e..6854783 100644
--- a/hw/drivers/sensors/bme280/pkg.yml
+++ b/hw/drivers/sensors/bme280/pkg.yml
@@ -33,6 +33,9 @@ pkg.deps:
     - "@apache-mynewt-core/hw/sensor"
     - "@apache-mynewt-core/sys/log/modlog"
 
+pkg.deps.!BUS_DRIVER_PRESENT:
+    - "@apache-mynewt-core/hw/util/i2cn"
+
 pkg.req_apis:
     - stats
 
diff --git a/hw/drivers/sensors/bmp280/pkg.yml b/hw/drivers/sensors/bmp280/pkg.yml
index 9afd46a..2379ec4 100644
--- a/hw/drivers/sensors/bmp280/pkg.yml
+++ b/hw/drivers/sensors/bmp280/pkg.yml
@@ -32,9 +32,11 @@ pkg.deps:
     - "@apache-mynewt-core/kernel/os"
     - "@apache-mynewt-core/hw/hal"
     - "@apache-mynewt-core/hw/sensor"
-    - "@apache-mynewt-core/hw/util/i2cn"
     - "@apache-mynewt-core/sys/log/modlog"
 
+#pkg.deps.!BUS_DRIVER_PRESENT:
+#    - "@apache-mynewt-core/hw/util/i2cn"
+
 pkg.req_apis:
     - stats
 


[mynewt-core] 03/06: bmp280/bme280: Fix pressure, humidity readout

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 57c46c88415af40cbb5efeb7ea8e47257e904ea3
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon Dec 3 15:47:49 2018 +0100

    bmp280/bme280: Fix pressure, humidity readout
    
    If user wanted to read only pressure and/or humidity from sensor only first value
    read from the device would be correct.
    Further pressure humidity read request would use incorrect value of t_fine that
    was computed only for the first reading when  temperature was actually read.
    
    Even if temperature reading was requested, pressure values would be incorrect,
    since temperature used for pressure compensation was taken from previous
    read. For slow rate readings pressure would be always calculated with
    old values from temperature.
    
    Now temperature is always read even if not requested by user code to make sure
    that pressure and humidity calculations are correct.
---
 hw/drivers/sensors/bme280/src/bme280.c | 41 ++++++++++++++++++----------------
 hw/drivers/sensors/bmp280/src/bmp280.c | 36 +++++++++++++++--------------
 2 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/hw/drivers/sensors/bme280/src/bme280.c b/hw/drivers/sensors/bme280/src/bme280.c
index 7c0f855..1e8eda2 100644
--- a/hw/drivers/sensors/bme280/src/bme280.c
+++ b/hw/drivers/sensors/bme280/src/bme280.c
@@ -489,35 +489,30 @@ bme280_sensor_read(struct sensor *sensor, sensor_type_t type,
 
     rawtemp = rawpress = rawhumid = 0;
 
+    /* Get a new temperature sample always */
+    rc = bme280_get_temperature(itf, &rawtemp);
+    if (rc) {
+        goto err;
+    }
+    databuf.std.std_temp = bme280_compensate_temperature(rawtemp, &(bme280->pdd));
+
     /* Get a new pressure sample */
     if (type & SENSOR_TYPE_PRESSURE) {
         rc = bme280_get_pressure(itf, &rawpress);
         if (rc) {
             goto err;
         }
+    }
 
-        databuf.spd.spd_press = bme280_compensate_pressure(itf, rawpress, &(bme280->pdd));
-
-        if (databuf.spd.spd_press != NAN) {
-            databuf.spd.spd_press_is_valid = 1;
-        }
-
-        /* Call data function */
-        rc = data_func(sensor, data_arg, &databuf.spd, SENSOR_TYPE_PRESSURE);
+    /* Get a new relative humidity sample */
+    if (type & SENSOR_TYPE_RELATIVE_HUMIDITY) {
+        rc = bme280_get_humidity(itf, &rawhumid);
         if (rc) {
             goto err;
         }
     }
 
-    /* Get a new temperature sample */
     if (type & SENSOR_TYPE_AMBIENT_TEMPERATURE) {
-        rc = bme280_get_temperature(itf, &rawtemp);
-        if (rc) {
-            goto err;
-        }
-
-        databuf.std.std_temp = bme280_compensate_temperature(rawtemp, &(bme280->pdd));
-
         if (databuf.std.std_temp != NAN) {
             databuf.std.std_temp_is_valid = 1;
         }
@@ -529,13 +524,21 @@ bme280_sensor_read(struct sensor *sensor, sensor_type_t type,
         }
     }
 
-    /* Get a new relative humidity sample */
-    if (type & SENSOR_TYPE_RELATIVE_HUMIDITY) {
-        rc = bme280_get_humidity(itf, &rawhumid);
+    if (type & SENSOR_TYPE_PRESSURE) {
+        databuf.spd.spd_press = bme280_compensate_pressure(itf, rawpress, &(bme280->pdd));
+
+        if (databuf.spd.spd_press != NAN) {
+            databuf.spd.spd_press_is_valid = 1;
+        }
+
+        /* Call data function */
+        rc = data_func(sensor, data_arg, &databuf.spd, SENSOR_TYPE_PRESSURE);
         if (rc) {
             goto err;
         }
+    }
 
+    if (type & SENSOR_TYPE_RELATIVE_HUMIDITY) {
         databuf.shd.shd_humid = bme280_compensate_humidity(itf, rawhumid, &(bme280->pdd));
 
         if (databuf.shd.shd_humid != NAN) {
diff --git a/hw/drivers/sensors/bmp280/src/bmp280.c b/hw/drivers/sensors/bmp280/src/bmp280.c
index 85bca22..10e331c 100644
--- a/hw/drivers/sensors/bmp280/src/bmp280.c
+++ b/hw/drivers/sensors/bmp280/src/bmp280.c
@@ -405,41 +405,43 @@ bmp280_sensor_read(struct sensor *sensor, sensor_type_t type,
 
     rawtemp = rawpress = 0;
 
-    /* Get a new pressure sample */
+    /* Temperature is always needed */
+    rc = bmp280_get_temperature(itf, &rawtemp);
+    if (rc) {
+        goto err;
+    }
+    databuf.std.std_temp = bmp280_compensate_temperature(rawtemp, &(bmp280->pdd));
+
+
+    /* Get a new pressure sample if needed */
     if (type & SENSOR_TYPE_PRESSURE) {
         rc = bmp280_get_pressure(itf, &rawpress);
         if (rc) {
             goto err;
         }
+    }
 
-        databuf.spd.spd_press = bmp280_compensate_pressure(itf, rawpress, &(bmp280->pdd));
-
-        if (databuf.spd.spd_press != NAN) {
-            databuf.spd.spd_press_is_valid = 1;
+    if (type & SENSOR_TYPE_AMBIENT_TEMPERATURE) {
+        if (databuf.std.std_temp != NAN) {
+            databuf.std.std_temp_is_valid = 1;
         }
 
         /* Call data function */
-        rc = data_func(sensor, data_arg, &databuf.spd, SENSOR_TYPE_PRESSURE);
+        rc = data_func(sensor, data_arg, &databuf.std, SENSOR_TYPE_AMBIENT_TEMPERATURE);
         if (rc) {
             goto err;
         }
     }
 
-    /* Get a new temperature sample */
-    if (type & SENSOR_TYPE_AMBIENT_TEMPERATURE) {
-        rc = bmp280_get_temperature(itf, &rawtemp);
-        if (rc) {
-            goto err;
-        }
-
-        databuf.std.std_temp = bmp280_compensate_temperature(rawtemp, &(bmp280->pdd));
+    if (type & SENSOR_TYPE_PRESSURE) {
+        databuf.spd.spd_press = bmp280_compensate_pressure(itf, rawpress, &(bmp280->pdd));
 
-        if (databuf.std.std_temp != NAN) {
-            databuf.std.std_temp_is_valid = 1;
+        if (databuf.spd.spd_press != NAN) {
+            databuf.spd.spd_press_is_valid = 1;
         }
 
         /* Call data function */
-        rc = data_func(sensor, data_arg, &databuf.std, SENSOR_TYPE_AMBIENT_TEMPERATURE);
+        rc = data_func(sensor, data_arg, &databuf.spd, SENSOR_TYPE_PRESSURE);
         if (rc) {
             goto err;
         }


[mynewt-core] 02/06: bmp280/bme280: Cleanup temperature and pressure reading function

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2bcc631747b581620c4a4b536b316a8d612b4646
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon Dec 3 15:36:51 2018 +0100

    bmp280/bme280: Cleanup temperature and pressure reading function
    
    There was unnecessary conditional code in functions:
    bmp280_get_temperature(), bmp280_get_pressure().
    It made functions return different values depending on compilation flag
    one version returned 20 bits values shifted by 4 bits left.
    Later on, one set of compensation functions shifted raw values anyway.
    
    Compensation functions that uses double float arithmetic also compared
    invalid value from sensor with incorrect (24 bit value) value 0x800000,
    instead of 0x80000 (20 bit value).
    Code was correct for 32 bits arithmetic because shifting was done after
    check and input value was 24 bit value.
---
 hw/drivers/sensors/bme280/src/bme280.c | 22 +++-------------------
 hw/drivers/sensors/bmp280/src/bmp280.c | 20 ++++----------------
 2 files changed, 7 insertions(+), 35 deletions(-)

diff --git a/hw/drivers/sensors/bme280/src/bme280.c b/hw/drivers/sensors/bme280/src/bme280.c
index 689368c..7c0f855 100644
--- a/hw/drivers/sensors/bme280/src/bme280.c
+++ b/hw/drivers/sensors/bme280/src/bme280.c
@@ -199,7 +199,7 @@ bme280_compensate_temperature(int32_t rawtemp, struct bme280_pdd *pdd)
 {
     double var1, var2, comptemp;
 
-    if (rawtemp == 0x800000) {
+    if (rawtemp == 0x80000) {
         BME280_LOG(ERROR, "Invalid temp data\n");
         STATS_INC(g_bme280stats, invalid_data_errors);
         return NAN;
@@ -234,7 +234,7 @@ bme280_compensate_pressure(struct sensor_itf *itf, int32_t rawpress,
     double var1, var2, p;
     int32_t temp;
 
-    if (rawpress == 0x800000) {
+    if (rawpress == 0x80000) {
         BME280_LOG(ERROR, "Invalid press data\n");
         STATS_INC(g_bme280stats, invalid_data_errors);
         return NAN;
@@ -335,8 +335,6 @@ bme280_compensate_temperature(int32_t rawtemp, struct bme280_pdd *pdd)
         return NAN;
     }
 
-    rawtemp >>= 4;
-
     var1 = ((((rawtemp>>3) - ((int32_t)pdd->bcd.bcd_dig_T1 <<1))) *
             ((int32_t)pdd->bcd.bcd_dig_T2)) >> 11;
 
@@ -366,7 +364,7 @@ bme280_compensate_pressure(struct sensor_itf *itf, int32_t rawpress,
     int64_t var1, var2, p;
     int32_t temp;
 
-    if (rawpress == 0x800000) {
+    if (rawpress == 0x80000) {
         BME280_LOG(ERROR, "Invalid pressure data\n");
         STATS_INC(g_bme280stats, invalid_data_errors);
         return NAN;
@@ -378,8 +376,6 @@ bme280_compensate_pressure(struct sensor_itf *itf, int32_t rawpress,
         }
     }
 
-    rawpress >>= 4;
-
     var1 = ((int64_t)pdd->t_fine) - 128000;
     var2 = var1 * var1 * (int64_t)pdd->bcd.bcd_dig_P6;
     var2 = var2 + ((int64_t)(var1*(int64_t)pdd->bcd.bcd_dig_P5) << 17);
@@ -974,13 +970,9 @@ bme280_get_temperature(struct sensor_itf *itf, int32_t *temp)
         goto err;
     }
 
-#if MYNEWT_VAL(BME280_SPEC_CALC)
     *temp = (int32_t)((((uint32_t)(tmp[0])) << 12) |
                       (((uint32_t)(tmp[1])) <<  4) |
                        ((uint32_t)tmp[2] >> 4));
-#else
-    *temp = ((tmp[0] << 16) | (tmp[1] << 8) | tmp[2]);
-#endif
 
     return 0;
 err:
@@ -1004,11 +996,7 @@ bme280_get_humidity(struct sensor_itf *itf, int32_t *humid)
     if (rc) {
         goto err;
     }
-#if MYNEWT_VAL(BME280_SPEC_CALC)
     *humid = (tmp[0] << 8 | tmp[1]);
-#else
-    *humid = (tmp[0] << 8 | tmp[1]);
-#endif
 
     return 0;
 err:
@@ -1033,13 +1021,9 @@ bme280_get_pressure(struct sensor_itf *itf, int32_t *press)
         goto err;
     }
 
-#if MYNEWT_VAL(BME280_SPEC_CALC)
     *press = (int32_t)((((uint32_t)(tmp[0])) << 12) |
                       (((uint32_t)(tmp[1])) <<  4)  |
                        ((uint32_t)tmp[2] >> 4));
-#else
-    *press = ((tmp[0] << 16) | (tmp[1] << 8) | tmp[2]);
-#endif
 
     return 0;
 err:
diff --git a/hw/drivers/sensors/bmp280/src/bmp280.c b/hw/drivers/sensors/bmp280/src/bmp280.c
index 83e24b0..85bca22 100644
--- a/hw/drivers/sensors/bmp280/src/bmp280.c
+++ b/hw/drivers/sensors/bmp280/src/bmp280.c
@@ -206,7 +206,7 @@ bmp280_compensate_temperature(int32_t rawtemp, struct bmp280_pdd *pdd)
 {
     double var1, var2, comptemp;
 
-    if (rawtemp == 0x800000) {
+    if (rawtemp == 0x80000) {
         BMP280_LOG(ERROR, "Invalid temp data\n");
         STATS_INC(g_bmp280stats, invalid_data_errors);
         return NAN;
@@ -241,7 +241,7 @@ bmp280_compensate_pressure(struct sensor_itf *itf, int32_t rawpress,
     double var1, var2, compp;
     int32_t temp;
 
-    if (rawpress == 0x800000) {
+    if (rawpress == 0x80000) {
         BMP280_LOG(ERROR, "Invalid press data\n");
         STATS_INC(g_bmp280stats, invalid_data_errors);
         return NAN;
@@ -292,14 +292,12 @@ bmp280_compensate_temperature(int32_t rawtemp, struct bmp280_pdd *pdd)
 {
     int32_t var1, var2, comptemp;
 
-    if (rawtemp == 0x800000) {
+    if (rawtemp == 0x80000) {
         BMP280_LOG(ERROR, "Invalid temp data\n");
         STATS_INC(g_bmp280stats, invalid_data_errors);
         return NAN;
     }
 
-    rawtemp >>= 4;
-
     var1 = ((((rawtemp>>3) - ((int32_t)pdd->bcd.bcd_dig_T1 <<1))) *
             ((int32_t)pdd->bcd.bcd_dig_T2)) >> 11;
 
@@ -330,7 +328,7 @@ bmp280_compensate_pressure(struct sensor_itf *itf, int32_t rawpress,
     int64_t var1, var2, p;
     int32_t temp;
 
-    if (rawpress == 0x800000) {
+    if (rawpress == 0x80000) {
         BMP280_LOG(ERROR, "Invalid pressure data\n");
         STATS_INC(g_bmp280stats, invalid_data_errors);
         return NAN;
@@ -342,8 +340,6 @@ bmp280_compensate_pressure(struct sensor_itf *itf, int32_t rawpress,
         }
     }
 
-    rawpress >>= 4;
-
     var1 = ((int64_t)pdd->t_fine) - 128000;
     var2 = var1 * var1 * (int64_t)pdd->bcd.bcd_dig_P6;
     var2 = var2 + ((int64_t)(var1*(int64_t)pdd->bcd.bcd_dig_P5) << 17);
@@ -996,13 +992,9 @@ bmp280_get_temperature(struct sensor_itf *itf, int32_t *temp)
         goto err;
     }
 
-#if MYNEWT_VAL(BMP280_SPEC_CALC)
     *temp = (int32_t)((((uint32_t)(tmp[0])) << 12) |
                       (((uint32_t)(tmp[1])) <<  4) |
                        ((uint32_t)tmp[2] >> 4));
-#else
-    *temp = ((tmp[0] << 16) | (tmp[1] << 8) | tmp[2]);
-#endif
 
     return 0;
 err:
@@ -1027,13 +1019,9 @@ bmp280_get_pressure(struct sensor_itf *itf, int32_t *press)
         goto err;
     }
 
-#if MYNEWT_VAL(BMP280_SPEC_CALC)
     *press = (int32_t)((((uint32_t)(tmp[0])) << 12) |
                       (((uint32_t)(tmp[1])) <<  4)  |
                        ((uint32_t)tmp[2] >> 4));
-#else
-    *press = ((tmp[0] << 16) | (tmp[1] << 8) | tmp[2]);
-#endif
 
     return 0;
 err:


[mynewt-core] 05/06: hw/drivers/bmp280: Fix build for bus driver

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 901dd08e42d2bf0d10b8a5450171be5338bec5cc
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Dec 7 12:27:19 2018 +0100

    hw/drivers/bmp280: Fix build for bus driver
    
    struct bmp280 did not have bus driver fields by accident.
---
 hw/drivers/sensors/bmp280/include/bmp280/bmp280.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/drivers/sensors/bmp280/include/bmp280/bmp280.h b/hw/drivers/sensors/bmp280/include/bmp280/bmp280.h
index 94d5ebe..271b6a6 100644
--- a/hw/drivers/sensors/bmp280/include/bmp280/bmp280.h
+++ b/hw/drivers/sensors/bmp280/include/bmp280/bmp280.h
@@ -102,7 +102,14 @@ struct bmp280_pdd {
 };
 
 struct bmp280 {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+    union {
+        struct bus_i2c_node i2c_node;
+        struct bus_spi_node spi_node;
+    };
+#else
     struct os_dev dev;
+#endif
     struct sensor sensor;
     struct bmp280_cfg cfg;
     struct bmp280_pdd pdd;


[mynewt-core] 01/06: bmp280/bme280: Update syscfg description

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3ade5d2c99608bb89db21482987ebf20d23f8299
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon Dec 3 15:32:14 2018 +0100

    bmp280/bme280: Update syscfg description
    
    syscfg description for BMx280_SPEC_CALC was cryptic.
    Now it explains clearly what to expect when value is changed.
    It switches between floating point and integer arithmetic used
    for compensation calculations.
---
 hw/drivers/sensors/bme280/syscfg.yml | 4 +++-
 hw/drivers/sensors/bmp280/syscfg.yml | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/drivers/sensors/bme280/syscfg.yml b/hw/drivers/sensors/bme280/syscfg.yml
index f26087e..054e890 100644
--- a/hw/drivers/sensors/bme280/syscfg.yml
+++ b/hw/drivers/sensors/bme280/syscfg.yml
@@ -34,7 +34,9 @@ syscfg.defs:
         description: 'Enable shell support for the BME280'
         value: 0
     BME280_SPEC_CALC:
-        description: 'BME280 Spec calculation insetad of built in one'
+        description:
+            When set to 1 compensation functions use double precission floating point arithmetic recomended by specification.
+            When set to 0 compensation functions use integer arithmetic.
         value : 1
     BME280_LOG_MODULE:
         description: 'Numeric module ID to use for BME280 log messages'
diff --git a/hw/drivers/sensors/bmp280/syscfg.yml b/hw/drivers/sensors/bmp280/syscfg.yml
index ca90ade..8265acd 100644
--- a/hw/drivers/sensors/bmp280/syscfg.yml
+++ b/hw/drivers/sensors/bmp280/syscfg.yml
@@ -37,7 +37,9 @@ syscfg.defs:
         description: 'Enable shell support for the BMP280'
         value: 0
     BMP280_SPEC_CALC:
-        description: 'BMP280 Spec calculation instead of built in one'
+        description:
+            When set to 1 compensation functions use double precission floating point arithmetic recomended by specification.
+            When set to 0 compensation functions use integer arithmetic.
         value : 1
     BMP280_ITF_LOCK_TMO:
         description: 'BMP280 interface lock timeout in milliseconds'


[mynewt-core] 04/06: hw/drivers/bme280: Fix integer calculation compilation

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7e05db326a8a0dbe165884d7aea58c115a855384
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Dec 7 09:47:37 2018 +0100

    hw/drivers/bme280: Fix integer calculation compilation
    
    Integer calculation build variant was outdated and would not build.
    This aligns code for double and integer computations.
---
 hw/drivers/sensors/bme280/src/bme280.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/drivers/sensors/bme280/src/bme280.c b/hw/drivers/sensors/bme280/src/bme280.c
index 1e8eda2..0570c3e 100644
--- a/hw/drivers/sensors/bme280/src/bme280.c
+++ b/hw/drivers/sensors/bme280/src/bme280.c
@@ -409,7 +409,7 @@ bme280_compensate_pressure(struct sensor_itf *itf, int32_t rawpress,
  */
 static float
 bme280_compensate_humidity(struct sensor_itf *itf, uint32_t rawhumid,
-                           struct bme280_calib_data *bcd)
+                           struct bme280_pdd *pdd)
 {
     int32_t h;
     int32_t temp;
@@ -421,13 +421,13 @@ bme280_compensate_humidity(struct sensor_itf *itf, uint32_t rawhumid,
         return NAN;
     }
 
-    if (!g_t_fine) {
-        if(!bme280_get_temperature(&temp)) {
-            (void)bme280_compensate_temperature(temp, bcd);
+    if (!pdd->t_fine) {
+        if(!bme280_get_temperature(itf, &temp)) {
+            (void)bme280_compensate_temperature(temp, pdd);
         }
     }
 
-    tmp32 = (g_t_fine - ((int32_t)76800));
+    tmp32 = (pdd->t_fine - ((int32_t)76800));
 
     tmp32 = (((((rawhumid << 14) - (((int32_t)pdd->bcd.bcd_dig_H4) << 20) -
              (((int32_t)pdd->bcd.bcd_dig_H5) * tmp32)) + ((int32_t)16384)) >> 15) *