Skip to content

Commit a3e7cea

Browse files
mhennerichMaureenHelm
authored andcommitted
drivers: sensors: adxl372: Add driver for ADXL372 high-g accelerometer
This patch adds support for the Analog Devices ADXL372 ultra-low power, 3-axis, +/-200 g MEMS accelerometer. The ADXL372 can be either connected via a SPI or I2C interface. Signed-off-by: Michael Hennerich <[email protected]>
1 parent 22b61c7 commit a3e7cea

File tree

7 files changed

+1899
-0
lines changed

7 files changed

+1899
-0
lines changed

drivers/sensor/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_subdirectory_ifdef(CONFIG_ADT7420 adt7420)
22
add_subdirectory_ifdef(CONFIG_ADXL362 adxl362)
3+
add_subdirectory_ifdef(CONFIG_ADXL372 adxl372)
34
add_subdirectory_ifdef(CONFIG_AK8975 ak8975)
45
add_subdirectory_ifdef(CONFIG_AMG88XX amg88xx)
56
add_subdirectory_ifdef(CONFIG_APDS9960 apds9960)

drivers/sensor/Kconfig

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

4040
source "drivers/sensor/adxl362/Kconfig"
4141

42+
source "drivers/sensor/adxl372/Kconfig"
43+
4244
source "drivers/sensor/ak8975/Kconfig"
4345

4446
source "drivers/sensor/amg88xx/Kconfig"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# Copyright (c) 2018 Analog Devices Inc.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
zephyr_library()
7+
8+
zephyr_library_sources_ifdef(CONFIG_ADXL372 adxl372.c)
9+
zephyr_library_sources_ifdef(CONFIG_ADXL372_TRIGGER adxl372_trigger.c)

