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 2019/01/02 09:48:04 UTC

[mynewt-core] 01/02: hw/drivers/lis2dw12: Adjust coding style

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 9218c05d0712ed13e7a903741e595fe1242dc14c
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Dec 13 12:53:49 2018 +0100

    hw/drivers/lis2dw12: Adjust coding style
    
    C++ comments changed to C style.
    White space changes.
    Variable declarations put before code.
    
    No functional changes.
---
 hw/drivers/sensors/lis2dw12/src/lis2dw12.c | 64 ++++++++++++++++--------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
index c25df42..359455a 100644
--- a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
+++ b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
@@ -2061,9 +2061,13 @@ int lis2dw12_run_self_test(struct sensor_itf *itf, int *result)
     int32_t scratch[3] = {0,0,0};
     int i;
     uint8_t prev_config[6];
-    *result = 0;
-    uint8_t config[6] = { LIS2DW12_DATA_RATE_50HZ | LIS2DW12_PM_HIGH_PERF, LIS2DW12_CTRL_REG2_IF_ADD_INC | LIS2DW12_CTRL_REG2_BDU, 0x00, 0x00, 0x00, LIS2DW12_FS_4G};
+    uint8_t config[6] = { LIS2DW12_DATA_RATE_50HZ | LIS2DW12_PM_HIGH_PERF,
+                          LIS2DW12_CTRL_REG2_IF_ADD_INC | LIS2DW12_CTRL_REG2_BDU,
+                          0x00, 0x00, 0x00, LIS2DW12_FS_4G};
     uint8_t fs;
+    int16_t diff;
+
+    *result = 0;
 
     rc = lis2dw12_readlen(itf, LIS2DW12_REG_CTRL_REG1, prev_config, 6);
     if (rc) {
@@ -2088,21 +2092,21 @@ int lis2dw12_run_self_test(struct sensor_itf *itf, int *result)
         return rc;
     }
 
-    //discard
+    /* discard */
     //TODO poll DRDY in STATUS (27h) instead?
-    rc = lis2dw12_get_data(itf, fs, &(data[0]), &(data[1]), &(data[2]));
+    rc = lis2dw12_get_data(itf, fs, &data[0], &data[1], &data[2]);
     if (rc) {
         return rc;
     }
 
     /* take no st offset reading */
