Repository: zephyrproject-rtos/zephyr
Pull request #88644: boards: shields: Add EVAL-ADXL367-ARDZ accelerometer shield and streaming configuration
Author: login: vladislav-pejic
Labels: name: area: Sensors
description: Sensors
name: area: Samples
description: Samples
name: area: Shields
description: Shields (add-on boards)
name: platform: ADI
description: Analog Devices, Inc.
Created: 2025-04-15T10:04:00Z | Merged: 2025-04-28T06:34:35Z

Add a new shield definition for the Analog Devices EVAL-ADXL367-ARDZ
accelerometer shield. This shield provides support for an ADI ADXL367
accelerometer over an Arduino SPI connector.
Also adds adxl367 streaming configuration to accelerometer samples.

Signed-off-by: Vladislav Pejic vladislav.pejic@orioninc.com


Diff:
diff --git a/boards/shields/eval_adxl367_ardz/Kconfig.shield b/boards/shields/eval_adxl367_ardz/Kconfig.shield
new file mode 100644
index 0000000000000..dbccde3756687
--- /dev/null
+++ b/boards/shields/eval_adxl367_ardz/Kconfig.shield
@@ -0,0 +1,5 @@
+# Copyright (c) 2025 Analog Devices, Inc.
+# SPDX-License-Identifier: Apache-2.0
+
+config SHIELD_EVAL_ADXL367_ARDZ
+	def_bool $(shields_list_contains,eval_adxl367_ardz)
diff --git a/boards/shields/eval_adxl367_ardz/doc/index.rst b/boards/shields/eval_adxl367_ardz/doc/index.rst
new file mode 100644
index 0000000000000..e144b28ecfe9c
--- /dev/null
+++ b/boards/shields/eval_adxl367_ardz/doc/index.rst
@@ -0,0 +1,40 @@
+.. _eval_adxl367_ardz:
+
+EVAL-ADXL367-ARDZ
+#################
+
+Overview
+********
+
+The EVAL-ADXL367-ARDZ is a 3-axis digital accelerometer Arduino shield powered
+by the Analog Devices ADXL367.
+
+Programming
+***********
+
+Set ``--shield eval_adxl367_ardz`` when you invoke ``west build``. For example:
+
+.. zephyr-app-commands::
+   :zephyr-app: samples/sensor/sensor_shell
+   :board: apard32690/max32690/m4
+   :shield: eval_adxl367_ardz
+   :goals: build
+
+Requirements
+************
+
+This shield can only be used with a board which provides a configuration for
+Arduino connectors and defines node aliases for SPI and GPIO interfaces (see
+:ref:`shields` for more details).
+
+References
+**********
+
+- `ADXL367 product page`_
+- `ADXL367 data sheet`_
+
+.. _ADXL367 product page:
+   https://www.analog.com/en/products/adxl367.html
+
+.. _ADXL367 data sheet:
+   https://www.analog.com/media/en/technical-documentation/data-sheets/adxl367.pdf
diff --git a/boards/shields/eval_adxl367_ardz/eval_adxl367_ardz.overlay b/boards/shields/eval_adxl367_ardz/eval_adxl367_ardz.overlay
new file mode 100644
index 0000000000000..98ab6236991a0
--- /dev/null
+++ b/boards/shields/eval_adxl367_ardz/eval_adxl367_ardz.overlay
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Analog Devices, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <zephyr/dt-bindings/sensor/adxl367.h>
+
+/ {
+	aliases {
+		accel0 = &adxl367_eval_adxl367_ardz;
+	};
+};
+
+&arduino_spi {
+	status = "okay";
+
+	adxl367_eval_adxl367_ardz: adxl367@0 {
+		compatible = "adi,adxl367";
+		reg = <0x0>;
+		spi-max-frequency = <DT_FREQ_M(1)>;
+		int1-gpios = <&arduino_header 8 GPIO_ACTIVE_HIGH>;
+		fifo-mode = <ADXL367_FIFO_MODE_STREAM>;
+		status = "okay";
+	};
+};
diff --git a/drivers/sensor/adi/adxl367/adxl367.c b/drivers/sensor/adi/adxl367/adxl367.c
index 6f1db94509cf9..06c69ad81e866 100644
--- a/drivers/sensor/adi/adxl367/adxl367.c
+++ b/drivers/sensor/adi/adxl367/adxl367.c
@@ -1097,7 +1097,7 @@ static int adxl367_init(const struct device *dev)
 #define ADXL367_CFG_IRQ(inst)
 #endif /* CONFIG_ADXL367_TRIGGER */
 
