drivers/sensor: lis2dw12: Move trigger pulse Kconfig property into DT
Move lis2dw12 trigger pulse configurations from Kconfigs to Device Tree. Moreover the dts properties have been renamed as 'tap', which sounds a better name to immediately catch the feature behind it. Since tap threshold cannot be zero, this value (which is the default in dts binding) is used to enable/disable the device feature per each axis. The event can be generated on INT1 only. Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
parent
8609733e76
commit
56ce558094
5 changed files with 181 additions and 174 deletions
|
@ -52,93 +52,10 @@ config LIS2DW12_THREAD_STACK_SIZE
|
||||||
help
|
help
|
||||||
Stack size of thread used by the driver to handle interrupts.
|
Stack size of thread used by the driver to handle interrupts.
|
||||||
|
|
||||||
menuconfig LIS2DW12_PULSE
|
config LIS2DW12_TAP
|
||||||
bool "Pulse detection"
|
bool "Tap and Tap-Tap detection"
|
||||||
help
|
help
|
||||||
Enable pulse (single/double tap) detection
|
Enable tap (single/double) detection
|
||||||
|
|
||||||
if LIS2DW12_PULSE
|
|
||||||
|
|
||||||
choice
|
|
||||||
prompt "Pulse interrupt source"
|
|
||||||
default LIS2DW12_ONLY_SINGLE
|
|
||||||
|
|
||||||
config LIS2DW12_ONLY_SINGLE
|
|
||||||
bool "single"
|
|
||||||
|
|
||||||
config LIS2DW12_SINGLE_DOUBLE
|
|
||||||
bool "single/double"
|
|
||||||
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_THSX
|
|
||||||
hex "Pulse X-axis threshold"
|
|
||||||
range 0 0x1F
|
|
||||||
default 0x0E
|
|
||||||
help
|
|
||||||
Threshold to start the pulse-event detection procedure on the X-axis.
|
|
||||||
Threshold values for each axis are unsigned 5-bit corresponding
|
|
||||||
to an 2g acceleration full-scale range.
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_THSY
|
|
||||||
hex "Pulse Y-axis threshold"
|
|
||||||
range 0 0x1F
|
|
||||||
default 0x0E
|
|
||||||
help
|
|
||||||
Threshold to start the pulse-event detection procedure on the Y-axis.
|
|
||||||
Threshold values for each axis are unsigned 5-bit corresponding
|
|
||||||
to an 2g acceleration full-scale range.
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_THSZ
|
|
||||||
hex "Pulse Z-axis threshold"
|
|
||||||
range 0 0x1F
|
|
||||||
default 0x0E
|
|
||||||
help
|
|
||||||
Threshold to start the pulse-event detection procedure on the Z-axis.
|
|
||||||
Threshold values for each axis are unsigned 5-bit corresponding
|
|
||||||
to an 2g acceleration full-scale range.
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_X
|
|
||||||
bool "Enable X axis for pulse"
|
|
||||||
default y
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_Y
|
|
||||||
bool "Enable Y axis for pulse"
|
|
||||||
default y
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_Z
|
|
||||||
bool "Enable Z axis for pulse"
|
|
||||||
default y
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_SHOCK
|
|
||||||
hex "Shock value"
|
|
||||||
range 0 0x03
|
|
||||||
default 0x00
|
|
||||||
help
|
|
||||||
Maximum duration of over-threshold event: this register represents
|
|
||||||
the maximum time of an over-threshold signal detection to be
|
|
||||||
recognized as a tap event. Where 0 equals 4*1/ODR and 1LSB = 8*1/ODR.
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_LTNCY
|
|
||||||
hex "Latency value"
|
|
||||||
range 0 0x0F
|
|
||||||
default 0x05
|
|
||||||
help
|
|
||||||
When double-tap recognition is enabled, this register expresses
|
|
||||||
the maximum time between two successive detected taps to
|
|
||||||
determine a double-tap event. Where 0 equals 16*1/ODR and
|
|
||||||
1LSB = 32*1/ODR.
|
|
||||||
|
|
||||||
config LIS2DW12_PULSE_QUIET
|
|
||||||
hex "Quiet value"
|
|
||||||
range 0 0x03
|
|
||||||
default 0x00
|
|
||||||
help
|
|
||||||
Expected quiet time after a tap detection: this register represents
|
|
||||||
the time after the first detected tap in which there must not be
|
|
||||||
any overthreshold event. Where 0 equals 2*1/ODR and 1LSB = 4*1/ODR.
|
|
||||||
|
|
||||||
endif # LIS2DW12_PULSE
|
|
||||||
|
|
||||||
endif # LIS2DW12_TRIGGER
|
endif # LIS2DW12_TRIGGER
|
||||||
|
|
||||||
|
|
|
@ -311,64 +311,6 @@ static int lis2dw12_init(const struct device *dev)
|
||||||
LOG_ERR("Failed to initialize interrupts");
|
LOG_ERR("Failed to initialize interrupts");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
|
||||||
if (lis2dw12_tap_mode_set(lis2dw12->ctx, cfg->pulse_trigger) < 0) {
|
|
||||||
LOG_ERR("Failed to select pulse trigger mode");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_threshold_x_set(lis2dw12->ctx,
|
|
||||||
cfg->pulse_ths[0]) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap X axis threshold");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_threshold_y_set(lis2dw12->ctx,
|
|
||||||
cfg->pulse_ths[1]) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap Y axis threshold");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_threshold_z_set(lis2dw12->ctx,
|
|
||||||
cfg->pulse_ths[2]) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap Z axis threshold");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_detection_on_x_set(lis2dw12->ctx,
|
|
||||||
CONFIG_LIS2DW12_PULSE_X) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap detection on X axis");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_detection_on_y_set(lis2dw12->ctx,
|
|
||||||
CONFIG_LIS2DW12_PULSE_Y) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap detection on Y axis");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_detection_on_z_set(lis2dw12->ctx,
|
|
||||||
CONFIG_LIS2DW12_PULSE_Z) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap detection on Z axis");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_shock_set(lis2dw12->ctx, cfg->pulse_shock) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap shock duration");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_dur_set(lis2dw12->ctx, cfg->pulse_ltncy) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap latency");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lis2dw12_tap_quiet_set(lis2dw12->ctx, cfg->pulse_quiet) < 0) {
|
|
||||||
LOG_ERR("Failed to set tap quiet time");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
|
||||||
#endif /* CONFIG_LIS2DW12_TRIGGER */
|
#endif /* CONFIG_LIS2DW12_TRIGGER */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -381,19 +323,13 @@ const struct lis2dw12_device_config lis2dw12_cfg = {
|
||||||
.gpio_int = GPIO_DT_SPEC_INST_GET_OR(0, irq_gpios, {0}),
|
.gpio_int = GPIO_DT_SPEC_INST_GET_OR(0, irq_gpios, {0}),
|
||||||
.int_pin = DT_INST_PROP(0, int_pin),
|
.int_pin = DT_INST_PROP(0, int_pin),
|
||||||
|
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
#if defined(CONFIG_LIS2DW12_ONLY_SINGLE)
|
.tap_mode = DT_INST_PROP(0, tap_mode),
|
||||||
.pulse_trigger = LIS2DW12_ONLY_SINGLE,
|
.tap_threshold = DT_INST_PROP(0, tap_threshold),
|
||||||
#elif defined(CONFIG_LIS2DW12_SINGLE_DOUBLE)
|
.tap_shock = DT_INST_PROP(0, tap_shock),
|
||||||
.pulse_trigger = LIS2DW12_BOTH_SINGLE_DOUBLE,
|
.tap_latency = DT_INST_PROP(0, tap_latency),
|
||||||
#endif
|
.tap_quiet = DT_INST_PROP(0, tap_quiet),
|
||||||
.pulse_ths[0] = CONFIG_LIS2DW12_PULSE_THSX,
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
.pulse_ths[1] = CONFIG_LIS2DW12_PULSE_THSY,
|
|
||||||
.pulse_ths[2] = CONFIG_LIS2DW12_PULSE_THSZ,
|
|
||||||
.pulse_shock = CONFIG_LIS2DW12_PULSE_SHOCK,
|
|
||||||
.pulse_ltncy = CONFIG_LIS2DW12_PULSE_LTNCY,
|
|
||||||
.pulse_quiet = CONFIG_LIS2DW12_PULSE_QUIET,
|
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
|
||||||
#endif /* CONFIG_LIS2DW12_TRIGGER */
|
#endif /* CONFIG_LIS2DW12_TRIGGER */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -85,13 +85,13 @@ struct lis2dw12_device_config {
|
||||||
#ifdef CONFIG_LIS2DW12_TRIGGER
|
#ifdef CONFIG_LIS2DW12_TRIGGER
|
||||||
struct gpio_dt_spec gpio_int;
|
struct gpio_dt_spec gpio_int;
|
||||||
uint8_t int_pin;
|
uint8_t int_pin;
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
uint8_t pulse_trigger;
|
uint8_t tap_mode;
|
||||||
uint8_t pulse_ths[3];
|
uint8_t tap_threshold[3];
|
||||||
uint8_t pulse_shock;
|
uint8_t tap_shock;
|
||||||
uint8_t pulse_ltncy;
|
uint8_t tap_latency;
|
||||||
uint8_t pulse_quiet;
|
uint8_t tap_quiet;
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
#endif /* CONFIG_LIS2DW12_TRIGGER */
|
#endif /* CONFIG_LIS2DW12_TRIGGER */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,10 +112,10 @@ struct lis2dw12_data {
|
||||||
|
|
||||||
struct gpio_callback gpio_cb;
|
struct gpio_callback gpio_cb;
|
||||||
sensor_trigger_handler_t drdy_handler;
|
sensor_trigger_handler_t drdy_handler;
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
sensor_trigger_handler_t tap_handler;
|
sensor_trigger_handler_t tap_handler;
|
||||||
sensor_trigger_handler_t double_tap_handler;
|
sensor_trigger_handler_t double_tap_handler;
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
#if defined(CONFIG_LIS2DW12_TRIGGER_OWN_THREAD)
|
#if defined(CONFIG_LIS2DW12_TRIGGER_OWN_THREAD)
|
||||||
K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LIS2DW12_THREAD_STACK_SIZE);
|
K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LIS2DW12_THREAD_STACK_SIZE);
|
||||||
struct k_thread thread;
|
struct k_thread thread;
|
||||||
|
|
|
@ -38,14 +38,14 @@ static int lis2dw12_enable_int(const struct device *dev,
|
||||||
case SENSOR_TRIG_DATA_READY:
|
case SENSOR_TRIG_DATA_READY:
|
||||||
int_route.ctrl4_int1_pad_ctrl.int1_drdy = enable;
|
int_route.ctrl4_int1_pad_ctrl.int1_drdy = enable;
|
||||||
break;
|
break;
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
case SENSOR_TRIG_TAP:
|
case SENSOR_TRIG_TAP:
|
||||||
int_route.ctrl4_int1_pad_ctrl.int1_single_tap = enable;
|
int_route.ctrl4_int1_pad_ctrl.int1_single_tap = enable;
|
||||||
break;
|
break;
|
||||||
case SENSOR_TRIG_DOUBLE_TAP:
|
case SENSOR_TRIG_DOUBLE_TAP:
|
||||||
int_route.ctrl4_int1_pad_ctrl.int1_tap = enable;
|
int_route.ctrl4_int1_pad_ctrl.int1_tap = enable;
|
||||||
break;
|
break;
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
default:
|
default:
|
||||||
LOG_ERR("Unsupported trigger interrupt route");
|
LOG_ERR("Unsupported trigger interrupt route");
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
@ -98,7 +98,7 @@ int lis2dw12_trigger_set(const struct device *dev,
|
||||||
}
|
}
|
||||||
return lis2dw12_enable_int(dev, SENSOR_TRIG_DATA_READY, state);
|
return lis2dw12_enable_int(dev, SENSOR_TRIG_DATA_READY, state);
|
||||||
break;
|
break;
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
case SENSOR_TRIG_TAP:
|
case SENSOR_TRIG_TAP:
|
||||||
lis2dw12->tap_handler = handler;
|
lis2dw12->tap_handler = handler;
|
||||||
return lis2dw12_enable_int(dev, SENSOR_TRIG_TAP, state);
|
return lis2dw12_enable_int(dev, SENSOR_TRIG_TAP, state);
|
||||||
|
@ -107,7 +107,7 @@ int lis2dw12_trigger_set(const struct device *dev,
|
||||||
lis2dw12->double_tap_handler = handler;
|
lis2dw12->double_tap_handler = handler;
|
||||||
return lis2dw12_enable_int(dev, SENSOR_TRIG_DOUBLE_TAP, state);
|
return lis2dw12_enable_int(dev, SENSOR_TRIG_DOUBLE_TAP, state);
|
||||||
break;
|
break;
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
default:
|
default:
|
||||||
LOG_ERR("Unsupported sensor trigger");
|
LOG_ERR("Unsupported sensor trigger");
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
@ -130,7 +130,7 @@ static int lis2dw12_handle_drdy_int(const struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
static int lis2dw12_handle_single_tap_int(const struct device *dev)
|
static int lis2dw12_handle_single_tap_int(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct lis2dw12_data *data = dev->data;
|
struct lis2dw12_data *data = dev->data;
|
||||||
|
@ -164,7 +164,7 @@ static int lis2dw12_handle_double_tap_int(const struct device *dev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lis2dw12_handle_interrupt - handle the drdy event
|
* lis2dw12_handle_interrupt - handle the drdy event
|
||||||
|
@ -181,14 +181,14 @@ static void lis2dw12_handle_interrupt(const struct device *dev)
|
||||||
if (sources.status_dup.drdy) {
|
if (sources.status_dup.drdy) {
|
||||||
lis2dw12_handle_drdy_int(dev);
|
lis2dw12_handle_drdy_int(dev);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_LIS2DW12_PULSE
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
if (sources.status_dup.single_tap) {
|
if (sources.status_dup.single_tap) {
|
||||||
lis2dw12_handle_single_tap_int(dev);
|
lis2dw12_handle_single_tap_int(dev);
|
||||||
}
|
}
|
||||||
if (sources.status_dup.double_tap) {
|
if (sources.status_dup.double_tap) {
|
||||||
lis2dw12_handle_double_tap_int(dev);
|
lis2dw12_handle_double_tap_int(dev);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_LIS2DW12_PULSE */
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
|
|
||||||
gpio_pin_interrupt_configure_dt(&cfg->gpio_int,
|
gpio_pin_interrupt_configure_dt(&cfg->gpio_int,
|
||||||
GPIO_INT_EDGE_TO_ACTIVE);
|
GPIO_INT_EDGE_TO_ACTIVE);
|
||||||
|
@ -234,6 +234,82 @@ static void lis2dw12_work_cb(struct k_work *work)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD */
|
#endif /* CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD */
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
|
static int lis2dw12_tap_init(const struct device *dev)
|
||||||
|
{
|
||||||
|
const struct lis2dw12_device_config *cfg = dev->config;
|
||||||
|
struct lis2dw12_data *lis2dw12 = dev->data;
|
||||||
|
|
||||||
|
LOG_DBG("TAP: tap mode is %d", cfg->tap_mode);
|
||||||
|
if (lis2dw12_tap_mode_set(lis2dw12->ctx, cfg->tap_mode) < 0) {
|
||||||
|
LOG_ERR("Failed to select tap trigger mode");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("TAP: ths_x is %02x", cfg->tap_threshold[0]);
|
||||||
|
if (lis2dw12_tap_threshold_x_set(lis2dw12->ctx, cfg->tap_threshold[0]) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap X axis threshold");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("TAP: ths_y is %02x", cfg->tap_threshold[1]);
|
||||||
|
if (lis2dw12_tap_threshold_y_set(lis2dw12->ctx, cfg->tap_threshold[1]) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap Y axis threshold");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("TAP: ths_z is %02x", cfg->tap_threshold[2]);
|
||||||
|
if (lis2dw12_tap_threshold_z_set(lis2dw12->ctx, cfg->tap_threshold[2]) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap Z axis threshold");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg->tap_threshold[0] > 0) {
|
||||||
|
LOG_DBG("TAP: tap_x enabled");
|
||||||
|
if (lis2dw12_tap_detection_on_x_set(lis2dw12->ctx, 1) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap detection on X axis");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg->tap_threshold[1] > 0) {
|
||||||
|
LOG_DBG("TAP: tap_y enabled");
|
||||||
|
if (lis2dw12_tap_detection_on_y_set(lis2dw12->ctx, 1) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap detection on Y axis");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg->tap_threshold[2] > 0) {
|
||||||
|
LOG_DBG("TAP: tap_z enabled");
|
||||||
|
if (lis2dw12_tap_detection_on_z_set(lis2dw12->ctx, 1) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap detection on Z axis");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("TAP: shock is %02x", cfg->tap_shock);
|
||||||
|
if (lis2dw12_tap_shock_set(lis2dw12->ctx, cfg->tap_shock) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap shock duration");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("TAP: latency is %02x", cfg->tap_latency);
|
||||||
|
if (lis2dw12_tap_dur_set(lis2dw12->ctx, cfg->tap_latency) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap latency");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DBG("TAP: quiet time is %02x", cfg->tap_quiet);
|
||||||
|
if (lis2dw12_tap_quiet_set(lis2dw12->ctx, cfg->tap_quiet) < 0) {
|
||||||
|
LOG_ERR("Failed to set tap quiet time");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
|
|
||||||
int lis2dw12_init_interrupt(const struct device *dev)
|
int lis2dw12_init_interrupt(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct lis2dw12_data *lis2dw12 = dev->data;
|
struct lis2dw12_data *lis2dw12 = dev->data;
|
||||||
|
@ -290,6 +366,13 @@ int lis2dw12_init_interrupt(const struct device *dev)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIS2DW12_TAP
|
||||||
|
ret = lis2dw12_tap_init(dev);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_LIS2DW12_TAP */
|
||||||
|
|
||||||
return gpio_pin_interrupt_configure_dt(&cfg->gpio_int,
|
return gpio_pin_interrupt_configure_dt(&cfg->gpio_int,
|
||||||
GPIO_INT_EDGE_TO_ACTIVE);
|
GPIO_INT_EDGE_TO_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,3 +29,74 @@ properties:
|
||||||
(INT1 or INT2) the drdy line is attached to. This property is not
|
(INT1 or INT2) the drdy line is attached to. This property is not
|
||||||
mandatory and if not present it defaults to 1 which is the
|
mandatory and if not present it defaults to 1 which is the
|
||||||
configuration at power-up.
|
configuration at power-up.
|
||||||
|
|
||||||
|
# tap and tap-tap configuration section
|
||||||
|
# All default values are selected to match the power-up values.
|
||||||
|
# tap and tap-tap events can be generated on INT1 only.
|
||||||
|
|
||||||
|
tap-mode:
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
|
default: 0
|
||||||
|
description: |
|
||||||
|
Tap mode. Default is power-up configuration.
|
||||||
|
|
||||||
|
0 # Only Single Tap
|
||||||
|
1 # Single and Double Tap
|
||||||
|
|
||||||
|
enum:
|
||||||
|
- 0
|
||||||
|
- 1
|
||||||
|
|
||||||
|
tap-threshold:
|
||||||
|
type: array
|
||||||
|
required: false
|
||||||
|
default: [0, 0, 0]
|
||||||
|
description: |
|
||||||
|
Tap X/Y/Z axes threshold. Default is power-up configuration.
|
||||||
|
(X/Y/Z values range from 0x00 to 0x1F)
|
||||||
|
|
||||||
|
Thresholds to start the tap-event detection procedure on the X/Y/Z axes.
|
||||||
|
Threshold values for each axis are unsigned 5-bit corresponding
|
||||||
|
to a 2g acceleration full-scale range. A threshold value equal to zero
|
||||||
|
corresponds to disable the tap detection on that axis.
|
||||||
|
|
||||||
|
For example, if you want to set the threshold for X to 12, for Z to 14
|
||||||
|
and want to disable tap detection on Y, you should specify in Device Tree
|
||||||
|
|
||||||
|
tap-threshold = <12>, <0>, <14>
|
||||||
|
|
||||||
|
which is equivalent to X = 12 * 2g/32 = 750mg and Z = 14 * 2g/32 = 875mg.
|
||||||
|
|
||||||
|
tap-shock:
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
|
default: 0x0
|
||||||
|
description: |
|
||||||
|
Tap shock value. Default is power-up configuration.
|
||||||
|
(values range from 0x0 to 0x3)
|
||||||
|
This register represents the maximum time of an over-threshold signal
|
||||||
|
detection to be recognized as a tap event. Where 0 equals 4*1/ODR and
|
||||||
|
1LSB = 8*1/ODR.
|
||||||
|
|
||||||
|
tap-latency:
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
|
default: 0x0
|
||||||
|
description: |
|
||||||
|
Tap latency. Default is power-up configuration.
|
||||||
|
(values range from 0x0 to 0xF)
|
||||||
|
When double-tap recognition is enabled, this register expresses the
|
||||||
|
maximum time between two successive detected taps to determine a
|
||||||
|
double-tap event. Where 0 equals 16*1/ODR and 1LSB = 32*1/ODR.
|
||||||
|
|
||||||
|
tap-quiet:
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
|
default: 0x0
|
||||||
|
description: |
|
||||||
|
Expected quiet time after a tap detection. Default is power-up configuration.
|
||||||
|
(values range from 0x0 to 0x3)
|
||||||
|
This register represents the time after the first detected tap in which
|
||||||
|
there must not be any overthreshold event. Where 0 equals 2*1/ODR
|
||||||
|
and 1LSB = 4*1/ODR.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue