diff --git a/doc/releases/release-notes-4.1.rst b/doc/releases/release-notes-4.1.rst index c2f2806acb5c..7353707aad71 100644 --- a/doc/releases/release-notes-4.1.rst +++ b/doc/releases/release-notes-4.1.rst @@ -517,6 +517,7 @@ New Drivers * :dtcompatible:`adi,adxl366` * :dtcompatible:`hc-sr04` * :dtcompatible:`invensense,icm42670s` + * :dtcompatible:`invensense,icm42370` * :dtcompatible:`maxim,ds3231-sensor` * :dtcompatible:`melexis,mlx90394` * :dtcompatible:`nordic,npm2100-vbat` diff --git a/drivers/sensor/tdk/CMakeLists.txt b/drivers/sensor/tdk/CMakeLists.txt index 0f5c85a2db0e..bcd50714bd80 100644 --- a/drivers/sensor/tdk/CMakeLists.txt +++ b/drivers/sensor/tdk/CMakeLists.txt @@ -3,8 +3,8 @@ # zephyr-keep-sorted-start add_subdirectory_ifdef(CONFIG_ICM42605 icm42605) -add_subdirectory_ifdef(CONFIG_ICM42670 icm42670) add_subdirectory_ifdef(CONFIG_ICM42688 icm42688) +add_subdirectory_ifdef(CONFIG_ICM42X70 icm42x70) add_subdirectory_ifdef(CONFIG_ICP10125 icp10125) add_subdirectory_ifdef(CONFIG_MPU6050 mpu6050) add_subdirectory_ifdef(CONFIG_MPU9250 mpu9250) diff --git a/drivers/sensor/tdk/Kconfig b/drivers/sensor/tdk/Kconfig index 57d92f9faf60..5e0627a22cd9 100644 --- a/drivers/sensor/tdk/Kconfig +++ b/drivers/sensor/tdk/Kconfig @@ -3,8 +3,8 @@ # zephyr-keep-sorted-start source "drivers/sensor/tdk/icm42605/Kconfig" -source "drivers/sensor/tdk/icm42670/Kconfig" source "drivers/sensor/tdk/icm42688/Kconfig" +source "drivers/sensor/tdk/icm42x70/Kconfig" source "drivers/sensor/tdk/icp10125/Kconfig" source "drivers/sensor/tdk/mpu6050/Kconfig" source "drivers/sensor/tdk/mpu9250/Kconfig" diff --git a/drivers/sensor/tdk/icm42670/CMakeLists.txt b/drivers/sensor/tdk/icm42670/CMakeLists.txt deleted file mode 100644 index f15f33398976..000000000000 --- a/drivers/sensor/tdk/icm42670/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -zephyr_library() - -zephyr_library_sources(icm42670.c) - -zephyr_library_sources_ifdef(CONFIG_SPI icm42670_spi.c) -zephyr_library_sources_ifdef(CONFIG_I2C icm42670_i2c.c) - -zephyr_library_sources_ifdef(CONFIG_ICM42670_TRIGGER icm42670_trigger.c) -zephyr_library_sources_ifdef(CONFIG_TDK_APEX icm42670_apex.c) diff --git a/drivers/sensor/tdk/icm42670/icm42670_trigger.h b/drivers/sensor/tdk/icm42670/icm42670_trigger.h deleted file mode 100644 index 7a9d2e1ab0bc..000000000000 --- a/drivers/sensor/tdk/icm42670/icm42670_trigger.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Esco Medical ApS - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef ZEPHYR_DRIVERS_SENSOR_ICM42670_TRIGGER_H_ -#define ZEPHYR_DRIVERS_SENSOR_ICM42670_TRIGGER_H_ - -#include - -/** implement the trigger_set sensor api function */ -int icm42670_trigger_set(const struct device *dev, const struct sensor_trigger *trig, - sensor_trigger_handler_t handler); - -/** - * @brief initialize the icm42670 trigger system - * - * @param dev icm42670 device pointer - * @return int 0 on success, negative error code otherwise - */ -int icm42670_trigger_init(const struct device *dev); - -/** - * @brief enable the trigger gpio interrupt - * - * @param dev icm42670 device pointer - * @return int 0 on success, negative error code otherwise - */ -int icm42670_trigger_enable_interrupt(const struct device *dev); - -/** - * @brief lock access to the icm42670 device driver - * - * @param dev icm42670 device pointer - */ -void icm42670_lock(const struct device *dev); - -/** - * @brief lock access to the icm42670 device driver - * - * @param dev icm42670 device pointer - */ -void icm42670_unlock(const struct device *dev); - -#endif /* ZEPHYR_DRIVERS_SENSOR_ICM42670_TRIGGER_H_ */ diff --git a/drivers/sensor/tdk/icm42x70/CMakeLists.txt b/drivers/sensor/tdk/icm42x70/CMakeLists.txt new file mode 100644 index 000000000000..0fd3a92aaa2b --- /dev/null +++ b/drivers/sensor/tdk/icm42x70/CMakeLists.txt @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() + +zephyr_library_sources(icm42x70.c) + +zephyr_library_sources_ifdef(CONFIG_SPI icm42x70_spi.c) +zephyr_library_sources_ifdef(CONFIG_I2C icm42x70_i2c.c) + +zephyr_library_sources_ifdef(CONFIG_USE_EMD_ICM42670 icm42670.c) + +zephyr_library_sources_ifdef(CONFIG_ICM42X70_TRIGGER icm42x70_trigger.c) +zephyr_library_sources_ifdef(CONFIG_TDK_APEX icm42x70_apex.c) diff --git a/drivers/sensor/tdk/icm42670/Kconfig b/drivers/sensor/tdk/icm42x70/Kconfig similarity index 53% rename from drivers/sensor/tdk/icm42670/Kconfig rename to drivers/sensor/tdk/icm42x70/Kconfig index 36804f1c9e3a..bc218388e242 100644 --- a/drivers/sensor/tdk/icm42670/Kconfig +++ b/drivers/sensor/tdk/icm42x70/Kconfig @@ -8,16 +8,19 @@ config TDK_APEX bool -menuconfig ICM42670 - bool "ICM42670-P/-S Six-Axis Motion Tracking Device" +menuconfig ICM42X70 + bool "ICM42670-P/-S Six-Axis or ICM42370-P Three-Axis Motion Tracking Device" default y depends on DT_HAS_INVENSENSE_ICM42670P_ENABLED \ - || DT_HAS_INVENSENSE_ICM42670S_ENABLED + || DT_HAS_INVENSENSE_ICM42670S_ENABLED \ + || DT_HAS_INVENSENSE_ICM42370P_ENABLED depends on ZEPHYR_HAL_TDK_MODULE select SPI if $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670P),spi) \ - || $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670S),spi) + || $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670S),spi) \ + || $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42370P),spi) select I2C if $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670P),i2c) \ - || $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670S),i2c) + || $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670S),i2c) \ + || $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42370P),i2c) select TDK_APEX if $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670p),apex,pedometer) \ || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670p),apex,tilt) \ || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670p),apex,smd) \ @@ -25,52 +28,61 @@ menuconfig ICM42670 || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670s),apex,pedometer) \ || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670s),apex,tilt) \ || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670s),apex,smd) \ - || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670s),apex,wom) + || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42670s),apex,wom) \ + || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42370p),apex,pedometer) \ + || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42370p),apex,tilt) \ + || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42370p),apex,smd) \ + || $(dt_node_str_prop_equals,$(dt_nodelabel_path,icm42370p),apex,wom) + select USE_EMD_ICM42670 if DT_HAS_INVENSENSE_ICM42670P_ENABLED || DT_HAS_INVENSENSE_ICM42670S_ENABLED + select USE_EMD_ICM42370 if DT_HAS_INVENSENSE_ICM42370P_ENABLED + select SENSOR_ASYNC_API help - Enable driver for ICM42670 SPI-based or I2C-based Six-Axis Motion Tracking device. + Enable driver for ICM42x70 SPI-based or I2C-based Six-Axis or Three-Axis Motion Tracking device. -if ICM42670 +if ICM42X70 -choice ICM42670_TRIGGER_MODE +choice ICM42X70_TRIGGER_MODE prompt "Trigger mode" - default ICM42670_TRIGGER_NONE + default ICM42X70_TRIGGER_NONE help Specify the type of triggering to be used by the driver. -config ICM42670_TRIGGER_NONE +config ICM42X70_TRIGGER_NONE bool "No trigger" -config ICM42670_TRIGGER_GLOBAL_THREAD +config ICM42X70_TRIGGER_GLOBAL_THREAD bool "Use global thread" depends on GPIO depends on $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42670P),int-gpios) \ - || $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42670S),int-gpios) - select ICM42670_TRIGGER + || $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42670S),int-gpios) \ + || $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42370P),int-gpios) + select ICM42X70_TRIGGER -config ICM42670_TRIGGER_OWN_THREAD +config ICM42X70_TRIGGER_OWN_THREAD bool "Use own thread" depends on GPIO depends on $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42670P),int-gpios) \ - || $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42670S),int-gpios) - select ICM42670_TRIGGER + || $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42670S),int-gpios) \ + || $(dt_compat_any_has_prop,$(DT_COMPAT_INVENSENSE_ICM42370P),int-gpios) + select ICM42X70_TRIGGER endchoice -config ICM42670_TRIGGER +config ICM42X70_TRIGGER bool -config ICM42670_THREAD_PRIORITY +config ICM42X70_THREAD_PRIORITY int "Thread priority" - depends on ICM42670_TRIGGER_OWN_THREAD + depends on ICM42X70_TRIGGER_OWN_THREAD default 10 help Priority of thread used by the driver to handle interrupts. -config ICM42670_THREAD_STACK_SIZE +config ICM42X70_THREAD_STACK_SIZE int "Thread stack size" - depends on ICM42670_TRIGGER_OWN_THREAD + depends on ICM42X70_TRIGGER_OWN_THREAD default 1024 help Stack size of thread used by the driver to handle interrupts. -endif # ICM42670 +endif # ICM42X70 diff --git a/drivers/sensor/tdk/icm42x70/icm42670.c b/drivers/sensor/tdk/icm42x70/icm42670.c new file mode 100644 index 000000000000..e629f61d83aa --- /dev/null +++ b/drivers/sensor/tdk/icm42x70/icm42670.c @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2025 TDK Invensense + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "icm42670.h" + +#include +#include + +#include +LOG_MODULE_REGISTER(ICM42670, CONFIG_SENSOR_LOG_LEVEL); + +static uint32_t convert_gyr_fs_to_bitfield(uint32_t val, uint16_t *fs) +{ + uint32_t bitfield = 0; + + if (val < 500 && val >= 250) { + bitfield = GYRO_CONFIG0_FS_SEL_250dps; + *fs = 250; + } else if (val < 1000 && val >= 500) { + bitfield = GYRO_CONFIG0_FS_SEL_500dps; + *fs = 500; + } else if (val < 2000 && val >= 1000) { + bitfield = GYRO_CONFIG0_FS_SEL_1000dps; + *fs = 1000; + } else if (val == 2000) { + bitfield = GYRO_CONFIG0_FS_SEL_2000dps; + *fs = 2000; + } + return bitfield; +} + +static int icm42670_set_gyro_odr(struct icm42x70_data *drv_data, const struct sensor_value *val) +{ + if (val->val1 <= 1600 && val->val1 > 12) { + if (drv_data->gyro_hz == 0) { + inv_imu_set_gyro_frequency( + &drv_data->driver, + convert_freq_to_bitfield(val->val1, &drv_data->gyro_hz)); + inv_imu_enable_gyro_low_noise_mode(&drv_data->driver); + } else { + inv_imu_set_gyro_frequency( + &drv_data->driver, + convert_freq_to_bitfield(val->val1, &drv_data->gyro_hz)); + } + } else if (val->val1 == 0) { + inv_imu_disable_gyro(&drv_data->driver); + drv_data->gyro_hz = val->val1; + } else { + LOG_ERR("Incorrect sampling value"); + return -EINVAL; + } + return 0; +} + +static int icm42670_set_gyro_fs(struct icm42x70_data *drv_data, const struct sensor_value *val) +{ + if (val->val1 > 2000 || val->val1 < 250) { + LOG_ERR("Incorrect fullscale value"); + return -EINVAL; + } + inv_imu_set_gyro_fsr(&drv_data->driver, + convert_gyr_fs_to_bitfield(val->val1, &drv_data->gyro_fs)); + LOG_DBG("Set gyro fullscale to: %d dps", drv_data->gyro_fs); + return 0; +} + +int icm42670_gyro_config(struct icm42x70_data *drv_data, enum sensor_attribute attr, + const struct sensor_value *val) +{ + if (attr == SENSOR_ATTR_SAMPLING_FREQUENCY) { + icm42670_set_gyro_odr(drv_data, val); + + } else if (attr == SENSOR_ATTR_FULL_SCALE) { + icm42670_set_gyro_fs(drv_data, val); + + } else if ((enum sensor_attribute_icm42x70)attr == SENSOR_ATTR_BW_FILTER_LPF) { + if (val->val1 > 180) { + LOG_ERR("Incorrect low pass filter bandwidth value"); + return -EINVAL; + } + inv_imu_set_gyro_ln_bw(&drv_data->driver, convert_ln_bw_to_bitfield(val->val1)); + + } else { + LOG_ERR("Unsupported attribute"); + return -EINVAL; + } + return 0; +} + +void icm42670_convert_gyro(struct sensor_value *val, int16_t raw_val, uint16_t fs) +{ + int64_t conv_val; + + /* 16 bit gyroscope. 2^15 bits represent the range in degrees/s */ + /* see datasheet section 3.1 for details */ + conv_val = ((int64_t)raw_val * fs * SENSOR_PI) / (INT16_MAX * 180U); + + val->val1 = conv_val / 1000000; + val->val2 = conv_val % 1000000; +} + +int icm42670_sample_fetch_gyro(const struct device *dev) +{ + struct icm42x70_data *data = dev->data; + uint8_t buffer[GYRO_DATA_SIZE]; + + int res = inv_imu_read_reg(&data->driver, GYRO_DATA_X1, GYRO_DATA_SIZE, buffer); + + if (res) { + return res; + } + + data->gyro_x = (int16_t)sys_get_be16(&buffer[0]); + data->gyro_y = (int16_t)sys_get_be16(&buffer[2]); + data->gyro_z = (int16_t)sys_get_be16(&buffer[4]); + + return 0; +} + +uint16_t convert_bitfield_to_gyr_fs(uint8_t bitfield) +{ + uint16_t gyr_fs = 0; + + if (bitfield == GYRO_CONFIG0_FS_SEL_250dps) { + gyr_fs = 250; + } else if (bitfield == GYRO_CONFIG0_FS_SEL_500dps) { + gyr_fs = 500; + } else if (bitfield == GYRO_CONFIG0_FS_SEL_1000dps) { + gyr_fs = 1000; + } else if (bitfield == GYRO_CONFIG0_FS_SEL_2000dps) { + gyr_fs = 2000; + } + return gyr_fs; +} diff --git a/drivers/sensor/tdk/icm42x70/icm42670.h b/drivers/sensor/tdk/icm42x70/icm42670.h new file mode 100644 index 000000000000..74e4f8fa9813 --- /dev/null +++ b/drivers/sensor/tdk/icm42x70/icm42670.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 TDK Invensense + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_DRIVERS_SENSOR_ICM42670_H_ +#define ZEPHYR_DRIVERS_SENSOR_ICM42670_H_ + +#include +#include +#include + +#include "icm42x70.h" + +int icm42670_gyro_config(struct icm42x70_data *drv_data, enum sensor_attribute attr, + const struct sensor_value *val); +void icm42670_convert_gyro(struct sensor_value *val, int16_t raw_val, uint16_t fs); +int icm42670_sample_fetch_gyro(const struct device *dev); +uint16_t convert_bitfield_to_gyr_fs(uint8_t bitfield); + +#endif /* ZEPHYR_DRIVERS_SENSOR_ICM42670_H_ */ diff --git a/drivers/sensor/tdk/icm42670/icm42670.c b/drivers/sensor/tdk/icm42x70/icm42x70.c similarity index 64% rename from drivers/sensor/tdk/icm42670/icm42670.c rename to drivers/sensor/tdk/icm42x70/icm42x70.c index a2fe604c75de..0312c6926d14 100644 --- a/drivers/sensor/tdk/icm42670/icm42670.c +++ b/drivers/sensor/tdk/icm42x70/icm42x70.c @@ -13,26 +13,27 @@ #include #include #include -#include +#include #include +#include "icm42x70.h" +#include "icm42x70_trigger.h" #include "icm42670.h" -#include "icm42670_trigger.h" #include -LOG_MODULE_REGISTER(ICM42670, CONFIG_SENSOR_LOG_LEVEL); +LOG_MODULE_REGISTER(ICM42X70, CONFIG_SENSOR_LOG_LEVEL); /* Convert DT enum to sensor ODR selection */ -#define ICM42670_CONVERT_ENUM_TO_ODR_POS (4) +#define ICM42X70_CONVERT_ENUM_TO_ODR_POS (4) -/* Maximum bytes to read/write on ICM42670 serial interface */ -#define ICM42670_SERIAL_INTERFACE_MAX_READ (1024 * 32) -#define ICM42670_SERIAL_INTERFACE_MAX_WRITE (1024 * 32) +/* Maximum bytes to read/write on ICM42X70 serial interface */ +#define ICM42X70_SERIAL_INTERFACE_MAX_READ (1024 * 32) +#define ICM42X70_SERIAL_INTERFACE_MAX_WRITE (1024 * 32) -static inline int icm42670_reg_read(const struct device *dev, uint8_t reg, uint8_t *buf, +static inline int icm42x70_reg_read(const struct device *dev, uint8_t reg, uint8_t *buf, uint32_t size) { - const struct icm42670_config *cfg = dev->config; + const struct icm42x70_config *cfg = dev->config; return cfg->bus_io->read(&cfg->bus, reg, buf, size); } @@ -40,13 +41,13 @@ static inline int icm42670_reg_read(const struct device *dev, uint8_t reg, uint8 static inline int inv_io_hal_read_reg(struct inv_imu_serif *serif, uint8_t reg, uint8_t *rbuffer, uint32_t rlen) { - return icm42670_reg_read(serif->context, reg, rbuffer, rlen); + return icm42x70_reg_read(serif->context, reg, rbuffer, rlen); } -static inline int icm42670_reg_write(const struct device *dev, uint8_t reg, const uint8_t *buf, +static inline int icm42x70_reg_write(const struct device *dev, uint8_t reg, const uint8_t *buf, uint32_t size) { - const struct icm42670_config *cfg = dev->config; + const struct icm42x70_config *cfg = dev->config; return cfg->bus_io->write(&cfg->bus, reg, (uint8_t *)buf, size); } @@ -54,7 +55,7 @@ static inline int icm42670_reg_write(const struct device *dev, uint8_t reg, cons static inline int inv_io_hal_write_reg(struct inv_imu_serif *serif, uint8_t reg, const uint8_t *wbuffer, uint32_t wlen) { - return icm42670_reg_write(serif->context, reg, wbuffer, wlen); + return icm42x70_reg_write(serif->context, reg, wbuffer, wlen); } void inv_imu_sleep_us(uint32_t us) @@ -116,7 +117,7 @@ static uint16_t convert_dt_enum_to_freq(uint8_t val) return freq; } -static uint32_t convert_freq_to_bitfield(uint32_t val, uint16_t *freq) +uint32_t convert_freq_to_bitfield(uint32_t val, uint16_t *freq) { uint32_t odr_bitfield = 0; @@ -177,27 +178,7 @@ static uint32_t convert_acc_fs_to_bitfield(uint32_t val, uint8_t *fs) return bitfield; } -static uint32_t convert_gyr_fs_to_bitfield(uint32_t val, uint16_t *fs) -{ - uint32_t bitfield = 0; - - if (val < 500 && val >= 250) { - bitfield = GYRO_CONFIG0_FS_SEL_250dps; - *fs = 250; - } else if (val < 1000 && val >= 500) { - bitfield = GYRO_CONFIG0_FS_SEL_500dps; - *fs = 500; - } else if (val < 2000 && val >= 1000) { - bitfield = GYRO_CONFIG0_FS_SEL_1000dps; - *fs = 1000; - } else if (val == 2000) { - bitfield = GYRO_CONFIG0_FS_SEL_2000dps; - *fs = 2000; - } - return bitfield; -} - -static uint32_t convert_ln_bw_to_bitfield(uint32_t val) +uint32_t convert_ln_bw_to_bitfield(uint32_t val) { uint32_t bitfield = 0xFF; @@ -258,27 +239,11 @@ static uint8_t convert_bitfield_to_acc_fs(uint8_t bitfield) return acc_fs; } -static uint16_t convert_bitfield_to_gyr_fs(uint8_t bitfield) -{ - uint16_t gyr_fs = 0; - - if (bitfield == GYRO_CONFIG0_FS_SEL_250dps) { - gyr_fs = 250; - } else if (bitfield == GYRO_CONFIG0_FS_SEL_500dps) { - gyr_fs = 500; - } else if (bitfield == GYRO_CONFIG0_FS_SEL_1000dps) { - gyr_fs = 1000; - } else if (bitfield == GYRO_CONFIG0_FS_SEL_2000dps) { - gyr_fs = 2000; - } - return gyr_fs; -} - -static int icm42670_set_accel_power_mode(struct icm42670_data *drv_data, +static int icm42x70_set_accel_power_mode(struct icm42x70_data *drv_data, const struct sensor_value *val) { - if ((val->val1 == ICM42670_LOW_POWER_MODE) && - (drv_data->accel_pwr_mode != ICM42670_LOW_POWER_MODE)) { + if ((val->val1 == ICM42X70_LOW_POWER_MODE) && + (drv_data->accel_pwr_mode != ICM42X70_LOW_POWER_MODE)) { if (drv_data->accel_hz != 0) { if (drv_data->accel_hz <= 400) { inv_imu_enable_accel_low_power_mode(&drv_data->driver); @@ -288,8 +253,8 @@ static int icm42670_set_accel_power_mode(struct icm42670_data *drv_data, } } drv_data->accel_pwr_mode = val->val1; - } else if ((val->val1 == ICM42670_LOW_NOISE_MODE) && - (drv_data->accel_pwr_mode != ICM42670_LOW_NOISE_MODE)) { + } else if ((val->val1 == ICM42X70_LOW_NOISE_MODE) && + (drv_data->accel_pwr_mode != ICM42X70_LOW_NOISE_MODE)) { if (drv_data->accel_hz != 0) { if (drv_data->accel_hz >= 12) { inv_imu_enable_accel_low_noise_mode(&drv_data->driver); @@ -306,16 +271,16 @@ static int icm42670_set_accel_power_mode(struct icm42670_data *drv_data, return 0; } -static int icm42670_set_accel_odr(struct icm42670_data *drv_data, const struct sensor_value *val) +static int icm42x70_set_accel_odr(struct icm42x70_data *drv_data, const struct sensor_value *val) { if (val->val1 <= 1600 && val->val1 >= 1) { if (drv_data->accel_hz == 0) { inv_imu_set_accel_frequency( &drv_data->driver, convert_freq_to_bitfield(val->val1, &drv_data->accel_hz)); - if (drv_data->accel_pwr_mode == ICM42670_LOW_POWER_MODE) { + if (drv_data->accel_pwr_mode == ICM42X70_LOW_POWER_MODE) { inv_imu_enable_accel_low_power_mode(&drv_data->driver); - } else if (drv_data->accel_pwr_mode == ICM42670_LOW_NOISE_MODE) { + } else if (drv_data->accel_pwr_mode == ICM42X70_LOW_NOISE_MODE) { inv_imu_enable_accel_low_noise_mode(&drv_data->driver); } } else { @@ -333,7 +298,7 @@ static int icm42670_set_accel_odr(struct icm42670_data *drv_data, const struct s return 0; } -static int icm42670_set_accel_fs(struct icm42670_data *drv_data, const struct sensor_value *val) +static int icm42x70_set_accel_fs(struct icm42x70_data *drv_data, const struct sensor_value *val) { if (val->val1 > 16 || val->val1 < 2) { LOG_ERR("Incorrect fullscale value"); @@ -345,26 +310,26 @@ static int icm42670_set_accel_fs(struct icm42670_data *drv_data, const struct se return 0; } -static int icm42670_accel_config(struct icm42670_data *drv_data, enum sensor_attribute attr, +static int icm42x70_accel_config(struct icm42x70_data *drv_data, enum sensor_attribute attr, const struct sensor_value *val) { if (attr == SENSOR_ATTR_CONFIGURATION) { - icm42670_set_accel_power_mode(drv_data, val); + icm42x70_set_accel_power_mode(drv_data, val); } else if (attr == SENSOR_ATTR_SAMPLING_FREQUENCY) { - icm42670_set_accel_odr(drv_data, val); + icm42x70_set_accel_odr(drv_data, val); } else if (attr == SENSOR_ATTR_FULL_SCALE) { - icm42670_set_accel_fs(drv_data, val); + icm42x70_set_accel_fs(drv_data, val); - } else if ((enum sensor_attribute_icm42670)attr == SENSOR_ATTR_BW_FILTER_LPF) { + } else if ((enum sensor_attribute_icm42x70)attr == SENSOR_ATTR_BW_FILTER_LPF) { if (val->val1 > 180) { LOG_ERR("Incorrect low pass filter bandwidth value"); return -EINVAL; } inv_imu_set_accel_ln_bw(&drv_data->driver, convert_ln_bw_to_bitfield(val->val1)); - } else if ((enum sensor_attribute_icm42670)attr == SENSOR_ATTR_AVERAGING) { + } else if ((enum sensor_attribute_icm42x70)attr == SENSOR_ATTR_AVERAGING) { if (val->val1 > 64 || val->val1 < 2) { LOG_ERR("Incorrect averaging filter value"); return -EINVAL; @@ -377,75 +342,17 @@ static int icm42670_accel_config(struct icm42670_data *drv_data, enum sensor_att return 0; } -static int icm42670_set_gyro_odr(struct icm42670_data *drv_data, const struct sensor_value *val) -{ - if (val->val1 <= 1600 && val->val1 > 12) { - if (drv_data->gyro_hz == 0) { - inv_imu_set_gyro_frequency( - &drv_data->driver, - convert_freq_to_bitfield(val->val1, &drv_data->gyro_hz)); - inv_imu_enable_gyro_low_noise_mode(&drv_data->driver); - } else { - inv_imu_set_gyro_frequency( - &drv_data->driver, - convert_freq_to_bitfield(val->val1, &drv_data->gyro_hz)); - } - } else if (val->val1 == 0) { - inv_imu_disable_gyro(&drv_data->driver); - drv_data->gyro_hz = val->val1; - } else { - LOG_ERR("Incorrect sampling value"); - return -EINVAL; - } - return 0; -} - -static int icm42670_set_gyro_fs(struct icm42670_data *drv_data, const struct sensor_value *val) -{ - if (val->val1 > 2000 || val->val1 < 250) { - LOG_ERR("Incorrect fullscale value"); - return -EINVAL; - } - inv_imu_set_gyro_fsr(&drv_data->driver, - convert_gyr_fs_to_bitfield(val->val1, &drv_data->gyro_fs)); - LOG_DBG("Set gyro fullscale to: %d dps", drv_data->gyro_fs); - return 0; -} - -static int icm42670_gyro_config(struct icm42670_data *drv_data, enum sensor_attribute attr, - const struct sensor_value *val) -{ - if (attr == SENSOR_ATTR_SAMPLING_FREQUENCY) { - icm42670_set_gyro_odr(drv_data, val); - - } else if (attr == SENSOR_ATTR_FULL_SCALE) { - icm42670_set_gyro_fs(drv_data, val); - - } else if ((enum sensor_attribute_icm42670)attr == SENSOR_ATTR_BW_FILTER_LPF) { - if (val->val1 > 180) { - LOG_ERR("Incorrect low pass filter bandwidth value"); - return -EINVAL; - } - inv_imu_set_gyro_ln_bw(&drv_data->driver, convert_ln_bw_to_bitfield(val->val1)); - - } else { - LOG_ERR("Unsupported attribute"); - return -EINVAL; - } - return 0; -} - -static int icm42670_sensor_init(const struct device *dev) +static int icm42x70_sensor_init(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; int err = 0; /* Initialize serial interface and device */ data->serif.context = (struct device *)dev; data->serif.read_reg = inv_io_hal_read_reg; data->serif.write_reg = inv_io_hal_write_reg; - data->serif.max_read = ICM42670_SERIAL_INTERFACE_MAX_READ; - data->serif.max_write = ICM42670_SERIAL_INTERFACE_MAX_WRITE; + data->serif.max_read = ICM42X70_SERIAL_INTERFACE_MAX_READ; + data->serif.max_write = ICM42X70_SERIAL_INTERFACE_MAX_WRITE; #if CONFIG_SPI data->serif.serif_type = UI_SPI4; #endif @@ -474,10 +381,10 @@ static int icm42670_sensor_init(const struct device *dev) return 0; } -static int icm42670_turn_on_sensor(const struct device *dev) +static int icm42x70_turn_on_sensor(const struct device *dev) { - struct icm42670_data *data = dev->data; - const struct icm42670_config *cfg = dev->config; + struct icm42x70_data *data = dev->data; + const struct icm42x70_config *cfg = dev->config; int err = 0; err = inv_imu_set_accel_fsr(&data->driver, @@ -490,6 +397,7 @@ static int icm42670_turn_on_sensor(const struct device *dev) } LOG_DBG("Set accel full scale to: %d G", data->accel_fs); +#if CONFIG_USE_EMD_ICM42670 err = inv_imu_set_gyro_fsr(&data->driver, (cfg->gyro_fs << GYRO_CONFIG0_GYRO_UI_FS_SEL_POS)); data->gyro_fs = @@ -499,13 +407,16 @@ static int icm42670_turn_on_sensor(const struct device *dev) return -EIO; } LOG_DBG("Set gyro full scale to: %d dps", data->gyro_fs); +#endif err = inv_imu_set_accel_lp_avg(&data->driver, (cfg->accel_avg << ACCEL_CONFIG1_ACCEL_UI_AVG_POS)); err |= inv_imu_set_accel_ln_bw(&data->driver, (cfg->accel_filt_bw << ACCEL_CONFIG1_ACCEL_UI_FILT_BW_POS)); +#if CONFIG_USE_EMD_ICM42670 err |= inv_imu_set_gyro_ln_bw(&data->driver, (cfg->gyro_filt_bw << GYRO_CONFIG1_GYRO_UI_FILT_BW_POS)); +#endif if (err < 0) { LOG_ERR("Failed to configure filtering."); return -EIO; @@ -513,23 +424,24 @@ static int icm42670_turn_on_sensor(const struct device *dev) if (cfg->accel_hz != 0) { err |= inv_imu_set_accel_frequency( - &data->driver, cfg->accel_hz + ICM42670_CONVERT_ENUM_TO_ODR_POS); - if ((cfg->accel_pwr_mode == ICM42670_LOW_NOISE_MODE) && + &data->driver, cfg->accel_hz + ICM42X70_CONVERT_ENUM_TO_ODR_POS); + if ((cfg->accel_pwr_mode == ICM42X70_LOW_NOISE_MODE) && (convert_dt_enum_to_freq(cfg->accel_hz) >= 12)) { err |= inv_imu_enable_accel_low_noise_mode(&data->driver); - } else if ((cfg->accel_pwr_mode == ICM42670_LOW_POWER_MODE) && + } else if ((cfg->accel_pwr_mode == ICM42X70_LOW_POWER_MODE) && (convert_dt_enum_to_freq(cfg->accel_hz) <= 400)) { err |= inv_imu_enable_accel_low_power_mode(&data->driver); } else { LOG_ERR("Not supported power mode value"); } } +#if CONFIG_USE_EMD_ICM42670 if (cfg->gyro_hz != 0) { err |= inv_imu_set_gyro_frequency(&data->driver, - cfg->gyro_hz + ICM42670_CONVERT_ENUM_TO_ODR_POS); + cfg->gyro_hz + ICM42X70_CONVERT_ENUM_TO_ODR_POS); err |= inv_imu_enable_gyro_low_noise_mode(&data->driver); } - +#endif if (err < 0) { LOG_ERR("Failed to configure ODR."); return -EIO; @@ -537,7 +449,9 @@ static int icm42670_turn_on_sensor(const struct device *dev) data->accel_pwr_mode = cfg->accel_pwr_mode; data->accel_hz = convert_dt_enum_to_freq(cfg->accel_hz); +#if CONFIG_USE_EMD_ICM42670 data->gyro_hz = convert_dt_enum_to_freq(cfg->gyro_hz); +#endif /* * Accelerometer sensor need at least 10ms startup time @@ -548,7 +462,7 @@ static int icm42670_turn_on_sensor(const struct device *dev) return 0; } -static void icm42670_convert_accel(struct sensor_value *val, int16_t raw_val, uint16_t fs) +static void icm42x70_convert_accel(struct sensor_value *val, int16_t raw_val, uint16_t fs) { int64_t conv_val; @@ -560,19 +474,7 @@ static void icm42670_convert_accel(struct sensor_value *val, int16_t raw_val, ui val->val2 = conv_val % 1000000; } -static void icm42670_convert_gyro(struct sensor_value *val, int16_t raw_val, uint16_t fs) -{ - int64_t conv_val; - - /* 16 bit gyroscope. 2^15 bits represent the range in degrees/s */ - /* see datasheet section 3.1 for details */ - conv_val = ((int64_t)raw_val * fs * SENSOR_PI) / (INT16_MAX * 180U); - - val->val1 = conv_val / 1000000; - val->val2 = conv_val % 1000000; -} - -static void icm42670_convert_temp(struct sensor_value *val, int16_t raw_val) +static void icm42x70_convert_temp(struct sensor_value *val, int16_t raw_val) { int64_t conv_val; @@ -582,27 +484,28 @@ static void icm42670_convert_temp(struct sensor_value *val, int16_t raw_val) val->val2 = conv_val % 1000000; } -static int icm42670_channel_get(const struct device *dev, enum sensor_channel chan, +static int icm42x70_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { int res = 0; - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; #ifdef CONFIG_TDK_APEX - const struct icm42670_config *cfg = dev->config; + const struct icm42x70_config *cfg = dev->config; #endif - icm42670_lock(dev); + icm42x70_lock(dev); if (chan == SENSOR_CHAN_ACCEL_XYZ) { - icm42670_convert_accel(&val[0], data->accel_x, data->accel_fs); - icm42670_convert_accel(&val[1], data->accel_y, data->accel_fs); - icm42670_convert_accel(&val[2], data->accel_z, data->accel_fs); + icm42x70_convert_accel(&val[0], data->accel_x, data->accel_fs); + icm42x70_convert_accel(&val[1], data->accel_y, data->accel_fs); + icm42x70_convert_accel(&val[2], data->accel_z, data->accel_fs); } else if (chan == SENSOR_CHAN_ACCEL_X) { - icm42670_convert_accel(val, data->accel_x, data->accel_fs); + icm42x70_convert_accel(val, data->accel_x, data->accel_fs); } else if (chan == SENSOR_CHAN_ACCEL_Y) { - icm42670_convert_accel(val, data->accel_y, data->accel_fs); + icm42x70_convert_accel(val, data->accel_y, data->accel_fs); } else if (chan == SENSOR_CHAN_ACCEL_Z) { - icm42670_convert_accel(val, data->accel_z, data->accel_fs); + icm42x70_convert_accel(val, data->accel_z, data->accel_fs); +#if CONFIG_USE_EMD_ICM42670 } else if (chan == SENSOR_CHAN_GYRO_XYZ) { icm42670_convert_gyro(&val[0], data->gyro_x, data->gyro_fs); icm42670_convert_gyro(&val[1], data->gyro_y, data->gyro_fs); @@ -613,19 +516,20 @@ static int icm42670_channel_get(const struct device *dev, enum sensor_channel ch icm42670_convert_gyro(val, data->gyro_y, data->gyro_fs); } else if (chan == SENSOR_CHAN_GYRO_Z) { icm42670_convert_gyro(val, data->gyro_z, data->gyro_fs); +#endif } else if (chan == SENSOR_CHAN_DIE_TEMP) { - icm42670_convert_temp(val, data->temp); + icm42x70_convert_temp(val, data->temp); #ifdef CONFIG_TDK_APEX } else if ((enum sensor_channel_tdk_apex)chan == SENSOR_CHAN_APEX_MOTION) { if (cfg->apex == TDK_APEX_PEDOMETER) { val[0].val1 = data->pedometer_cnt; val[1].val1 = data->pedometer_activity; - icm42670_apex_pedometer_cadence_convert(&val[2], data->pedometer_cadence, + icm42x70_apex_pedometer_cadence_convert(&val[2], data->pedometer_cadence, data->dmp_odr_hz); } else if (cfg->apex == TDK_APEX_WOM) { - val[0].val1 = (data->apex_status & ICM42670_APEX_STATUS_MASK_WOM_X) ? 1 : 0; - val[1].val1 = (data->apex_status & ICM42670_APEX_STATUS_MASK_WOM_Y) ? 1 : 0; - val[2].val1 = (data->apex_status & ICM42670_APEX_STATUS_MASK_WOM_Z) ? 1 : 0; + val[0].val1 = (data->apex_status & ICM42X70_APEX_STATUS_MASK_WOM_X) ? 1 : 0; + val[1].val1 = (data->apex_status & ICM42X70_APEX_STATUS_MASK_WOM_Y) ? 1 : 0; + val[2].val1 = (data->apex_status & ICM42X70_APEX_STATUS_MASK_WOM_Z) ? 1 : 0; } else if ((cfg->apex == TDK_APEX_TILT) || (cfg->apex == TDK_APEX_SMD)) { val[0].val1 = data->apex_status; } @@ -634,15 +538,15 @@ static int icm42670_channel_get(const struct device *dev, enum sensor_channel ch res = -ENOTSUP; } - icm42670_unlock(dev); + icm42x70_unlock(dev); return res; } -#ifdef CONFIG_ICM42670_TRIGGER -static int icm42670_fetch_from_fifo(const struct device *dev) +#ifdef CONFIG_ICM42X70_TRIGGER +static int icm42x70_fetch_from_fifo(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; int status = 0; uint8_t int_status; uint16_t packet_size = FIFO_HEADER_SIZE + FIFO_ACCEL_DATA_SIZE + FIFO_GYRO_DATA_SIZE + @@ -701,11 +605,13 @@ static int icm42670_fetch_from_fifo(const struct device *dev) data->accel_y = event.accel[1]; data->accel_z = event.accel[2]; } +#if CONFIG_USE_EMD_ICM42670 if (event.sensor_mask & (1 << INV_SENSOR_GYRO)) { data->gyro_x = event.gyro[0]; data->gyro_y = event.gyro[1]; data->gyro_z = event.gyro[2]; } +#endif if (event.sensor_mask & (1 << INV_SENSOR_TEMPERATURE)) { data->temp = event.temperature; } @@ -726,10 +632,10 @@ static int icm42670_fetch_from_fifo(const struct device *dev) } #endif -#ifndef CONFIG_ICM42670_TRIGGER -static int icm42670_sample_fetch_accel(const struct device *dev) +#ifndef CONFIG_ICM42X70_TRIGGER +static int icm42x70_sample_fetch_accel(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; uint8_t buffer[ACCEL_DATA_SIZE]; int res = inv_imu_read_reg(&data->driver, ACCEL_DATA_X1, ACCEL_DATA_SIZE, buffer); @@ -745,27 +651,9 @@ static int icm42670_sample_fetch_accel(const struct device *dev) return 0; } -static int icm42670_sample_fetch_gyro(const struct device *dev) -{ - struct icm42670_data *data = dev->data; - uint8_t buffer[GYRO_DATA_SIZE]; - - int res = inv_imu_read_reg(&data->driver, GYRO_DATA_X1, GYRO_DATA_SIZE, buffer); - - if (res) { - return res; - } - - data->gyro_x = (int16_t)sys_get_be16(&buffer[0]); - data->gyro_y = (int16_t)sys_get_be16(&buffer[2]); - data->gyro_z = (int16_t)sys_get_be16(&buffer[4]); - - return 0; -} - -static int icm42670_sample_fetch_temp(const struct device *dev) +static int icm42x70_sample_fetch_temp(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; uint8_t buffer[TEMP_DATA_SIZE]; int res = inv_imu_read_reg(&data->driver, TEMP_DATA1, TEMP_DATA_SIZE, buffer); @@ -779,15 +667,15 @@ static int icm42670_sample_fetch_temp(const struct device *dev) return 0; } -static int icm42670_fetch_from_registers(const struct device *dev, enum sensor_channel chan) +static int icm42x70_fetch_from_registers(const struct device *dev, enum sensor_channel chan) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; int res = 0; uint8_t int_status; LOG_ERR("Fetch from reg"); - icm42670_lock(dev); + icm42x70_lock(dev); /* Ensure data ready status bit is set */ int err = inv_imu_read_reg(&data->driver, INT_STATUS_DRDY, 1, &int_status); @@ -795,24 +683,28 @@ static int icm42670_fetch_from_registers(const struct device *dev, enum sensor_c if (int_status & INT_STATUS_DRDY_DATA_RDY_INT_MASK) { switch (chan) { case SENSOR_CHAN_ALL: - err |= icm42670_sample_fetch_accel(dev); + err |= icm42x70_sample_fetch_accel(dev); +#if CONFIG_USE_EMD_ICM42670 err |= icm42670_sample_fetch_gyro(dev); - err |= icm42670_sample_fetch_temp(dev); +#endif + err |= icm42x70_sample_fetch_temp(dev); break; case SENSOR_CHAN_ACCEL_XYZ: case SENSOR_CHAN_ACCEL_X: case SENSOR_CHAN_ACCEL_Y: case SENSOR_CHAN_ACCEL_Z: - err |= icm42670_sample_fetch_accel(dev); + err |= icm42x70_sample_fetch_accel(dev); break; +#if CONFIG_USE_EMD_ICM42670 case SENSOR_CHAN_GYRO_XYZ: case SENSOR_CHAN_GYRO_X: case SENSOR_CHAN_GYRO_Y: case SENSOR_CHAN_GYRO_Z: err |= icm42670_sample_fetch_gyro(dev); break; +#endif case SENSOR_CHAN_DIE_TEMP: - err |= icm42670_sample_fetch_temp(dev); + err |= icm42x70_sample_fetch_temp(dev); break; default: res = -ENOTSUP; @@ -820,7 +712,7 @@ static int icm42670_fetch_from_registers(const struct device *dev, enum sensor_c } } - icm42670_unlock(dev); + icm42x70_unlock(dev); if (err < 0) { res = -EIO; @@ -829,57 +721,57 @@ static int icm42670_fetch_from_registers(const struct device *dev, enum sensor_c } #endif -static int icm42670_sample_fetch(const struct device *dev, enum sensor_channel chan) +static int icm42x70_sample_fetch(const struct device *dev, enum sensor_channel chan) { int status = -ENOTSUP; - icm42670_lock(dev); + icm42x70_lock(dev); #ifdef CONFIG_TDK_APEX if ((enum sensor_channel_tdk_apex)chan == SENSOR_CHAN_APEX_MOTION) { - status = icm42670_apex_fetch_from_dmp(dev); + status = icm42x70_apex_fetch_from_dmp(dev); } #endif - if ((chan == SENSOR_CHAN_ALL) || (chan == SENSOR_CHAN_ACCEL_XYZ) || - (chan == SENSOR_CHAN_ACCEL_X) || (chan == SENSOR_CHAN_ACCEL_Y) || - (chan == SENSOR_CHAN_ACCEL_Z) || (chan == SENSOR_CHAN_GYRO_XYZ) || - (chan == SENSOR_CHAN_GYRO_X) || (chan == SENSOR_CHAN_GYRO_Y) || - (chan == SENSOR_CHAN_GYRO_Z) || (chan == SENSOR_CHAN_DIE_TEMP)) { -#ifdef CONFIG_ICM42670_TRIGGER - status = icm42670_fetch_from_fifo(dev); + if ((chan == SENSOR_CHAN_ALL) || SENSOR_CHANNEL_IS_ACCEL(chan) +#if CONFIG_USE_EMD_ICM42670 + || SENSOR_CHANNEL_IS_GYRO(chan) +#endif + || (chan == SENSOR_CHAN_DIE_TEMP)) { +#ifdef CONFIG_ICM42X70_TRIGGER + status = icm42x70_fetch_from_fifo(dev); #else - status = icm42670_fetch_from_registers(dev, chan); + status = icm42x70_fetch_from_registers(dev, chan); #endif } - icm42670_unlock(dev); + icm42x70_unlock(dev); return status; } -static int icm42670_attr_set(const struct device *dev, enum sensor_channel chan, +static int icm42x70_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { - struct icm42670_data *drv_data = dev->data; + struct icm42x70_data *drv_data = dev->data; __ASSERT_NO_MSG(val != NULL); - icm42670_lock(dev); + icm42x70_lock(dev); if ((enum sensor_channel_tdk_apex)chan == SENSOR_CHAN_APEX_MOTION) { if (attr == SENSOR_ATTR_CONFIGURATION) { #ifdef CONFIG_TDK_APEX if (val->val1 == TDK_APEX_PEDOMETER) { - icm42670_apex_enable(&drv_data->driver); - icm42670_apex_enable_pedometer(dev, &drv_data->driver); + icm42x70_apex_enable(&drv_data->driver); + icm42x70_apex_enable_pedometer(dev, &drv_data->driver); } else if (val->val1 == TDK_APEX_TILT) { - icm42670_apex_enable(&drv_data->driver); - icm42670_apex_enable_tilt(&drv_data->driver); + icm42x70_apex_enable(&drv_data->driver); + icm42x70_apex_enable_tilt(&drv_data->driver); } else if (val->val1 == TDK_APEX_SMD) { - icm42670_apex_enable(&drv_data->driver); - icm42670_apex_enable_smd(&drv_data->driver); + icm42x70_apex_enable(&drv_data->driver); + icm42x70_apex_enable_smd(&drv_data->driver); } else if (val->val1 == TDK_APEX_WOM) { - icm42670_apex_enable_wom(&drv_data->driver); + icm42x70_apex_enable_wom(&drv_data->driver); } else { LOG_ERR("Not supported ATTR value"); } @@ -888,35 +780,33 @@ static int icm42670_attr_set(const struct device *dev, enum sensor_channel chan, LOG_ERR("Not supported ATTR"); return -EINVAL; } - } else if ((chan == SENSOR_CHAN_ACCEL_XYZ) || (chan == SENSOR_CHAN_ACCEL_X) || - (chan == SENSOR_CHAN_ACCEL_Y) || (chan == SENSOR_CHAN_ACCEL_Z)) { - icm42670_accel_config(drv_data, attr, val); - - } else if ((chan == SENSOR_CHAN_GYRO_XYZ) || (chan == SENSOR_CHAN_GYRO_X) || - (chan == SENSOR_CHAN_GYRO_Y) || (chan == SENSOR_CHAN_GYRO_Z)) { + } else if (SENSOR_CHANNEL_IS_ACCEL(chan)) { + icm42x70_accel_config(drv_data, attr, val); +#if CONFIG_USE_EMD_ICM42670 + } else if (SENSOR_CHANNEL_IS_GYRO(chan)) { icm42670_gyro_config(drv_data, attr, val); - +#endif } else { LOG_ERR("Unsupported channel"); (void)drv_data; return -EINVAL; } - icm42670_unlock(dev); + icm42x70_unlock(dev); return 0; } -static int icm42670_attr_get(const struct device *dev, enum sensor_channel chan, +static int icm42x70_attr_get(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val) { - const struct icm42670_data *data = dev->data; - const struct icm42670_config *cfg = dev->config; + const struct icm42x70_data *data = dev->data; + const struct icm42x70_config *cfg = dev->config; int res = 0; __ASSERT_NO_MSG(val != NULL); - icm42670_lock(dev); + icm42x70_lock(dev); switch (chan) { case SENSOR_CHAN_ACCEL_X: @@ -932,7 +822,7 @@ static int icm42670_attr_get(const struct device *dev, enum sensor_channel chan, res = -EINVAL; } break; - +#if CONFIG_USE_EMD_ICM42670 case SENSOR_CHAN_GYRO_X: case SENSOR_CHAN_GYRO_Y: case SENSOR_CHAN_GYRO_Z: @@ -946,7 +836,7 @@ static int icm42670_attr_get(const struct device *dev, enum sensor_channel chan, res = -EINVAL; } break; - +#endif case SENSOR_CHAN_APEX_MOTION: if (attr == SENSOR_ATTR_CONFIGURATION) { val->val1 = cfg->apex; @@ -959,24 +849,24 @@ static int icm42670_attr_get(const struct device *dev, enum sensor_channel chan, break; } - icm42670_unlock(dev); + icm42x70_unlock(dev); return res; } -static inline int icm42670_bus_check(const struct device *dev) +static inline int icm42x70_bus_check(const struct device *dev) { - const struct icm42670_config *cfg = dev->config; + const struct icm42x70_config *cfg = dev->config; return cfg->bus_io->check(&cfg->bus); } -static int icm42670_init(const struct device *dev) +static int icm42x70_init(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; int res = 0; - if (icm42670_bus_check(dev) < 0) { + if (icm42x70_bus_check(dev) < 0) { LOG_ERR("bus check failed"); return -ENODEV; } @@ -984,107 +874,120 @@ static int icm42670_init(const struct device *dev) data->accel_x = 0; data->accel_y = 0; data->accel_z = 0; +#if CONFIG_USE_EMD_ICM42670 data->gyro_x = 0; data->gyro_y = 0; data->gyro_z = 0; +#endif data->temp = 0; - if (icm42670_sensor_init(dev)) { + if (icm42x70_sensor_init(dev)) { LOG_ERR("could not initialize sensor"); return -EIO; } -#ifdef CONFIG_ICM42670_TRIGGER - res |= icm42670_trigger_enable_interrupt(dev); - res |= icm42670_trigger_init(dev); +#ifdef CONFIG_ICM42X70_TRIGGER + res |= icm42x70_trigger_enable_interrupt(dev); + res |= icm42x70_trigger_init(dev); if (res < 0) { LOG_ERR("Failed to initialize interrupt."); return res; } #endif - res |= icm42670_turn_on_sensor(dev); + res |= icm42x70_turn_on_sensor(dev); return res; } -#ifndef CONFIG_ICM42670_TRIGGER +#ifndef CONFIG_ICM42X70_TRIGGER -void icm42670_lock(const struct device *dev) +void icm42x70_lock(const struct device *dev) { ARG_UNUSED(dev); } -void icm42670_unlock(const struct device *dev) +void icm42x70_unlock(const struct device *dev) { ARG_UNUSED(dev); } #endif -static DEVICE_API(sensor, icm42670_driver_api) = { -#ifdef CONFIG_ICM42670_TRIGGER - .trigger_set = icm42670_trigger_set, +static DEVICE_API(sensor, icm42x70_driver_api) = { +#ifdef CONFIG_ICM42X70_TRIGGER + .trigger_set = icm42x70_trigger_set, #endif - .sample_fetch = icm42670_sample_fetch, - .channel_get = icm42670_channel_get, - .attr_set = icm42670_attr_set, - .attr_get = icm42670_attr_get, + .sample_fetch = icm42x70_sample_fetch, + .channel_get = icm42x70_channel_get, + .attr_set = icm42x70_attr_set, + .attr_get = icm42x70_attr_get, }; /* device defaults to spi mode 0/3 support */ -#define ICM42670_SPI_CFG (SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_MODE_CPOL | SPI_MODE_CPHA) +#define ICM42X70_SPI_CFG (SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_MODE_CPOL | SPI_MODE_CPHA) -/* Initializes a common struct icm42670_config */ -#define ICM42670_CONFIG_COMMON(inst) \ - IF_ENABLED(CONFIG_ICM42670_TRIGGER, \ +/* Initializes a common struct icm42x70_config */ +#define ICM42X70_CONFIG_COMMON(inst) \ + IF_ENABLED(CONFIG_ICM42X70_TRIGGER, \ (.gpio_int = GPIO_DT_SPEC_INST_GET_OR(inst, int_gpios, {0}),)) \ .accel_fs = DT_INST_ENUM_IDX(inst, accel_fs), \ .accel_hz = DT_INST_ENUM_IDX(inst, accel_hz), \ .accel_avg = DT_INST_ENUM_IDX(inst, accel_avg), \ .accel_filt_bw = DT_INST_ENUM_IDX(inst, accel_filt_bw_hz), \ - .gyro_fs = DT_INST_ENUM_IDX(inst, gyro_fs), \ - .gyro_hz = DT_INST_ENUM_IDX(inst, gyro_hz), \ - .gyro_filt_bw = DT_INST_ENUM_IDX(inst, gyro_filt_bw_hz), \ .accel_pwr_mode = DT_INST_ENUM_IDX(inst, power_mode), \ - .apex = DT_INST_ENUM_IDX(inst, apex), + .apex = DT_INST_ENUM_IDX(inst, apex), \ + .accel_pwr_mode = DT_INST_ENUM_IDX(inst, power_mode), \ + .apex = DT_INST_ENUM_IDX(inst, apex), \ + IF_ENABLED(CONFIG_USE_EMD_ICM42670, \ + (.gyro_fs = DT_INST_ENUM_IDX(inst, gyro_fs),)) \ + IF_ENABLED(CONFIG_USE_EMD_ICM42670, \ + (.gyro_hz = DT_INST_ENUM_IDX(inst, gyro_hz),)) \ + IF_ENABLED(CONFIG_USE_EMD_ICM42670, \ + (.gyro_filt_bw = DT_INST_ENUM_IDX(inst, gyro_filt_bw_hz),)) /* Initializes the bus members for an instance on a SPI bus. */ -#define ICM42670_CONFIG_SPI(inst) \ - {.bus.spi = SPI_DT_SPEC_INST_GET(inst, ICM42670_SPI_CFG, 0), \ - .bus_io = &icm42670_bus_io_spi, \ - ICM42670_CONFIG_COMMON(inst)} +#define ICM42X70_CONFIG_SPI(inst) \ + {.bus.spi = SPI_DT_SPEC_INST_GET(inst, ICM42X70_SPI_CFG, 0), \ + .bus_io = &icm42x70_bus_io_spi, \ + ICM42X70_CONFIG_COMMON(inst)} /* Initializes the bus members for an instance on an I2C bus. */ -#define ICM42670_CONFIG_I2C(inst) \ +#define ICM42X70_CONFIG_I2C(inst) \ {.bus.i2c = I2C_DT_SPEC_INST_GET(inst), \ - .bus_io = &icm42670_bus_io_i2c, \ - ICM42670_CONFIG_COMMON(inst)} + .bus_io = &icm42x70_bus_io_i2c, \ + ICM42X70_CONFIG_COMMON(inst)} /* * Main instantiation macro, which selects the correct bus-specific * instantiation macros for the instance. */ -#define ICM42670_DEFINE(inst, name, whoami) \ - static struct icm42670_data icm42670_data_##inst = { \ +#define ICM42X70_DEFINE(inst, name, whoami) \ + static struct icm42x70_data icm42x70_data_##inst = { \ .imu_name = name, \ .imu_whoami = whoami, \ }; \ - static const struct icm42670_config icm42670_config_##inst = \ + static const struct icm42x70_config icm42x70_config_##inst = \ COND_CODE_1(DT_INST_ON_BUS(inst, spi), \ - (ICM42670_CONFIG_SPI(inst)), \ - (ICM42670_CONFIG_I2C(inst))); \ - SENSOR_DEVICE_DT_INST_DEFINE(inst, icm42670_init, NULL, &icm42670_data_##inst, \ - &icm42670_config_##inst, POST_KERNEL, \ - CONFIG_SENSOR_INIT_PRIORITY, &icm42670_driver_api); + (ICM42X70_CONFIG_SPI(inst)), \ + (ICM42X70_CONFIG_I2C(inst))); \ + SENSOR_DEVICE_DT_INST_DEFINE(inst, icm42x70_init, NULL, &icm42x70_data_##inst, \ + &icm42x70_config_##inst, POST_KERNEL, \ + CONFIG_SENSOR_INIT_PRIORITY, &icm42x70_driver_api); #define DT_DRV_COMPAT invensense_icm42670p #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -DT_INST_FOREACH_STATUS_OKAY_VARGS(ICM42670_DEFINE, INV_ICM42670P_STRING_ID, INV_ICM42670P_WHOAMI); +DT_INST_FOREACH_STATUS_OKAY_VARGS(ICM42X70_DEFINE, INV_ICM42670P_STRING_ID, INV_ICM42670P_WHOAMI); #endif #undef DT_DRV_COMPAT #define DT_DRV_COMPAT invensense_icm42670s #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -DT_INST_FOREACH_STATUS_OKAY_VARGS(ICM42670_DEFINE, INV_ICM42670S_STRING_ID, INV_ICM42670S_WHOAMI); +DT_INST_FOREACH_STATUS_OKAY_VARGS(ICM42X70_DEFINE, INV_ICM42670S_STRING_ID, INV_ICM42670S_WHOAMI); +#endif +#undef DT_DRV_COMPAT + +#define DT_DRV_COMPAT invensense_icm42370p +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) +DT_INST_FOREACH_STATUS_OKAY_VARGS(ICM42X70_DEFINE, INV_ICM42370P_STRING_ID, INV_ICM42370P_WHOAMI); #endif diff --git a/drivers/sensor/tdk/icm42670/icm42670.h b/drivers/sensor/tdk/icm42x70/icm42x70.h similarity index 51% rename from drivers/sensor/tdk/icm42670/icm42670.h rename to drivers/sensor/tdk/icm42x70/icm42x70.h index c029d7c6f911..5fa74f5c7b98 100644 --- a/drivers/sensor/tdk/icm42670/icm42670.h +++ b/drivers/sensor/tdk/icm42x70/icm42x70.h @@ -6,8 +6,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_DRIVERS_SENSOR_ICM42670_H_ -#define ZEPHYR_DRIVERS_SENSOR_ICM42670_H_ +#ifndef ZEPHYR_DRIVERS_SENSOR_ICM42X70_H_ +#define ZEPHYR_DRIVERS_SENSOR_ICM42X70_H_ #include #include @@ -20,7 +20,7 @@ #include "imu/inv_imu_apex.h" #endif -union icm42670_bus { +union icm42x70_bus { #if CONFIG_SPI struct spi_dt_spec spi; #endif @@ -29,27 +29,27 @@ union icm42670_bus { #endif }; -typedef int (*icm42670_bus_check_fn)(const union icm42670_bus *bus); -typedef int (*icm42670_reg_read_fn)(const union icm42670_bus *bus, uint8_t reg, uint8_t *buf, +typedef int (*icm42x70_bus_check_fn)(const union icm42x70_bus *bus); +typedef int (*icm42x70_reg_read_fn)(const union icm42x70_bus *bus, uint8_t reg, uint8_t *buf, uint32_t size); -typedef int (*icm42670_reg_write_fn)(const union icm42670_bus *bus, uint8_t reg, uint8_t *buf, +typedef int (*icm42x70_reg_write_fn)(const union icm42x70_bus *bus, uint8_t reg, uint8_t *buf, uint32_t size); -struct icm42670_bus_io { - icm42670_bus_check_fn check; - icm42670_reg_read_fn read; - icm42670_reg_write_fn write; +struct icm42x70_bus_io { + icm42x70_bus_check_fn check; + icm42x70_reg_read_fn read; + icm42x70_reg_write_fn write; }; #if CONFIG_SPI -extern const struct icm42670_bus_io icm42670_bus_io_spi; +extern const struct icm42x70_bus_io icm42x70_bus_io_spi; #endif #if CONFIG_I2C -extern const struct icm42670_bus_io icm42670_bus_io_i2c; +extern const struct icm42x70_bus_io icm42x70_bus_io_i2c; #endif -struct icm42670_data { +struct icm42x70_data { struct inv_imu_serif serif; struct inv_imu_device driver; uint8_t imu_whoami; @@ -61,11 +61,13 @@ struct icm42670_data { uint16_t accel_hz; uint8_t accel_fs; uint8_t accel_pwr_mode; +#if CONFIG_USE_EMD_ICM42670 int32_t gyro_x; int32_t gyro_y; int32_t gyro_z; uint16_t gyro_hz; uint16_t gyro_fs; +#endif int32_t temp; #ifdef CONFIG_TDK_APEX uint8_t dmp_odr_hz; @@ -75,54 +77,59 @@ struct icm42670_data { uint8_t apex_status; #endif -#ifdef CONFIG_ICM42670_TRIGGER +#ifdef CONFIG_ICM42X70_TRIGGER const struct device *dev; struct gpio_callback gpio_cb; sensor_trigger_handler_t data_ready_handler; const struct sensor_trigger *data_ready_trigger; struct k_mutex mutex; #endif -#ifdef CONFIG_ICM42670_TRIGGER_OWN_THREAD - K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_ICM42670_THREAD_STACK_SIZE); +#ifdef CONFIG_ICM42X70_TRIGGER_OWN_THREAD + K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_ICM42X70_THREAD_STACK_SIZE); struct k_thread thread; struct k_sem gpio_sem; #endif -#ifdef CONFIG_ICM42670_TRIGGER_GLOBAL_THREAD +#ifdef CONFIG_ICM42X70_TRIGGER_GLOBAL_THREAD struct k_work work; #endif }; -struct icm42670_config { - union icm42670_bus bus; - const struct icm42670_bus_io *bus_io; +struct icm42x70_config { + union icm42x70_bus bus; + const struct icm42x70_bus_io *bus_io; struct gpio_dt_spec gpio_int; uint8_t accel_fs; uint16_t accel_hz; uint16_t accel_avg; uint16_t accel_filt_bw; +#if CONFIG_USE_EMD_ICM42670 uint16_t gyro_fs; uint16_t gyro_hz; uint16_t gyro_filt_bw; +#endif uint8_t accel_pwr_mode; uint8_t apex; }; +uint32_t convert_freq_to_bitfield(uint32_t val, uint16_t *freq); +uint32_t convert_ln_bw_to_bitfield(uint32_t val); + #ifdef CONFIG_TDK_APEX -#define ICM42670_APEX_STATUS_MASK_TILT BIT(0) -#define ICM42670_APEX_STATUS_MASK_SMD BIT(1) -#define ICM42670_APEX_STATUS_MASK_WOM_X BIT(2) -#define ICM42670_APEX_STATUS_MASK_WOM_Y BIT(3) -#define ICM42670_APEX_STATUS_MASK_WOM_Z BIT(4) +#define ICM42X70_APEX_STATUS_MASK_TILT BIT(0) +#define ICM42X70_APEX_STATUS_MASK_SMD BIT(1) +#define ICM42X70_APEX_STATUS_MASK_WOM_X BIT(2) +#define ICM42X70_APEX_STATUS_MASK_WOM_Y BIT(3) +#define ICM42X70_APEX_STATUS_MASK_WOM_Z BIT(4) -int icm42670_apex_enable(inv_imu_device_t *s); -int icm42670_apex_fetch_from_dmp(const struct device *dev); -void icm42670_apex_pedometer_cadence_convert(struct sensor_value *val, uint8_t raw_val, +int icm42x70_apex_enable(inv_imu_device_t *s); +int icm42x70_apex_fetch_from_dmp(const struct device *dev); +void icm42x70_apex_pedometer_cadence_convert(struct sensor_value *val, uint8_t raw_val, uint8_t dmp_odr_hz); -int icm42670_apex_enable_pedometer(const struct device *dev, inv_imu_device_t *s); -int icm42670_apex_enable_tilt(inv_imu_device_t *s); -int icm42670_apex_enable_smd(inv_imu_device_t *s); -int icm42670_apex_enable_wom(inv_imu_device_t *s); +int icm42x70_apex_enable_pedometer(const struct device *dev, inv_imu_device_t *s); +int icm42x70_apex_enable_tilt(inv_imu_device_t *s); +int icm42x70_apex_enable_smd(inv_imu_device_t *s); +int icm42x70_apex_enable_wom(inv_imu_device_t *s); #endif -#endif /* ZEPHYR_DRIVERS_SENSOR_ICM42670_H_ */ +#endif /* ZEPHYR_DRIVERS_SENSOR_ICM42X70_H_ */ diff --git a/drivers/sensor/tdk/icm42670/icm42670_apex.c b/drivers/sensor/tdk/icm42x70/icm42x70_apex.c similarity index 85% rename from drivers/sensor/tdk/icm42670/icm42670_apex.c rename to drivers/sensor/tdk/icm42x70/icm42x70_apex.c index bdd128b6238e..0761ff9db692 100644 --- a/drivers/sensor/tdk/icm42670/icm42670_apex.c +++ b/drivers/sensor/tdk/icm42x70/icm42x70_apex.c @@ -4,10 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "icm42670.h" +#include "icm42x70.h" #include "imu/inv_imu_apex.h" -int icm42670_apex_enable(inv_imu_device_t *s) +int icm42x70_apex_enable(inv_imu_device_t *s) { int err = 0; inv_imu_apex_parameters_t apex_inputs; @@ -47,9 +47,9 @@ int icm42670_apex_enable(inv_imu_device_t *s) return err; } -int icm42670_apex_fetch_from_dmp(const struct device *dev) +int icm42x70_apex_fetch_from_dmp(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; int rc = 0; uint8_t int_status2, int_status3; @@ -81,30 +81,30 @@ int icm42670_apex_fetch_from_dmp(const struct device *dev) } /* Test Tilt interrupt */ if (int_status3 & (INT_STATUS3_TILT_DET_INT_MASK)) { - data->apex_status = ICM42670_APEX_STATUS_MASK_TILT; + data->apex_status = ICM42X70_APEX_STATUS_MASK_TILT; } /* Test SMD interrupt */ if ((int_status2 & (INT_STATUS2_SMD_INT_MASK)) || (rc != 0)) { - data->apex_status = ICM42670_APEX_STATUS_MASK_SMD; + data->apex_status = ICM42X70_APEX_STATUS_MASK_SMD; } /* Test WOM interrupts */ if (int_status2 & (INT_STATUS2_WOM_X_INT_MASK | INT_STATUS2_WOM_Y_INT_MASK | INT_STATUS2_WOM_Z_INT_MASK)) { data->apex_status = 0; if (int_status2 & INT_STATUS2_WOM_X_INT_MASK) { - data->apex_status |= ICM42670_APEX_STATUS_MASK_WOM_X; + data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_X; } if (int_status2 & INT_STATUS2_WOM_Y_INT_MASK) { - data->apex_status |= ICM42670_APEX_STATUS_MASK_WOM_Y; + data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Y; } if (int_status2 & INT_STATUS2_WOM_Z_INT_MASK) { - data->apex_status |= ICM42670_APEX_STATUS_MASK_WOM_Z; + data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Z; } } return rc; } -void icm42670_apex_pedometer_cadence_convert(struct sensor_value *val, uint8_t raw_val, +void icm42x70_apex_pedometer_cadence_convert(struct sensor_value *val, uint8_t raw_val, uint8_t dmp_odr_hz) { int64_t conv_val; @@ -115,22 +115,22 @@ void icm42670_apex_pedometer_cadence_convert(struct sensor_value *val, uint8_t r val->val2 = conv_val % 1000000; } -int icm42670_apex_enable_pedometer(const struct device *dev, inv_imu_device_t *s) +int icm42x70_apex_enable_pedometer(const struct device *dev, inv_imu_device_t *s) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; data->dmp_odr_hz = 50; /* Enable the pedometer */ return inv_imu_apex_enable_pedometer(s); } -int icm42670_apex_enable_tilt(inv_imu_device_t *s) +int icm42x70_apex_enable_tilt(inv_imu_device_t *s) { /* Enable Tilt */ return inv_imu_apex_enable_tilt(s); } -int icm42670_apex_enable_smd(inv_imu_device_t *s) +int icm42x70_apex_enable_smd(inv_imu_device_t *s) { int rc = 0; @@ -141,7 +141,7 @@ int icm42670_apex_enable_smd(inv_imu_device_t *s) return rc; } -int icm42670_apex_enable_wom(inv_imu_device_t *s) +int icm42x70_apex_enable_wom(inv_imu_device_t *s) { int rc = 0; inv_imu_interrupt_parameter_t config_int = {(inv_imu_interrupt_value)0}; diff --git a/drivers/sensor/tdk/icm42670/icm42670_i2c.c b/drivers/sensor/tdk/icm42x70/icm42x70_i2c.c similarity index 52% rename from drivers/sensor/tdk/icm42670/icm42670_i2c.c rename to drivers/sensor/tdk/icm42x70/icm42x70_i2c.c index a3871ec25d5c..7f81c9bc8a7e 100644 --- a/drivers/sensor/tdk/icm42670/icm42670_i2c.c +++ b/drivers/sensor/tdk/icm42x70/icm42x70_i2c.c @@ -6,32 +6,32 @@ */ /* - * Bus-specific functionality for ICM42670 accessed via I2C. + * Bus-specific functionality for ICM42X70 accessed via I2C. */ -#include "icm42670.h" +#include "icm42x70.h" #if CONFIG_I2C -static int icm42670_bus_check_i2c(const union icm42670_bus *bus) +static int icm42x70_bus_check_i2c(const union icm42x70_bus *bus) { return device_is_ready(bus->i2c.bus) ? 0 : -ENODEV; } -static int icm42670_reg_read_i2c(const union icm42670_bus *bus, uint8_t reg, uint8_t *buf, +static int icm42x70_reg_read_i2c(const union icm42x70_bus *bus, uint8_t reg, uint8_t *buf, uint32_t size) { return i2c_burst_read_dt(&bus->i2c, reg, buf, size); } -static int icm42670_reg_write_i2c(const union icm42670_bus *bus, uint8_t reg, uint8_t *buf, +static int icm42x70_reg_write_i2c(const union icm42x70_bus *bus, uint8_t reg, uint8_t *buf, uint32_t size) { return i2c_burst_write_dt(&bus->i2c, reg, buf, size); } -const struct icm42670_bus_io icm42670_bus_io_i2c = { - .check = icm42670_bus_check_i2c, - .read = icm42670_reg_read_i2c, - .write = icm42670_reg_write_i2c, +const struct icm42x70_bus_io icm42x70_bus_io_i2c = { + .check = icm42x70_bus_check_i2c, + .read = icm42x70_reg_read_i2c, + .write = icm42x70_reg_write_i2c, }; #endif /* CONFIG_I2C */ diff --git a/drivers/sensor/tdk/icm42670/icm42670_spi.c b/drivers/sensor/tdk/icm42x70/icm42x70_spi.c similarity index 71% rename from drivers/sensor/tdk/icm42670/icm42670_spi.c rename to drivers/sensor/tdk/icm42x70/icm42x70_spi.c index 22c778c5ee99..1e55efcd5073 100644 --- a/drivers/sensor/tdk/icm42670/icm42670_spi.c +++ b/drivers/sensor/tdk/icm42x70/icm42x70_spi.c @@ -7,22 +7,22 @@ */ /* - * Bus-specific functionality for ICM42670 accessed via SPI. + * Bus-specific functionality for ICM42X70 accessed via SPI. */ -#include "icm42670.h" +#include "icm42x70.h" #if CONFIG_SPI #include -LOG_MODULE_DECLARE(ICM42670, CONFIG_SENSOR_LOG_LEVEL); +LOG_MODULE_DECLARE(ICM42X70, CONFIG_SENSOR_LOG_LEVEL); -static int icm42670_bus_check_spi(const union icm42670_bus *bus) +static int icm42x70_bus_check_spi(const union icm42x70_bus *bus) { return spi_is_ready_dt(&bus->spi) ? 0 : -ENODEV; } -static int icm42670_reg_read_spi(const union icm42670_bus *bus, uint8_t start, uint8_t *buf, +static int icm42x70_reg_read_spi(const union icm42x70_bus *bus, uint8_t start, uint8_t *buf, uint32_t size) { @@ -47,7 +47,7 @@ static int icm42670_reg_read_spi(const union icm42670_bus *bus, uint8_t start, u return 0; } -static int icm42670_reg_write_spi(const union icm42670_bus *bus, uint8_t reg, uint8_t *buf, +static int icm42x70_reg_write_spi(const union icm42x70_bus *bus, uint8_t reg, uint8_t *buf, uint32_t size) { uint8_t cmd[] = {reg & 0x7F}; @@ -63,10 +63,10 @@ static int icm42670_reg_write_spi(const union icm42670_bus *bus, uint8_t reg, ui return 0; } -const struct icm42670_bus_io icm42670_bus_io_spi = { - .check = icm42670_bus_check_spi, - .read = icm42670_reg_read_spi, - .write = icm42670_reg_write_spi, +const struct icm42x70_bus_io icm42x70_bus_io_spi = { + .check = icm42x70_bus_check_spi, + .read = icm42x70_reg_read_spi, + .write = icm42x70_reg_write_spi, }; #endif /* CONFIG_SPI */ diff --git a/drivers/sensor/tdk/icm42670/icm42670_trigger.c b/drivers/sensor/tdk/icm42x70/icm42x70_trigger.c similarity index 59% rename from drivers/sensor/tdk/icm42670/icm42670_trigger.c rename to drivers/sensor/tdk/icm42x70/icm42x70_trigger.c index cfe0f0723ff5..e6dfd0e33e1c 100644 --- a/drivers/sensor/tdk/icm42670/icm42670_trigger.c +++ b/drivers/sensor/tdk/icm42x70/icm42x70_trigger.c @@ -9,33 +9,33 @@ #include #include #include -#include "icm42670.h" -#include "icm42670_trigger.h" +#include "icm42x70.h" +#include "icm42x70_trigger.h" #include -LOG_MODULE_DECLARE(ICM42670, CONFIG_SENSOR_LOG_LEVEL); +LOG_MODULE_DECLARE(ICM42X70, CONFIG_SENSOR_LOG_LEVEL); -static void icm42670_gpio_callback(const struct device *dev, struct gpio_callback *cb, +static void icm42x70_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { ARG_UNUSED(dev); ARG_UNUSED(pins); - struct icm42670_data *data = CONTAINER_OF(cb, struct icm42670_data, gpio_cb); + struct icm42x70_data *data = CONTAINER_OF(cb, struct icm42x70_data, gpio_cb); -#if defined(CONFIG_ICM42670_TRIGGER_OWN_THREAD) +#if defined(CONFIG_ICM42X70_TRIGGER_OWN_THREAD) k_sem_give(&data->gpio_sem); -#elif defined(CONFIG_ICM42670_TRIGGER_GLOBAL_THREAD) +#elif defined(CONFIG_ICM42X70_TRIGGER_GLOBAL_THREAD) k_work_submit(&data->work); #endif } -static void icm42670_thread_cb(const struct device *dev) +static void icm42x70_thread_cb(const struct device *dev) { - struct icm42670_data *data = dev->data; - const struct icm42670_config *cfg = dev->config; + struct icm42x70_data *data = dev->data; + const struct icm42x70_config *cfg = dev->config; - icm42670_lock(dev); + icm42x70_lock(dev); gpio_pin_interrupt_configure_dt(&cfg->gpio_int, GPIO_INT_DISABLE); if (data->data_ready_handler) { @@ -43,45 +43,45 @@ static void icm42670_thread_cb(const struct device *dev) } gpio_pin_interrupt_configure_dt(&cfg->gpio_int, GPIO_INT_EDGE_TO_ACTIVE); - icm42670_unlock(dev); + icm42x70_unlock(dev); } -#if defined(CONFIG_ICM42670_TRIGGER_OWN_THREAD) +#if defined(CONFIG_ICM42X70_TRIGGER_OWN_THREAD) -static void icm42670_thread(void *p1, void *p2, void *p3) +static void icm42x70_thread(void *p1, void *p2, void *p3) { ARG_UNUSED(p2); ARG_UNUSED(p3); - struct icm42670_data *data = p1; + struct icm42x70_data *data = p1; while (1) { k_sem_take(&data->gpio_sem, K_FOREVER); - icm42670_thread_cb(data->dev); + icm42x70_thread_cb(data->dev); } } -#elif defined(CONFIG_ICM42670_TRIGGER_GLOBAL_THREAD) +#elif defined(CONFIG_ICM42X70_TRIGGER_GLOBAL_THREAD) -static void icm42670_work_handler(struct k_work *work) +static void icm42x70_work_handler(struct k_work *work) { - struct icm42670_data *data = CONTAINER_OF(work, struct icm42670_data, work); + struct icm42x70_data *data = CONTAINER_OF(work, struct icm42x70_data, work); - icm42670_thread_cb(data->dev); + icm42x70_thread_cb(data->dev); } #endif -int icm42670_trigger_set(const struct device *dev, const struct sensor_trigger *trig, +int icm42x70_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { - struct icm42670_data *data = dev->data; - const struct icm42670_config *cfg = dev->config; + struct icm42x70_data *data = dev->data; + const struct icm42x70_config *cfg = dev->config; if (!handler) { return -EINVAL; } - icm42670_lock(dev); + icm42x70_lock(dev); gpio_pin_interrupt_configure_dt(&cfg->gpio_int, GPIO_INT_DISABLE); if (trig->type == SENSOR_TRIG_DATA_READY) { @@ -96,16 +96,16 @@ int icm42670_trigger_set(const struct device *dev, const struct sensor_trigger * return -ENOTSUP; } - icm42670_unlock(dev); + icm42x70_unlock(dev); gpio_pin_interrupt_configure_dt(&cfg->gpio_int, GPIO_INT_EDGE_TO_ACTIVE); return 0; } -int icm42670_trigger_init(const struct device *dev) +int icm42x70_trigger_init(const struct device *dev) { - struct icm42670_data *data = dev->data; - const struct icm42670_config *cfg = dev->config; + struct icm42x70_data *data = dev->data; + const struct icm42x70_config *cfg = dev->config; int res = 0; if (!cfg->gpio_int.port) { @@ -120,7 +120,7 @@ int icm42670_trigger_init(const struct device *dev) data->dev = dev; gpio_pin_configure_dt(&cfg->gpio_int, GPIO_INPUT); - gpio_init_callback(&data->gpio_cb, icm42670_gpio_callback, BIT(cfg->gpio_int.pin)); + gpio_init_callback(&data->gpio_cb, icm42x70_gpio_callback, BIT(cfg->gpio_int.pin)); res = gpio_add_callback(cfg->gpio_int.port, &data->gpio_cb); if (res < 0) { @@ -130,21 +130,21 @@ int icm42670_trigger_init(const struct device *dev) k_mutex_init(&data->mutex); -#if defined(CONFIG_ICM42670_TRIGGER_OWN_THREAD) +#if defined(CONFIG_ICM42X70_TRIGGER_OWN_THREAD) k_sem_init(&data->gpio_sem, 0, K_SEM_MAX_LIMIT); - k_thread_create(&data->thread, data->thread_stack, CONFIG_ICM42670_THREAD_STACK_SIZE, - icm42670_thread, data, NULL, NULL, - K_PRIO_COOP(CONFIG_ICM42670_THREAD_PRIORITY), 0, K_NO_WAIT); -#elif defined(CONFIG_ICM42670_TRIGGER_GLOBAL_THREAD) - data->work.handler = icm42670_work_handler; + k_thread_create(&data->thread, data->thread_stack, CONFIG_ICM42X70_THREAD_STACK_SIZE, + icm42x70_thread, data, NULL, NULL, + K_PRIO_COOP(CONFIG_ICM42X70_THREAD_PRIORITY), 0, K_NO_WAIT); +#elif defined(CONFIG_ICM42X70_TRIGGER_GLOBAL_THREAD) + data->work.handler = icm42x70_work_handler; #endif return gpio_pin_interrupt_configure_dt(&cfg->gpio_int, GPIO_INT_EDGE_TO_INACTIVE); } -int icm42670_trigger_enable_interrupt(const struct device *dev) +int icm42x70_trigger_enable_interrupt(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; int err = 0; inv_imu_int1_pin_config_t int1_pin_config; inv_imu_interrupt_parameter_t config_int = {(inv_imu_interrupt_value)0}; @@ -161,16 +161,16 @@ int icm42670_trigger_enable_interrupt(const struct device *dev) return err; } -void icm42670_lock(const struct device *dev) +void icm42x70_lock(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; k_mutex_lock(&data->mutex, K_FOREVER); } -void icm42670_unlock(const struct device *dev) +void icm42x70_unlock(const struct device *dev) { - struct icm42670_data *data = dev->data; + struct icm42x70_data *data = dev->data; k_mutex_unlock(&data->mutex); } diff --git a/drivers/sensor/tdk/icm42x70/icm42x70_trigger.h b/drivers/sensor/tdk/icm42x70/icm42x70_trigger.h new file mode 100644 index 000000000000..bd89107ac4fb --- /dev/null +++ b/drivers/sensor/tdk/icm42x70/icm42x70_trigger.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Esco Medical ApS + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_DRIVERS_SENSOR_ICM42X70_TRIGGER_H_ +#define ZEPHYR_DRIVERS_SENSOR_ICM42X70_TRIGGER_H_ + +#include + +/** implement the trigger_set sensor api function */ +int icm42x70_trigger_set(const struct device *dev, const struct sensor_trigger *trig, + sensor_trigger_handler_t handler); + +/** + * @brief initialize the icm42x70 trigger system + * + * @param dev icm42x70 device pointer + * @return int 0 on success, negative error code otherwise + */ +int icm42x70_trigger_init(const struct device *dev); + +/** + * @brief enable the trigger gpio interrupt + * + * @param dev icm42x70 device pointer + * @return int 0 on success, negative error code otherwise + */ +int icm42x70_trigger_enable_interrupt(const struct device *dev); + +/** + * @brief lock access to the icm42x70 device driver + * + * @param dev icm42x70 device pointer + */ +void icm42x70_lock(const struct device *dev); + +/** + * @brief lock access to the icm42x70 device driver + * + * @param dev icm42x70 device pointer + */ +void icm42x70_unlock(const struct device *dev); + +#endif /* ZEPHYR_DRIVERS_SENSOR_ICM42X70_TRIGGER_H_ */ diff --git a/dts/bindings/sensor/invensense,icm42370p-i2c.yaml b/dts/bindings/sensor/invensense,icm42370p-i2c.yaml new file mode 100644 index 000000000000..6ae7b24ce50a --- /dev/null +++ b/dts/bindings/sensor/invensense,icm42370p-i2c.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. +# SPDX-License-Identifier: Apache-2.0 + +description: ICM-42370-P motion tracking device + +compatible: "invensense,icm42370p" + +include: [i2c-device.yaml, "invensense,icm42x70.yaml"] diff --git a/dts/bindings/sensor/invensense,icm42370p-spi.yaml b/dts/bindings/sensor/invensense,icm42370p-spi.yaml new file mode 100644 index 000000000000..4f7b0ddc1346 --- /dev/null +++ b/dts/bindings/sensor/invensense,icm42370p-spi.yaml @@ -0,0 +1,9 @@ +# Copyright (c) 2022 Esco Medical ApS +# Copyright (c) 2020 TDK Invensense +# SPDX-License-Identifier: Apache-2.0 + +description: ICM-42370-P motion tracking device + +compatible: "invensense,icm42370p" + +include: [spi-device.yaml, "invensense,icm42x70.yaml"] diff --git a/dts/bindings/sensor/invensense,icm42670.yaml b/dts/bindings/sensor/invensense,icm42670.yaml index 6b79dcb3034f..01654f1f6f86 100644 --- a/dts/bindings/sensor/invensense,icm42670.yaml +++ b/dts/bindings/sensor/invensense,icm42670.yaml @@ -5,37 +5,9 @@ description: ICM-42670 motion tracking device -include: [sensor-device.yaml] +include: invensense,icm42x70.yaml properties: - int-gpios: - type: phandle-array - description: | - The INT signal default configuration is active-high. The - property value should ensure the flags properly describe the - signal that is presented to the driver. - - accel-hz: - type: int - required: true - description: | - Default frequency of accelerometer. (Unit - Hz) - Maps to ACCEL_ODR field in ACCEL_CONFIG0 setting - Power-on reset value is 800. - enum: - - 0 - - 1600 - - 800 - - 400 - - 200 - - 100 - - 50 - - 25 - - 12 - - 6 - - 3 - - 1 - gyro-hz: type: int required: true @@ -54,67 +26,6 @@ properties: - 25 - 12 - power-mode: - type: string - default: "low-noise" - description: | - Power mode. - Low power mode is allowed for accelerometer sensor only from - 1.5625Hz to 400Hz. - The default is chosen to support both accelerometer and - gyroscope sensors. - enum: - - "low-noise" - - "low-power" - - - accel-fs: - type: int - required: true - description: | - Default full scale of accelerometer. (Unit - g) - Maps to ACCEL_FS_SEL field in ACCEL_CONFIG0 setting - Power-on reset value is 16 - enum: - - 16 - - 8 - - 4 - - 2 - - accel-avg: - type: int - default: 32 - description: | - Averaging filter setting to create accelerometer output - in accelerometer low power mode. - Maps to ACCEL_UI_AVG field in ACCEL_CONFIG1 setting. - The default corresponds to the reset value of the register field. - enum: - - 2 - - 4 - - 8 - - 16 - - 32 - - 64 - - accel-filt-bw-hz: - type: int - default: 180 - description: | - Accelerometer low pass filter bandwidth frequency (Unit - Hz). - Maps to ACCEL_UI_FILT_BW field in ACCEL_CONFIG1 setting. - The default corresponds to the reset value of the register field. - enum: - - 0 - - 180 - - 121 - - 73 - - 53 - - 34 - - 25 - - 16 - - gyro-fs: type: int required: true @@ -144,21 +55,3 @@ properties: - 34 - 25 - 16 - - apex: - type: string - default: "none" - description: | - APEX (Advanced Pedometer and Event Detection) features. It consists of: - * Pedometer: Tracks step count, and provide details such as the cadence and - the estimated activity type (Walk, Run, Unknown). - * Tilt Detection: Detects the Tilt when tilting the board with an angle of - 30 degrees or more held for 4 seconds. - * Wake on Motion (WoM): Detects motion per axis exceeding 195 mg threshold. - * Significant Motion Detector (SMD): Detects when the user has moved significantly. - enum: - - "none" - - "pedometer" - - "tilt" - - "smd" - - "wom" diff --git a/dts/bindings/sensor/invensense,icm42x70.yaml b/dts/bindings/sensor/invensense,icm42x70.yaml new file mode 100644 index 000000000000..169b51459653 --- /dev/null +++ b/dts/bindings/sensor/invensense,icm42x70.yaml @@ -0,0 +1,114 @@ +# Copyright (c) 2024 TDK Invensense +# Copyright (c) 2022 Esco Medical ApS +# Copyright (c) 2020 TDK Invensense +# SPDX-License-Identifier: Apache-2.0 + +description: ICM-42670 motion tracking device + +include: sensor-device.yaml + +properties: + int-gpios: + type: phandle-array + description: | + The INT signal default configuration is active-high. The + property value should ensure the flags properly describe the + signal that is presented to the driver. + + accel-hz: + type: int + required: true + description: | + Default frequency of accelerometer. (Unit - Hz) + Maps to ACCEL_ODR field in ACCEL_CONFIG0 setting + Power-on reset value is 800. + enum: + - 0 + - 1600 + - 800 + - 400 + - 200 + - 100 + - 50 + - 25 + - 12 + - 6 + - 3 + - 1 + + power-mode: + type: string + default: "low-noise" + description: | + Power mode. + Low power mode is allowed for accelerometer sensor only from + 1.5625Hz to 400Hz. + The default is chosen to support both accelerometer and + gyroscope sensors. + enum: + - "low-noise" + - "low-power" + + accel-fs: + type: int + required: true + description: | + Default full scale of accelerometer. (Unit - g) + Maps to ACCEL_FS_SEL field in ACCEL_CONFIG0 setting + Power-on reset value is 16 + enum: + - 16 + - 8 + - 4 + - 2 + + accel-avg: + type: int + default: 32 + description: | + Averaging filter setting to create accelerometer output + in accelerometer low power mode. + Maps to ACCEL_UI_AVG field in ACCEL_CONFIG1 setting. + The default corresponds to the reset value of the register field. + enum: + - 2 + - 4 + - 8 + - 16 + - 32 + - 64 + + accel-filt-bw-hz: + type: int + default: 180 + description: | + Accelerometer low pass filter bandwidth frequency (Unit - Hz). + Maps to ACCEL_UI_FILT_BW field in ACCEL_CONFIG1 setting. + The default corresponds to the reset value of the register field. + enum: + - 0 + - 180 + - 121 + - 73 + - 53 + - 34 + - 25 + - 16 + + apex: + type: string + default: "none" + description: | + APEX (Advanced Pedometer and Event Detection) features. It consists of: + * Pedometer: Tracks step count, and provide details such as the cadence and + the estimated activity type (Walk, Run, Unknown). + * Tilt Detection: Detects the Tilt when tilting the board with an angle of + 30 degrees or more held for 4 seconds. + * Wake on Motion (WoM): Detects motion per axis exceeding 195 mg threshold. + * Significant Motion Detector (SMD): Detects when the user has moved significantly. + enum: + - "none" + - "pedometer" + - "tilt" + - "smd" + - "wom" diff --git a/include/zephyr/drivers/sensor/icm42670.h b/include/zephyr/drivers/sensor/icm42x70.h similarity index 72% rename from include/zephyr/drivers/sensor/icm42670.h rename to include/zephyr/drivers/sensor/icm42x70.h index 9894109fd75d..06c2c1ae396a 100644 --- a/include/zephyr/drivers/sensor/icm42670.h +++ b/include/zephyr/drivers/sensor/icm42x70.h @@ -4,27 +4,27 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_ICM42670_H_ -#define ZEPHYR_INCLUDE_DRIVERS_SENSOR_ICM42670_H_ +#ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_ICM42X70_H_ +#define ZEPHYR_INCLUDE_DRIVERS_SENSOR_ICM42X70_H_ #include /** * @file - * @brief Extended public API for ICM42670 6-axis MEMS sensor + * @brief Extended public API for ICM42X70 MEMS sensor * * Some capabilities and operational requirements for this sensor * cannot be expressed within the sensor driver abstraction. */ -/** ICM42670 power mode */ -#define ICM42670_LOW_NOISE_MODE (0) -#define ICM42670_LOW_POWER_MODE (1) +/** ICM42X70 power mode */ +#define ICM42X70_LOW_NOISE_MODE (0) +#define ICM42X70_LOW_POWER_MODE (1) /** - * @brief Extended sensor attributes for ICM42670 6-axis MEMS sensor + * @brief Extended sensor attributes for ICM42X70 MEMS sensor * - * This exposes attributes for the ICM42670 which can be used for + * This exposes attributes for the ICM42X70 which can be used for * setting the signal path filtering parameters. * * The signal path starts with ADCs for the gyroscope and accelerometer. @@ -39,7 +39,7 @@ * The output of 1st Order LPF in Low-Noise Mode, or Average filter in Low-Power * Mode is subject to ODR selection, with user selectable ODR. */ -enum sensor_attribute_icm42670 { +enum sensor_attribute_icm42x70 { /** BW filtering */ /** Low-pass filter configuration */ @@ -47,4 +47,4 @@ enum sensor_attribute_icm42670 { /** Averaging configuration */ SENSOR_ATTR_AVERAGING, }; -#endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_ICM42670_H_ */ +#endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_ICM42X70_H_ */ diff --git a/modules/hal_tdk/Kconfig b/modules/hal_tdk/Kconfig index deeae5d0142a..9c48ad6739ec 100644 --- a/modules/hal_tdk/Kconfig +++ b/modules/hal_tdk/Kconfig @@ -17,4 +17,11 @@ config USE_EMD_ICM42670 depends on DT_HAS_INVENSENSE_ICM42670P_ENABLED \ || DT_HAS_INVENSENSE_ICM42670S_ENABLED +config USE_EMD_ICM42370 + bool "ICM42370P High Performance 3-Axis MotionTracking Accelerometer" + default y + imply TDK_HAL + depends on ZEPHYR_HAL_TDK_MODULE + depends on DT_HAS_INVENSENSE_ICM42370P_ENABLED + endmenu diff --git a/samples/sensor/6dof_motion_drdy/prj.conf b/samples/sensor/6dof_motion_drdy/prj.conf index 30d939774836..7731b5b6de1e 100644 --- a/samples/sensor/6dof_motion_drdy/prj.conf +++ b/samples/sensor/6dof_motion_drdy/prj.conf @@ -16,4 +16,4 @@ CONFIG_CBPRINTF_FP_SUPPORT=y CONFIG_USE_SEGGER_RTT=n # Trigger mode: sample is using interrupt triggering -CONFIG_ICM42670_TRIGGER_OWN_THREAD=y +CONFIG_ICM42X70_TRIGGER_OWN_THREAD=y diff --git a/samples/sensor/tdk_apex/prj.conf b/samples/sensor/tdk_apex/prj.conf index 30d939774836..7731b5b6de1e 100644 --- a/samples/sensor/tdk_apex/prj.conf +++ b/samples/sensor/tdk_apex/prj.conf @@ -16,4 +16,4 @@ CONFIG_CBPRINTF_FP_SUPPORT=y CONFIG_USE_SEGGER_RTT=n # Trigger mode: sample is using interrupt triggering -CONFIG_ICM42670_TRIGGER_OWN_THREAD=y +CONFIG_ICM42X70_TRIGGER_OWN_THREAD=y diff --git a/tests/drivers/build_all/sensor/sensors_trigger_global.conf b/tests/drivers/build_all/sensor/sensors_trigger_global.conf index 7bbf2f56cc52..d637c2dde8e0 100644 --- a/tests/drivers/build_all/sensor/sensors_trigger_global.conf +++ b/tests/drivers/build_all/sensor/sensors_trigger_global.conf @@ -24,7 +24,7 @@ CONFIG_GROW_R502A_TRIGGER_GLOBAL_THREAD=y CONFIG_HMC5883L_TRIGGER_GLOBAL_THREAD=y CONFIG_HTS221_TRIGGER_GLOBAL_THREAD=y CONFIG_ICM42605_TRIGGER_GLOBAL_THREAD=y -CONFIG_ICM42670_TRIGGER_GLOBAL_THREAD=y +CONFIG_ICM42X70_TRIGGER_GLOBAL_THREAD=y CONFIG_ICM42688_TRIGGER_GLOBAL_THREAD=y CONFIG_IIS2DH_TRIGGER_GLOBAL_THREAD=y CONFIG_IIS2DLPC_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 3f56c634f3d1..c1e268da5a50 100644 --- a/tests/drivers/build_all/sensor/sensors_trigger_none.conf +++ b/tests/drivers/build_all/sensor/sensors_trigger_none.conf @@ -24,7 +24,7 @@ CONFIG_GROW_R502A_TRIGGER_NONE=y CONFIG_HMC5883L_TRIGGER_NONE=y CONFIG_HTS221_TRIGGER_NONE=y CONFIG_ICM42605_TRIGGER_NONE=y -CONFIG_ICM42670_TRIGGER_NONE=y +CONFIG_ICM42X70_TRIGGER_NONE=y CONFIG_ICM42688_TRIGGER_NONE=y CONFIG_IIS2DH_TRIGGER_NONE=y CONFIG_IIS2DLPC_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 a698b2966e4c..76df7af962c4 100644 --- a/tests/drivers/build_all/sensor/sensors_trigger_own.conf +++ b/tests/drivers/build_all/sensor/sensors_trigger_own.conf @@ -22,7 +22,7 @@ CONFIG_FXLS8974_TRIGGER_OWN_THREAD=y CONFIG_GROW_R502A_TRIGGER_OWN_THREAD=y CONFIG_HMC5883L_TRIGGER_OWN_THREAD=y CONFIG_HTS221_TRIGGER_OWN_THREAD=y -CONFIG_ICM42670_TRIGGER_OWN_THREAD=y +CONFIG_ICM42X70_TRIGGER_OWN_THREAD=y CONFIG_ICM42688_TRIGGER_OWN_THREAD=y CONFIG_IIS2DH_TRIGGER_OWN_THREAD=y CONFIG_IIS2DLPC_TRIGGER_OWN_THREAD=y diff --git a/west.yml b/west.yml index c005d3f727e8..c20614806c54 100644 --- a/west.yml +++ b/west.yml @@ -243,7 +243,7 @@ manifest: groups: - hal - name: hal_tdk - revision: e0ade95b29841d915c38bc157bb5509270e8aa21 + revision: 29fcd7a65d048805c1b28f6aeaa07b5839da60df path: modules/hal/tdk groups: - hal