Skip to content

Commit

Permalink
drivers: sensor: Add suport for TMAG5170 3D Hall sensor
Browse files Browse the repository at this point in the history
Introduce support for Texas Instruments TMAG5170
high-precision linear 3D Hall-effect SPI sensor.
This driver allows to configure measurements on
magnetic and temperature channels. It is also
possible to read rotation of the magnet.

Signed-off-by: Michal Morsisko <morsisko@gmail.com>
  • Loading branch information
morsisko committed Aug 9, 2023
1 parent 598f484 commit c580bec
Show file tree
Hide file tree
Showing 12 changed files with 1,102 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/sensor/CMakeLists.txt
Expand Up @@ -130,6 +130,7 @@ add_subdirectory_ifdef(CONFIG_TEMP_NRF5 nrf5)
add_subdirectory_ifdef(CONFIG_TH02 th02)
add_subdirectory_ifdef(CONFIG_TI_HDC ti_hdc)
add_subdirectory_ifdef(CONFIG_TI_HDC20XX ti_hdc20xx)
add_subdirectory_ifdef(CONFIG_TMAG5170 tmag5170)
add_subdirectory_ifdef(CONFIG_TMD2620 tmd2620)
add_subdirectory_ifdef(CONFIG_TMP007 tmp007)
add_subdirectory_ifdef(CONFIG_TMP108 tmp108)
Expand Down
1 change: 1 addition & 0 deletions drivers/sensor/Kconfig
Expand Up @@ -186,6 +186,7 @@ source "drivers/sensor/tcs3400/Kconfig"
source "drivers/sensor/th02/Kconfig"
source "drivers/sensor/ti_hdc/Kconfig"
source "drivers/sensor/ti_hdc20xx/Kconfig"
source "drivers/sensor/tmag5170/Kconfig"
source "drivers/sensor/tmd2620/Kconfig"
source "drivers/sensor/tmp007/Kconfig"
source "drivers/sensor/tmp108/Kconfig"
Expand Down
6 changes: 6 additions & 0 deletions drivers/sensor/tmag5170/CMakeLists.txt
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library()

zephyr_library_sources(tmag5170.c)
zephyr_library_sources_ifdef(CONFIG_TMAG5170_TRIGGER tmag5170_trigger.c)
69 changes: 69 additions & 0 deletions drivers/sensor/tmag5170/Kconfig
@@ -0,0 +1,69 @@
# Texas Instruments TMAG5170 high-precision, linear 3D Hall-effect sensor with SPI bus interface

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

menuconfig TMAG5170
bool "TMAG5170 SPI Hall-effect sensor driver"
default y
depends on DT_HAS_TI_TMAG5170_ENABLED
select SPI
help
Enable driver for TMAG5170 Hall-effect sensor driver

if TMAG5170

choice TMAG5170_TRIGGER_MODE
prompt "Trigger mode"
help
Specify the type of triggering to be used by the driver.

config TMAG5170_TRIGGER_NONE
bool "No trigger"

config TMAG5170_TRIGGER_GLOBAL_THREAD
bool "Use global thread"
depends on GPIO
select TMAG5170_TRIGGER

config TMAG5170_TRIGGER_OWN_THREAD
bool "Use own thread"
depends on GPIO
select TMAG5170_TRIGGER

config TMAG5170_TRIGGER_DIRECT
bool "Process trigger within interrupt context"
depends on GPIO
select TMAG5170_TRIGGER

endchoice

config TMAG5170_CRC
bool "Use CRC error detection"
default y
select CRC
help
Verify CRC of RX data and append CRC to TX data

config TMAG5170_TRIGGER
bool

if TMAG5170_TRIGGER

config TMAG5170_THREAD_PRIORITY
int "Thread priority"
depends on TMAG5170_TRIGGER_OWN_THREAD
default 10
help
Priority of thread used by the driver to handle interrupts.

config TMAG5170_THREAD_STACK_SIZE
int "Thread stack size"
depends on TMAG5170_TRIGGER_OWN_THREAD
default 1024
help
Stack size of thread used by the driver to handle interrupts.

endif # TMAG5170_TRIGGER

endif # TMAG5170

0 comments on commit c580bec

Please sign in to comment.