diff --git a/drivers/sensor/st/lis2dw12/lis2dw12.c b/drivers/sensor/st/lis2dw12/lis2dw12.c index 3f1e7580780a5b..1029376f8dc50f 100644 --- a/drivers/sensor/st/lis2dw12/lis2dw12.c +++ b/drivers/sensor/st/lis2dw12/lis2dw12.c @@ -135,6 +135,18 @@ static inline void lis2dw12_channel_get_acc(const struct device *dev, } } +static inline void lis2dw12_channel_get_status(const struct device *dev, + struct sensor_value *val) +{ + const struct lis2dw12_device_config *cfg = dev->config; + stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; + lis2dw12_status_t status; + + /* fetch manually the interrupt status reg */ + lis2dw12_status_reg_get(ctx, &status); + val->val1 = (int32_t)*(uint8_t *)&status; +} + static int lis2dw12_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) @@ -149,6 +161,9 @@ static int lis2dw12_channel_get(const struct device *dev, case SENSOR_CHAN_DIE_TEMP: lis2dw12_channel_get_temp(dev, val); return 0; + case SENSOR_CHAN_LIS2DW12_INT_STATUS: + lis2dw12_channel_get_status(dev, val); + return 0; default: LOG_DBG("Channel not supported"); break; diff --git a/drivers/sensor/st/lis2dw12/lis2dw12.h b/drivers/sensor/st/lis2dw12/lis2dw12.h index b0a16660f648fc..6f9011a4231710 100644 --- a/drivers/sensor/st/lis2dw12/lis2dw12.h +++ b/drivers/sensor/st/lis2dw12/lis2dw12.h @@ -163,4 +163,9 @@ int lis2dw12_trigger_set(const struct device *dev, sensor_trigger_handler_t handler); #endif /* CONFIG_LIS2DW12_TRIGGER */ +/* LIS2DW12 specific channels */ +enum sensor_channel_lis2dw12 { + SENSOR_CHAN_LIS2DW12_INT_STATUS = SENSOR_CHAN_PRIV_START, +}; + #endif /* ZEPHYR_DRIVERS_SENSOR_LIS2DW12_LIS2DW12_H_ */