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/04/26 05:30:32 UTC
[mynewt-core] branch master updated: LIS2DW12 Self Test (#1780)
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 20d9a44 LIS2DW12 Self Test (#1780)
20d9a44 is described below
commit 20d9a445828c943e931957d89f8eba5c0a1c418e
Author: brolan-juul <33...@users.noreply.github.com>
AuthorDate: Thu Apr 25 22:30:27 2019 -0700
LIS2DW12 Self Test (#1780)
* Updating LIS2DH12 self test to report back individual axis.
* Updated to not use defined enums.
* Added new function as to not break any current functionality.
* Results now are bit masked in a single integer value.
---
hw/drivers/sensors/lis2dh12/include/lis2dh12/lis2dh12.h | 12 ++++++++++--
hw/drivers/sensors/lis2dh12/src/lis2dh12.c | 4 ++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/hw/drivers/sensors/lis2dh12/include/lis2dh12/lis2dh12.h b/hw/drivers/sensors/lis2dh12/include/lis2dh12/lis2dh12.h
index 987ee1e..52c5a5c 100644
--- a/hw/drivers/sensors/lis2dh12/include/lis2dh12/lis2dh12.h
+++ b/hw/drivers/sensors/lis2dh12/include/lis2dh12/lis2dh12.h
@@ -233,6 +233,13 @@ struct lis2dh12_cfg {
sensor_type_t lc_s_mask;
};
+enum lis2dh12_axis {
+ LIS2DH12_AXIS_X = 0,
+ LIS2DH12_AXIS_Y,
+ LIS2DH12_AXIS_Z,
+ LIS2DH12_AXIS_MAX
+};
+
/* Used to track interrupt state to wake any present waiters */
struct lis2dh12_int {
/* Synchronize access to this structure */
@@ -640,12 +647,13 @@ int
lis2dh12_get_fifo_samples(struct sensor_itf *itf, uint8_t *samples);
/**
- * Run Self test on sensor
+ * Run Self test on sensor to see if any axis has an error
*
* Self test sequence as described in lis2dh12 application note AN5005.
*
* @param the sensor interface
- * @param pointer to return test result in (0 on pass, non-zero on failure)
+ * @param pointer to return test result in (0 on pass, 0x1 Failure on X-Axis,
+ 0x2 Failure on Y-Axis, 0x4 Failure on Z-Axis)
*
* @return 0 on sucess, non-zero on failure
*/
diff --git a/hw/drivers/sensors/lis2dh12/src/lis2dh12.c b/hw/drivers/sensors/lis2dh12/src/lis2dh12.c
index 67ad320..a235a56 100644
--- a/hw/drivers/sensors/lis2dh12/src/lis2dh12.c
+++ b/hw/drivers/sensors/lis2dh12/src/lis2dh12.c
@@ -1642,10 +1642,10 @@ int lis2dh12_run_self_test(struct sensor_itf *itf, int *result)
/* |Min(ST_X)| <=|OUTX_AVG_ST - OUTX_AVG_NO_ST| <= |Max(ST_X)| */
/* Compare values to thresholds */
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < LIS2DH12_AXIS_MAX; i++) {
diff = abs(st[i] - no_st[i]);
if (diff < LIS2DH12_ST_MIN || diff > LIS2DH12_ST_MAX) {
- *result -= 1;
+ *result |= 1 << i;
}
}
end: