Skip to content

Commit 4a90297

Browse files
vladislav-pejickartben
authored andcommitted
drivers: sensor: adxl367: FIFO mode from DT
Add support for setting FIFO mode using DT property. Signed-off-by: Vladislav Pejic <vladislav.pejic@orioninc.com>
1 parent 9809788 commit 4a90297

File tree

4 files changed

+65
-6
lines changed

4 files changed

+65
-6
lines changed

drivers/sensor/adi/adxl367/adxl367.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ static int adxl367_init(const struct device *dev)
10971097
#define ADXL367_CFG_IRQ(inst)
10981098
#endif /* CONFIG_ADXL367_TRIGGER */
10991099

1100-
#define ADXL367_CONFIG(inst, chipid) \
1100+
#define ADXL367_CONFIG(inst, chipid) \
11011101
.odr = DT_INST_PROP(inst, odr), \
11021102
.autosleep = false, \
11031103
.low_noise = false, \
@@ -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, \

drivers/sensor/adi/adxl367/adxl367.h

Lines changed: 5 additions & 4 deletions
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

Lines changed: 30 additions & 0 deletions
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,17 @@ 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+
description: |
52+
Accelerometer FIFO Mode.
53+
0 # ADXL367_FIFO_MODE_DISABLED
54+
1 # ADXL367_FIFO_MODE_OLDEST_SAVED
55+
2 # ADXL367_FIFO_MODE_STREAM
56+
3 # ADXL367_FIFO_MODE_TRIGGERED
57+
enum:
58+
- 0
59+
- 1
60+
- 2
61+
- 3
Lines changed: 27 additions & 0 deletions
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)