-#define ADXL367_CONFIG(inst, chipid)								\
+#define ADXL367_CONFIG(inst, chipid)							\
 		.odr = DT_INST_PROP(inst, odr),						\
 		.autosleep = false,							\
 		.low_noise = false,							\
@@ -1115,7 +1115,8 @@ static int adxl367_init(const struct device *dev)
 		.inactivity_th.enable =							\
 			IS_ENABLED(CONFIG_ADXL367_INACTIVITY_DETECTION_MODE),		\
 		.inactivity_time = CONFIG_ADXL367_INACTIVITY_TIME,			\
-		.fifo_config.fifo_mode = ADXL367_FIFO_DISABLED,				\
+		.fifo_config.fifo_mode =						\
+		DT_INST_PROP_OR(inst, fifo_mode, ADXL367_FIFO_DISABLED),		\
 		.fifo_config.fifo_format = ADXL367_FIFO_FORMAT_XYZ,			\
 		.fifo_config.fifo_samples = 128,					\
 		.fifo_config.fifo_read_mode = ADXL367_14B_CHID,				\
diff --git a/drivers/sensor/adi/adxl367/adxl367.h b/drivers/sensor/adi/adxl367/adxl367.h
index a8d28a6ad0846..a1ff9d3b25059 100644
--- a/drivers/sensor/adi/adxl367/adxl367.h
+++ b/drivers/sensor/adi/adxl367/adxl367.h
@@ -13,6 +13,7 @@
 #include <zephyr/drivers/gpio.h>
 #include <zephyr/kernel.h>
 #include <zephyr/sys/util.h>
+#include <zephyr/dt-bindings/sensor/adxl367.h>
 
 #define DT_DRV_COMPAT  adi_adxl367
 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
