From 9b847bb3c33a7c640c53b78e68e2a8660f4fc22f Mon Sep 17 00:00:00 2001 From: Wajdi ELMuhtadi Date: Wed, 6 Sep 2023 14:15:21 +0200 Subject: [PATCH] drivers: sensor: wsen_itds_2533020201601: add sensor driver Add wsen_itds_2533020201601 driver with the corrected name and compatibility with the hal update as well as added new features. Signed-off-by: Wajdi ELMuhtadi --- drivers/sensor/wsen/CMakeLists.txt | 1 + drivers/sensor/wsen/Kconfig | 1 + .../wsen_itds_2533020201601/CMakeLists.txt | 7 + .../wsen/wsen_itds_2533020201601/Kconfig | 80 ++ .../wsen_itds_2533020201601.c | 704 ++++++++++++++++++ .../wsen_itds_2533020201601.h | 144 ++++ .../wsen_itds_2533020201601_trigger.c | 563 ++++++++++++++ .../we,wsen-itds-2533020201601-common.yaml | 209 ++++++ .../we,wsen-itds-2533020201601-i2c.yaml | 10 + .../we,wsen-itds-2533020201601-spi.yaml | 10 + tests/drivers/build_all/sensor/i2c.dtsi | 19 + .../sensor/sensors_trigger_global.conf | 1 + .../sensor/sensors_trigger_none.conf | 1 + .../build_all/sensor/sensors_trigger_own.conf | 1 + 14 files changed, 1751 insertions(+) create mode 100644 drivers/sensor/wsen/wsen_itds_2533020201601/CMakeLists.txt create mode 100644 drivers/sensor/wsen/wsen_itds_2533020201601/Kconfig create mode 100644 drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.c create mode 100644 drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.h create mode 100644 drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601_trigger.c create mode 100644 dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-common.yaml create mode 100644 dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-i2c.yaml create mode 100644 dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-spi.yaml diff --git a/drivers/sensor/wsen/CMakeLists.txt b/drivers/sensor/wsen/CMakeLists.txt index ffcb71adc0399b..072a55fd05e5db 100644 --- a/drivers/sensor/wsen/CMakeLists.txt +++ b/drivers/sensor/wsen/CMakeLists.txt @@ -4,6 +4,7 @@ # zephyr-keep-sorted-start add_subdirectory_ifdef(CONFIG_WSEN_HIDS_2525020210001 wsen_hids_2525020210001) add_subdirectory_ifdef(CONFIG_WSEN_HIDS_2525020210002 wsen_hids_2525020210002) +add_subdirectory_ifdef(CONFIG_WSEN_ITDS_2533020201601 wsen_itds_2533020201601) add_subdirectory_ifdef(CONFIG_WSEN_PADS_2511020213301 wsen_pads_2511020213301) add_subdirectory_ifdef(CONFIG_WSEN_PDUS_25131308XXXXX wsen_pdus_25131308XXXXX) add_subdirectory_ifdef(CONFIG_WSEN_TIDS_2521020222501 wsen_tids_2521020222501) diff --git a/drivers/sensor/wsen/Kconfig b/drivers/sensor/wsen/Kconfig index 108a13adcee9f7..47af84023fd1d2 100644 --- a/drivers/sensor/wsen/Kconfig +++ b/drivers/sensor/wsen/Kconfig @@ -4,6 +4,7 @@ # zephyr-keep-sorted-start source "drivers/sensor/wsen/wsen_hids_2525020210001/Kconfig" source "drivers/sensor/wsen/wsen_hids_2525020210002/Kconfig" +source "drivers/sensor/wsen/wsen_itds_2533020201601/Kconfig" source "drivers/sensor/wsen/wsen_pads_2511020213301/Kconfig" source "drivers/sensor/wsen/wsen_pdus_25131308XXXXX/Kconfig" source "drivers/sensor/wsen/wsen_tids_2521020222501/Kconfig" diff --git a/drivers/sensor/wsen/wsen_itds_2533020201601/CMakeLists.txt b/drivers/sensor/wsen/wsen_itds_2533020201601/CMakeLists.txt new file mode 100644 index 00000000000000..bef2c49125b12c --- /dev/null +++ b/drivers/sensor/wsen/wsen_itds_2533020201601/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() + +zephyr_library_sources(wsen_itds_2533020201601.c) +zephyr_library_sources_ifdef(CONFIG_WSEN_ITDS_2533020201601_TRIGGER wsen_itds_2533020201601_trigger.c) diff --git a/drivers/sensor/wsen/wsen_itds_2533020201601/Kconfig b/drivers/sensor/wsen/wsen_itds_2533020201601/Kconfig new file mode 100644 index 00000000000000..3d0c50a7ab62c9 --- /dev/null +++ b/drivers/sensor/wsen/wsen_itds_2533020201601/Kconfig @@ -0,0 +1,80 @@ +# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG +# SPDX-License-Identifier: Apache-2.0 + +menuconfig WSEN_ITDS_2533020201601 + bool "WSEN-ITDS-2533020201601 3-axis acceleration sensor" + default y + depends on DT_HAS_WE_WSEN_ITDS_2533020201601_ENABLED + select I2C if $(dt_compat_on_bus,$(DT_COMPAT_WE_WSEN_ITDS_2533020201601),i2c) + select SPI if $(dt_compat_on_bus,$(DT_COMPAT_WE_WSEN_ITDS_2533020201601),spi) + select HAS_WESENSORS + help + Enable driver for the WSEN-ITDS I2C/SPI-based acceleration sensor with integrated + temperature sensor. + +if WSEN_ITDS_2533020201601 + +choice WSEN_ITDS_2533020201601_TRIGGER_MODE + prompt "Trigger mode" + default WSEN_ITDS_2533020201601_TRIGGER_NONE + help + Specify the type of triggering to be used by the driver. + +config WSEN_ITDS_2533020201601_TRIGGER_NONE + bool "No trigger" + +config WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD + bool "Use global thread" + depends on GPIO + select WSEN_ITDS_2533020201601_TRIGGER + +config WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD + bool "Use own thread" + depends on GPIO + select WSEN_ITDS_2533020201601_TRIGGER + +endchoice # WSEN_ITDS_2533020201601_TRIGGER_MODE + +config WSEN_ITDS_2533020201601_TRIGGER + bool + +config WSEN_ITDS_2533020201601_EVENTS + bool + +config WSEN_ITDS_2533020201601_THREAD_PRIORITY + int "Thread priority" + depends on WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD + default 10 + help + Priority of thread used by the driver to handle interrupts. + +config WSEN_ITDS_2533020201601_THREAD_STACK_SIZE + int "Thread stack size" + depends on WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD + default 1024 + help + Stack size of thread used by the driver to handle interrupts. + +config WSEN_ITDS_2533020201601_TAP + bool "Tap and double tap detection" + depends on WSEN_ITDS_2533020201601_TRIGGER + select WSEN_ITDS_2533020201601_EVENTS + help + Enable tap (single/double) detection + Note that the minimum ODR required for using the tap recognition functionality is 400 Hz. + +config WSEN_ITDS_2533020201601_FREEFALL + bool "Free-fall detection" + depends on WSEN_ITDS_2533020201601_TRIGGER + select WSEN_ITDS_2533020201601_EVENTS + help + Enable free-fall detection + +config WSEN_ITDS_2533020201601_DELTA + bool "Wake-up detection (SENSOR_TRIG_DELTA)" + depends on WSEN_ITDS_2533020201601_TRIGGER + select WSEN_ITDS_2533020201601_EVENTS + help + Enable wake-up detection (SENSOR_TRIG_DELTA) + +endif # WSEN_ITDS_2533020201601 diff --git a/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.c b/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.c new file mode 100644 index 00000000000000..06198a35c5455b --- /dev/null +++ b/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.c @@ -0,0 +1,704 @@ +/* + * Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT we_wsen_itds_2533020201601 + +#include + +#include +#include +#include + +#include "wsen_itds_2533020201601.h" + +LOG_MODULE_REGISTER(WSEN_ITDS_2533020201601, CONFIG_SENSOR_LOG_LEVEL); + +/* + * List of supported output data rates (sensor_value struct, input to + * sensor_attr_set()). Index into this list is used as argument for + * ITDS_setOutputDataRate(). + */ +static const struct sensor_value itds_2533020201601_odr_list[] = { + {.val1 = 0, .val2 = 0}, {.val1 = 1, .val2 = 6 * 100000}, + {.val1 = 12, .val2 = 5 * 100000}, {.val1 = 25, .val2 = 0}, + {.val1 = 50, .val2 = 0}, {.val1 = 100, .val2 = 0}, + {.val1 = 200, .val2 = 0}, {.val1 = 400, .val2 = 0}, + {.val1 = 800, .val2 = 0}, {.val1 = 1600, .val2 = 0}, +}; + +/* + * List of supported full scale values (i.e. measurement ranges, in g). + * Index into this list is used as input for ITDS_setFullScale(). + */ +static const int itds_2533020201601_full_scale_list[] = { + 2, + 4, + 8, + 16, +}; + +#define MAX_POLL_STEP_COUNT 10 + +/* convert raw temperature to celsius */ +static inline int16_t itds_2533020201601_raw_temp_to_celsius(int16_t raw_temp) +{ + return ((raw_temp * 100) / 16) + 2500; +} + +static int itds_2533020201601_sample_fetch(const struct device *dev, enum sensor_channel channel) +{ + struct itds_2533020201601_data *data = dev->data; + const struct itds_2533020201601_config *cfg = dev->config; + int16_t temperature, acceleration_x, acceleration_y, acceleration_z; + + switch (channel) { + case SENSOR_CHAN_ALL: + case SENSOR_CHAN_AMBIENT_TEMP: + case SENSOR_CHAN_ACCEL_X: + case SENSOR_CHAN_ACCEL_Y: + case SENSOR_CHAN_ACCEL_Z: + case SENSOR_CHAN_ACCEL_XYZ: + break; + default: + LOG_ERR("Fetching is not supported on channel %d.", channel); + return -ENOTSUP; + } + + if (cfg->op_mode == ITDS_singleConversion) { + if (ITDS_startSingleDataConversion(&data->sensor_interface, ITDS_enable) != + WE_SUCCESS) { + LOG_ERR("Failed to start single data conversion."); + return -EIO; + } + + k_sleep(K_MSEC(5)); + } + + ITDS_state_t acceleration_data_ready, temp_data_ready; + + acceleration_data_ready = temp_data_ready = ITDS_disable; + + bool data_ready = false; + int step_count = 0; + uint32_t step_sleep_duration = + ((uint32_t)1000000000 / + (uint32_t)sensor_value_to_milli(&itds_2533020201601_odr_list[data->sensor_odr]) / + MAX_POLL_STEP_COUNT); + + while (1) { + + switch (channel) { + case SENSOR_CHAN_ALL: { + if (ITDS_isAccelerationDataReady(&data->sensor_interface, + &acceleration_data_ready) != WE_SUCCESS) { + LOG_ERR("Failed to check if acceleration data is ready."); + return -EIO; + } + + if (ITDS_isTemperatureDataReady(&data->sensor_interface, + &temp_data_ready) != WE_SUCCESS) { + LOG_ERR("Failed to check if temperature data is ready."); + return -EIO; + } + + data_ready = (acceleration_data_ready == ITDS_enable && + temp_data_ready == ITDS_enable); + + break; + } + case SENSOR_CHAN_AMBIENT_TEMP: { + if (ITDS_isTemperatureDataReady(&data->sensor_interface, + &temp_data_ready) != WE_SUCCESS) { + LOG_ERR("Failed to check if temperature data is ready."); + return -EIO; + } + + data_ready = (temp_data_ready == ITDS_enable); + + break; + } + case SENSOR_CHAN_ACCEL_X: + case SENSOR_CHAN_ACCEL_Y: + case SENSOR_CHAN_ACCEL_Z: + case SENSOR_CHAN_ACCEL_XYZ: { + if (ITDS_isAccelerationDataReady(&data->sensor_interface, + &acceleration_data_ready) != WE_SUCCESS) { + LOG_ERR("Failed to check if acceleration data is ready."); + return -EIO; + } + + data_ready = (acceleration_data_ready == ITDS_enable); + + break; + } + default: + break; + } + + if (data_ready) { + break; + } else if (step_count >= MAX_POLL_STEP_COUNT) { + return -EIO; + } + + step_count++; + k_sleep(K_USEC(step_sleep_duration)); + } + + switch (channel) { + case SENSOR_CHAN_ALL: { + if (ITDS_getRawAccelerationX(&data->sensor_interface, &acceleration_x) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + + if (ITDS_getRawAccelerationY(&data->sensor_interface, &acceleration_y) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + + if (ITDS_getRawAccelerationZ(&data->sensor_interface, &acceleration_z) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + + data->acceleration_x = + ITDS_convertAcceleration_int(acceleration_x, data->sensor_range); + data->acceleration_y = + ITDS_convertAcceleration_int(acceleration_y, data->sensor_range); + data->acceleration_z = + ITDS_convertAcceleration_int(acceleration_z, data->sensor_range); + + if (ITDS_getRawTemperature12bit(&data->sensor_interface, &temperature) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "temperature"); + return -EIO; + } + data->temperature = itds_2533020201601_raw_temp_to_celsius(temperature); + break; + } + case SENSOR_CHAN_AMBIENT_TEMP: { + if (ITDS_getRawTemperature12bit(&data->sensor_interface, &temperature) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "temperature"); + return -EIO; + } + data->temperature = itds_2533020201601_raw_temp_to_celsius(temperature); + break; + } + case SENSOR_CHAN_ACCEL_X: { + if (ITDS_getRawAccelerationX(&data->sensor_interface, &acceleration_x) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + data->acceleration_x = + ITDS_convertAcceleration_int(acceleration_x, data->sensor_range); + break; + } + case SENSOR_CHAN_ACCEL_Y: { + if (ITDS_getRawAccelerationY(&data->sensor_interface, &acceleration_y) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + data->acceleration_y = + ITDS_convertAcceleration_int(acceleration_y, data->sensor_range); + break; + } + case SENSOR_CHAN_ACCEL_Z: { + if (ITDS_getRawAccelerationZ(&data->sensor_interface, &acceleration_z) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + data->acceleration_z = + ITDS_convertAcceleration_int(acceleration_z, data->sensor_range); + break; + } + case SENSOR_CHAN_ACCEL_XYZ: { + if (ITDS_getRawAccelerationX(&data->sensor_interface, &acceleration_x) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + + if (ITDS_getRawAccelerationY(&data->sensor_interface, &acceleration_y) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + + if (ITDS_getRawAccelerationZ(&data->sensor_interface, &acceleration_z) != + WE_SUCCESS) { + LOG_ERR("Failed to fetch %s sample.", "acceleration"); + return -EIO; + } + + data->acceleration_x = + ITDS_convertAcceleration_int(acceleration_x, data->sensor_range); + data->acceleration_y = + ITDS_convertAcceleration_int(acceleration_y, data->sensor_range); + data->acceleration_z = + ITDS_convertAcceleration_int(acceleration_z, data->sensor_range); + break; + } + default: + break; + } + + return 0; +} + +/* Convert acceleration value from mg (int16) to m/s^2 (sensor_value). */ +static inline void itds_2533020201601_convert_acceleration(struct sensor_value *val, + int16_t raw_val) +{ + int64_t dval; + /* Convert to m/s^2 */ + dval = (((int64_t)raw_val) * SENSOR_G) / 1000000LL; + val->val1 = dval / 1000LL; + val->val2 = (dval % 1000LL) * 1000; +} + +static int itds_2533020201601_channel_get(const struct device *dev, enum sensor_channel channel, + struct sensor_value *value) +{ + struct itds_2533020201601_data *data = dev->data; + + switch (channel) { + case SENSOR_CHAN_AMBIENT_TEMP: + value->val1 = (int32_t)data->temperature / 100; + value->val2 = ((int32_t)data->temperature % 100) * (1000000 / 100); + break; + case SENSOR_CHAN_ACCEL_X: + case SENSOR_CHAN_ACCEL_Y: + case SENSOR_CHAN_ACCEL_Z: + case SENSOR_CHAN_ACCEL_XYZ: + /* Convert requested acceleration(s) */ + if (channel == SENSOR_CHAN_ACCEL_X || channel == SENSOR_CHAN_ACCEL_XYZ) { + itds_2533020201601_convert_acceleration(value, data->acceleration_x); + value++; + } + if (channel == SENSOR_CHAN_ACCEL_Y || channel == SENSOR_CHAN_ACCEL_XYZ) { + itds_2533020201601_convert_acceleration(value, data->acceleration_y); + value++; + } + if (channel == SENSOR_CHAN_ACCEL_Z || channel == SENSOR_CHAN_ACCEL_XYZ) { + itds_2533020201601_convert_acceleration(value, data->acceleration_z); + value++; + } + break; + default: + LOG_ERR("Channel not supported %d", channel); + return -ENOTSUP; + } + + return 0; +} + +/* Set full scale (measurement range). See itds_2533020201601_full_scale_list for allowed values. */ +static int itds_2533020201601_full_scale_set(const struct device *dev, + const struct sensor_value *fs) +{ + struct itds_2533020201601_data *data = dev->data; + + uint8_t scaleg = (uint8_t)sensor_ms2_to_g(fs); + + uint8_t idx; + + for (idx = 0; idx < ARRAY_SIZE(itds_2533020201601_full_scale_list); idx++) { + if (itds_2533020201601_full_scale_list[idx] == scaleg) { + break; + } + } + + if (idx == ARRAY_SIZE(itds_2533020201601_full_scale_list)) { + /* ODR not allowed (was not found in itds_2533020201601_full_scale_list) */ + LOG_ERR("Bad scale %d", scaleg); + return -EINVAL; + } + + if (ITDS_setFullScale(&data->sensor_interface, (ITDS_fullScale_t)idx) != WE_SUCCESS) { + LOG_ERR("Failed to set full scale."); + return -EIO; + } + + data->sensor_range = idx; + + return 0; +} + +/* Get full scale (measurement range). See itds_2533020201601_full_scale_list for allowed values. */ +static int itds_2533020201601_full_scale_get(const struct device *dev, struct sensor_value *fs) +{ + struct itds_2533020201601_data *data = dev->data; + + ITDS_fullScale_t full_scale; + + if (ITDS_getFullScale(&data->sensor_interface, &full_scale) != WE_SUCCESS) { + LOG_ERR("Failed to get full scale"); + return -EIO; + } + + data->sensor_range = full_scale; + + fs->val1 = itds_2533020201601_full_scale_list[full_scale]; + fs->val2 = 0; + + return 0; +} + +/* Set output data rate. See itds_2533020201601_odr_list for allowed values. */ +static int itds_2533020201601_odr_set(const struct device *dev, const struct sensor_value *odr) +{ + struct itds_2533020201601_data *data = dev->data; + int odr_index; + + for (odr_index = 0; odr_index < ARRAY_SIZE(itds_2533020201601_odr_list); odr_index++) { + if (odr->val1 == itds_2533020201601_odr_list[odr_index].val1 && + odr->val2 == itds_2533020201601_odr_list[odr_index].val2) { + break; + } + } + + if (odr_index == ARRAY_SIZE(itds_2533020201601_odr_list)) { + /* ODR not allowed (was not found in itds_2533020201601_odr_list) */ + LOG_ERR("Bad sampling frequency %d.%d", odr->val1, odr->val2); + return -EINVAL; + } + + ITDS_outputDataRate_t odr_enum = (ITDS_outputDataRate_t)odr_index; + + if (ITDS_setOutputDataRate(&data->sensor_interface, odr_enum) != WE_SUCCESS) { + LOG_ERR("Failed to set output data rate"); + return -EIO; + } + + data->sensor_odr = odr_enum; + + return 0; +} + +/* Get output data rate. See itds_2533020201601_odr_list for allowed values. */ +static int itds_2533020201601_odr_get(const struct device *dev, struct sensor_value *odr) +{ + struct itds_2533020201601_data *data = dev->data; + + ITDS_outputDataRate_t odr_index; + + if (ITDS_getOutputDataRate(&data->sensor_interface, &odr_index) != WE_SUCCESS) { + LOG_ERR("Failed to get output data rate"); + return -EIO; + } + + data->sensor_odr = odr_index; + + odr->val1 = itds_2533020201601_odr_list[odr_index].val1; + odr->val2 = itds_2533020201601_odr_list[odr_index].val2; + + return 0; +} + +static int itds_2533020201601_attr_set(const struct device *dev, enum sensor_channel chan, + enum sensor_attribute attr, const struct sensor_value *val) +{ + switch ((int)attr) { + case SENSOR_ATTR_SAMPLING_FREQUENCY: + if (chan != SENSOR_CHAN_ALL) { + break; + } + return itds_2533020201601_odr_set(dev, val); + case SENSOR_ATTR_FULL_SCALE: + switch (chan) { + case SENSOR_CHAN_ACCEL_X: + case SENSOR_CHAN_ACCEL_Y: + case SENSOR_CHAN_ACCEL_Z: + case SENSOR_CHAN_ACCEL_XYZ: + return itds_2533020201601_full_scale_set(dev, val); + default: + break; + } + break; + default: + break; + } + + LOG_ERR("attr_set() is not supported on channel %d.", chan); + return -ENOTSUP; +} + +static int itds_2533020201601_attr_get(const struct device *dev, enum sensor_channel chan, + enum sensor_attribute attr, struct sensor_value *val) +{ + + if (val == NULL) { + LOG_WRN("address of passed value is NULL."); + return -EFAULT; + } + + switch ((int)attr) { + case SENSOR_ATTR_SAMPLING_FREQUENCY: + if (chan != SENSOR_CHAN_ALL) { + break; + } + return itds_2533020201601_odr_get(dev, val); + case SENSOR_ATTR_FULL_SCALE: + switch (chan) { + case SENSOR_CHAN_ACCEL_X: + case SENSOR_CHAN_ACCEL_Y: + case SENSOR_CHAN_ACCEL_Z: + case SENSOR_CHAN_ACCEL_XYZ: + return itds_2533020201601_full_scale_get(dev, val); + default: + break; + } + break; + default: + break; + } + + LOG_ERR("attr_get() is not supported on channel %d.", chan); + return -ENOTSUP; +} + +static const struct sensor_driver_api itds_2533020201601_driver_api = { + .attr_set = itds_2533020201601_attr_set, +#if CONFIG_WSEN_ITDS_2533020201601_TRIGGER + .trigger_set = itds_2533020201601_trigger_set, +#endif + .attr_get = itds_2533020201601_attr_get, + .sample_fetch = itds_2533020201601_sample_fetch, + .channel_get = itds_2533020201601_channel_get, +}; + +int itds_2533020201601_init(const struct device *dev) +{ + const struct itds_2533020201601_config *config = dev->config; + struct itds_2533020201601_data *data = dev->data; + struct sensor_value fs; + uint8_t device_id; + ITDS_state_t sw_reset; + + /* Initialize WE sensor interface */ + WE_sensorInterfaceType_t interface_type = data->sensor_interface.interfaceType; + + ITDS_getDefaultInterface(&data->sensor_interface); + data->sensor_interface.interfaceType = interface_type; + + switch (data->sensor_interface.interfaceType) { +#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) + case WE_i2c: + if (!i2c_is_ready_dt(&config->bus_cfg.i2c)) { + LOG_ERR("I2C bus device not ready"); + return -ENODEV; + } + data->sensor_interface.handle = (void *)&config->bus_cfg.i2c; + break; +#endif +#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) + case WE_spi: + if (!spi_is_ready_dt(&config->bus_cfg.spi)) { + LOG_ERR("SPI bus device not ready"); + return -ENODEV; + } + data->sensor_interface.handle = (void *)&config->bus_cfg.spi; + break; +#endif + default: + LOG_ERR("Invalid interface type"); + return -EINVAL; + } + + /* First communication test - check device ID */ + if (ITDS_getDeviceID(&data->sensor_interface, &device_id) != WE_SUCCESS) { + LOG_ERR("Failed to read device ID."); + return -EIO; + } + + if (device_id != ITDS_DEVICE_ID_VALUE) { + LOG_ERR("Invalid device ID 0x%x.", device_id); + return -EINVAL; + } + + /* Perform soft reset of the sensor */ + ITDS_softReset(&data->sensor_interface, ITDS_enable); + + k_sleep(K_USEC(5)); + + do { + if (ITDS_getSoftResetState(&data->sensor_interface, &sw_reset) != WE_SUCCESS) { + LOG_ERR("Failed to get sensor reset state."); + return -EIO; + } + } while (sw_reset); + + if (ITDS_setOperatingMode(&data->sensor_interface, config->op_mode) != WE_SUCCESS) { + LOG_ERR("Failed to set operating mode."); + return -EIO; + } + + if (ITDS_setPowerMode(&data->sensor_interface, config->power_mode) != WE_SUCCESS) { + LOG_ERR("Failed to set power mode."); + return -EIO; + } + + if (itds_2533020201601_odr_set(dev, &itds_2533020201601_odr_list[config->odr]) < 0) { + LOG_ERR("Failed to set output data rate."); + return -EIO; + } + + if (ITDS_enableLowNoise(&data->sensor_interface, config->low_noise) != WE_SUCCESS) { + LOG_ERR("Failed to set low-noise mode."); + return -EIO; + } + + sensor_g_to_ms2((int32_t)config->range, &fs); + + if (itds_2533020201601_full_scale_set(dev, &fs) < 0) { + LOG_ERR("Failed to set full scale"); + return -EIO; + } + + if (ITDS_enableAutoIncrement(&data->sensor_interface, ITDS_enable) != WE_SUCCESS) { + LOG_ERR("Failed to enable auto increment."); + return -EIO; + } + + if (ITDS_enableBlockDataUpdate(&data->sensor_interface, ITDS_enable) != WE_SUCCESS) { + LOG_ERR("Failed to enable block data update."); + return -EIO; + } + + if (config->op_mode == ITDS_singleConversion) { + if (ITDS_setSingleDataConversionTrigger(&data->sensor_interface, + ITDS_registerTrigger) != WE_SUCCESS) { + LOG_ERR("Failed to set single data conversion trigger."); + return -EIO; + } + } + +#if CONFIG_WSEN_ITDS_2533020201601_TRIGGER + if (itds_2533020201601_init_interrupt(dev) < 0) { + LOG_ERR("Failed to initialize interrupt(s)."); + return -EIO; + } +#endif + + return 0; +} + +#if DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 0 +#warning "ITDS driver enabled without any devices" +#endif + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TRIGGER +#define ITDS_2533020201601_CFG_EVENTS_IRQ(inst) \ + .events_interrupt_gpio = GPIO_DT_SPEC_INST_GET(inst, events_interrupt_gpios), +#define ITDS_2533020201601_CFG_DRDY_IRQ(inst) \ + .drdy_interrupt_gpio = GPIO_DT_SPEC_INST_GET(inst, drdy_interrupt_gpios), +#else +#define ITDS_2533020201601_CFG_EVENTS_IRQ(inst) +#define ITDS_2533020201601_CFG_DRDY_IRQ(inst) +#endif /* CONFIG_WSEN_ITDS_2533020201601_TRIGGER */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TAP +#define ITDS_2533020201601_CONFIG_TAP(inst) \ + .tap_mode = DT_INST_PROP(inst, tap_mode), \ + .tap_threshold = DT_INST_PROP(inst, tap_threshold), \ + .tap_shock = DT_INST_PROP(inst, tap_shock), \ + .tap_latency = DT_INST_PROP(inst, tap_latency), \ + .tap_quiet = DT_INST_PROP(inst, tap_quiet), +#else +#define ITDS_2533020201601_CONFIG_TAP(inst) +#endif /* CONFIG_WSEN_ITDS_2533020201601_TAP */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_FREEFALL +#define ITDS_2533020201601_CONFIG_FREEFALL(inst) \ + .freefall_duration = DT_INST_PROP(inst, freefall_duration), \ + .freefall_threshold = \ + (ITDS_FreeFallThreshold_t)DT_INST_ENUM_IDX(inst, freefall_threshold), +#else +#define ITDS_2533020201601_CONFIG_FREEFALL(inst) +#endif /* CONFIG_WSEN_ITDS_2533020201601_FREEFALL */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_DELTA +#define ITDS_2533020201601_CONFIG_DELTA(inst) \ + .delta_threshold = DT_INST_PROP(inst, delta_threshold), \ + .delta_duration = DT_INST_PROP(inst, delta_duration), \ + .delta_offsets = DT_INST_PROP(inst, delta_offsets), \ + .delta_offset_weight = DT_INST_PROP(inst, delta_offset_weight), +#else +#define ITDS_2533020201601_CONFIG_DELTA(inst) +#endif /* CONFIG_WSEN_ITDS_2533020201601_DELTA */ + +#define ITDS_2533020201601_CONFIG_COMMON(inst) \ + .odr = (ITDS_outputDataRate_t)(DT_INST_ENUM_IDX(inst, odr) + 1), \ + .op_mode = (ITDS_operatingMode_t)DT_INST_ENUM_IDX(inst, op_mode), \ + .power_mode = (ITDS_powerMode_t)DT_INST_ENUM_IDX(inst, power_mode), \ + .range = DT_INST_PROP(inst, range), \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, low_noise), \ + (.low_noise = (ITDS_state_t)ITDS_enable), \ + (.low_noise = (ITDS_state_t)ITDS_disable)), \ + ITDS_2533020201601_CONFIG_TAP(inst) ITDS_2533020201601_CONFIG_FREEFALL(inst) \ + ITDS_2533020201601_CONFIG_DELTA(inst) \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, events_interrupt_gpios), \ + (ITDS_2533020201601_CFG_EVENTS_IRQ(inst)), ()) \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_interrupt_gpios), \ + (ITDS_2533020201601_CFG_DRDY_IRQ(inst)), ()) + +/* + * Instantiation macros used when device is on SPI bus. + */ + +#define ITDS_2533020201601_SPI_OPERATION \ + (SPI_WORD_SET(8) | SPI_OP_MODE_MASTER | SPI_MODE_CPOL | SPI_MODE_CPHA) + +#define ITDS_2533020201601_CONFIG_SPI(inst) \ + { \ + .bus_cfg = \ + { \ + .spi = SPI_DT_SPEC_INST_GET(inst, \ + ITDS_2533020201601_SPI_OPERATION, 0), \ + }, \ + ITDS_2533020201601_CONFIG_COMMON(inst) \ + } + +/* + * Instantiation macros used when device is on I2C bus. + */ + +#define ITDS_2533020201601_CONFIG_I2C(inst) \ + { \ + .bus_cfg = \ + { \ + .i2c = I2C_DT_SPEC_INST_GET(inst), \ + }, \ + ITDS_2533020201601_CONFIG_COMMON(inst) \ + } + +/* + * Main instantiation macro. Use of COND_CODE_1() selects the right + * bus-specific macro at preprocessor time. + */ +#define ITDS_2533020201601_DEFINE(inst) \ + static struct itds_2533020201601_data itds_2533020201601_data_##inst = COND_CODE_1( \ + DT_INST_ON_BUS(inst, i2c), ({.sensor_interface = {.interfaceType = WE_i2c}}), ()) \ + COND_CODE_1(DT_INST_ON_BUS(inst, spi), \ + ({.sensor_interface = {.interfaceType = WE_spi}}), ()); \ + static const struct itds_2533020201601_config itds_2533020201601_config_##inst = \ + COND_CODE_1(DT_INST_ON_BUS(inst, i2c), (ITDS_2533020201601_CONFIG_I2C(inst)), ()) \ + COND_CODE_1(DT_INST_ON_BUS(inst, spi), \ + (ITDS_2533020201601_CONFIG_SPI(inst)), ()); \ + SENSOR_DEVICE_DT_INST_DEFINE(inst, itds_2533020201601_init, NULL, \ + &itds_2533020201601_data_##inst, \ + &itds_2533020201601_config_##inst, POST_KERNEL, \ + CONFIG_SENSOR_INIT_PRIORITY, &itds_2533020201601_driver_api); + +DT_INST_FOREACH_STATUS_OKAY(ITDS_2533020201601_DEFINE) diff --git a/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.h b/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.h new file mode 100644 index 00000000000000..a5f8ced1ba6c81 --- /dev/null +++ b/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_DRIVERS_SENSOR_WSEN_ITDS_2533020201601_WSEN_ITDS_2533020201601_H_ +#define ZEPHYR_DRIVERS_SENSOR_WSEN_ITDS_2533020201601_WSEN_ITDS_2533020201601_H_ + +#include +#include + +#include + +#include "WSEN_ITDS_2533020201601_hal.h" + +#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) +#include +#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */ + +#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) +#include +#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) */ + +struct itds_2533020201601_data { + /* WE sensor interface configuration */ + WE_sensorInterface_t sensor_interface; + + /* Last acceleration samples */ + int16_t acceleration_x; + int16_t acceleration_y; + int16_t acceleration_z; + + /* Last temperature sample */ + int16_t temperature; + + ITDS_outputDataRate_t sensor_odr; + + ITDS_fullScale_t sensor_range; + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TRIGGER + const struct device *dev; + /* Callback for interrupts */ + struct gpio_callback drdy_interrupt_cb; + +#ifdef CONFIG_WSEN_ITDS_2533020201601_EVENTS + struct gpio_callback events_interrupt_cb; +#endif + + /* Registered trigger handlers */ + sensor_trigger_handler_t accel_data_ready_handler; + sensor_trigger_handler_t temp_data_ready_handler; + sensor_trigger_handler_t single_tap_handler; + sensor_trigger_handler_t double_tap_handler; + sensor_trigger_handler_t freefall_handler; + sensor_trigger_handler_t delta_handler; + + const struct sensor_trigger *accel_data_ready_trigger; + const struct sensor_trigger *temp_data_ready_trigger; + const struct sensor_trigger *single_tap_trigger; + const struct sensor_trigger *double_tap_trigger; + const struct sensor_trigger *freefall_trigger; + const struct sensor_trigger *delta_trigger; + +#if defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD) + K_KERNEL_STACK_MEMBER(drdy_thread_stack, CONFIG_WSEN_ITDS_2533020201601_THREAD_STACK_SIZE); + struct k_thread drdy_thread; + struct k_sem drdy_sem; +#ifdef CONFIG_WSEN_ITDS_2533020201601_EVENTS + K_KERNEL_STACK_MEMBER(events_thread_stack, + CONFIG_WSEN_ITDS_2533020201601_THREAD_STACK_SIZE); + struct k_thread events_thread; + struct k_sem events_sem; +#endif +#elif defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD) + struct k_work drdy_work; +#ifdef CONFIG_WSEN_ITDS_2533020201601_EVENTS + struct k_work events_work; +#endif +#endif +#endif /* CONFIG_WSEN_ITDS_2533020201601_TRIGGER */ +}; + +struct itds_2533020201601_config { + union { +#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) + const struct i2c_dt_spec i2c; +#endif +#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) + const struct spi_dt_spec spi; +#endif + } bus_cfg; + + /* Output data rate */ + const ITDS_outputDataRate_t odr; + + /* Operation mode */ + const ITDS_operatingMode_t op_mode; + + /* Power mode */ + const ITDS_powerMode_t power_mode; + + /* Measurement range (full scale) */ + const uint8_t range; + + /* Low-noise mode */ + const ITDS_state_t low_noise; + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TRIGGER + /* Interrupt pins */ + const struct gpio_dt_spec events_interrupt_gpio; + const struct gpio_dt_spec drdy_interrupt_gpio; + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TAP + const uint8_t tap_mode; + const uint8_t tap_threshold[3]; + const uint8_t tap_shock; + const uint8_t tap_latency; + const uint8_t tap_quiet; +#endif /* CONFIG_WSEN_ITDS_2533020201601_TAP */ +#ifdef CONFIG_WSEN_ITDS_2533020201601_FREEFALL + const uint8_t freefall_duration; + const ITDS_FreeFallThreshold_t freefall_threshold; +#endif /* CONFIG_WSEN_ITDS_2533020201601_FREEFALL */ +#ifdef CONFIG_WSEN_ITDS_2533020201601_DELTA + const uint8_t delta_threshold; + const uint8_t delta_duration; + const int8_t delta_offsets[3]; + const uint8_t delta_offset_weight; +#endif /* CONFIG_WSEN_ITDS_2533020201601_DELTA */ +#endif /* CONFIG_WSEN_ITDS_2533020201601_TRIGGER */ +}; + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TRIGGER +int itds_2533020201601_trigger_set(const struct device *dev, const struct sensor_trigger *trig, + sensor_trigger_handler_t handler); + +int itds_2533020201601_init_interrupt(const struct device *dev); +#endif /* CONFIG_WSEN_ITDS_2533020201601_TRIGGER */ + +int itds_2533020201601_spi_init(const struct device *dev); +int itds_2533020201601_i2c_init(const struct device *dev); + +#endif /* ZEPHYR_DRIVERS_SENSOR_WSEN_ITDS_2533020201601_WSEN_ITDS_2533020201601_H_ */ diff --git a/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601_trigger.c b/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601_trigger.c new file mode 100644 index 00000000000000..421db3beb8619d --- /dev/null +++ b/drivers/sensor/wsen/wsen_itds_2533020201601/wsen_itds_2533020201601_trigger.c @@ -0,0 +1,563 @@ +/* + * Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT we_wsen_itds_2533020201601 + +#include + +#include "wsen_itds_2533020201601.h" + +LOG_MODULE_DECLARE(WSEN_ITDS_2533020201601, CONFIG_SENSOR_LOG_LEVEL); + +/* Enable/disable interrupt handling for tap, free-fall, delta/wake-up */ +static inline int itds_2533020201601_setup_interrupt(const struct device *dev, + const struct gpio_dt_spec *pin, bool enable) +{ + unsigned int flags = enable ? GPIO_INT_EDGE_TO_ACTIVE : GPIO_INT_DISABLE; + + return gpio_pin_interrupt_configure_dt(pin, flags); +} + +static inline void itds_2533020201601_handle_interrupt_1(const struct device *dev) +{ + struct itds_2533020201601_data *data = dev->data; + const struct itds_2533020201601_config *cfg = dev->config; + + /* Disable interrupt handling until the interrupt has been processed */ + itds_2533020201601_setup_interrupt(data->dev, &cfg->drdy_interrupt_gpio, false); + +#if defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD) + k_sem_give(&data->drdy_sem); +#elif defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD) + k_work_submit(&data->drdy_work); +#endif +} + +#ifdef CONFIG_WSEN_ITDS_2533020201601_EVENTS +static inline void itds_2533020201601_handle_interrupt_0(const struct device *dev) +{ + struct itds_2533020201601_data *data = dev->data; + const struct itds_2533020201601_config *cfg = dev->config; + + /* Disable interrupt handling until the interrupt has been processed */ + itds_2533020201601_setup_interrupt(data->dev, &cfg->events_interrupt_gpio, false); + +#if defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD) + k_sem_give(&data->events_sem); +#elif defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD) + k_work_submit(&data->events_work); +#endif +} + +/* Asynchronous handling of interrupt triggered in itds_2533020201601_gpio_callback() */ +static void itds_2533020201601_process_interrupt_0(const struct device *dev) +{ + struct itds_2533020201601_data *data = dev->data; + const struct itds_2533020201601_config *cfg = dev->config; + ITDS_status_t itds_2533020201601_status; + + /* Read status register to check for data-ready - if not using soft trigger, the + * status register is also used to find out which interrupt occurred. + */ + if (ITDS_getStatusRegister(&data->sensor_interface, &itds_2533020201601_status) != + WE_SUCCESS) { + LOG_ERR("Failed to read status register"); + return; + } + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TAP + + if (data->single_tap_handler && itds_2533020201601_status.singleTap) { + data->single_tap_handler(dev, data->single_tap_trigger); + } + + if (data->double_tap_handler && itds_2533020201601_status.doubleTap) { + data->double_tap_handler(dev, data->double_tap_trigger); + } +#endif /* CONFIG_WSEN_ITDS_2533020201601_TAP */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_FREEFALL + if (data->freefall_handler && itds_2533020201601_status.freeFall) { + data->freefall_handler(dev, data->freefall_trigger); + } +#endif /* CONFIG_WSEN_ITDS_2533020201601_FREEFALL */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_DELTA + if (data->delta_handler && itds_2533020201601_status.wakeUp) { + data->delta_handler(dev, data->delta_trigger); + } +#endif /* CONFIG_WSEN_ITDS_2533020201601_DELTA */ + + /* Re-enable interrupt handling */ + itds_2533020201601_setup_interrupt(dev, &cfg->events_interrupt_gpio, true); +} + +#endif /* CONFIG_WSEN_ITDS_2533020201601_EVENTS */ + +static void itds_2533020201601_process_interrupt_1(const struct device *dev) +{ + struct itds_2533020201601_data *data = dev->data; + const struct itds_2533020201601_config *cfg = dev->config; + ITDS_statusDetect_t status_detect; + + /* Read status register to check for data-ready - if not using soft trigger, the + * status register is also used to find out which interrupt occurred. + */ + if (ITDS_getStatusDetectRegister(&data->sensor_interface, &status_detect) != WE_SUCCESS) { + LOG_ERR("Failed to read status register"); + return; + } + + if (data->accel_data_ready_handler && status_detect.dataReady) { + data->accel_data_ready_handler(dev, data->accel_data_ready_trigger); + } + + if (data->temp_data_ready_handler && status_detect.temperatureDataReady) { + data->temp_data_ready_handler(dev, data->temp_data_ready_trigger); + } + + /* Re-enable interrupt handling */ + itds_2533020201601_setup_interrupt(dev, &cfg->drdy_interrupt_gpio, true); +} + +/* + * Is called when interrupt on INT1. + * Triggers asynchronous handling of interrupt in itds_2533020201601_process_interrupt(). + */ +static void itds_2533020201601_interrupt_1_gpio_callback(const struct device *dev, + struct gpio_callback *cb, uint32_t pins) +{ + struct itds_2533020201601_data *data = + CONTAINER_OF(cb, struct itds_2533020201601_data, drdy_interrupt_cb); + + ARG_UNUSED(pins); + + itds_2533020201601_handle_interrupt_1(data->dev); +} + +#ifdef CONFIG_WSEN_ITDS_2533020201601_EVENTS +/* + * Is called when interrupt on INT0. + * Triggers asynchronous handling of interrupt in itds_2533020201601_process_interrupt(). + */ +static void itds_2533020201601_interrupt_0_gpio_callback(const struct device *dev, + struct gpio_callback *cb, uint32_t pins) +{ + struct itds_2533020201601_data *data = + CONTAINER_OF(cb, struct itds_2533020201601_data, events_interrupt_cb); + + ARG_UNUSED(pins); + + itds_2533020201601_handle_interrupt_0(data->dev); +} +#endif + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD +static void itds_2533020201601_drdy_thread(void *p1, void *p2, void *p3) +{ + ARG_UNUSED(p2); + ARG_UNUSED(p3); + + struct itds_2533020201601_data *data = p1; + + while (true) { + k_sem_take(&data->drdy_sem, K_FOREVER); + itds_2533020201601_process_interrupt_1(data->dev); + } +} +#ifdef CONFIG_WSEN_ITDS_2533020201601_EVENTS +static void itds_2533020201601_events_thread(void *p1, void *p2, void *p3) +{ + ARG_UNUSED(p2); + ARG_UNUSED(p3); + + struct itds_2533020201601_data *data = p1; + + while (true) { + k_sem_take(&data->events_sem, K_FOREVER); + itds_2533020201601_process_interrupt_0(data->dev); + } +} +#endif /* CONFIG_WSEN_ITDS_2533020201601_EVENTS */ +#endif /* CONFIG_WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD +static void itds_2533020201601_drdy_work_cb(struct k_work *work) +{ + struct itds_2533020201601_data *itds_2533020201601 = + CONTAINER_OF(work, struct itds_2533020201601_data, drdy_work); + + itds_2533020201601_process_interrupt_1(itds_2533020201601->dev); +} +#ifdef CONFIG_WSEN_ITDS_2533020201601_EVENTS +static void itds_2533020201601_events_work_cb(struct k_work *work) +{ + struct itds_2533020201601_data *itds_2533020201601 = + CONTAINER_OF(work, struct itds_2533020201601_data, events_work); + + itds_2533020201601_process_interrupt_0(itds_2533020201601->dev); +} +#endif /* CONFIG_WSEN_ITDS_2533020201601_EVENTS */ +#endif /* CONFIG_WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD */ + +/* (Un)register trigger handler and enable/disable the corresponding sensor interrupt */ +int itds_2533020201601_trigger_set(const struct device *dev, const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) +{ + struct itds_2533020201601_data *data = dev->data; + const struct itds_2533020201601_config *cfg = dev->config; + + ITDS_state_t state = (handler != NULL) ? ITDS_enable : ITDS_disable; + + switch (trig->type) { + case SENSOR_TRIG_DATA_READY: { + int16_t x, y, z; + + switch (trig->chan) { + case SENSOR_CHAN_ACCEL_X: + case SENSOR_CHAN_ACCEL_Y: + case SENSOR_CHAN_ACCEL_Z: + case SENSOR_CHAN_ACCEL_XYZ: { + data->accel_data_ready_handler = handler; + data->accel_data_ready_trigger = trig; + itds_2533020201601_setup_interrupt(dev, &cfg->drdy_interrupt_gpio, + data->accel_data_ready_handler || + data->temp_data_ready_handler); + if (state) { + /* Dummy read: re-trigger interrupt */ + ITDS_getRawAccelerationX(&data->sensor_interface, &x); + ITDS_getRawAccelerationY(&data->sensor_interface, &y); + ITDS_getRawAccelerationZ(&data->sensor_interface, &z); + } + if (ITDS_enableDataReadyINT1(&data->sensor_interface, state) != + WE_SUCCESS) { + return -EIO; + } + break; + } + case SENSOR_CHAN_AMBIENT_TEMP: { + data->temp_data_ready_handler = handler; + data->temp_data_ready_trigger = trig; + itds_2533020201601_setup_interrupt(dev, &cfg->drdy_interrupt_gpio, + data->accel_data_ready_handler || + data->temp_data_ready_handler); + if (state) { + /* Dummy read: re-trigger interrupt */ + ITDS_getRawTemperature12bit(&data->sensor_interface, &x); + } + if (ITDS_enableTempDataReadyINT1(&data->sensor_interface, state) != + WE_SUCCESS) { + return -EIO; + } + break; + } + default: + goto error; + } + return 0; + } +#ifdef CONFIG_WSEN_ITDS_2533020201601_TAP + case SENSOR_TRIG_TAP: + if (trig->chan != SENSOR_CHAN_ALL) { + break; + } + data->single_tap_handler = handler; + data->single_tap_trigger = trig; + itds_2533020201601_setup_interrupt( + dev, &cfg->events_interrupt_gpio, + data->single_tap_handler || data->double_tap_handler || + data->freefall_handler || data->delta_handler); + if (ITDS_enableSingleTapINT0(&data->sensor_interface, state) != WE_SUCCESS) { + return -EIO; + } + return 0; + case SENSOR_TRIG_DOUBLE_TAP: + if (trig->chan != SENSOR_CHAN_ALL) { + break; + } + data->double_tap_handler = handler; + data->double_tap_trigger = trig; + itds_2533020201601_setup_interrupt( + dev, &cfg->events_interrupt_gpio, + data->single_tap_handler || data->double_tap_handler || + data->freefall_handler || data->delta_handler); + if (ITDS_enableDoubleTapINT0(&data->sensor_interface, state) != WE_SUCCESS) { + return -EIO; + } + return 0; +#endif /* CONFIG_WSEN_ITDS_2533020201601_TAP */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_FREEFALL + case SENSOR_TRIG_FREEFALL: + if (trig->chan != SENSOR_CHAN_ALL) { + break; + } + data->freefall_handler = handler; + data->freefall_trigger = trig; + itds_2533020201601_setup_interrupt( + dev, &cfg->events_interrupt_gpio, + data->single_tap_handler || data->double_tap_handler || + data->freefall_handler || data->delta_handler); + if (ITDS_enableFreeFallINT0(&data->sensor_interface, state) != WE_SUCCESS) { + return -EIO; + } + return 0; +#endif /* CONFIG_WSEN_ITDS_2533020201601_FREEFALL */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_DELTA + case SENSOR_TRIG_DELTA: + if (trig->chan != SENSOR_CHAN_ALL) { + break; + } + data->delta_handler = handler; + data->delta_trigger = trig; + itds_2533020201601_setup_interrupt( + dev, &cfg->events_interrupt_gpio, + data->single_tap_handler || data->double_tap_handler || + data->freefall_handler || data->delta_handler); + if (ITDS_enableWakeUpOnINT0(&data->sensor_interface, state) != WE_SUCCESS) { + return -EIO; + } + return 0; +#endif /* CONFIG_WSEN_ITDS_2533020201601_DELTA */ + default: + break; + } + +error: + LOG_ERR("Unsupported sensor trigger"); + return -ENOTSUP; +} + +int itds_2533020201601_init_interrupt(const struct device *dev) +{ + struct itds_2533020201601_data *data = dev->data; + const struct itds_2533020201601_config *cfg = dev->config; + + data->dev = dev; + + if (cfg->drdy_interrupt_gpio.port == NULL) { + LOG_DBG("drdy-interrupt-gpios is not defined in the device tree."); + return -EINVAL; + } + + if (!gpio_is_ready_dt(&cfg->drdy_interrupt_gpio)) { + LOG_ERR("Device %s is not ready", cfg->drdy_interrupt_gpio.port->name); + return -ENODEV; + } + + /* Setup interrupt gpio */ + if (gpio_pin_configure_dt(&cfg->drdy_interrupt_gpio, GPIO_INPUT) < 0) { + LOG_ERR("Failed to configure %s.%02u", cfg->drdy_interrupt_gpio.port->name, + cfg->drdy_interrupt_gpio.pin); + return -EIO; + } + + gpio_init_callback(&data->drdy_interrupt_cb, itds_2533020201601_interrupt_1_gpio_callback, + BIT(cfg->drdy_interrupt_gpio.pin)); + + if (gpio_add_callback(cfg->drdy_interrupt_gpio.port, &data->drdy_interrupt_cb) < 0) { + LOG_ERR("Failed to set gpio callback"); + return -EIO; + } + +#if defined(CONFIG_WSEN_ITDS_2533020201601_EVENTS) + + if (cfg->events_interrupt_gpio.port == NULL) { + LOG_DBG("events-interrupt-gpios is not defined in the device tree."); + return -EINVAL; + } + + if (!gpio_is_ready_dt(&cfg->events_interrupt_gpio)) { + LOG_ERR("Device %s is not ready", cfg->events_interrupt_gpio.port->name); + return -ENODEV; + } + + /* Setup interrupt gpio */ + if (gpio_pin_configure_dt(&cfg->events_interrupt_gpio, GPIO_INPUT) < 0) { + LOG_ERR("Failed to configure %s.%02u", cfg->events_interrupt_gpio.port->name, + cfg->events_interrupt_gpio.pin); + return -EIO; + } + + gpio_init_callback(&data->events_interrupt_cb, itds_2533020201601_interrupt_0_gpio_callback, + BIT(cfg->events_interrupt_gpio.pin)); + + if (gpio_add_callback(cfg->events_interrupt_gpio.port, &data->events_interrupt_cb) < 0) { + LOG_ERR("Failed to set gpio callback"); + return -EIO; + } + +#endif + +#if defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD) + k_sem_init(&data->drdy_sem, 0, K_SEM_MAX_LIMIT); + + k_thread_create(&data->drdy_thread, data->drdy_thread_stack, + CONFIG_WSEN_ITDS_2533020201601_THREAD_STACK_SIZE, + itds_2533020201601_drdy_thread, data, NULL, NULL, + K_PRIO_COOP(CONFIG_WSEN_ITDS_2533020201601_THREAD_PRIORITY), 0, K_NO_WAIT); +#if defined(CONFIG_WSEN_ITDS_2533020201601_EVENTS) + k_sem_init(&data->events_sem, 0, K_SEM_MAX_LIMIT); + + k_thread_create(&data->events_thread, data->events_thread_stack, + CONFIG_WSEN_ITDS_2533020201601_THREAD_STACK_SIZE, + itds_2533020201601_events_thread, data, NULL, NULL, + K_PRIO_COOP(CONFIG_WSEN_ITDS_2533020201601_THREAD_PRIORITY), 0, K_NO_WAIT); +#endif +#elif defined(CONFIG_WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD) + data->drdy_work.handler = itds_2533020201601_drdy_work_cb; +#if defined(CONFIG_WSEN_ITDS_2533020201601_EVENTS) + data->events_work.handler = itds_2533020201601_events_work_cb; + +#endif +#endif + + /* Enable interrupt in pulsed mode */ + if (ITDS_enableLatchedInterrupt(&data->sensor_interface, ITDS_disable) != WE_SUCCESS) { + LOG_ERR("Failed to disable latched mode"); + return -EIO; + } + + /* Enable data-ready in pulsed mode */ + if (ITDS_setDataReadyPulsed(&data->sensor_interface, ITDS_pulsed) != WE_SUCCESS) { + LOG_ERR("Failed to enable data-ready pulsed mode"); + return -EIO; + } + + if (ITDS_enableInterrupts(&data->sensor_interface, ITDS_enable) != WE_SUCCESS) { + LOG_ERR("Failed to enable interrupts"); + return -EIO; + } + +#ifdef CONFIG_WSEN_ITDS_2533020201601_TAP + if (!(cfg->op_mode == ITDS_highPerformance && cfg->odr >= ITDS_odr7)) { + LOG_WRN("A minimum output data rate of 400 Hz is recommended when using the tap " + "recognition feature"); + } + + if (ITDS_enableDoubleTapEvent(&data->sensor_interface, + (cfg->tap_mode == 1) ? ITDS_enable : ITDS_disable) != + WE_SUCCESS) { + LOG_ERR("Failed to enable/disable double tap event"); + return -EIO; + } + + if (ITDS_setTapThresholdX(&data->sensor_interface, cfg->tap_threshold[0]) != WE_SUCCESS) { + LOG_ERR("Failed to set X axis tap threshold"); + return -EIO; + } + + if (ITDS_setTapThresholdY(&data->sensor_interface, cfg->tap_threshold[1]) != WE_SUCCESS) { + LOG_ERR("Failed to set Y axis tap threshold"); + return -EIO; + } + + if (ITDS_setTapThresholdZ(&data->sensor_interface, cfg->tap_threshold[2]) != WE_SUCCESS) { + LOG_ERR("Failed to set Z axis tap threshold"); + return -EIO; + } + + if (cfg->tap_threshold[0] > 0) { + if (ITDS_enableTapX(&data->sensor_interface, ITDS_enable) != WE_SUCCESS) { + LOG_ERR("Failed to enable tap recognition in X direction"); + return -EIO; + } + } + + if (cfg->tap_threshold[1] > 0) { + if (ITDS_enableTapY(&data->sensor_interface, ITDS_enable) != WE_SUCCESS) { + LOG_ERR("Failed to enable tap recognition in Y direction"); + return -EIO; + } + } + + if (cfg->tap_threshold[2] > 0) { + if (ITDS_enableTapZ(&data->sensor_interface, ITDS_enable) != WE_SUCCESS) { + LOG_ERR("Failed to enable tap recognition in Z direction"); + return -EIO; + } + } + + if (ITDS_setTapShockTime(&data->sensor_interface, cfg->tap_shock) != WE_SUCCESS) { + LOG_ERR("Failed to set tap shock duration"); + return -EIO; + } + + if (ITDS_setTapLatencyTime(&data->sensor_interface, cfg->tap_latency) != WE_SUCCESS) { + LOG_ERR("Failed to set tap latency"); + return -EIO; + } + + if (ITDS_setTapQuietTime(&data->sensor_interface, cfg->tap_quiet) != WE_SUCCESS) { + LOG_ERR("Failed to set tap quiet time"); + return -EIO; + } +#endif /* CONFIG_WSEN_ITDS_2533020201601_TAP */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_FREEFALL + if (ITDS_setFreeFallDuration(&data->sensor_interface, cfg->freefall_duration) != + WE_SUCCESS) { + LOG_ERR("Failed to set free-fall duration"); + return -EIO; + } + + if (ITDS_setFreeFallThreshold(&data->sensor_interface, cfg->freefall_threshold) != + WE_SUCCESS) { + LOG_ERR("Failed to set free-fall threshold"); + return -EIO; + } +#endif /* CONFIG_WSEN_ITDS_2533020201601_FREEFALL */ + +#ifdef CONFIG_WSEN_ITDS_2533020201601_DELTA + if (ITDS_setWakeUpDuration(&data->sensor_interface, cfg->delta_duration) != WE_SUCCESS) { + LOG_ERR("Failed to set wake-up duration"); + return -EIO; + } + + if (ITDS_setWakeUpThreshold(&data->sensor_interface, cfg->delta_threshold) != WE_SUCCESS) { + LOG_ERR("Failed to set wake-up threshold"); + return -EIO; + } + + if (cfg->delta_offsets[0] != 0 || cfg->delta_offsets[1] != 0 || + cfg->delta_offsets[2] != 0) { + if (ITDS_setOffsetWeight(&data->sensor_interface, (cfg->delta_offset_weight) != 0 + ? ITDS_enable + : ITDS_disable) != + WE_SUCCESS) { + LOG_ERR("Failed to set wake-up offset weight"); + return -EIO; + } + + if (ITDS_setOffsetValueX(&data->sensor_interface, cfg->delta_offsets[0]) != + WE_SUCCESS) { + LOG_ERR("Failed to set wake-up X offset"); + return -EIO; + } + + if (ITDS_setOffsetValueY(&data->sensor_interface, cfg->delta_offsets[1]) != + WE_SUCCESS) { + LOG_ERR("Failed to set wake-up Y offset"); + return -EIO; + } + + if (ITDS_setOffsetValueZ(&data->sensor_interface, cfg->delta_offsets[2]) != + WE_SUCCESS) { + LOG_ERR("Failed to set wake-up Z offset"); + return -EIO; + } + + if (ITDS_enableApplyWakeUpOffset(&data->sensor_interface, ITDS_enable) != + WE_SUCCESS) { + LOG_ERR("Failed to enable wake-up offsets"); + return -EIO; + } + } +#endif /* CONFIG_WSEN_ITDS_2533020201601_DELTA */ + + return 0; +} diff --git a/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-common.yaml b/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-common.yaml new file mode 100644 index 00000000000000..fe2a8c39bd334f --- /dev/null +++ b/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-common.yaml @@ -0,0 +1,209 @@ +# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG +# SPDX-License-Identifier: Apache-2.0 + +properties: + events-interrupt-gpios: + type: phandle-array + description: | + Events Interrupt pin (Tap, Freefall, .. etc) (INT0 Pin). + Interrupts are active high by default. + + drdy-interrupt-gpios: + type: phandle-array + description: | + DRDY Interrupt pin (INT1 Pin). + Interrupts are active high by default. + + odr: + type: string + required: true + enum: + - "1.6" + - "12.5" + - "25" + - "50" + - "100" + - "200" + - "400" + - "800" + - "1600" + description: Output data rate in Hz + Note that the available output data rates depend on the selected operating mode. In + high performance mode the output data rate of the sensor can be configured between + 12.5 Hz and 1600 Hz. In normal/low power mode the output data rate of the sensor can + be configured between 1.6 Hz and 200 Hz. Consult the ITDS user manual for more + information. + Also note that the minimum ODR required for using the tap recognition functionality + is 400 Hz. + + op-mode: + type: string + required: true + enum: + - "low-power/normal" # Low power or Normal mode + - "high-perf" # High performance mode + - "single-conversion" # Single Conversion mode + description: Operating mode of the sensor. + + power-mode: + type: string + required: true + enum: + - "low-power" # Low power mode + - "normal" # Normal mode + description: Power mode of the sensor. + + range: + type: int + default: 2 + enum: + - 16 # 16g (1.952 mg/LSB) + - 8 # 8g (0.976 mg/LSB) + - 4 # 4g (0.488 mg/LSB) + - 2 # 2g (0.244 mg/LSB) + description: Range (full scale) in g. Defaults to 2, which is + the configuration at power-up. + + low-noise: + type: boolean + description: Enables low-noise mode. + + tap-mode: + type: int + default: 0 + enum: + - 0 # Only single tap + - 1 # Single and double tap + description: Tap mode (only single tap or single and double tap). + Defaults to 0, which is the configuration at power-up. + + tap-threshold: + type: array + default: [0, 0, 0] + description: | + Tap X/Y/Z axis thresholds (unsigned 5-bit, ranging from 0x00 to 0x1F). + Defaults to "<0>, <0>, <0>", which is the configuration at power-up. + + Thresholds for tap recognition on the X/Y/Z axes corresponding to a + 2g full-scale range. Setting a threshold to zero disables tap + detection on the corresponding axis. + + Example: + + tap-threshold = <0>, <6>, <10> + + This disables tap recognition on X axis and sets thresholds for Y and Z + as follows: Y = 6 \* 2g/32 = 375mg and Z = 10 \* 2g/32 = 625mg. + + tap-shock: + type: int + default: 0x0 + description: | + Maximum duration of over-threshold event when detecting taps (unsigned + 2-bit, ranging from 0x0 to 0x3). Defaults to zero, which is the + configuration at power-up. + + A value of 0 corresponds to 4 \* 1/ODR and 1 LSB = 8 \* 1/ODR. + + tap-latency: + type: int + default: 0x0 + description: | + Maximum duration time gap for double-tap recognition (unsigned 4-bit, + ranging from 0x0 to 0xF). Defaults to zero, which is the + configuration at power-up. + + A value of 0 corresponds to 16 \* 1/ODR and 1 LSB = 32 \* 1/ODR. + + tap-quiet: + type: int + default: 0x0 + description: | + Expected quiet time for double-tap recognition (unsigned 2-bit, ranging + from 0x0 to 0x3). This defines the time after the first detected tap in + which there must not be any over-threshold event. Defaults to zero, which + is the configuration at power-up. + + A value of 0 corresponds to 2 \* 1/ODR and 1 LSB = 4 \* 1/ODR. + + freefall-duration: + type: int + default: 0x0 + description: | + Minimum duration of free-fall event (unsigned 6-bit, ranging from 0x0 + to 0x3F). Defaults to 0, which is the configuration at power-up. + + 1 LSB = 1 \* 1/ODR. + + freefall-threshold: + type: int + default: 0x5 + enum: + - 5 # 156.50 mg + - 7 # 218.75 mg + - 8 # 250.00 mg + - 10 # 312.50 mg + - 11 # 343.75 mg + - 13 # 406.25 mg + - 15 # 468.75 mg + - 16 # 500.00 mg + description: | + Free-fall threshold (amplitude of the "free-fall zone" around zero-g + level where the accelerations of all axes are small enough to generate + the free-fall interrupt). Defaults to 0x5, which is the configuration + at power-up. + + Multiply by 31.25mg to get the used threshold. + + delta-duration: + type: int + default: 0x0 + enum: + - 0 + - 1 + - 2 + - 3 + description: | + Wake-up duration, i.e. minimum duration of wake-up event to be + recognized (unsigned 2-bit, ranging from 0x0 to 0x3). + Defaults to 0, which is the configuration at power-up. + + 1 LSB = 1 \* 1/ODR + + delta-threshold: + type: int + default: 0x0 + description: | + Wake-up threshold (unsigned 6-bit, ranging from 0x0 to 0x3F). + The threshold value is applicable to both positive and negative + acceleration data. A wake-up event is recognized, if at least + one of the acceleration axis values exceeds the threshold value. + + Defaults to 0, which is the configuration at power-up. + + 1 LSB = 1/64 of measurement range (full scale). + + delta-offsets: + type: array + default: [0, 0, 0] + description: | + Wake-up X/Y/Z axis offsets (signed 8-bit, ranging from -128 to 127). + Defaults to "<0>, <0>, <0>", which is the configuration at power-up. + + The weight of the offsets depends on the delta-offset-weight property. + E.g. for delta-offset-weight=<1>, an offset value of 0x40 corresponds + to approximately 1g. + + delta-offset-weight: + type: int + default: 0x0 + enum: + - 0 # 0.977 mg/LSB + - 1 # 15.6 mg/LSB + description: | + Wake-up offset weight (0 or 1). + Weight of the offsets specified in the delta-offsets property. + Defaults to 0, which is the configuration at power-up. + + A value of 0 corresponds to 0.977 mg/LSB, a value of 1 + corresponds to 15.6 mg/LSB. diff --git a/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-i2c.yaml b/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-i2c.yaml new file mode 100644 index 00000000000000..f26314a34c5814 --- /dev/null +++ b/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-i2c.yaml @@ -0,0 +1,10 @@ +# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG +# SPDX-License-Identifier: Apache-2.0 + +description: | + Würth Elektronik WSEN-ITDS-2533020201601 acceleration sensor with + integrated temperature sensor (I2C bus) + +compatible: "we,wsen-itds-2533020201601" + +include: ["i2c-device.yaml", "we,wsen-itds-2533020201601-common.yaml"] diff --git a/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-spi.yaml b/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-spi.yaml new file mode 100644 index 00000000000000..9357a672aedd89 --- /dev/null +++ b/dts/bindings/sensor/we,wsen-itds-2533020201601/we,wsen-itds-2533020201601-spi.yaml @@ -0,0 +1,10 @@ +# Copyright (c) 2023 Würth Elektronik eiSos GmbH & Co. KG +# SPDX-License-Identifier: Apache-2.0 + +description: | + Würth Elektronik WSEN-ITDS-2533020201601 acceleration sensor with + integrated temperature sensor (SPI bus) + +compatible: "we,wsen-itds-2533020201601" + +include: ["spi-device.yaml", "we,wsen-itds-2533020201601-common.yaml"] diff --git a/tests/drivers/build_all/sensor/i2c.dtsi b/tests/drivers/build_all/sensor/i2c.dtsi index db19c89f5d6465..8cf2b6a8216a15 100644 --- a/tests/drivers/build_all/sensor/i2c.dtsi +++ b/tests/drivers/build_all/sensor/i2c.dtsi @@ -521,6 +521,25 @@ test_i2c_wsen_hids_2525020210001: wsen_hids_2525020210001@4d { odr = "1"; }; +test_i2c_itds_2533020201601: wsen_itds_2533020201601@4e { + compatible = "we,wsen-itds-2533020201601"; + reg = <0x4e>; + events-interrupt-gpios = <&test_gpio 0 0>; + drdy-interrupt-gpios = <&test_gpio 0 0>; + odr = "400"; + tap-threshold = <0>, <0>, <6>; + tap-latency = < 5 >; + tap-shock = < 2 >; + tap-quiet = < 1 >; + tap-mode = < 1 >; + freefall-duration = < 6 >; + freefall-threshold = < 10 >; + delta-duration = < 1 >; + delta-threshold = < 4 >; + op-mode = "high-perf"; + power-mode = "normal"; +}; + test_i2c_max17055: max17055@4f { compatible = "maxim,max17055"; reg = <0x4f>; diff --git a/tests/drivers/build_all/sensor/sensors_trigger_global.conf b/tests/drivers/build_all/sensor/sensors_trigger_global.conf index f31f3073c6855f..c4b53ea2a6e785 100644 --- a/tests/drivers/build_all/sensor/sensors_trigger_global.conf +++ b/tests/drivers/build_all/sensor/sensors_trigger_global.conf @@ -64,5 +64,6 @@ CONFIG_TSL2540_TRIGGER_GLOBAL_THREAD=y CONFIG_TSL2591_TRIGGER_GLOBAL_THREAD=y CONFIG_VCNL4040_TRIGGER_GLOBAL_THREAD=y CONFIG_WSEN_HIDS_2525020210001_TRIGGER_GLOBAL_THREAD=y +CONFIG_WSEN_ITDS_2533020201601_TRIGGER_GLOBAL_THREAD=y CONFIG_WSEN_PADS_2511020213301_TRIGGER_GLOBAL_THREAD=y CONFIG_WSEN_TIDS_2521020222501_TRIGGER_GLOBAL_THREAD=y diff --git a/tests/drivers/build_all/sensor/sensors_trigger_none.conf b/tests/drivers/build_all/sensor/sensors_trigger_none.conf index c9b52a04c5c553..a51eda8b88eb6f 100644 --- a/tests/drivers/build_all/sensor/sensors_trigger_none.conf +++ b/tests/drivers/build_all/sensor/sensors_trigger_none.conf @@ -64,5 +64,6 @@ CONFIG_TSL2540_TRIGGER_NONE=y CONFIG_TSL2591_TRIGGER_NONE=y CONFIG_VCNL4040_TRIGGER_NONE=y CONFIG_WSEN_HIDS_2525020210001_TRIGGER_NONE=y +CONFIG_WSEN_ITDS_2533020201601_TRIGGER_NONE=y CONFIG_WSEN_PADS_2511020213301_TRIGGER_NONE=y CONFIG_WSEN_TIDS_2521020222501_TRIGGER_NONE=y diff --git a/tests/drivers/build_all/sensor/sensors_trigger_own.conf b/tests/drivers/build_all/sensor/sensors_trigger_own.conf index 8e37d4eff9c099..b618c6da3d0dec 100644 --- a/tests/drivers/build_all/sensor/sensors_trigger_own.conf +++ b/tests/drivers/build_all/sensor/sensors_trigger_own.conf @@ -61,5 +61,6 @@ CONFIG_TSL2540_TRIGGER_OWN_THREAD=y CONFIG_TSL2591_TRIGGER_OWN_THREAD=y CONFIG_VCNL4040_TRIGGER_OWN_THREAD=y CONFIG_WSEN_HIDS_2525020210001_TRIGGER_OWN_THREAD=y +CONFIG_WSEN_ITDS_2533020201601_TRIGGER_OWN_THREAD=y CONFIG_WSEN_PADS_2511020213301_TRIGGER_OWN_THREAD=y CONFIG_WSEN_TIDS_2521020222501_TRIGGER_OWN_THREAD=y