← Back to Pull requests

driver: sensor: icm42x70: Add Apex handling while stream #31

Open
JHKim8212 opened this pull request with 321 lines diff across 8 files
View on GitHub
JHKim8212 JHKim8212 commented on Nov 27, 2026 07:40 UTC
Author

Added APEX handling feature for
activate APEX event while stream raw data.
With this feature User can use APEX feature while
stream accel and/or gyro sensor data.

Diff: 321 lines (+255 / -66) across 8 files Reviewer: rbuisson-invn Review duration: 5821m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.48) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 321 lines diff across 8 files
0.48
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.88 · 5 substantive comment(s)
0.88
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.345
Real PR Conversation Timeline
20 items
afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:11 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42670.c:1
@@ -39,9 +42,8 @@ static int icm42670_set_gyro_odr(struct icm42x70_data *drv_data, const struct se
 
 	if (val->val1 <= 1600 && val->val1 >= 12) {
 		bool was_disabled = (drv_data->gyro_hz == 0);
-
 		err = inv_imu_set_gyro_frequency(&drv_data->driver,
-						 convert_freq_to_bitfield(val->val1, &gyro_hz));
+				convert_freq_to_bitfield(val->val1, &gyro_hz));

Please remove the indent modifications, it creates noise in the review.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:20 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.c:1
@@ -301,12 +332,24 @@ static int icm42x70_set_accel_odr(struct icm42x70_data *drv_data, const struct s
 				return -EIO;
 			}
 		}
+		if (drv_data->apex_enabled == 0) {
+			inv_imu_configure_fifo_data_rate(&drv_data->driver, FDR_CONFIG_FDR_SEL_DIS);
+		}

I wonder if you should set this config prior to enable the sensor? In case of apex on/off then accel on it might have an unwanted decimation factor configured when starting the sensor.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:24 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.c:1
@@ -301,12 +332,24 @@ static int icm42x70_set_accel_odr(struct icm42x70_data *drv_data, const struct s
 				return -EIO;
 			}
 		}
