Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lis2du12 accelerometer driver #65734

Merged
merged 4 commits into from Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions boards/arm/sensortile_box_pro/sensortile_box_pro.dts
Expand Up @@ -169,17 +169,27 @@
pinctrl-names = "default";
status = "okay";

cs-gpios = <&gpioi 5 GPIO_ACTIVE_LOW>;
cs-gpios = <&gpioi 5 GPIO_ACTIVE_LOW>, <&gpioi 7 GPIO_ACTIVE_LOW>;

lsm6dsv16x: lsm6dsv16x@0 {
compatible = "st,lsm6dsv16x";
spi-max-frequency = <DT_FREQ_M(10)>; /* 10 MHz */
spi-max-frequency = <DT_FREQ_M(10)>;
reg = <0>;
int1-gpios = <&gpioa 4 GPIO_ACTIVE_HIGH>;
int2-gpios = <&gpiod 11 GPIO_ACTIVE_HIGH>;

drdy-pin = <2>;
};

lis2du12: lis2du12@1 {
compatible = "st,lis2du12";
spi-max-frequency = <DT_FREQ_M(10)>;
reg = <1>;
int1-gpios = <&gpiof 2 GPIO_ACTIVE_HIGH>;
int2-gpios = <&gpiof 15 GPIO_ACTIVE_HIGH>;

drdy-pin = <2>;
};
};

&timers4 {
Expand Down
1 change: 1 addition & 0 deletions drivers/sensor/CMakeLists.txt
Expand Up @@ -68,6 +68,7 @@ add_subdirectory_ifdef(CONFIG_ISM330DHCX ism330dhcx)
add_subdirectory_ifdef(CONFIG_ITDS wsen_itds)
add_subdirectory_ifdef(CONFIG_LIS2DH lis2dh)
add_subdirectory_ifdef(CONFIG_LIS2DS12 lis2ds12)
add_subdirectory_ifdef(CONFIG_LIS2DU12 lis2du12)
add_subdirectory_ifdef(CONFIG_LIS2DW12 lis2dw12)
add_subdirectory_ifdef(CONFIG_LIS2MDL lis2mdl)
add_subdirectory_ifdef(CONFIG_LIS3MDL lis3mdl)
Expand Down
1 change: 1 addition & 0 deletions drivers/sensor/Kconfig
Expand Up @@ -140,6 +140,7 @@ source "drivers/sensor/ite_tach_it8xxx2/Kconfig"
source "drivers/sensor/ite_vcmp_it8xxx2/Kconfig"
source "drivers/sensor/lis2dh/Kconfig"
source "drivers/sensor/lis2ds12/Kconfig"
source "drivers/sensor/lis2du12/Kconfig"
source "drivers/sensor/lis2dw12/Kconfig"
source "drivers/sensor/lis2mdl/Kconfig"
source "drivers/sensor/lis3mdl/Kconfig"
Expand Down
44 changes: 44 additions & 0 deletions drivers/sensor/Kconfig.trigger_template
@@ -0,0 +1,44 @@
# Common Kconfig template for all sensors
# Copyright (c) 2023 STMicroelectronics
# SPDX-License-Identifier: Apache-2.0

choice "$(module)_TRIGGER_MODE"
prompt "Trigger mode"
help
Specify the type of triggering to be used by the sensor module.

config $(module)_TRIGGER_NONE
bool "No trigger"

config $(module)_TRIGGER_GLOBAL_THREAD
bool "Use global thread"
depends on GPIO
select $(module)_TRIGGER

config $(module)_TRIGGER_OWN_THREAD
bool "Use own thread"
depends on GPIO
select $(module)_TRIGGER

endchoice

config $(module)_TRIGGER
bool

if $(module)_TRIGGER

config $(module)_THREAD_PRIORITY
int "Thread priority"
depends on $(module)_TRIGGER_OWN_THREAD
default $(thread_priority)
help
Priority of thread used by the driver to handle interrupts.

config $(module)_THREAD_STACK_SIZE
int "Thread stack size"
depends on $(module)_TRIGGER_OWN_THREAD
default $(thread_stack_size)
help
Stack size of thread used by the driver to handle interrupts.

endif # $(module)_TRIGGER
12 changes: 12 additions & 0 deletions drivers/sensor/lis2du12/CMakeLists.txt
@@ -0,0 +1,12 @@
# ST Microelectronics LIS2DU12 3-axis accelerometer sensor driver
#
# Copyright (c) 2023 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0
#
zephyr_library()

zephyr_library_sources(lis2du12.c)
zephyr_library_sources_ifdef(CONFIG_LIS2DU12_TRIGGER lis2du12_trigger.c)

zephyr_library_include_directories(../stmemsc)
24 changes: 24 additions & 0 deletions drivers/sensor/lis2du12/Kconfig
@@ -0,0 +1,24 @@
# ST Microelectronics LIS2DU12 3-axis accelerometer sensor driver

# Copyright (c) 2023 STMicroelectronics
# SPDX-License-Identifier: Apache-2.0

menuconfig LIS2DU12
bool "LIS2DU12 I2C/SPI smartxl Chip"
default y
depends on DT_HAS_ST_LIS2DU12_ENABLED
select I2C if $(dt_compat_on_bus,$(DT_COMPAT_ST_LIS2DU12),i2c)
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_ST_LIS2DU12),spi)
select HAS_STMEMSC
select USE_STDC_LIS2DU12
help
Enable driver for LIS2DU12 smartxl sensor.

if LIS2DU12

module = LIS2DU12
thread_priority = 10
thread_stack_size = 1024
source "drivers/sensor/Kconfig.trigger_template"

endif # LIS2DU12