Skip to content

Commit e13205b

Browse files
aviscontiMaureenHelm
authored andcommitted
drivers/sensor: add support to IIS2DLPC accelerometer sensor
The IIS2DLPC is a 3D digital accelerometer ultra-low power sensor for industrial applications, which can be interfaced through either I2C or SPI bus. https://www.st.com/resource/en/datasheet/iis2dlpc.pdf This driver is based on stmemsc i/f v1.02 Signed-off-by: Armando Visconti <[email protected]>
1 parent 8da8b5c commit e13205b

File tree

14 files changed

+1320
-0
lines changed

14 files changed

+1320
-0
lines changed

drivers/sensor/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ add_subdirectory_ifdef(CONFIG_TI_HDC ti_hdc)
2525
add_subdirectory_ifdef(CONFIG_HMC5883L hmc5883l)
2626
add_subdirectory_ifdef(CONFIG_HP206C hp206c)
2727
add_subdirectory_ifdef(CONFIG_HTS221 hts221)
28+
add_subdirectory_ifdef(CONFIG_IIS2DLPC iis2dlpc)
2829
add_subdirectory_ifdef(CONFIG_IIS3DHHC iis3dhhc)
2930
add_subdirectory_ifdef(CONFIG_ISL29035 isl29035)
3031
add_subdirectory_ifdef(CONFIG_LIS2DH lis2dh)

drivers/sensor/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ source "drivers/sensor/hp206c/Kconfig"
7979

8080
source "drivers/sensor/hts221/Kconfig"
8181

82+
source "drivers/sensor/iis2dlpc/Kconfig"
83+
8284
source "drivers/sensor/iis3dhhc/Kconfig"
8385

8486
source "drivers/sensor/isl29035/Kconfig"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ST Microelectronics IIS2DLPC 3-axis accelerometer driver
2+
#
3+
# Copyright (c) 2020 STMicroelectronics
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
zephyr_library()
8+
9+
zephyr_library_sources_ifdef(CONFIG_IIS2DLPC iis2dlpc)
10+
zephyr_library_sources_ifdef(CONFIG_IIS2DLPC iis2dlpc_i2c.c)
11+
zephyr_library_sources_ifdef(CONFIG_IIS2DLPC iis2dlpc_spi.c)
12+
zephyr_library_sources_ifdef(CONFIG_IIS2DLPC_TRIGGER iis2dlpc_trigger.c)