+		if (drv_data->apex_enabled == 0) {
+			inv_imu_configure_fifo_data_rate(&drv_data->driver, FDR_CONFIG_FDR_SEL_DIS);
+		}
 	} else if (val->val1 == 0) {
-		err = inv_imu_disable_accel(&drv_data->driver);
-		if (err != 0) {
-			return -EIO;
+		if (drv_data->apex_enabled == 0) {
+			err = inv_imu_disable_accel(&drv_data->driver);
+			if (err != 0)
+				return -EIO;
 		}
+

What about recomputing the decimation factor when the apex is on and the accel is disabled ?

rbuisson-invn rbuisson-invn commented on code on Nov 27, 2026 14:27 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42670.c:1
@@ -51,12 +53,28 @@ static int icm42670_set_gyro_odr(struct icm42x70_data *drv_data, const struct se
 				return -EIO;
 			}
 		}
+#ifdef CONFIG_ICM42X70_TRIGGER
+		/* FIFO and its interrupt are disabled by icm42x70_apex_enable() */
+		if (icm42x70_trigger_enable_interrupt(drv_data) != 0) {
+			return -EIO;
+		}
+#endif
 	} else if (val->val1 == 0) {
 		err = inv_imu_disable_gyro(&drv_data->driver);
 		if (err != 0) {
 			return -EIO;
 		}
 		drv_data->gyro_hz = val->val1;
+
+#ifdef CONFIG_ICM42X70_TRIGGER
+		if ((drv_data->accel_hz == 0)
+#ifdef CONFIG_TDK_APEX
+				|| (drv_data->apex_enabled == 1)
+#endif
+		   ) {
+			icm42x70_trigger_disable_interrupt(drv_data);

Not sure it is necessary to disable the interrupt.
If no sensor is enabled then no interrupt will occur, no need to disable it.

rbuisson-invn rbuisson-invn commented on code on Nov 27, 2026 14:28 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.c:1
@@ -301,12 +332,24 @@ static int icm42x70_set_accel_odr(struct icm42x70_data *drv_data, const struct s
 				return -EIO;
 			}
 		}
+		if (drv_data->apex_enabled == 0) {
+			inv_imu_configure_fifo_data_rate(&drv_data->driver, FDR_CONFIG_FDR_SEL_DIS);
+		}
 	} else if (val->val1 == 0) {
-		err = inv_imu_disable_accel(&drv_data->driver);
-		if (err != 0) {
-			return -EIO;
+		if (drv_data->apex_enabled == 0) {
+			err = inv_imu_disable_accel(&drv_data->driver);
+			if (err != 0)
+				return -EIO;
 		}
+
 		drv_data->accel_hz = val->val1;
+#ifdef CONFIG_ICM42X70_TRIGGER
+		if (drv_data->gyro_hz == 0) {
+			err = icm42x70_trigger_disable_interrupt(drv_data);

Same here, why do you need to disable interrupts?

rbuisson-invn rbuisson-invn commented on code on Nov 27, 2026 14:32 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.c:1
@@ -280,18 +280,49 @@ static int icm42x70_set_accel_power_mode(struct icm42x70_data *drv_data,
 static int icm42x70_set_accel_odr(struct icm42x70_data *drv_data, const struct sensor_value *val)
 {
 	uint16_t accel_hz;
-	int err;
+	int err = 0;
+	FDR_CONFIG_FDR_SEL_t dec_factor = FDR_CONFIG_FDR_SEL_DIS;
 
 	if (val->val1 <= 1600 && val->val1 >= 1) {
 		bool was_disabled = (drv_data->accel_hz == 0);
 
-		err = inv_imu_set_accel_frequency(&drv_data->driver,
-						  convert_freq_to_bitfield(val->val1, &accel_hz));
+		if (drv_data->apex_enabled == 0) {
+			err = inv_imu_set_accel_frequency(
+				&drv_data->driver, convert_freq_to_bitfield(val->val1, &accel_hz));
+			if (err != 0) {
+				return -EIO;
+			}
+		} else {
+			/*
+			 * The DMP runs from the accel ODR set by icm42x70_apex_enable():
+			 * keep it and only record the requested rate. The FIFO output
+			 * rate is reduced with the FIFO decimation factor below.
+			 */
+			(void)convert_freq_to_bitfield(val->val1, &accel_hz);
+		}
+		drv_data->accel_hz = accel_hz;
+#ifdef CONFIG_ICM42X70_TRIGGER
+		/* FIFO and its interrupt are disabled by icm42x70_apex_enable() */
+		err = icm42x70_trigger_enable_interrupt(drv_data);
 		if (err != 0) {
 			return -EIO;
 		}
-		drv_data->accel_hz = accel_hz;
-		if (was_disabled) {
+#endif
+		if (drv_data->apex_enabled == 1) {
+			if (val->val1 == 200) {
+				dec_factor = FDR_CONFIG_FDR_SEL_FACTOR_2;
+			} else if (val->val1 == 100) {
+				dec_factor = FDR_CONFIG_FDR_SEL_FACTOR_4;
+			} else if (val->val1 == 50) {
+				dec_factor = FDR_CONFIG_FDR_SEL_FACTOR_8;
+			} else if (val->val1 == 25) {
+				dec_factor = FDR_CONFIG_FDR_SEL_FACTOR_16;
+			}
+			if (val->val1 < 400) {
+				inv_imu_configure_fifo_data_rate(&drv_data->driver, dec_factor);

This decimates also gyro samples, we need a decimation for accel samples only.
The decimation would probably require an anti aliasing filter, to be discuss with Pierre Grenet.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:32 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.h:1
@@ -117,20 +126,32 @@ uint32_t convert_ln_bw_to_bitfield(uint32_t val);
 
 #ifdef CONFIG_TDK_APEX
 
-#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)
+#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)
+
+#define ICM42X70_APEX_STATUS_SINGLE_TAP       1
+#define ICM42X70_APEX_STATUS_DOUBLE_TAP       2
+#define ICM42X70_APEX_STATUS_TRIPLE_TAP       3
+
+#define ICM42X70_APEX_STATUS_TAP_X            0
+#define ICM42X70_APEX_STATUS_TAP_Y            1
+#define ICM42X70_APEX_STATUS_TAP_Z            2

This is already defined in inv_imu_tap.h in tdk_hal driver

/** @brief Tap axis definition */
typedef enum {
	INV_IMU_DMP_TAP_AXIS_Z = 0x02,
	INV_IMU_DMP_TAP_AXIS_Y = 0x01,
	INV_IMU_DMP_TAP_AXIS_X = 0x00,
} inv_imu_tap_axis_t;

Please use this instead.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:32 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.h:1
@@ -117,20 +126,32 @@ uint32_t convert_ln_bw_to_bitfield(uint32_t val);
 
 #ifdef CONFIG_TDK_APEX
 
-#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)
+#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)
+
+#define ICM42X70_APEX_STATUS_SINGLE_TAP       1
+#define ICM42X70_APEX_STATUS_DOUBLE_TAP       2
+#define ICM42X70_APEX_STATUS_TRIPLE_TAP       3
+
+#define ICM42X70_APEX_STATUS_TAP_X            0
+#define ICM42X70_APEX_STATUS_TAP_Y            1
+#define ICM42X70_APEX_STATUS_TAP_Z            2
+
+#define ICM42X70_APEX_STATUS_MASK_TAP_POS     0
+#define ICM42X70_APEX_STATUS_MASK_TAP_NEG     1

This is already defined in inv_imu_tap.h in tdk_hal driver

/** @brief Tap direction definition */
typedef enum {
	INV_IMU_DMP_TAP_DIR_POSITIVE = 0x01,
	INV_IMU_DMP_TAP_DIR_NEGATIVE = 0x00,
} inv_imu_tap_dir_t;

Please use this instead.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:33 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70_apex.c:1
@@ -6,15 +6,21 @@
 
 #include "icm42x70.h"
 #include "imu/inv_imu_apex.h"
+#include "imu/inv_imu_tap.h"
+//#define USE_POWER_SAVE

Please removed unused comment

rbuisson-invn rbuisson-invn commented on code on Nov 27, 2026 14:34 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.c:1
@@ -864,19 +901,29 @@ static int icm42x70_attr_set(const struct device *dev, enum sensor_channel chan,
 				if (res == 0) {
 					res = icm42x70_apex_enable_pedometer(dev,
 									     &drv_data->driver);
+					drv_data->apex_enabled = 1;
 				}
 			} else if (val->val1 == TDK_APEX_TILT) {
 				res = icm42x70_apex_enable(&drv_data->driver);
 				if (res == 0) {
 					res = icm42x70_apex_enable_tilt(&drv_data->driver);
+					drv_data->apex_enabled = 1;
 				}
 			} else if (val->val1 == TDK_APEX_SMD) {
 				res = icm42x70_apex_enable(&drv_data->driver);
 				if (res == 0) {
 					res = icm42x70_apex_enable_smd(&drv_data->driver);
+					drv_data->apex_enabled = 1;
 				}
 			} else if (val->val1 == TDK_APEX_WOM) {
 				res = icm42x70_apex_enable_wom(&drv_data->driver);
+				drv_data->apex_enabled = 1;
+			} else if (val->val1 == TDK_APEX_TAP) {

From previous PR:
I think this must be reworked.
We could use MOTION and TAP triggers to enable/disable APEX instead of TDK specific Attributes that no one knows about.
It needs a bit of discussion to decide of the best implementation.

JHKim8212 replied on Oct 14
@JHKim8212
JHKim8212
on Oct 14
Collaborator
Author
As I mentioned from
https://github.com/InvenSenseInc/fork.zephyr-rtos/pull/24/changes/BASE..ca7feaedd06fb232118eb7744257f718ccc0fcc4#r4273558568

zephyr sensor.h doesn't contain some motions.
So use TDK_APEX_XXX is more good instead of use sensor.h definitions.

rbuisson-invn replied on Oct 15
@rbuisson-invn
rbuisson-invn
on Oct 15
Collaborator
I agree that not all APEX are known to basic Zephyr sensor.h, however the aim of such drivers is to provide as much as possible regular interfaces, in order for an application to use them.
The goal of an OS is to provide basic services to ease spreading of applications relying on those, each time a non-conventional interface is used, the app using it is no more portable. And the other way around, if an application requires TAP support, and our sensor does not offers it, that will be an issue as well.

So I think we should take more time thinking about using those regular APIs, when they exist.

rbuisson-invn rbuisson-invn commented on code on Nov 27, 2026 14:35 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70_apex.c:1
@@ -6,15 +6,21 @@
 
 #include "icm42x70.h"
 #include "imu/inv_imu_apex.h"
+#include "imu/inv_imu_tap.h"
+//#define USE_POWER_SAVE

Remove the comment

rbuisson-invn rbuisson-invn commented on code on Nov 27, 2026 14:37 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70_apex.c:1
@@ -23,26 +29,54 @@ int icm42x70_apex_enable(inv_imu_device_t *s)
 	config_int.INV_SMD = INV_IMU_ENABLE;
 	err |= inv_imu_set_config_int1(s, &config_int);
 
+	/* Enable Tap interrupts */
+	config_tap_int.INV_SINGLE_TAP_DET = INV_IMU_ENABLE;
+	config_tap_int.INV_DOUBLE_TAP_DET = INV_IMU_ENABLE;
+	config_tap_int.INV_TRIPLE_TAP_DET = INV_IMU_ENABLE;
+	err |= inv_imu_tap_set_config_int1(s, &config_tap_int);
+
 	/* Enable accelerometer to feed the APEX Pedometer algorithm */
-	err |= inv_imu_set_accel_frequency(s, ACCEL_CONFIG0_ODR_50_HZ);
+	err |= inv_imu_set_accel_frequency(s, ACCEL_CONFIG0_ODR_400_HZ);

Discussion from previous PR:
Only TAP requires 400Hz, may be clever to adapt frequency only when TAP is enabled.

JHKim8212 replied on Oct 14
@JHKim8212
JHKim8212
on Oct 14
Collaborator
Author
int icm42x70_apex_enable(inv_imu_device_t s)
this function doesn't know tap is enabled or not.
So I guess that set 50Hz in this function and re-set accel and dmp ODR to 400 in tap_enable function is more good.

below function is executed after icm42x70_apex_enable().
So how about adding inv_imu_set_accel_frequency(s, ACCEL_CONFIG0_ODR_400_HZ); and inv_imu_apex_set_frequency(s, APEX_CONFIG1_DMP_ODR_400Hz); in this function?

int icm42x70_apex_enable_tap(const struct device dev, inv_imu_device_t s)
{
int rc = 0;
struct icm42x70_data data = dev->data;
/ Enable TAP
/
rc |= inv_imu_tap_enable(s);
data->dmp_odr_hz = 400;

return rc;
}

afontaine-invn replied on Oct 15
@afontaine-invn
afontaine-invn
on Oct 15
Collaborator
Your proposal seems reasonable, but it would be easier to review the new modified code. I would say, go ahead with the implementation you proposed.

rbuisson-invn replied on Oct 16
@rbuisson-invn
rbuisson-invn
on Oct 16
Collaborator
If this function does not know what APEX is started or not, the accel should not be started at all

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:38 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70.h:1
@@ -117,20 +126,32 @@ uint32_t convert_ln_bw_to_bitfield(uint32_t val);
 
 #ifdef CONFIG_TDK_APEX
 
-#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)
+#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)
+
+#define ICM42X70_APEX_STATUS_SINGLE_TAP       1
+#define ICM42X70_APEX_STATUS_DOUBLE_TAP       2
+#define ICM42X70_APEX_STATUS_TRIPLE_TAP       3

These defines are supposed to be mask, because it can be triggered at the same time than the other apex.
Please define BIT(x) for each to be able to report apex_status properly.

rbuisson-invn rbuisson-invn commented on code on Nov 27, 2026 14:46 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70_trigger.c:1
@@ -81,16 +98,21 @@ int icm42x70_trigger_set(const struct device *dev, const struct sensor_trigger *
 		return -EINVAL;
 	}
 
-	if (trig->type != SENSOR_TRIG_DATA_READY &&
-	    !(IS_ENABLED(CONFIG_TDK_APEX) && trig->type == SENSOR_TRIG_MOTION)) {
-		return -ENOTSUP;
-	}
-
 	icm42x70_lock(dev);
 	gpio_pin_interrupt_configure_dt(&cfg->gpio_int, GPIO_INT_DISABLE);
 
-	data->data_ready_handler = handler;
-	data->data_ready_trigger = trig;
+	if (trig->type == SENSOR_TRIG_DATA_READY) {
+		data->data_ready_handler = handler;
+		data->data_ready_trigger = trig;
+#ifdef CONFIG_TDK_APEX
+	} else if (trig->type == SENSOR_TRIG_MOTION) {

IMO, we need to rediscuss the need to use standard Zephyr API for TAP triggers (i.e. SENSOR_TRIG_TAP).

rbuisson-invn rbuisson-invn requested changes on Nov 27, 2026 14:48 UTC
Changes Requested Reviewer

Requested changes.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:50 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70_apex.c:1
@@ -80,32 +109,45 @@ int icm42x70_apex_fetch_from_dmp(const struct device *dev)
 		}
 	}
 	/* Test Tilt interrupt */
-	if (int_status3 & (INT_STATUS3_TILT_DET_INT_MASK)) {
+	if (data->int_status3 & (INT_STATUS3_TILT_DET_INT_MASK)) {
 		data->apex_status = ICM42X70_APEX_STATUS_MASK_TILT;
 	}
 	/* Test SMD interrupt */
-	if ((int_status2 & (INT_STATUS2_SMD_INT_MASK)) || (rc != 0)) {
+	if ((data->int_status2 & (INT_STATUS2_SMD_INT_MASK)) || (rc != 0)) {
 		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 |
+	if (data->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) {
+		if (data->int_status2 & INT_STATUS2_WOM_X_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_X;
 		}
-		if (int_status2 & INT_STATUS2_WOM_Y_INT_MASK) {
+		if (data->int_status2 & INT_STATUS2_WOM_Y_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Y;
 		}
-		if (int_status2 & INT_STATUS2_WOM_Z_INT_MASK) {
+		if (data->int_status2 & INT_STATUS2_WOM_Z_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Z;
 		}
 	}
+	if ((data->int_status3 & (INT_STATUS3_SINGLE_TAP_INT_MASK)) || (rc != 0)) {
+		inv_imu_tap_get_data(&data->driver, &data->inv_imu_tap_info);
+		data->apex_status = ICM42X70_APEX_STATUS_SINGLE_TAP;

This should be a mask, the value should be |= to not clear the other apex status.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:50 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70_apex.c:1
@@ -80,32 +109,45 @@ int icm42x70_apex_fetch_from_dmp(const struct device *dev)
 		}
 	}
 	/* Test Tilt interrupt */
-	if (int_status3 & (INT_STATUS3_TILT_DET_INT_MASK)) {
+	if (data->int_status3 & (INT_STATUS3_TILT_DET_INT_MASK)) {
 		data->apex_status = ICM42X70_APEX_STATUS_MASK_TILT;
 	}
 	/* Test SMD interrupt */
-	if ((int_status2 & (INT_STATUS2_SMD_INT_MASK)) || (rc != 0)) {
+	if ((data->int_status2 & (INT_STATUS2_SMD_INT_MASK)) || (rc != 0)) {
 		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 |
+	if (data->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) {
+		if (data->int_status2 & INT_STATUS2_WOM_X_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_X;
 		}
-		if (int_status2 & INT_STATUS2_WOM_Y_INT_MASK) {
+		if (data->int_status2 & INT_STATUS2_WOM_Y_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Y;
 		}
-		if (int_status2 & INT_STATUS2_WOM_Z_INT_MASK) {
+		if (data->int_status2 & INT_STATUS2_WOM_Z_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Z;
 		}
 	}
+	if ((data->int_status3 & (INT_STATUS3_SINGLE_TAP_INT_MASK)) || (rc != 0)) {
+		inv_imu_tap_get_data(&data->driver, &data->inv_imu_tap_info);
+		data->apex_status = ICM42X70_APEX_STATUS_SINGLE_TAP;
+	}
+	if ((data->int_status3 & (INT_STATUS3_DOUBLE_TAP_INT_MASK)) || (rc != 0)) {
+		inv_imu_tap_get_data(&data->driver, &data->inv_imu_tap_info);
+		data->apex_status = ICM42X70_APEX_STATUS_DOUBLE_TAP;

Same here.
The value should be |= to not clear the other apex status.

afontaine-invn afontaine-invn commented on code on Nov 27, 2026 14:50 UTC
Code Review
drivers/sensor/tdk/icm42x70/icm42x70_apex.c:1
@@ -80,32 +109,45 @@ int icm42x70_apex_fetch_from_dmp(const struct device *dev)
 		}
 	}
 	/* Test Tilt interrupt */
-	if (int_status3 & (INT_STATUS3_TILT_DET_INT_MASK)) {
+	if (data->int_status3 & (INT_STATUS3_TILT_DET_INT_MASK)) {
 		data->apex_status = ICM42X70_APEX_STATUS_MASK_TILT;
 	}
 	/* Test SMD interrupt */
-	if ((int_status2 & (INT_STATUS2_SMD_INT_MASK)) || (rc != 0)) {
+	if ((data->int_status2 & (INT_STATUS2_SMD_INT_MASK)) || (rc != 0)) {
 		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 |
+	if (data->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) {
+		if (data->int_status2 & INT_STATUS2_WOM_X_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_X;
 		}
-		if (int_status2 & INT_STATUS2_WOM_Y_INT_MASK) {
+		if (data->int_status2 & INT_STATUS2_WOM_Y_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Y;
 		}
-		if (int_status2 & INT_STATUS2_WOM_Z_INT_MASK) {
+		if (data->int_status2 & INT_STATUS2_WOM_Z_INT_MASK) {
 			data->apex_status |= ICM42X70_APEX_STATUS_MASK_WOM_Z;
 		}
 	}
+	if ((data->int_status3 & (INT_STATUS3_SINGLE_TAP_INT_MASK)) || (rc != 0)) {
+		inv_imu_tap_get_data(&data->driver, &data->inv_imu_tap_info);
+		data->apex_status = ICM42X70_APEX_STATUS_SINGLE_TAP;
+	}
+	if ((data->int_status3 & (INT_STATUS3_DOUBLE_TAP_INT_MASK)) || (rc != 0)) {
+		inv_imu_tap_get_data(&data->driver, &data->inv_imu_tap_info);
+		data->apex_status = ICM42X70_APEX_STATUS_DOUBLE_TAP;
+	}
+	if ((data->int_status3 & (INT_STATUS3_TRIPLE_TAP_INT_MASK)) || (rc != 0)) {
+		inv_imu_tap_get_data(&data->driver, &data->inv_imu_tap_info);
+		data->apex_status = ICM42X70_APEX_STATUS_TRIPLE_TAP;

Same here.
The value should be |= to not clear the other apex status.

afontaine-invn afontaine-invn requested changes on Nov 27, 2026 14:56 UTC
Changes Requested Reviewer

Requested changes.

Reviewers
Assignees
JHKim8212 JHKim8212
Labels
risk: low confidence: 90.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.8% (MEDIUM) · Higher = larger blast radius
47.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 90.1% · Lower = rushed or shallow review
90.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4.7% · Safe to merge
4.7%