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 2018/03/29 20:56:00 UTC
[mynewt-core] branch master updated: Add Wake Up configuration to
LIS2DW12 driver (#967)
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 19db587 Add Wake Up configuration to LIS2DW12 driver (#967)
19db587 is described below
commit 19db5877e423ba2b585bb79998a7de40b1e6b6ba
Author: matthewwarnes <36...@users.noreply.github.com>
AuthorDate: Thu Mar 29 21:55:58 2018 +0100
Add Wake Up configuration to LIS2DW12 driver (#967)
* add configuration of wake_up registers and functions to read wake_up_src, tap_src & sixd_src
* seperate out WAKE_UP_THS & WAKE_UP_DUR configuration into different functions
---
.../sensors/lis2dw12/include/lis2dw12/lis2dw12.h | 175 +++++++++-
hw/drivers/sensors/lis2dw12/src/lis2dw12.c | 374 ++++++++++++++++++++-
hw/drivers/sensors/lis2dw12/src/lis2dw12_priv.h | 15 +
hw/sensor/creator/src/sensor_creator.c | 16 +-
4 files changed, 574 insertions(+), 6 deletions(-)
diff --git a/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h b/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h
index 25b7829..931742c 100644
--- a/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h
+++ b/hw/drivers/sensors/lis2dw12/include/lis2dw12/lis2dw12.h
@@ -89,6 +89,29 @@ extern "C" {
#define LIS2DW12_INT_SRC_WU_IA 0x02
#define LIS2DW12_INT_SRC_FF_IA 0x01
+#define LIS2DW12_WAKE_UP_SRC_FF_IA 0x20
+#define LIS2DW12_WAKE_UP_SRC_SLEEP_STATE_IA 0x10
+#define LIS2DW12_WAKE_UP_SRC_WU_IA 0x08
+#define LIS2DW12_WAKE_UP_SRC_X_WU 0x04
+#define LIS2DW12_WAKE_UP_SRC_Y_WU 0x02
+#define LIS2DW12_WAKE_UP_SRC_Z_WU 0x01
+
+#define LIS2DW12_TAP_SRC_TAP_IA 0x40
+#define LIS2DW12_TAP_SRC_SINGLE_TAP 0x20
+#define LIS2DW12_TAP_SRC_DOUBLE_TAP 0x10
+#define LIS2DW12_TAP_SRC_TAP_SIGN 0x08
+#define LIS2DW12_TAP_SRC_X_TAP 0x04
+#define LIS2DW12_TAP_SRC_Y_TAP 0x02
+#define LIS2DW12_TAP_SRC_Z_TAP 0x01
+
+#define LIS2DW12_SIXD_SRC_6D_IA 0x40
+#define LIS2DW12_SIXD_SRC_ZH 0x20
+#define LIS2DW12_SIXD_SRC_ZL 0x10
+#define LIS2DW12_SIXD_SRC_YH 0x08
+#define LIS2DW12_SIXD_SRC_YL 0x04
+#define LIS2DW12_SIXD_SRC_XH 0x02
+#define LIS2DW12_SIXD_SRC_XL 0x01
+
enum lis2dw12_ths_6d {
LIS2DW12_6D_THS_80_DEG = 0,
@@ -155,14 +178,28 @@ struct lis2dw12_cfg {
uint8_t offset_weight;
uint8_t offset_en;
- struct lis2dw12_tap_settings tap_cfg;
+ uint8_t filter_bw;
+ uint8_t high_pass;
+ struct lis2dw12_tap_settings tap_cfg;
+ uint8_t double_tap_event_enable;
+
uint8_t int1_pin_cfg;
uint8_t int2_pin_cfg;
uint8_t int_enable;
enum lis2dw12_fifo_mode fifo_mode;
uint8_t fifo_threshold;
+
+ uint8_t wake_up_ths;
+ uint8_t wake_up_dur;
+ uint8_t sleep_duration;
+
+ uint8_t stationary_detection_enable;
+
+ uint8_t power_mode;
+ uint8_t inactivity_sleep_enable;
+ uint8_t low_noise_enable;
enum lis2dw12_read_mode read_mode;
uint8_t stream_read_interrupt;
@@ -465,6 +502,34 @@ int lis2dw12_clear_int(struct sensor_itf *itf, uint8_t *src);
int lis2dw12_get_int_src(struct sensor_itf *itf, uint8_t *status);
/**
+ * Get Wake Up Source
+ *
+ * @param the sensor interface
+ * @param pointer to return wake_up_src in
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_wake_up_src(struct sensor_itf *itf, uint8_t *status);
+
+/**
+ * Get Tap Source
+ *
+ * @param the sensor interface
+ * @param pointer to return tap_src in
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_tap_src(struct sensor_itf *itf, uint8_t *status);
+
+/**
+ * Get 6D Source
+ *
+ * @param the sensor interface
+ * @param pointer to return sixd_src in
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_sixd_src(struct sensor_itf *itf, uint8_t *status);
+
+
+/**
* Setup FIFO
*
* @param the sensor interface
@@ -482,6 +547,114 @@ int lis2dw12_set_fifo_cfg(struct sensor_itf *itf, enum lis2dw12_fifo_mode mode,
* @return 0 on success, non-zero on failure
*/
int lis2dw12_get_fifo_samples(struct sensor_itf *itf, uint8_t *samples);
+
+/**
+ * Set Wake Up Threshold configuration
+ *
+ * @param the sensor interface
+ * @param wake_up_ths value to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_wake_up_ths(struct sensor_itf *itf, uint8_t reg);
+
+/**
+ * Get Wake Up Threshold config
+ *
+ * @param the sensor interface
+ * @param ptr to store wake_up_ths value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_wake_up_ths(struct sensor_itf *itf, uint8_t *reg);
+
+/**
+ * Set whether sleep on inactivity is enabled
+ *
+ * @param the sensor interface
+ * @param value to set (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_inactivity_sleep_en(struct sensor_itf *itf, uint8_t en);
+
+/**
+ * Get whether sleep on inactivity is enabled
+ *
+ * @param the sensor interface
+ * @param ptr to store read state (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_inactivity_sleep_en(struct sensor_itf *itf, uint8_t *en);
+
+/**
+ * Set whether double tap event is enabled
+ *
+ * @param the sensor interface
+ * @param value to set (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_double_tap_event_en(struct sensor_itf *itf, uint8_t en);
+
+/**
+ * Get whether double tap event is enabled
+ *
+ * @param the sensor interface
+ * @param ptr to store read state (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_double_tap_event_en(struct sensor_itf *itf, uint8_t *en);
+
+/**
+ * Set Wake Up Duration
+ *
+ * @param the sensor interface
+ * @param duration to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_wake_up_dur(struct sensor_itf *itf, uint8_t reg);
+
+/**
+ * Get Wake Up Duration
+ *
+ * @param the sensor interface
+ * @param ptr to store wake_up_dur value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_wake_up_dur(struct sensor_itf *itf, uint8_t *reg);
+
+/**
+ * Set Sleep Duration
+ *
+ * @param the sensor interface
+ * @param duration to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_sleep_dur(struct sensor_itf *itf, uint8_t reg);
+
+/**
+ * Get Sleep Duration
+ *
+ * @param the sensor interface
+ * @param ptr to store sleep_dur value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_sleep_dur(struct sensor_itf *itf, uint8_t *reg);
+
+/**
+ * Set Stationary Detection Enable
+ *
+ * @param the sensor interface
+ * @param value to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_stationary_en(struct sensor_itf *itf, uint8_t en);
+
+/**
+ * Get Stationary Detection Enable
+ *
+ * @param the sensor interface
+ * @param ptr to store sleep_dur value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_stationary_en(struct sensor_itf *itf, uint8_t *en);
/**
* Run Self test on sensor
diff --git a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
index 2dd04e8..f662af0 100644
--- a/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
+++ b/hw/drivers/sensors/lis2dw12/src/lis2dw12.c
@@ -1105,6 +1105,274 @@ lis2dw12_set_int2_pin_cfg(struct sensor_itf *itf, uint8_t cfg)
}
/**
+ * Set Wake Up Threshold configuration
+ *
+ * @param the sensor interface
+ * @param wake_up_ths value to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_wake_up_ths(struct sensor_itf *itf, uint8_t val)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_THS, ®);
+ if (rc) {
+ return rc;
+ }
+
+ reg &= ~LIS2DW12_WAKE_THS_THS;
+ reg |= val & LIS2DW12_WAKE_THS_THS;
+
+ return lis2dw12_write8(itf, LIS2DW12_REG_WAKE_UP_THS, reg);
+}
+
+/**
+ * Get Wake Up Threshold config
+ *
+ * @param the sensor interface
+ * @param ptr to store wake_up_ths value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_wake_up_ths(struct sensor_itf *itf, uint8_t *val)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_THS, ®);
+ if (rc) {
+ return rc;
+ }
+
+ *val = reg & LIS2DW12_WAKE_THS_THS;
+ return 0;
+}
+
+/**
+ * Set whether sleep on inactivity is enabled
+ *
+ * @param the sensor interface
+ * @param value to set (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_inactivity_sleep_en(struct sensor_itf *itf, uint8_t en)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_THS, ®);
+ if (rc) {
+ return rc;
+ }
+
+ reg &= ~LIS2DW12_WAKE_THS_SLEEP_ON;
+ reg |= en ? LIS2DW12_WAKE_THS_SLEEP_ON : 0;
+
+ return lis2dw12_write8(itf, LIS2DW12_REG_WAKE_UP_THS, reg);
+}
+
+/**
+ * Get whether sleep on inactivity is enabled
+ *
+ * @param the sensor interface
+ * @param ptr to store read state (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_inactivity_sleep_en(struct sensor_itf *itf, uint8_t *en)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_THS, ®);
+ if (rc) {
+ return rc;
+ }
+
+ *en = (reg & LIS2DW12_WAKE_THS_SLEEP_ON) ? 1 : 0;
+ return 0;
+
+}
+
+/**
+ * Set whether double tap event is enabled
+ *
+ * @param the sensor interface
+ * @param value to set (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_double_tap_event_en(struct sensor_itf *itf, uint8_t en)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_THS, ®);
+ if (rc) {
+ return rc;
+ }
+
+ reg &= ~LIS2DW12_WAKE_THS_SINGLE_DOUBLE_TAP;
+ reg |= en ? LIS2DW12_WAKE_THS_SINGLE_DOUBLE_TAP : en;
+
+ return lis2dw12_write8(itf, LIS2DW12_REG_WAKE_UP_THS, reg);
+}
+
+/**
+ * Get whether double tap event is enabled
+ *
+ * @param the sensor interface
+ * @param ptr to store read state (0 = disabled, 1 = enabled)
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_double_tap_event_en(struct sensor_itf *itf, uint8_t *en)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_THS, ®);
+ if (rc) {
+ return rc;
+ }
+
+ *en = (reg & LIS2DW12_WAKE_THS_SINGLE_DOUBLE_TAP) ? 1 : 0;
+ return 0;
+
+}
+
+/**
+ * Set Wake Up Duration
+ *
+ * @param the sensor interface
+ * @param value to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_wake_up_dur(struct sensor_itf *itf, uint8_t val)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_DUR, ®);
+ if (rc) {
+ return rc;
+ }
+
+ reg &= ~LIS2DW12_WAKE_DUR_DUR;
+ reg |= (val & LIS2DW12_WAKE_DUR_DUR) << 5;
+
+ return lis2dw12_write8(itf, LIS2DW12_REG_WAKE_UP_DUR, reg);
+
+}
+
+/**
+ * Get Wake Up Duration
+ *
+ * @param the sensor interface
+ * @param ptr to store wake_up_dur value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_wake_up_dur(struct sensor_itf *itf, uint8_t *val)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_DUR, ®);
+ if (rc) {
+ return rc;
+ }
+
+ *val = (reg & LIS2DW12_WAKE_DUR_DUR) >> 5;
+ return 0;
+}
+
+/**
+ * Set Sleep Duration
+ *
+ * @param the sensor interface
+ * @param value to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_sleep_dur(struct sensor_itf *itf, uint8_t val)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_DUR, ®);
+ if (rc) {
+ return rc;
+ }
+
+ reg &= ~LIS2DW12_WAKE_DUR_SLEEP_DUR;
+ reg |= (val & LIS2DW12_WAKE_DUR_SLEEP_DUR);
+
+ return lis2dw12_write8(itf, LIS2DW12_REG_WAKE_UP_DUR, reg);
+}
+
+/**
+ * Get Sleep Duration
+ *
+ * @param the sensor interface
+ * @param ptr to store sleep_dur value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_sleep_dur(struct sensor_itf *itf, uint8_t *val)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_DUR, ®);
+ if (rc) {
+ return rc;
+ }
+
+ *val = reg & LIS2DW12_WAKE_DUR_SLEEP_DUR;
+ return 0;
+}
+
+/**
+ * Set Stationary Detection Enable
+ *
+ * @param the sensor interface
+ * @param value to set
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_set_stationary_en(struct sensor_itf *itf, uint8_t en)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_DUR, ®);
+ if (rc) {
+ return rc;
+ }
+
+ reg &= ~LIS2DW12_WAKE_DUR_STATIONARY;
+ reg |= en ? LIS2DW12_WAKE_DUR_STATIONARY : 0;
+
+ return lis2dw12_write8(itf, LIS2DW12_REG_WAKE_UP_DUR, reg);
+
+}
+
+/**
+ * Get Stationary Detection Enable
+ *
+ * @param the sensor interface
+ * @param ptr to store sleep_dur value
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_stationary_en(struct sensor_itf *itf, uint8_t *en)
+{
+ int rc;
+ uint8_t reg;
+
+ rc = lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_DUR, ®);
+ if (rc) {
+ return rc;
+ }
+
+ *en = (reg & LIS2DW12_WAKE_DUR_STATIONARY) ? 1 : 0;
+ return 0;
+}
+
+/**
* Clear interrupt 1
*
* @param the sensor interface
@@ -1128,6 +1396,43 @@ int lis2dw12_get_int_src(struct sensor_itf *itf, uint8_t *status)
}
/**
+ * Get Wake Up Source
+ *
+ * @param the sensor interface
+ * @param pointer to return wake_up_src in
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_wake_up_src(struct sensor_itf *itf, uint8_t *status)
+{
+ return lis2dw12_read8(itf, LIS2DW12_REG_WAKE_UP_SRC, status);
+}
+
+/**
+ * Get Tap Source
+ *
+ * @param the sensor interface
+ * @param pointer to return tap_src in
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_tap_src(struct sensor_itf *itf, uint8_t *status)
+{
+ return lis2dw12_read8(itf, LIS2DW12_REG_TAP_SRC, status);
+}
+
+/**
+ * Get 6D Source
+ *
+ * @param the sensor interface
+ * @param pointer to return sixd_src in
+ * @return 0 on success, non-zero on failure
+ */
+int lis2dw12_get_sixd_src(struct sensor_itf *itf, uint8_t *status)
+{
+ return lis2dw12_read8(itf, LIS2DW12_REG_SIXD_SRC, status);
+}
+
+
+/**
* Set whether interrupts are enabled
*
* @param the sensor interface
@@ -1682,6 +1987,7 @@ static int
lis2dw12_sensor_set_notification(struct sensor *sensor, sensor_event_type_t type)
{
struct lis2dw12 * lis2dw12;
+ struct sensor_itf *itf;
uint8_t int_cfg = 0;
struct lis2dw12_private_driver_data *pdd;
int rc;
@@ -1698,6 +2004,7 @@ lis2dw12_sensor_set_notification(struct sensor *sensor, sensor_event_type_t type
}
lis2dw12 = (struct lis2dw12 *)SENSOR_GET_DEVICE(sensor);
+ itf = SENSOR_GET_ITF(sensor);
pdd = &lis2dw12->pdd;
if (pdd->registered_mask & LIS2DW12_NOTIFY_MASK) {
@@ -1717,6 +2024,14 @@ lis2dw12_sensor_set_notification(struct sensor *sensor, sensor_event_type_t type
return rc;
}
+ /* enable double tap detection in wake_up_ths */
+ if(type == SENSOR_EVENT_TYPE_DOUBLE_TAP) {
+ rc = lis2dw12_set_double_tap_event_en(itf, 1);
+ if (rc) {
+ return rc;
+ }
+ }
+
pdd->notify_ctx.snec_evtype |= type;
pdd->registered_mask |= LIS2DW12_NOTIFY_MASK;
@@ -1737,6 +2052,8 @@ static int
lis2dw12_sensor_unset_notification(struct sensor *sensor, sensor_event_type_t type)
{
struct lis2dw12 * lis2dw12;
+ struct sensor_itf *itf;
+ int rc;
if ((type & ~(SENSOR_EVENT_TYPE_DOUBLE_TAP |
SENSOR_EVENT_TYPE_SINGLE_TAP)) != 0) {
@@ -1750,9 +2067,15 @@ lis2dw12_sensor_unset_notification(struct sensor *sensor, sensor_event_type_t ty
}
lis2dw12 = (struct lis2dw12 *)SENSOR_GET_DEVICE(sensor);
-
+ itf = SENSOR_GET_ITF(sensor);
+
lis2dw12->pdd.notify_ctx.snec_evtype &= ~type;
lis2dw12->pdd.registered_mask &= ~LIS2DW12_NOTIFY_MASK;
+
+ rc = lis2dw12_set_double_tap_event_en(itf, lis2dw12->cfg.double_tap_event_enable);
+ if (rc) {
+ return rc;
+ }
return disable_interrupt(sensor, 0);
}
@@ -1986,11 +2309,14 @@ lis2dw12_config(struct lis2dw12 *lis2dw12, struct lis2dw12_cfg *cfg)
lis2dw12->cfg.offset_en = cfg->offset_en;
- rc = lis2dw12_set_filter_cfg(itf, LIS2DW12_FILTER_BW_ODR_DIV_2, 0);
+ rc = lis2dw12_set_filter_cfg(itf, cfg->filter_bw, cfg->high_pass);
if (rc) {
goto err;
}
+ lis2dw12->cfg.filter_bw = cfg->filter_bw;
+ lis2dw12->cfg.high_pass = cfg->high_pass;
+
rc = lis2dw12_set_full_scale(itf, cfg->fs);
if (rc) {
goto err;
@@ -2010,16 +2336,20 @@ lis2dw12_config(struct lis2dw12 *lis2dw12, struct lis2dw12_cfg *cfg)
goto err;
}
- rc = lis2dw12_set_power_mode(itf, LIS2DW12_PM_HIGH_PERF);
+ rc = lis2dw12_set_power_mode(itf, cfg->power_mode);
if (rc) {
goto err;
}
- rc = lis2dw12_set_low_noise(itf, 1);
+ lis2dw12->cfg.power_mode = cfg->power_mode;
+
+ rc = lis2dw12_set_low_noise(itf, cfg->low_noise_enable);
if (rc) {
goto err;
}
+ lis2dw12->cfg.low_noise_enable = cfg->low_noise_enable;
+
rc = lis2dw12_set_fifo_cfg(itf, cfg->fifo_mode, cfg->fifo_threshold);
if (rc) {
goto err;
@@ -2027,6 +2357,42 @@ lis2dw12_config(struct lis2dw12 *lis2dw12, struct lis2dw12_cfg *cfg)
lis2dw12->cfg.fifo_mode = cfg->fifo_mode;
lis2dw12->cfg.fifo_threshold = cfg->fifo_threshold;
+
+ rc = lis2dw12_set_wake_up_ths(itf, cfg->wake_up_ths);
+ if (rc) {
+ goto err;
+ }
+ lis2dw12->cfg.wake_up_ths = cfg->wake_up_ths;
+
+ rc = lis2dw12_set_wake_up_dur(itf, cfg->wake_up_dur);
+ if (rc) {
+ goto err;
+ }
+ lis2dw12->cfg.wake_up_dur = cfg->wake_up_dur;
+
+ rc = lis2dw12_set_sleep_dur(itf, cfg->sleep_duration);
+ if (rc) {
+ goto err;
+ }
+ lis2dw12->cfg.sleep_duration = cfg->sleep_duration;
+
+ rc = lis2dw12_set_stationary_en(itf, cfg->stationary_detection_enable);
+ if (rc) {
+ goto err;
+ }
+ lis2dw12->cfg.stationary_detection_enable = cfg->stationary_detection_enable;
+
+ rc = lis2dw12_set_inactivity_sleep_en(itf, cfg->inactivity_sleep_enable);
+ if (rc) {
+ goto err;
+ }
+ lis2dw12->cfg.inactivity_sleep_enable = cfg->inactivity_sleep_enable;
+
+ rc = lis2dw12_set_double_tap_event_en(itf, cfg->double_tap_event_enable);
+ if (rc) {
+ goto err;
+ }
+ lis2dw12->cfg.double_tap_event_enable = cfg->double_tap_event_enable;
rc = lis2dw12_set_int_enable(itf, cfg->int_enable);
if (rc) {
diff --git a/hw/drivers/sensors/lis2dw12/src/lis2dw12_priv.h b/hw/drivers/sensors/lis2dw12/src/lis2dw12_priv.h
index 157112e..95760a0 100644
--- a/hw/drivers/sensors/lis2dw12/src/lis2dw12_priv.h
+++ b/hw/drivers/sensors/lis2dw12/src/lis2dw12_priv.h
@@ -111,10 +111,25 @@ extern "C" {
#define LIS2DW12_INT_DUR_QUIET (0x3 << 2)
#define LIS2DW12_INT_DUR_SHOCK (0x3 << 0)
+#define LIS2DW12_REG_WAKE_UP_THS 0x34
+#define LIS2DW12_WAKE_THS_SINGLE_DOUBLE_TAP 0x80
+#define LIS2DW12_WAKE_THS_SLEEP_ON 0x40
+#define LIS2DW12_WAKE_THS_THS 0x3F
+
+#define LIS2DW12_REG_WAKE_UP_DUR 0x35
+#define LIS2DW12_WAKE_DUR_FF_DUR 0x80
+#define LIS2DW12_WAKE_DUR_DUR 0x60
+#define LIS2DW12_WAKE_DUR_STATIONARY 0x10
+#define LIS2DW12_WAKE_DUR_SLEEP_DUR 0x0F
+
#define LIS2DW12_REG_FREEFALL 0x36
#define LIS2DW12_FREEFALL_DUR (0x1F << 3)
#define LIS2DW12_FREEFALL_THS (0x7 << 0)
+#define LIS2DW12_REG_WAKE_UP_SRC 0x38
+#define LIS2DW12_REG_TAP_SRC 0x39
+#define LIS2DW12_REG_SIXD_SRC 0x3A
+
#define LIS2DW12_REG_INT_SRC 0x3B
#define LIS2DW12_REG_X_OFS 0x3C
diff --git a/hw/sensor/creator/src/sensor_creator.c b/hw/sensor/creator/src/sensor_creator.c
index 40e3939..ab0619c 100644
--- a/hw/sensor/creator/src/sensor_creator.c
+++ b/hw/sensor/creator/src/sensor_creator.c
@@ -706,6 +706,9 @@ config_lis2dw12_sensor(void)
cfg.offset_weight = 0;
cfg.offset_en = 0;
+ cfg.filter_bw = LIS2DW12_FILTER_BW_ODR_DIV_2;
+ cfg.high_pass = 0;
+
cfg.tap_cfg.en_x = 1;
cfg.tap_cfg.en_y = 1;
cfg.tap_cfg.en_z = 1;
@@ -718,7 +721,8 @@ config_lis2dw12_sensor(void)
cfg.tap_cfg.latency = 8; /* 640ms */
cfg.tap_cfg.quiet = 0; /* 10ms */
cfg.tap_cfg.shock = 3; /* 120ms */
-
+ cfg.double_tap_event_enable = 0;
+
cfg.int1_pin_cfg = 0;
cfg.int2_pin_cfg = 0;
cfg.int_enable = 0;
@@ -726,6 +730,16 @@ config_lis2dw12_sensor(void)
cfg.fifo_mode = LIS2DW12_FIFO_M_BYPASS;
cfg.fifo_threshold = 32;
cfg.stream_read_interrupt = LIS2DW12_INT1_CFG_DRDY;
+
+ cfg.wake_up_ths = 0;
+ cfg.wake_up_dur = 0;
+ cfg.sleep_duration = 0;
+
+ cfg.stationary_detection_enable = 0;
+
+ cfg.power_mode = LIS2DW12_PM_HIGH_PERF;
+ cfg.inactivity_sleep_enable = 0;
+ cfg.low_noise_enable = 1;
cfg.read_mode = LIS2DW12_READ_M_POLL;
cfg.mask = SENSOR_TYPE_ACCELEROMETER;
--
To stop receiving notification emails like this one, please contact
vipulrahane@apache.org.