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>
This commit is contained in:
Vladislav Pejic 2025-04-15 11:51:36 +02:00 committed by Benjamin Cabé
commit 4a9029771f
4 changed files with 65 additions and 6 deletions

View file

@ -1097,7 +1097,7 @@ static int adxl367_init(const struct device *dev)
#define ADXL367_CFG_IRQ(inst) #define ADXL367_CFG_IRQ(inst)
#endif /* CONFIG_ADXL367_TRIGGER */ #endif /* CONFIG_ADXL367_TRIGGER */
#define ADXL367_CONFIG(inst, chipid) \ #define ADXL367_CONFIG(inst, chipid) \
.odr = DT_INST_PROP(inst, odr), \ .odr = DT_INST_PROP(inst, odr), \
.autosleep = false, \ .autosleep = false, \
.low_noise = false, \ .low_noise = false, \
@ -1115,7 +1115,8 @@ static int adxl367_init(const struct device *dev)
.inactivity_th.enable = \ .inactivity_th.enable = \
IS_ENABLED(CONFIG_ADXL367_INACTIVITY_DETECTION_MODE), \ IS_ENABLED(CONFIG_ADXL367_INACTIVITY_DETECTION_MODE), \
.inactivity_time = CONFIG_ADXL367_INACTIVITY_TIME, \ .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_format = ADXL367_FIFO_FORMAT_XYZ, \
.fifo_config.fifo_samples = 128, \ .fifo_config.fifo_samples = 128, \
.fifo_config.fifo_read_mode = ADXL367_14B_CHID, \ .fifo_config.fifo_read_mode = ADXL367_14B_CHID, \

View file

@ -13,6 +13,7 @@
#include <zephyr/drivers/gpio.h> #include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/sys/util.h> #include <zephyr/sys/util.h>
#include <zephyr/dt-bindings/sensor/adxl367.h>
#define DT_DRV_COMPAT adi_adxl367 #define DT_DRV_COMPAT adi_adxl367
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) #if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
@ -280,10 +281,10 @@ enum adxl367_fifo_format {
}; };
enum adxl367_fifo_mode { enum adxl367_fifo_mode {
ADXL367_FIFO_DISABLED, ADXL367_FIFO_DISABLED = ADXL367_FIFO_MODE_DISABLED,
ADXL367_OLDEST_SAVED, ADXL367_OLDEST_SAVED = ADXL367_FIFO_MODE_OLDEST_SAVED,
ADXL367_STREAM_MODE, ADXL367_STREAM_MODE = ADXL367_FIFO_MODE_STREAM,
ADXL367_TRIGGERED_MODE ADXL367_TRIGGERED_MODE = ADXL367_FIFO_MODE_TRIGGERED
}; };
enum adxl367_fifo_read_mode { enum adxl367_fifo_read_mode {

View file

@ -1,6 +1,22 @@
# Copyright (c) 2023 Analog Devices Inc. # Copyright (c) 2023 Analog Devices Inc.
# SPDX-License-Identifier: Apache-2.0 # 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 include: sensor-device.yaml
properties: properties:
@ -29,3 +45,17 @@ properties:
The INT1 signal defaults to active high as produced by the The INT1 signal defaults to active high as produced by the
sensor. The property value should ensure the flags properly sensor. The property value should ensure the flags properly
describe the signal that is presented to the driver. 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

View file

@ -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_ */