Commit 44d101ac authored by Andrew Sonzogni's avatar Andrew Sonzogni Committed by Fabio Baltieri
Browse files

drivers: sensor: lis2dw12: add interrupt status fetch



INT status can be fetched if the feature can't trigger via interrupt

Signed-off-by: default avatarAndrew Sonzogni <andrew@safehear.fr>
parent 70de35d9
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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;
+5 −0
Original line number Diff line number Diff line
@@ -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_ */