dt-bindings: sensor: iis2dlpc: add macros for DT properties setting

Add macros for setting in a clear way iis2dlpc DT properties.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2023-11-17 11:31:10 +01:00 committed by Carles Cufí
parent 0d68d9e493
commit 6e09f91fec
3 changed files with 87 additions and 17 deletions

View File

@ -1,6 +1,20 @@
# Copyright (c) 2018 STMicroelectronics
# SPDX-License-Identifier: Apache-2.0
description: |
When setting the odr property in a .dts or .dtsi file you may include
st_iis2dlpc.h and use the macros defined there.
Example:
#include <zephyr/dt-bindings/sensor/st_iis2dlpc.h>
iis2dlpc: iis2dlpc@0 {
...
tap-mode = <IIS2DLPC_DT_SINGLE_DOUBLE_TAP>;
power-mode = <IIS2DLPC_DT_HP_MODE>;
};
include: sensor-device.yaml
properties:
@ -16,36 +30,44 @@ properties:
drdy-int:
type: int
default: 1
enum:
- 1 # drdy is generated from INT1
- 2 # drdy is generated from INT2
description: Select DRDY pin number (1 or 2).
enum: [1, 2]
description: |
Select DRDY pin number (1 or 2).
This number represents which of the two interrupt pins
(INT1 or INT2) the drdy line is attached to. This property is not
mandatory and if not present it defaults to 1 which is the
configuration at power-up.
- 1 # drdy is generated from INT1
- 2 # drdy is generated from INT2
range:
type: int
default: 2
description: Range in g. Default is power-up configuration.
enum:
description: |
Range in g. Default is power-up configuration.
- 16 # 16g (1.952 mg/LSB)
- 8 # 8g (0.976 mg/LSB)
- 4 # 4g (0.488 mg/LSB)
- 2 # 2g (0.244 mg/LSB)
enum: [16, 8, 4, 2]
power-mode:
type: int
default: 0
description: Specify the sensor power mode. Default is power-up configuration.
enum:
- 0 # Low Power M1
- 1 # Low Power M2
- 2 # Low Power M3
- 3 # Low Power M4
- 4 # High Performance
description: |
Specify the sensor power mode. Default is power-up configuration.
- 0 # IIS2DLPC_DT_LP_M1
- 1 # IIS2DLPC_DT_LP_M2
- 2 # IIS2DLPC_DT_LP_M3
- 3 # IIS2DLPC_DT_LP_M4
- 4 # IIS2DLPC_DT_HP_MODE
enum: [0, 1, 2, 3, 4]
# tap and tap-tap configuration section
# All default values are selected to match the power-up values.
@ -54,10 +76,13 @@ properties:
tap-mode:
type: int
default: 0
description: Tap mode. Default is power-up configuration.
enum:
- 0 # Only Single Tap
- 1 # Single and Double Tap
description: |
Tap mode. Default is power-up configuration.
- 0 # IIS2DLPC_DT_SINGLE_TAP
- 1 # IIS2DLPC_DT_SINGLE_DOUBLE_TAP
enum: [0, 1]
tap-threshold:
type: array

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2023 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_ST_IIS2DLPC_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_ST_IIS2DLPC_H_
/* power-modes */
#define IIS2DLPC_DT_LP_M1 0
#define IIS2DLPC_DT_LP_M2 1
#define IIS2DLPC_DT_LP_M3 2
#define IIS2DLPC_DT_LP_M4 3
#define IIS2DLPC_DT_HP_MODE 4
/* Filter bandwidth */
#define IIS2DLPC_DT_FILTER_BW_ODR_DIV_2 0
#define IIS2DLPC_DT_FILTER_BW_ODR_DIV_4 1
#define IIS2DLPC_DT_FILTER_BW_ODR_DIV_10 2
#define IIS2DLPC_DT_FILTER_BW_ODR_DIV_20 3
/* Tap mode */
#define IIS2DLPC_DT_SINGLE_TAP 0
#define IIS2DLPC_DT_SINGLE_DOUBLE_TAP 1
/* Free-Fall threshold */
#define IIS2DLPC_DT_FF_THRESHOLD_156_mg 0
#define IIS2DLPC_DT_FF_THRESHOLD_219_mg 1
#define IIS2DLPC_DT_FF_THRESHOLD_250_mg 2
#define IIS2DLPC_DT_FF_THRESHOLD_312_mg 3
#define IIS2DLPC_DT_FF_THRESHOLD_344_mg 4
#define IIS2DLPC_DT_FF_THRESHOLD_406_mg 5
#define IIS2DLPC_DT_FF_THRESHOLD_469_mg 6
#define IIS2DLPC_DT_FF_THRESHOLD_500_mg 7
/* wakeup duration */
#define IIS2DLPC_DT_WAKEUP_1_ODR 0
#define IIS2DLPC_DT_WAKEUP_2_ODR 1
#define IIS2DLPC_DT_WAKEUP_3_ODR 2
#define IIS2DLPC_DT_WAKEUP_4_ODR 3
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ST_IIS2DLPC_H_ */

View File

@ -14,6 +14,7 @@
#include <zephyr/dt-bindings/sensor/lis2ds12.h>
#include <zephyr/dt-bindings/sensor/lis2dw12.h>
#include <zephyr/dt-bindings/sensor/ism330dhcx.h>
#include <zephyr/dt-bindings/sensor/iis2dlpc.h>
/****************************************
* PLEASE KEEP REG ADDRESSES SEQUENTIAL *
@ -260,6 +261,8 @@ test_i2c_iis2dlpc: iis2dlpc@27 {
compatible = "st,iis2dlpc";
reg = <0x27>;
drdy-gpios = <&test_gpio 0 0>;
tap-mode = <IIS2DLPC_DT_SINGLE_DOUBLE_TAP>;
power-mode = <IIS2DLPC_DT_HP_MODE>;
};
test_i2c_iis2mdc: iis2mdc@28 {