-    for(i=0; i<LIS2DW12_ST_NUM_READINGS; i++) {
+    for (i = 0; i < LIS2DW12_ST_NUM_READINGS; i++) {
 
         // TODO poll DRDY in STATUS (27h) instead?
         /* wait at least 20 ms */
         os_time_delay(OS_TICKS_PER_SEC / 50 + 1);
 
-        rc = lis2dw12_get_data(itf, fs, &(data[0]), &(data[1]), &(data[2]));
+        rc = lis2dw12_get_data(itf, fs, &data[0], &data[1], &data[2]);
         if (rc) {
             return rc;
         }
@@ -2111,12 +2115,12 @@ int lis2dw12_run_self_test(struct sensor_itf *itf, int *result)
         scratch[2] += data[2];
     }
 
-    //average
-    no_st[0] = scratch[0]/LIS2DW12_ST_NUM_READINGS;
-    no_st[1] = scratch[1]/LIS2DW12_ST_NUM_READINGS;
-    no_st[2] = scratch[2]/LIS2DW12_ST_NUM_READINGS;
+    /* average */
+    no_st[0] = scratch[0] / LIS2DW12_ST_NUM_READINGS;
+    no_st[1] = scratch[1] / LIS2DW12_ST_NUM_READINGS;
+    no_st[2] = scratch[2] / LIS2DW12_ST_NUM_READINGS;
 
-    //clean scratch
+    /* clean scratch */
     memset(&scratch, 0, sizeof scratch);
 
     /* go into self test mode 1 */
@@ -2128,21 +2132,21 @@ int lis2dw12_run_self_test(struct sensor_itf *itf, int *result)
     /* wait 200ms */
     os_time_delay(OS_TICKS_PER_SEC / 5 + 1);
 
-    //discard
+    /* discard */
     //TODO poll DRDY in STATUS (27h) instead?
-    rc = lis2dw12_get_data(itf, fs, &(data[0]), &(data[1]), &(data[2]));
+    rc = lis2dw12_get_data(itf, fs, &data[0], &data[1], &data[2]);
     if (rc) {
         return rc;
     }
 
     /* take positive offset reading */
-    for(i=0; i<LIS2DW12_ST_NUM_READINGS; i++) {
+    for (i = 0; i < LIS2DW12_ST_NUM_READINGS; i++) {
 
         // TODO poll DRDY in STATUS (27h) instead?
         /* wait at least 20 ms */
         os_time_delay(OS_TICKS_PER_SEC / 50 + 1);
 
-        rc = lis2dw12_get_data(itf, fs, &(data[0]), &(data[1]), &(data[2]));
+        rc = lis2dw12_get_data(itf, fs, &data[0], &data[1], &data[2]);
         if (rc) {
             return rc;
         }
@@ -2151,15 +2155,15 @@ int lis2dw12_run_self_test(struct sensor_itf *itf, int *result)
         scratch[2] += data[2];
     }
 
-    //average
-    st[0] = scratch[0]/LIS2DW12_ST_NUM_READINGS;
-    st[1] = scratch[1]/LIS2DW12_ST_NUM_READINGS;
-    st[2] = scratch[2]/LIS2DW12_ST_NUM_READINGS;
+    /* average */
+    st[0] = scratch[0] / LIS2DW12_ST_NUM_READINGS;
+    st[1] = scratch[1] / LIS2DW12_ST_NUM_READINGS;
+    st[2] = scratch[2] / LIS2DW12_ST_NUM_READINGS;
 
-    //clean scratch
+    /* clean scratch */
     memset(&scratch, 0, sizeof scratch);
 
-    // |Min(ST_X)| <=|OUTX_AVG_ST - OUTX_AVG_NO_ST| <= |Max(ST_X)|
+    /* |Min(ST_X)| <=|OUTX_AVG_ST - OUTX_AVG_NO_ST| <= |Max(ST_X)| */
     /* compare values to thresholds */
     for (i = 0; i < 3; i++) {
         int16_t diff = abs(st[i] - no_st[i]);
@@ -2177,20 +2181,20 @@ int lis2dw12_run_self_test(struct sensor_itf *itf, int *result)
     /* wait 200ms */
     os_time_delay(OS_TICKS_PER_SEC / 5 + 1);
 
-    //discard
-    rc = lis2dw12_get_data(itf, fs, &(data[0]), &(data[1]), &(data[2]));
+    /* discard */
+    rc = lis2dw12_get_data(itf, fs, &data[0], &data[1], &data[2]);
     if (rc) {
         return rc;
     }
 
     /* take negative offset reading */
-    for(i=0; i<LIS2DW12_ST_NUM_READINGS; i++) {
+    for ( i = 0; i < LIS2DW12_ST_NUM_READINGS; i++) {
 
         // TODO poll DRDY in STATUS (27h) instead?
         /* wait at least 20 ms */
         os_time_delay(OS_TICKS_PER_SEC / 50 + 1);
 
-        rc = lis2dw12_get_data(itf, fs, &(data[0]), &(data[1]), &(data[2]));
+        rc = lis2dw12_get_data(itf, fs, &data[0], &data[1], &data[2]);
         if (rc) {
             return rc;
         }
@@ -2199,14 +2203,14 @@ int lis2dw12_run_self_test(struct sensor_itf *itf, int *result)
         scratch[2] += data[2];
     }
 
-    //average
-    st[0] = scratch[0]/LIS2DW12_ST_NUM_READINGS;
-    st[1] = scratch[1]/LIS2DW12_ST_NUM_READINGS;
-    st[2] = scratch[2]/LIS2DW12_ST_NUM_READINGS;
+    /* average */
+    st[0] = scratch[0] / LIS2DW12_ST_NUM_READINGS;
+    st[1] = scratch[1] / LIS2DW12_ST_NUM_READINGS;
+    st[2] = scratch[2] / LIS2DW12_ST_NUM_READINGS;
 
     /* compare values to thresholds */
     for (i = 0; i < 3; i++) {
-        int16_t diff = abs(st[i] - no_st[i]);
+        diff = abs(st[i] - no_st[i]);
         if (diff < LIS2DW12_ST_MIN || diff > LIS2DW12_ST_MAX) {
             *result -= 1;
         }