You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/12/20 15:00:41 UTC

(nuttx) branch master updated (34a6dddb7a -> 6b3aa3b6b9)

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

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 34a6dddb7a boards/esp32s2: Increase init task stack size to 3072
     new d9455ab420 sensors: mx56xx: Fix threshold of second order compensation
     new 19ac909eea sensors: mx56xx: Fix calculation of second order compensation
     new 6b3aa3b6b9 sensors: mx56xx: Correct type of temperature

The 3 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:
 drivers/sensors/ms56xx_uorb.c | 45 ++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 20 deletions(-)


(nuttx) 03/03: sensors: mx56xx: Correct type of temperature

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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 6b3aa3b6b92591925c402d9714d7eb406168d6d9
Author: Takumi Ando <t-...@advaly.co.jp>
AuthorDate: Wed Dec 20 11:28:40 2023 +0900

    sensors: mx56xx: Correct type of temperature
    
    The "temp" variable shouldn't be used as both raw
    value and compensated.
    
    Signed-off-by: Takumi Ando <t-...@advaly.co.jp>
---
 drivers/sensors/ms56xx_uorb.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/sensors/ms56xx_uorb.c b/drivers/sensors/ms56xx_uorb.c
index 6463147742..0bb8d2507d 100644
--- a/drivers/sensors/ms56xx_uorb.c
+++ b/drivers/sensors/ms56xx_uorb.c
@@ -114,7 +114,7 @@ static int ms56xx_read24(FAR struct ms56xx_dev_s *priv,
                          FAR uint8_t *regval);
 
 static int32_t ms56xx_compensate_temp(FAR struct ms56xx_dev_s *priv,
-                                      uint32_t temp, int32_t *deltat);
+                                      uint32_t temp_raw, int32_t *deltat);
 static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
                                         uint32_t press, uint32_t dt,
                                         int32_t *temp);
@@ -257,7 +257,8 @@ static inline void baro_measure_read(FAR struct ms56xx_dev_s *priv,
                                      FAR struct sensor_baro *baro)
 {
   uint32_t press;
-  uint32_t temp;
+  uint32_t temp_raw;
+  int32_t temp;
   int32_t deltat;
   int ret;
   uint8_t buffer[3];
@@ -340,9 +341,9 @@ static inline void baro_measure_read(FAR struct ms56xx_dev_s *priv,
       return;
     }
 
-  temp = (uint32_t) buffer[0] << 16 |
-         (uint32_t) buffer[1] << 8 |
-         (uint32_t) buffer[2];
+  temp_raw = (uint32_t) buffer[0] << 16 |
+             (uint32_t) buffer[1] << 8 |
+             (uint32_t) buffer[2];
 
   /* Release the mutex */
 
@@ -350,7 +351,7 @@ static inline void baro_measure_read(FAR struct ms56xx_dev_s *priv,
 
   /* Compensate the temp/press with calibration data */
 
-  temp = ms56xx_compensate_temp(priv, temp, &deltat);
+  temp = ms56xx_compensate_temp(priv, temp_raw, &deltat);
   press = ms56xx_compensate_press(priv, press, deltat, &temp);
 
   baro->timestamp = ms56xx_curtime();
@@ -491,14 +492,15 @@ static int ms56xx_initialize(FAR struct ms56xx_dev_s *priv)
  ****************************************************************************/
 
 static int32_t ms56xx_compensate_temp(FAR struct ms56xx_dev_s *priv,
-                                      uint32_t temp, int32_t *deltat)
+                                      uint32_t temp_raw, int32_t *deltat)
 {
   struct ms56xx_calib_s *c = &priv->calib;
   int32_t dt;
+  int32_t temp;
 
   /* dt = d1 - c5 * 256 */
 
-  dt = temp - ((int32_t) c->c5 << 8);
+  dt = temp_raw - ((int32_t) c->c5 << 8);
 
   /* temp = 2000 + (dt * c6) / 8388608 */
 


(nuttx) 02/03: sensors: mx56xx: Fix calculation of second order compensation

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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 19ac909eeae202a1f45c15245165b7571916d78e
Author: Takumi Ando <t-...@advaly.co.jp>
AuthorDate: Wed Dec 20 11:11:55 2023 +0900

    sensors: mx56xx: Fix calculation of second order compensation
    
    The temperature won't be compensated correctly without this patch.
    
    Signed-off-by: Takumi Ando <t-...@advaly.co.jp>
---
 drivers/sensors/ms56xx_uorb.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/sensors/ms56xx_uorb.c b/drivers/sensors/ms56xx_uorb.c
index 1d6499dd56..6463147742 100644
--- a/drivers/sensors/ms56xx_uorb.c
+++ b/drivers/sensors/ms56xx_uorb.c
@@ -117,7 +117,7 @@ static int32_t ms56xx_compensate_temp(FAR struct ms56xx_dev_s *priv,
                                       uint32_t temp, int32_t *deltat);
 static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
                                         uint32_t press, uint32_t dt,
-                                        int32_t temp);
+                                        int32_t *temp);
 
 static unsigned long ms56xx_curtime(void);
 