drivers/sensor/adxl372/Kconfig

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
# Kconfig - Micropower, 3-Axis, +/-200g Digital Accelerometer
2+
#
3+
# Copyright (c) 2018 Analog Devices Inc.
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
menuconfig ADXL372
9+
bool "ADXL372 Three Axis High-g I2C/SPI accelerometer"
10+
depends on SENSOR && (I2C || SPI)
11+
help
12+
Enable driver for ADXL372 Three-Axis Digital Accelerometers.
13+
14+
if ADXL372
15+
16+
choice ADXL372_BUS_TYPE
17+
prompt "Interface type"
18+
help
19+
Select interface the digital interface type for the ADXL372
20+
21+
config ADXL372_I2C
22+
depends on I2C
23+
bool "I2C Interface"
24+
25+
config ADXL372_SPI
26+
depends on SPI
27+
bool "SPI Interface"
28+
29+
endchoice
30+
31+
if !HAS_DTS_I2C_DEVICE
32+
33+
config ADXL372_DEV_NAME
34+
string "ADXL372 device name"
35+
depends on ADXL372_I2C
36+
default "ADXL372"
37+
38+
config ADXL372_I2C_ADDR
39+
hex "I2C address for ADXL372"
40+
depends on ADXL372_I2C
41+
default 0x1D
42+
help
43+
I2C address of the ADXL372 sensor.
44+
45+
0x1D: if MISO is pulled low
46+
0x53: if MISO is pulled high
47+
48+
config ADXL372_I2C_MASTER_DEV_NAME
49+
string "I2C master where ADXL372 is connected"
50+
depends on ADXL372_I2C
51+
default "I2C_0"
52+
help
53+
Specify the device name of the I2C master device to which the
54+
ADXL372 chip is connected.
55+
56+
endif # !HAS_DTS_I2C_DEVICE
57+
58+
if !HAS_DTS_SPI_DEVICE
59+
60+
config ADXL372_DEV_NAME
61+
string "ADXL372 device name"
62+
depends on ADXL372_SPI
63+
default "ADXL372"
64+
65+
config ADXL372_SPI_DEV_NAME
66+
string "SPI device where ADXL372 is connected"
67+
depends on ADXL372_SPI
68+
default "SPI_0"
69+
help
70+
Specify the device name of the SPI device to which ADXL372 is
71+
connected.
72+
73+
config ADXL372_SPI_DEV_SLAVE
74+
int "SPI Slave Select where ADXL372 is connected"
75+
depends on ADXL372_SPI
76+
default 2
77+
help
78+
Specify the slave select pin of the SPI to which ADXL372 is
79+
connected.
80+
81+
config ADXL372_SPI_GPIO_CS
82+
bool "ADXL372 SPI CS through a GPIO pin"
83+
depends on ADXL372_SPI
84+
help
85+
This option is useful if one needs to manage SPI CS through a GPIO
86+
pin to by-pass the SPI controller's CS logic.
87+
88+
config ADXL372_SPI_BUS_FREQ
89+
int "ADXL372 SPI bus speed in Hz"
90+
range 10000 10000000
91+
default 8000000
92+
help
93+
This is the maximum supported SPI bus frequency. The chip supports a
94+
frequency up to 10MHz.
95+
96+
endif # !HAS_DTS_SPI_DEVICE
97+
98+
if !HAS_DTS_SPI_PINS
99+
100+
config ADXL372_SPI_GPIO_CS_DRV_NAME
101+
string "GPIO driver's name to use to drive SPI CS through"
102+
default "GPIO_0"
103+
depends on ADXL372_SPI_GPIO_CS
104+
help
105+
This option is mandatory to set which GPIO controller to use in order
106+
to actually emulate the SPI CS.
107+
108+
config ADXL372_SPI_GPIO_CS_PIN
109+
int "GPIO PIN to use to drive SPI CS through"
110+
default 0
111+
depends on ADXL372_SPI_GPIO_CS
112+
help
113+
This option is mandatory to set which GPIO pin to use in order
114+
to actually emulate the SPI CS.
115+
116+
endif # !HAS_DTS_SPI_PINS
117+
118+
choice
119+
prompt "Operating mode"
120+
default ADXL372_PEAK_DETECT_MODE
121+
122+
config ADXL372_PEAK_DETECT_MODE
123+
bool "Max Peak detect mode"
124+
help
125+
In most high-g applications, a single (3-axis) acceleration sample at
126+
the peak of an impact event contains sufficient information
127+
about the event, and the full acceleration history is not required.
128+
In this mode the device returns only the over threshold
129+
Peak Acceleration between two consecutive sample fetches.
130+
131+
config ADXL372_MEASUREMENT_MODE
132+
bool "Measurement Mode"
133+
help
134+
In this mode, acceleration data is provided continuously at the
135+
output data rate (ODR).
136+
137+
endchoice
138+
139+
choice
140+
prompt "Accelerometer sampling frequency (ODR)"
141+
default ADXL372_ODR_6400HZ if ADXL372_PEAK_DETECT_MODE
142+
default ADXL372_ODR_400HZ if ADXL372_MEASUREMENT_MODE
143+
144+
config ADXL372_ODR_400HZ
145+
bool "400 Hz"
146+
147+
config ADXL372_ODR_800HZ
148+
bool "800 Hz"
149+
150+
config ADXL372_ODR_1600HZ
151+
bool "1600 Hz"
152+
153+
config ADXL372_ODR_3200HZ
154+
bool "3200 Hz"
155+
156+
config ADXL372_ODR_6400HZ
157+
bool "6400 Hz"
158+
159+
endchoice
160+
161+
choice
162+
prompt "Low-Pass (Antialiasing) Filter corner frequency"
163+
default ADXL372_BW_200HZ if ADXL372_ODR_400HZ
164+
default ADXL372_BW_400HZ if ADXL372_ODR_800HZ
165+
default ADXL372_BW_800HZ if ADXL372_ODR_1600HZ
166+
default ADXL372_BW_1600HZ if ADXL372_ODR_3200HZ
167+
default ADXL372_BW_3200HZ if ADXL372_ODR_6400HZ
168+
help
169+
High g events often include acceleration content over a wide range
170+
of frequencies. The ADC of the ADXL372 samples the input acceleration
171+
at the user selected ODR.
172+
In the absence of antialiasing filters, input signals whose frequency
173+
is more than half the ODR alias or fold into the measurement bandwidth
174+
can lead to inaccurate measurements.
175+
176+
config ADXL372_LPF_DISABLE
177+
bool "Disabled"
178+
179+
config ADXL372_BW_200HZ
180+
bool "200 Hz"
181+
182+
config ADXL372_BW_400HZ
183+
bool "400 Hz"
184+
185+
config ADXL372_BW_800HZ
186+
bool "800 Hz"
187+
188+
config ADXL372_BW_1600HZ
189+
bool "1600 Hz"
190+
191+
config ADXL372_BW_3200HZ
192+
bool "3200 Hz"
193+
194+
endchoice
195+
196+
choice
197+
prompt "High-Pass Filter corner frequency"
198+
default ADXL372_HPF_CORNER0
199+
help
200+
The ADXL372 offers a one-pole, high-pass filter with a user
201+
selectable −3 dB frequency. Applications that do not require dc
202+
acceleration measurements can use the high-pass filter to minimize
203+
constant or slow varying offset errors including initial bias,
204+
bias drift due to temperature, and bias drift due to supply voltage
205+
206+
config ADXL372_HPF_DISABLE
207+
bool "Disabled"
208+
209+
config ADXL372_HPF_CORNER0
210+
bool "ODR/210"
211+
212+
config ADXL372_HPF_CORNER1
213+
bool "ODR/411"
214+
215+
config ADXL372_HPF_CORNER2
216+
bool "ODR/812"
217+
218+
config ADXL372_HPF_CORNER3
219+
bool "ODR/1616"
220+
221+
endchoice
222+
223+
224+
config ADXL372_ACTIVITY_THRESHOLD
225+
int "Activity threshold in mg"
226+
range 0 200000
227+
default 500
228+
help
229+
Threshold for activity detection.
230+
231+
config ADXL372_INACTIVITY_THRESHOLD
232+
int "In-activity threshold in mg"
233+
range 0 200000
234+
default 400
235+
help
236+
Threshold for in-activity detection.
237+
238+
config ADXL372_ACTIVITY_TIME
239+
int "Activity time"
240+
range 0 255
241+
default 1
242+
help
243+
The activity timer implements a robust activity detection that
244+
minimizes false positive motion triggers. When the timer is used,
245+
only sustained motion can trigger activity detection.
246+
Number of multiples of 3.3 ms activity timer for which above threshold
247+
acceleration is required to detect activity. It is 3.3 ms per code
248+
for 6400 Hz ODR, and it is 6.6 ms per code for 3200 Hz ODR and below.
249+
250+
config ADXL372_INACTIVITY_TIME
251+
int "In-activity time"
252+
range 0 255
253+
default 2
254+
help
255+
The time that all enabled axes must be lower than the inactivity
256+
threshold for an inactivity event to be detected. Number of multiples
257+
of 26 ms inactivity timer for which below threshold acceleration is
258+
required to detect inactivity. It is 26 ms per code for 3200 Hz ODR
259+
and below, and it is 13 ms per code for 6400 Hz ODR.
260+
261+
config ADXL372_REFERENCED_ACTIVITY_DETECTION_MODE
262+
bool "Use referenced activity/in-activity detection"
263+
default y
264+
help
265+
Activity detection can be configured as referenced or absolute.
266+
When using absolute activity detection, acceleration samples are
267+
compared directly to a user set threshold to determine whether
268+
motion is present. In many applications, it is advantageous for
269+
activity detection to be based not on an absolute threshold,
270+
but on a deviation from a reference point or orientation.
271+
272+
choice
273+
prompt "Trigger mode"
274+
default ADXL372_TRIGGER_NONE
275+
help
276+
Specify the type of triggering used by the driver.
277+
278+
config ADXL372_TRIGGER_NONE
279+
bool "No trigger"
280+
281+
config ADXL372_TRIGGER_GLOBAL_THREAD
282+
bool "Use global thread"
283+
depends on GPIO
284+
select ADXL372_TRIGGER
285+
286+
config ADXL372_TRIGGER_OWN_THREAD
287+
bool "Use own thread"
288+
depends on GPIO
289+
select ADXL372_TRIGGER
290+
291+
endchoice
292+
293+
config ADXL372_TRIGGER
294+
bool
295+
296+
if !HAS_DTS_GPIO_DEVICE
297+
298+
config ADXL372_GPIO_DEV_NAME
299+
string "GPIO device"
300+
default "GPIO_0"
301+
depends on ADXL372_TRIGGER
302+
help
303+
The GPIO device's name where the ADXL372 interrupt 1 or 2 pin is
304+
connected.
305+
306+
config ADXL372_GPIO_PIN_NUM
307+
int "Interrupt GPIO pin number"
308+
default 0
309+
depends on ADXL372_TRIGGER
310+
help
311+
The GPIO pin number receiving the interrupt signal from the
312+
ADXL372 sensor.
313+
314+
endif # !HAS_DTS_GPIO_DEVICE
315+
316+
config ADXL372_THREAD_PRIORITY
317+
int "Thread priority"
318+
depends on ADXL372_TRIGGER_OWN_THREAD && ADXL372_TRIGGER
319+
default 10
320+
help
321+
Priority of thread used by the driver to handle interrupts.
322+
323+
config ADXL372_THREAD_STACK_SIZE
324+
int "Thread stack size"
325+
depends on ADXL372_TRIGGER_OWN_THREAD && ADXL372_TRIGGER
326+
default 1024
327+
help
328+
Stack size of thread used by the driver to handle interrupts.
329+
330+
endif #ADXL372

0 commit comments

Comments
 (0)