drivers/sensor/iis2dlpc/Kconfig

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
# ST Microelectronics IIS2DLPC 3-axis accelerometer driver
2+
3+
# Copyright (c) 2020 STMicroelectronics
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
menuconfig IIS2DLPC
7+
bool "IIS2DLPC I2C/SPI accelerometer sensor driver"
8+
depends on (I2C && HAS_DTS_I2C) || SPI
9+
select HAS_STMEMSC
10+
select USE_STDC_IIS2DLPC
11+
help
12+
Enable driver for IIS2DLPC accelerometer sensor driver
13+
14+
if IIS2DLPC
15+
16+
choice IIS2DLPC_TRIGGER_MODE
17+
prompt "Trigger mode"
18+
help
19+
Specify the type of triggering to be used by the driver.
20+
21+
config IIS2DLPC_TRIGGER_NONE
22+
bool "No trigger"
23+
24+
config IIS2DLPC_TRIGGER_GLOBAL_THREAD
25+
bool "Use global thread"
26+
depends on GPIO
27+
select IIS2DLPC_TRIGGER
28+
29+
config IIS2DLPC_TRIGGER_OWN_THREAD
30+
bool "Use own thread"
31+
depends on GPIO
32+
select IIS2DLPC_TRIGGER
33+
34+
endchoice
35+
36+
config IIS2DLPC_TRIGGER
37+
bool
38+
39+
if IIS2DLPC_TRIGGER
40+
41+
config IIS2DLPC_THREAD_PRIORITY
42+
int "Thread priority"
43+
depends on IIS2DLPC_TRIGGER_OWN_THREAD
44+
default 10
45+
help
46+
Priority of thread used by the driver to handle interrupts.
47+
48+
config IIS2DLPC_THREAD_STACK_SIZE
49+
int "Thread stack size"
50+
depends on IIS2DLPC_TRIGGER_OWN_THREAD
51+
default 1024
52+
help
53+
Stack size of thread used by the driver to handle interrupts.
54+
55+
choice
56+
prompt "Sensor INT pin number"
57+
default IIS2DLPC_INT_PIN_1
58+
help
59+
The number of IIS2DLPC int pin used to generate interrupt to cpu.
60+
Supported values are int1 or int2
61+
62+
config IIS2DLPC_INT_PIN_1
63+
bool "int1"
64+
65+
config IIS2DLPC_INT_PIN_2
66+
bool "int2"
67+
endchoice
68+
69+
menuconfig IIS2DLPC_PULSE
70+
bool "Pulse detection"
71+
help
72+
Enable pulse (single/double tap) detection
73+
74+
if IIS2DLPC_PULSE
75+
76+
choice
77+
prompt "Pulse interrupt source"
78+
default IIS2DLPC_ONLY_SINGLE
79+
80+
config IIS2DLPC_ONLY_SINGLE
81+
bool "single"
82+
83+
config IIS2DLPC_SINGLE_DOUBLE
84+
bool "single/double"
85+
86+
endchoice
87+
88+
config IIS2DLPC_PULSE_THSX
89+
hex "Pulse X-axis threshold"
90+
range 0 0x1F
91+
default 0x0E
92+
help
93+
Threshold to start the pulse-event detection procedure on the X-axis.
94+
Threshold values for each axis are unsigned 5-bit corresponding
95+
to an 2g acceleration full-scale range.
96+
97+
config IIS2DLPC_PULSE_THSY
98+
hex "Pulse Y-axis threshold"
99+
range 0 0x1F
100+
default 0x0E
101+
help
102+
Threshold to start the pulse-event detection procedure on the Y-axis.
103+
Threshold values for each axis are unsigned 5-bit corresponding
104+
to an 2g acceleration full-scale range.
105+
106+
config IIS2DLPC_PULSE_THSZ
107+
hex "Pulse Z-axis threshold"
108+
range 0 0x1F
109+
default 0x0E
110+
help
111+
Threshold to start the pulse-event detection procedure on the Z-axis.
112+
Threshold values for each axis are unsigned 5-bit corresponding
113+
to an 2g acceleration full-scale range.
114+
115+
config IIS2DLPC_PULSE_X
116+
bool "Enable X axis for pulse"
117+
default y
118+
119+
config IIS2DLPC_PULSE_Y
120+
bool "Enable Y axis for pulse"
121+
default y
122+
123+
config IIS2DLPC_PULSE_Z
124+
bool "Enable Z axis for pulse"
125+
default y
126+
127+
config IIS2DLPC_PULSE_SHOCK
128+
hex "Shock value"
129+
range 0 0x03
130+
default 0x00
131+
help
132+
Maximum duration of over-threshold event: this register represents
133+
the maximum time of an over-threshold signal detection to be
134+
recognized as a tap event. Where 0 equals 4*1/ODR and 1LSB = 8*1/ODR.
135+
136+
config IIS2DLPC_PULSE_LTNCY
137+
hex "Latency value"
138+
range 0 0x0F
139+
default 0x05
140+
help
141+
When double-tap recognition is enabled, this register expresses
142+
the maximum time between two successive detected taps to
143+
determine a double-tap event. Where 0 equals 16*1/ODR and
144+
1LSB = 32*1/ODR.
145+
146+
config IIS2DLPC_PULSE_QUIET
147+
hex "Quiet value"
148+
range 0 0x03
149+
default 0x00
150+
help
151+
Expected quiet time after a tap detection: this register represents
152+
the time after the first detected tap in which there must not be
153+
any overthreshold event. Where 0 equals 2*1/ODR and 1LSB = 4*1/ODR.
154+
155+
endif # IIS2DLPC_PULSE
156+
157+
endif # IIS2DLPC_TRIGGER
158+
159+
choice
160+
prompt "Accelerometer Full-scale range setting"
161+
default IIS2DLPC_ACCEL_RANGE_RUNTIME
162+
163+
config IIS2DLPC_ACCEL_RANGE_RUNTIME
164+
bool "Set at runtime (Default 2G)"
165+
166+
config IIS2DLPC_ACCEL_RANGE_2G
167+
bool "2G"
168+
169+
config IIS2DLPC_ACCEL_RANGE_4G
170+
bool "4G"
171+
172+
config IIS2DLPC_ACCEL_RANGE_8G
173+
bool "8G"
174+
175+
config IIS2DLPC_ACCEL_RANGE_16G
176+
bool "16G"
177+
endchoice
178+
179+
choice
180+
prompt "Accelerometer sampling frequency (ODR)"
181+
default IIS2DLPC_ODR_RUNTIME
182+
183+
config IIS2DLPC_ODR_RUNTIME
184+
bool "Set at runtime (Default 100 Hz)"
185+
186+
config IIS2DLPC_ODR_1_6
187+
bool "1.6 Hz"
188+
189+
config IIS2DLPC_ODR_12_5
190+
bool "12.5 Hz"
191+
192+
config IIS2DLPC_ODR_25
193+
bool "25 Hz"
194+
195+
config IIS2DLPC_ODR_50
196+
bool "50 Hz"
197+
198+
config IIS2DLPC_ODR_100
199+
bool "100 Hz"
200+
201+
config IIS2DLPC_ODR_200
202+
bool "200 Hz"
203+
204+
config IIS2DLPC_ODR_400
205+
bool "400 Hz"
206+
207+
config IIS2DLPC_ODR_800
208+
bool "800 Hz"
209+
210+
config IIS2DLPC_ODR_1600
211+
bool "1600 Hz"
212+
213+
endchoice
214+
215+
config IIS2DLPC_POWER_MODE
216+
int "Sensor Power Modes"
217+
range 0 4
218+
default 0
219+
help
220+
Specify the sensor power mode
221+
0: Low Power M1
222+
1: Low Power M2
223+
2: Low Power M3
224+
3: Low Power M4
225+
4: High Performance
226+
227+
endif # IIS2DLPC

0 commit comments

Comments
 (0)