Skip to content

Commit c0f7a1a

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

15 files changed

+2577
-0
lines changed

drivers/sensor/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_subdirectory_ifdef(CONFIG_HTS221 hts221)
2828
add_subdirectory_ifdef(CONFIG_IIS2DLPC iis2dlpc)
2929
add_subdirectory_ifdef(CONFIG_IIS3DHHC iis3dhhc)
3030
add_subdirectory_ifdef(CONFIG_ISL29035 isl29035)
31+
add_subdirectory_ifdef(CONFIG_ISM330DHCX ism330dhcx)
3132
add_subdirectory_ifdef(CONFIG_LIS2DH lis2dh)
3233
add_subdirectory_ifdef(CONFIG_LIS2DS12 lis2ds12)
3334
add_subdirectory_ifdef(CONFIG_LIS2DW12 lis2dw12)

drivers/sensor/Kconfig

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ source "drivers/sensor/iis3dhhc/Kconfig"
8585

8686
source "drivers/sensor/isl29035/Kconfig"
8787

88+
source "drivers/sensor/ism330dhcx/Kconfig"
89+
8890
source "drivers/sensor/lis2dh/Kconfig"
8991

9092
source "drivers/sensor/lis2ds12/Kconfig"
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ST Microelectronics ISM330DHCX 6-axis IMU sensor 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_ISM330DHCX ism330dhcx.c)
10+
zephyr_library_sources_ifdef(CONFIG_ISM330DHCX ism330dhcx_i2c.c)
11+
zephyr_library_sources_ifdef(CONFIG_ISM330DHCX ism330dhcx_spi.c)
12+
zephyr_library_sources_ifdef(CONFIG_ISM330DHCX_SENSORHUB ism330dhcx_shub.c)
13+
zephyr_library_sources_ifdef(CONFIG_ISM330DHCX_TRIGGER ism330dhcx_trigger.c)

