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/20 08:59:47 UTC

[mynewt-core] branch master updated (1b251c5 -> cfa2cd0)

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 1b251c5  hw/drivers/bq27z561: Remove double precision constant
     new 1e1aaee  hw/drivers/ls33[t]hw: Fix floating point constants
     new cfa2cd0  hw/drivers/lps33[t]hw: Simplify 24 to 32 bits conversion

The 2 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/lps33hw/src/lps33hw.c   | 11 +++--------
 hw/drivers/sensors/lps33thw/src/lps33thw.c | 11 +++--------
 2 files changed, 6 insertions(+), 16 deletions(-)


[mynewt-core] 01/02: hw/drivers/ls33[t]hw: Fix floating point constants

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 1e1aaee31c107c12b10db6345eaf2193bb5ed13f
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Tue Dec 18 16:16:18 2018 +0100

    hw/drivers/ls33[t]hw: Fix floating point constants
    
    Constant needed for temperature and pressure conversion did not
    have f suffix resultine in double computation and later
    conversion to single precision.
    In case of hardware that only supports single precision performance
    penalty was taken in speed and code size.
---
 hw/drivers/sensors/lps33hw/src/lps33hw.c   | 4 ++--
 hw/drivers/sensors/lps33thw/src/lps33thw.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/drivers/sensors/lps33hw/src/lps33hw.c b/hw/drivers/sensors/lps33hw/src/lps33hw.c
index d215b36..5eebf6e 100644
--- a/hw/drivers/sensors/lps33hw/src/lps33hw.c
+++ b/hw/drivers/sensors/lps33hw/src/lps33hw.c
@@ -67,8 +67,8 @@ STATS_SECT_DECL(lps33hw_stat_section) g_lps33hwstats;
 #define LPS33HW_LOG(lvl_, ...) \
     MODLOG_ ## lvl_(MYNEWT_VAL(LPS33HW_LOG_MODULE), __VA_ARGS__)
 
-#define LPS33HW_PRESS_OUT_DIV (40.96)
-#define LPS33HW_TEMP_OUT_DIV (100.0)
+#define LPS33HW_PRESS_OUT_DIV (40.96f)
+#define LPS33HW_TEMP_OUT_DIV (100.0f)
 #define LPS33HW_PRESS_THRESH_DIV (16)
 
 /* Exports for the sensor API */
diff --git a/hw/drivers/sensors/lps33thw/src/lps33thw.c b/hw/drivers/sensors/lps33thw/src/lps33thw.c
index eaab21a..b136ae6 100644
--- a/hw/drivers/sensors/lps33thw/src/lps33thw.c
+++ b/hw/drivers/sensors/lps33thw/src/lps33thw.c
@@ -67,8 +67,8 @@ STATS_SECT_DECL(lps33thw_stat_section) g_lps33thwstats;
 #define LPS33THW_LOG(lvl_, ...) \
     MODLOG_ ## lvl_(MYNEWT_VAL(LPS33THW_LOG_MODULE), __VA_ARGS__)
 
-#define LPS33THW_PRESS_OUT_DIV (40.96)
-#define LPS33THW_TEMP_OUT_DIV (100.0)
+#define LPS33THW_PRESS_OUT_DIV (40.96f)
+#define LPS33THW_TEMP_OUT_DIV (100.0f)
 #define LPS33THW_PRESS_THRESH_DIV (16)
 
 /* Exports for the sensor API */


[mynewt-core] 02/02: hw/drivers/lps33[t]hw: Simplify 24 to 32 bits conversion

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 cfa2cd0b7bc8ea702c47a09863f834d63c81a45f
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Tue Dec 18 16:21:42 2018 +0100

    hw/drivers/lps33[t]hw: Simplify 24 to 32 bits conversion
    
    Casting used for creating int value from uin8_t array resulted
    in non optimal code that required additional manual sign extension.
    If work is left to compiler instead code is more compact.
---
 hw/drivers/sensors/lps33hw/src/lps33hw.c   | 7 +------
 hw/drivers/sensors/lps33thw/src/lps33thw.c | 7 +------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/hw/drivers/sensors/lps33hw/src/lps33hw.c b/hw/drivers/sensors/lps33hw/src/lps33hw.c
index 5eebf6e..a55a7a6 100644
--- a/hw/drivers/sensors/lps33hw/src/lps33hw.c
+++ b/hw/drivers/sensors/lps33hw/src/lps33hw.c
@@ -510,12 +510,7 @@ lps33hw_get_pressure_regs(struct sensor_itf *itf, uint8_t reg, float *pressure)
         return rc;
     }
 
-    int_press = (((int32_t)payload[2] << 16) |
-        ((int32_t)payload[1] << 8) | payload[0]);
-
-    if (int_press & 0x00800000) {
-        int_press |= 0xff000000;
-    }
+    int_press = (((int8_t)payload[2] << 16) | (payload[1] << 8) | payload[0]);
 
     *pressure = lps33hw_reg_to_pa(int_press);
 
diff --git a/hw/drivers/sensors/lps33thw/src/lps33thw.c b/hw/drivers/sensors/lps33thw/src/lps33thw.c
index b136ae6..a7347a7 100644
--- a/hw/drivers/sensors/lps33thw/src/lps33thw.c
+++ b/hw/drivers/sensors/lps33thw/src/lps33thw.c
@@ -517,12 +517,7 @@ lps33thw_get_pressure_regs(struct sensor_itf *itf, uint8_t reg, float *pressure)
         return rc;
     }
 
-    int_press = (((int32_t)payload[2] << 16) |
-        ((int32_t)payload[1] << 8) | payload[0]);
-
-    if (int_press & 0x00800000) {
-        int_press |= 0xff000000;
-    }
+    int_press = ((int8_t)payload[2] << 16) | (payload[1] << 8) | payload[0];
 
     *pressure = lps33thw_reg_to_pa(int_press);