Skip to content

Commit 567493c

Browse files
drivers: sensor: adxl367: FIFO mode from DT
Add support for setting FIFO mode using DT property. Signed-off-by: Vladislav Pejic <[email protected]>
1 parent 168655c commit 567493c

File tree

4 files changed

+69
-5
lines changed

4 files changed

+69
-5
lines changed

drivers/sensor/adi/adxl367/adxl367.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,8 @@ static int adxl367_init(const struct device *dev)
11151115
.inactivity_th.enable = \
11161116
IS_ENABLED(CONFIG_ADXL367_INACTIVITY_DETECTION_MODE), \
11171117
.inactivity_time = CONFIG_ADXL367_INACTIVITY_TIME, \
1118-
.fifo_config.fifo_mode = ADXL367_FIFO_DISABLED, \
1118+
.fifo_config.fifo_mode = \
1119+
DT_INST_PROP_OR(inst, fifo_mode, ADXL367_FIFO_DISABLED), \
11191120
.fifo_config.fifo_format = ADXL367_FIFO_FORMAT_XYZ, \
11201121
.fifo_config.fifo_samples = 128, \
11211122
.fifo_config.fifo_read_mode = ADXL367_14B_CHID, \
@@ -1142,6 +1143,10 @@ static int adxl367_init(const struct device *dev)
11421143
}
11431144

11441145
#define ADXL367_DEFINE_SPI(inst, chipid) \
1146+
BUILD_ASSERT(!IS_ENABLED(CONFIG_ADXL367_STREAM) || \
1147+
DT_INST_NODE_HAS_PROP(inst, fifo_mode), \
1148+
"Streaming requires fifo-mode property. Please set it in the device-tree" \
1149+
"node properties"); \
11451150
IF_ENABLED(CONFIG_ADXL367_STREAM, (ADXL367_RTIO_DEFINE(inst, chipid))); \
11461151
static struct adxl367_data adxl367_data_##inst##chipid = { \
11471152
IF_ENABLED(CONFIG_ADXL367_STREAM, (.rtio_ctx = &adxl367_rtio_ctx_##inst##chipid, \

drivers/sensor/adi/adxl367/adxl367.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <zephyr/drivers/gpio.h>
1414
#include <zephyr/kernel.h>
1515
#include <zephyr/sys/util.h>
16+
#include <zephyr/dt-bindings/sensor/adxl367.h>
1617

1718
#define DT_DRV_COMPAT adi_adxl367
1819
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
@@ -280,10 +281,10 @@ enum adxl367_fifo_format {
280281
};
281282

282283
enum adxl367_fifo_mode {
283-
ADXL367_FIFO_DISABLED,
284-
ADXL367_OLDEST_SAVED,
285-
ADXL367_STREAM_MODE,
286-
ADXL367_TRIGGERED_MODE
284+
ADXL367_FIFO_DISABLED = ADXL367_FIFO_MODE_DISABLED,
285+
ADXL367_OLDEST_SAVED = ADXL367_FIFO_MODE_OLDEST_SAVED,
286+
ADXL367_STREAM_MODE = ADXL367_FIFO_MODE_STREAM,
287+
ADXL367_TRIGGERED_MODE = ADXL367_FIFO_MODE_TRIGGERED
287288
};
288289

289290
enum adxl367_fifo_read_mode {

dts/bindings/sensor/adi,adxl367-common.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# Copyright (c) 2023 Analog Devices Inc.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
description: |
5+
ADXL367 3-axis accelerometer
6+
When setting the accelerometer DTS properties and want to use
7+
streaming funcionality, make sure to include adxl367.h and
8+
use the macros defined there for fifo_mode property.
9+
10+
Example:
11+
#include <zephyr/dt-bindings/sensor/adxl367.h>
12+
13+
adxl367: adxl367@0 {
14+
...
15+
16+
fifo_mode = <ADXL367_FIFO_MODE_STREAM>;
17+
};
18+
19+
420
include: sensor-device.yaml
521

622
properties:
@@ -29,3 +45,18 @@ properties:
2945
The INT1 signal defaults to active high as produced by the
3046
sensor. The property value should ensure the flags properly
3147
describe the signal that is presented to the driver.
48+
49+
fifo-mode:
50+
type: int
51+
default: 0
52+
description: |
53+
Accelerometer FIFO Mode. Default is power on reset value.
54+
0 # ADXL367_FIFO_MODE_DISABLED
55+
1 # ADXL367_FIFO_MODE_OLDEST_SAVED
56+
2 # ADXL367_FIFO_MODE_STREAM
57+
3 # ADXL367_FIFO_MODE_TRIGGERED
58+
enum:
59+
- 0
60+
- 1
61+
- 2
62+
- 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025 Analog Devices Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_ADI_ADX367_H_
7+
#define ZEPHYR_INCLUDE_DT_BINDINGS_ADI_ADX367_H_
8+
9+
/**
10+
* @defgroup ADXL367 ADI DT Options
11+
* @ingroup sensor_interface
12+
* @{
13+
*/
14+
15+
/**
16+
* @defgroup ADXL367_FIFO_MODE FIFO mode options
17+
* @{
18+
*/
19+
#define ADXL367_FIFO_MODE_DISABLED 0x0
20+
#define ADXL367_FIFO_MODE_OLDEST_SAVED 0x1
21+
#define ADXL367_FIFO_MODE_STREAM 0x2
22+
#define ADXL367_FIFO_MODE_TRIGGERED 0x3
23+
/** @} */
24+
25+
/** @} */
26+
27+
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ADI_ADX367_H_ */

0 commit comments

Comments
 (0)