@@ -351,7 +351,7 @@ static inline void baro_measure_read(FAR struct ms56xx_dev_s *priv,
   /* Compensate the temp/press with calibration data */
 
   temp = ms56xx_compensate_temp(priv, temp, &deltat);
-  press = ms56xx_compensate_press(priv, press, deltat, temp);
+  press = ms56xx_compensate_press(priv, press, deltat, &temp);
 
   baro->timestamp = ms56xx_curtime();
   baro->pressure = press / 100.0f;
@@ -527,7 +527,7 @@ static int32_t ms56xx_compensate_temp(FAR struct ms56xx_dev_s *priv,
 
 static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
                                         uint32_t press, uint32_t dt,
-                                        int32_t temp)
+                                        int32_t *temp)
 {
   struct ms56xx_calib_s *c = &priv->calib;
   int64_t off = 0;
@@ -535,6 +535,7 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
 #if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE)
   int64_t off2 = 0;
   int64_t sens2 = 0;
+  int64_t t2 = 0;
   uint64_t delta;
 #endif
 
@@ -544,20 +545,21 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
         off = ((int64_t) c->c2 << 17) + ((int64_t) (c->c4 * dt) >> 6);
         sens = ((int64_t) c->c1 << 16) + ((int64_t) (c->c3 * dt) >> 7);
 #if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE)
-        if (temp < 2000)
+        if (*temp < 2000)
           {
             /* Low temperature */
 
-            delta = temp - 2000;
+            t2 = ((dt * dt) >> 31);
+            delta = *temp - 2000;
             delta *= delta;
             off2 = (61 * delta) >> 4;
             sens2 = 2 * delta;
 
-            if (temp < -1500)
+            if (*temp < -1500)
               {
                 /* Very low temperature */
 
-                delta = temp + 1500;
+                delta = *temp + 1500;
                 delta *= delta;
                 off2 += 15 * delta;
                 sens2 += 8 * delta;
@@ -570,20 +572,21 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
         off = ((int64_t) c->c2 << 16) + ((int64_t) (c->c4 * dt) >> 7);
         sens = ((int64_t) c->c1 << 15) + ((int64_t) (c->c3 * dt) >> 8);
 #if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE)
-        if (temp < 2000)
+        if (*temp < 2000)
           {
             /* Low temperature */
 
-            delta = temp - 2000;
+            t2 = ((dt * dt) >> 31);
+            delta = *temp - 2000;
             delta *= delta;
             off2 = (5 * delta) >> 1;
             sens2 = (5 * delta) >> 2;
 
-            if (temp < -1500)
+            if (*temp < -1500)
               {
                 /* Very low temperature */
 
-                delta = temp + 1500;
+                delta = *temp + 1500;
                 delta *= delta;
                 off2 += 7 * delta;
                 sens2 += (11 * delta) >> 1;
@@ -594,7 +597,7 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
     }
 
 #if defined(CONFIG_MS56XX_SECOND_ORDER_COMPENSATE)
-  temp -= ((dt * dt) >> 31);
+  *temp -= t2;
   off -= off2;
   sens -= sens2;
 #endif


(nuttx) 01/03: sensors: mx56xx: Fix threshold of second order compensation

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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit d9455ab42057ee27de4891132b4772c643848d18
Author: Takumi Ando <t-...@advaly.co.jp>
AuthorDate: Wed Dec 20 10:49:59 2023 +0900

    sensors: mx56xx: Fix threshold of second order compensation
    
    The threshold of second order compensation at
    very low temperature is -15°C.
    
    Signed-off-by: Takumi Ando <t-...@advaly.co.jp>
---
 drivers/sensors/ms56xx_uorb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/sensors/ms56xx_uorb.c b/drivers/sensors/ms56xx_uorb.c
index 1306b426ae..1d6499dd56 100644
--- a/drivers/sensors/ms56xx_uorb.c
+++ b/drivers/sensors/ms56xx_uorb.c
@@ -553,7 +553,7 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
             off2 = (61 * delta) >> 4;
             sens2 = 2 * delta;
 
-            if (temp < 1500)
+            if (temp < -1500)
               {
                 /* Very low temperature */
 
@@ -579,7 +579,7 @@ static uint32_t ms56xx_compensate_press(FAR struct ms56xx_dev_s *priv,
             off2 = (5 * delta) >> 1;
             sens2 = (5 * delta) >> 2;
 
-            if (temp < 1500)
+            if (temp < -1500)
               {
                 /* Very low temperature */