drivers/sensor/ism330dhcx/Kconfig

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# ST Microelectronics ISM330DHCX 6-axis IMU sensor driver
2+
3+
# Copyright (c) 2020 STMicroelectronics
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
menuconfig ISM330DHCX
7+
bool "ISM330DHCX I2C/SPI accelerometer and gyroscope Chip"
8+
depends on (I2C && HAS_DTS_I2C) || SPI
9+
select HAS_STMEMSC
10+
select USE_STDC_ISM330DHCX
11+
help
12+
Enable driver for ISM330DHCX accelerometer and gyroscope
13+
sensor.
14+
15+
if ISM330DHCX
16+
17+
choice ISM330DHCX_TRIGGER_MODE
18+
prompt "Trigger mode"
19+
help
20+
Specify the type of triggering to be used by the driver.
21+
22+
config ISM330DHCX_TRIGGER_NONE
23+
bool "No trigger"
24+
25+
config ISM330DHCX_TRIGGER_GLOBAL_THREAD
26+
bool "Use global thread"
27+
depends on GPIO
28+
select ISM330DHCX_TRIGGER
29+
30+
config ISM330DHCX_TRIGGER_OWN_THREAD
31+
bool "Use own thread"
32+
depends on GPIO
33+
select ISM330DHCX_TRIGGER
34+
35+
endchoice
36+
37+
config ISM330DHCX_TRIGGER
38+
bool
39+
40+
if ISM330DHCX_TRIGGER
41+
42+
config ISM330DHCX_THREAD_PRIORITY
43+
int "Thread priority"
44+
depends on ISM330DHCX_TRIGGER_OWN_THREAD
45+
default 10
46+
help
47+
Priority of thread used by the driver to handle interrupts.
48+
49+
config ISM330DHCX_THREAD_STACK_SIZE
50+
int "Thread stack size"
51+
depends on ISM330DHCX_TRIGGER_OWN_THREAD
52+
default 1024
53+
help
54+
Stack size of thread used by the driver to handle interrupts.
55+
56+
choice ISM330DHCX_INT_PIN
57+
prompt "Sensor INT pin number"
58+
default ISM330DHCX_INT_PIN_1
59+
help
60+
The number of ISM330DHCX int pin used to generate interrupt to cpu.
61+
Supported values are int1 or int2
62+
63+
config ISM330DHCX_INT_PIN_1
64+
bool "int1"
65+
66+
config ISM330DHCX_INT_PIN_2
67+
bool "int2"
68+
endchoice
69+
70+
endif # ISM330DHCX_TRIGGER
71+
72+
config ISM330DHCX_ENABLE_TEMP
73+
bool "Enable temperature"
74+
help
75+
Enable/disable temperature
76+
77+
config ISM330DHCX_SENSORHUB
78+
bool "Enable I2C sensorhub feature"
79+
help
80+
Enable/disable internal sensorhub. You can enable
81+
a maximum of two external sensors (if more than two are enabled
82+
the system would enumerate only the first two found)
83+
84+
if ISM330DHCX_SENSORHUB
85+
86+
config ISM330DHCX_EXT_LIS2MDL
87+
bool "Enable LIS2MDL as external sensor"
88+
89+
config ISM330DHCX_EXT_IIS2MDC
90+
bool "Enable IIS2MDC as external sensor"
91+
92+
config ISM330DHCX_EXT_LPS22HH
93+
bool "Enable LPS22HH as external sensor"
94+
95+
config ISM330DHCX_EXT_HTS221
96+
bool "Enable HTS221 as external sensor"
97+
98+
config ISM330DHCX_EXT_LPS22HB
99+
bool "Enable LPS22HB as external sensor"
100+
101+
endif # ISM330DHCX_SENSORHUB
102+
103+
menu "Attributes"
104+
105+
config ISM330DHCX_GYRO_FS
106+
int "Gyroscope full-scale range"
107+
default 0
108+
help
109+
Specify the default gyroscope full-scale range.
110+
An X value for the config represents a range of +/- X degree per
111+
second. Valid values are:
112+
0: Full Scale selected at runtime
113+
125: +/- 125dps
114+
250: +/- 250dps
115+
500: +/- 500dps
116+
1000: +/- 1000dps
117+
2000: +/- 2000dps
118+
119+
config ISM330DHCX_GYRO_ODR
120+
int "Gyroscope Output data rate frequency"
121+
range 0 10
122+
default 0
123+
help
124+
Specify the default accelerometer output data rate expressed in
125+
samples per second (Hz).
126+
0: ODR selected at runtime
127+
1: 12.5Hz
128+
2: 26Hz
129+
3: 52Hz
130+
4: 104Hz
131+
5: 208Hz
132+
6: 416Hz
133+
7: 833Hz
134+
8: 1660Hz
135+
9: 3330Hz
136+
10: 6660Hz
137+
138+
config ISM330DHCX_ACCEL_FS
139+
int "Accelerometer full-scale range"
140+
default 0
141+
help
142+
Specify the default accelerometer full-scale range.
143+
An X value for the config represents a range of +/- X G. Valid values
144+
are:
145+
0: Full Scale selected at runtime
146+
2: +/- 2g
147+
4: +/- 4g
148+
8: +/- 8g
149+
16: +/- 16g
150+
151+
config ISM330DHCX_ACCEL_ODR
152+
int "Accelerometer Output data rate frequency"
153+
range 0 10
154+
default 0
155+
help
156+
Specify the default accelerometer output data rate expressed in
157+
samples per second (Hz).
158+
0: ODR selected at runtime
159+
1: 12.5Hz
160+
2: 26Hz
161+
3: 52Hz
162+
4: 104Hz
163+
5: 208Hz
164+
6: 416Hz
165+
7: 833Hz
166+
8: 1660Hz
167+
9: 3330Hz
168+
10: 6660Hz
169+
endmenu
170+
171+
endif # ISM330DHCX

0 commit comments

Comments
 (0)