@@ -280,10 +281,10 @@ enum adxl367_fifo_format {
 };
 
 enum adxl367_fifo_mode {
-	ADXL367_FIFO_DISABLED,
-	ADXL367_OLDEST_SAVED,
-	ADXL367_STREAM_MODE,
-	ADXL367_TRIGGERED_MODE
+	ADXL367_FIFO_DISABLED = ADXL367_FIFO_MODE_DISABLED,
+	ADXL367_OLDEST_SAVED = ADXL367_FIFO_MODE_OLDEST_SAVED,
+	ADXL367_STREAM_MODE = ADXL367_FIFO_MODE_STREAM,
+	ADXL367_TRIGGERED_MODE = ADXL367_FIFO_MODE_TRIGGERED
 };
 
 enum adxl367_fifo_read_mode {
diff --git a/dts/bindings/sensor/adi,adxl367-common.yaml b/dts/bindings/sensor/adi,adxl367-common.yaml
index 722d13d92e07f..b445f6ab9fc76 100644
--- a/dts/bindings/sensor/adi,adxl367-common.yaml
+++ b/dts/bindings/sensor/adi,adxl367-common.yaml
@@ -1,6 +1,22 @@
 # Copyright (c) 2023 Analog Devices Inc.
 # SPDX-License-Identifier: Apache-2.0
 
+description: |
+  ADXL367 3-axis accelerometer
+  When setting the accelerometer DTS properties and want to use
+  streaming funcionality, make sure to include adxl367.h and
+  use the macros defined there for fifo-mode property.
+
+  Example:
+  #include <zephyr/dt-bindings/sensor/adxl367.h>
+
+  adxl367: adxl367@0 {
+    ...
+
+    fifo-mode = <ADXL367_FIFO_MODE_STREAM>;
+  };
+
+
 include: sensor-device.yaml
 
 properties:
@@ -29,3 +45,17 @@ properties:
       The INT1 signal defaults to active high as produced by the
       sensor.  The property value should ensure the flags properly
       describe the signal that is presented to the driver.
+
+  fifo-mode:
+    type: int
+    description: |
+          Accelerometer FIFO Mode.
+          0 # ADXL367_FIFO_MODE_DISABLED
+          1 # ADXL367_FIFO_MODE_OLDEST_SAVED
+          2 # ADXL367_FIFO_MODE_STREAM
+          3 # ADXL367_FIFO_MODE_TRIGGERED
+    enum:
+      - 0
+      - 1
+      - 2
+      - 3
diff --git a/include/zephyr/dt-bindings/sensor/adxl367.h b/include/zephyr/dt-bindings/sensor/adxl367.h
new file mode 100644
index 0000000000000..f3bb0afd0f85b
--- /dev/null
+++ b/include/zephyr/dt-bindings/sensor/adxl367.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Analog Devices Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_ADI_ADX367_H_
+#define ZEPHYR_INCLUDE_DT_BINDINGS_ADI_ADX367_H_
+
+/**
+ * @defgroup ADXL367 ADI DT Options
+ * @ingroup sensor_interface
+ * @{
+ */
+
+/**
+ * @defgroup ADXL367_FIFO_MODE FIFO mode options
+ * @{
+ */
+#define ADXL367_FIFO_MODE_DISABLED        0x0
+#define ADXL367_FIFO_MODE_OLDEST_SAVED    0x1
+#define ADXL367_FIFO_MODE_STREAM          0x2
+#define ADXL367_FIFO_MODE_TRIGGERED       0x3
+/** @} */
+
+/** @} */
+
+#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ADI_ADX367_H_ */
diff --git a/samples/sensor/accel_polling/adxl367-stream.conf b/samples/sensor/accel_polling/adxl367-stream.conf
new file mode 100644
index 0000000000000..de1ee8900ba99
--- /dev/null
+++ b/samples/sensor/accel_polling/adxl367-stream.conf
@@ -0,0 +1,6 @@
+# Copyright (c) 2025 Analog Devices, Inc.
+# SPDX-License-Identifier: Apache-2.0
+
+CONFIG_SPI_RTIO=y
+CONFIG_SENSOR_ASYNC_API=y
+CONFIG_ADXL367_STREAM=y
diff --git a/samples/sensor/accel_polling/sample.yaml b/samples/sensor/accel_polling/sample.yaml
index 74c5f07f5ba42..24e3c5f4bbd78 100644
--- a/samples/sensor/accel_polling/sample.yaml
+++ b/samples/sensor/accel_polling/sample.yaml
@@ -34,3 +34,10 @@ tests:
       - SNIPPET=rtt-tracing;rtt-console
     platform_allow:
       - apard32690/max32690/m4
+  sample.sensor.accel_polling.adxl367-stream:
+    extra_args:
+      - SHIELD="eval_adxl367_ardz"
+      - EXTRA_CONF_FILE="adxl367-stream.conf"
+      - SNIPPET="rtt-tracing;rtt-console"
+    platform_allow:
+      - apard32690/max32690/m4


Reviews:
user: login: kartben
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-15T10:11:58Z
user: login: vladislav-pejic
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-15T10:42:48Z
user: login: nordicjm
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-15T11:49:48Z
user: login: nordicjm
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-22T08:21:00Z
user: login: MaureenHelm
body: > I'm wondering whether this should be a device-tree property. That way multiple instances can be configured differently

Agree
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-22T12:59:37Z
user: login: MaureenHelm
body: Thanks @vladislav-pejic !
state: CHANGES_REQUESTED
author_association: MEMBER
submitted_at: 2025-04-24T13:14:20Z
user: login: MaureenHelm
state: DISMISSED
author_association: MEMBER
submitted_at: 2025-04-24T13:23:33Z
user: login: nordicjm
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-25T06:24:23Z
user: login: vladislav-pejic
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-25T09:56:56Z
user: login: MaureenHelm
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-25T14:21:28Z
user: login: nordicjm
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T06:27:10Z

Review comments:
diff_hunk: @@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2025 Analog Devices, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/ {
+	aliases {
+		accel0 = &adxl367_eval_adxl367_ardz;
+	};
path: boards/shields/eval_adxl367_ardz/boards/apard32690_max32690_m4.overlay
user: login: kartben
body: just move this to the shield's overlay so that "everyone" just benefits from this alias when using the shield.
created_at: 2025-04-15T10:10:39Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2025 Analog Devices, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/ {
+	aliases {
+		accel0 = &adxl367_eval_adxl367_ardz;
+	};
path: boards/shields/eval_adxl367_ardz/boards/apard32690_max32690_m4.overlay
user: login: vladislav-pejic
body: Is it ok now?
created_at: 2025-04-15T10:42:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -126,6 +126,25 @@ config ADXL367_STREAM
 	help
 	  Use this configuration option to enable streaming sensor data via RTIO.
 
+choice
+	prompt "Accelerometer FIFO mode."
+	default ADXL367_FIFO_STREAM_MODE if ADXL367_STREAM
+	default ADXL367_FIFO_DISABLED if !ADXL367_STREAM
+
+	config ADXL367_FIFO_DISABLED
+		bool "FIFO disabled"
+
+	config ADXL367_FIFO_OLDEST_SAVED
+		bool "FIFO Oldest saved mode"
+
+	config ADXL367_FIFO_STREAM_MODE
+		bool "FIFO Stream mode"
+
+	config ADXL367_FIFO_TRIGGERED_MODE
+		bool "FIFO Triggered mode"
path: drivers/sensor/adi/adxl367/Kconfig
user: login: nordicjm
body: no indents for configs inside of choice
created_at: 2025-04-15T11:49:07Z
author_association: CONTRIBUTOR
diff_hunk: @@ -126,6 +126,25 @@ config ADXL367_STREAM
 	help
 	  Use this configuration option to enable streaming sensor data via RTIO.
 
+choice
+	prompt "Accelerometer FIFO mode."
path: drivers/sensor/adi/adxl367/Kconfig
user: login: nordicjm
body: ```suggestion
	prompt "Accelerometer FIFO mode"
```
created_at: 2025-04-15T11:49:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -34,3 +34,10 @@ tests:
       - SNIPPET=rtt-tracing;rtt-console
     platform_allow:
       - apard32690/max32690/m4
+  sample.sensor.accel_polling.adxl367-stream:
+    extra_args:
+      - SHIELD=eval_adxl367_ardz
+      - EXTRA_CONF_FILE=adxl367-stream.conf
+      - SNIPPET=rtt-tracing;rtt-console
path: samples/sensor/accel_polling/sample.yaml
user: login: nordicjm
body: put quotes around these, they are strings
created_at: 2025-04-15T11:49:46Z
author_association: CONTRIBUTOR
diff_hunk: @@ -232,6 +232,16 @@
 #define ADXL367_ACCEL_4G_LSB_PER_G	2000
 #define ADXL367_ACCEL_8G_LSB_PER_G	1000
 
+#if CONFIG_ADXL367_FIFO_DISABLED
+#	define ADXL367_DEFAULT_FIFO_MODE		ADXL367_FIFO_DISABLED
path: drivers/sensor/adi/adxl367/adxl367.h
user: login: nordicjm
body: can we not do this weird indent and just do #define normally
created_at: 2025-04-22T08:21:00Z
author_association: CONTRIBUTOR
diff_hunk: @@ -29,3 +45,14 @@ properties:
       The INT1 signal defaults to active high as produced by the
       sensor.  The property value should ensure the flags properly
       describe the signal that is presented to the driver.
+
+  fifo-mode:
+    type: int
+    default: 0
+    description: |
+          Accelerometer FIFO Mode. If not set, default value is ADXL367_FIFO_MODE_DISABLED.
+    enum:
+      - 0 # ADXL367_FIFO_MODE_DISABLED
+      - 1 # ADXL367_FIFO_MODE_OLDEST_SAVED
+      - 2 # ADXL367_FIFO_MODE_STREAM
+      - 3 # ADXL367_FIFO_MODE_TRIGGERED
path: dts/bindings/sensor/adi,adxl367-common.yaml
user: login: MaureenHelm
body: Need to explain in the description why the default value was selected
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#dt-bindings-default-rules

The enumeration decoding needs to be moved from comments to the description so it will be included in the rendered documentation.
created_at: 2025-04-24T13:13:43Z
author_association: MEMBER
diff_hunk: @@ -1115,7 +1115,8 @@ static int adxl367_init(const struct device *dev)
 		.inactivity_th.enable =							\
 			IS_ENABLED(CONFIG_ADXL367_INACTIVITY_DETECTION_MODE),		\
 		.inactivity_time = CONFIG_ADXL367_INACTIVITY_TIME,			\
-		.fifo_config.fifo_mode = ADXL367_FIFO_DISABLED,				\
+		.fifo_config.fifo_mode =					\
+		DT_INST_PROP_OR(inst, fifo_mode, ADXL367_FIFO_DISABLED),	\
path: drivers/sensor/adi/adxl367/adxl367.c
user: login: nordicjm
body: end of line alignment seems off?
created_at: 2025-04-25T06:24:23Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1115,7 +1115,8 @@ static int adxl367_init(const struct device *dev)
 		.inactivity_th.enable =							\
 			IS_ENABLED(CONFIG_ADXL367_INACTIVITY_DETECTION_MODE),		\
 		.inactivity_time = CONFIG_ADXL367_INACTIVITY_TIME,			\
-		.fifo_config.fifo_mode = ADXL367_FIFO_DISABLED,				\
+		.fifo_config.fifo_mode =					\
+		DT_INST_PROP_OR(inst, fifo_mode, ADXL367_FIFO_DISABLED),	\
path: drivers/sensor/adi/adxl367/adxl367.c
user: login: vladislav-pejic
body: Fixed
created_at: 2025-04-25T09:56:56Z
author_association: CONTRIBUTOR

PR comments:
user: login: ubieda
created_at: 2025-04-15T11:55:34Z
body: I'm wondering whether this should be a device-tree property. That way multiple instances can be configured differently
author_association: MEMBER
user: login: vladislav-pejic
created_at: 2025-04-24T12:51:12Z
body: > > I'm wondering whether this should be a device-tree property. That way multiple instances can be configured differently
> 
> Agree

Done!
author_association: CONTRIBUTOR