Skip to content

Commit

Permalink
drivers: sensor: icm42670: supports icm42670-P and icm42670-S
Browse files Browse the repository at this point in the history
samples: sensor: icm42670: adds sample to support enhanced features

Adds official TDK Invensense Inc. driver for icm42670-P and icm42670-S 6-axis sensor. Also adds SPI and I2C interface support. Adds APEX features, such as Pedometer, Tilt detection, Wake on Motion and Significant Motion Detector. Adds AML support for icm42670-S to demonstrate pointing, gestures recognition, quaternion computing features with AML library built for CM4 target.
Add samples for this driver.
Validated with custom setup based on nrf52dk_nrf52832 + icm42670-p/icm42670-s EVB board
Build ok by running: west -T samples\sensor\icm42670\data_stream -p nrf52dk/nrf52832
Build ok by running: west -T samples\sensor\icm42670\apex -p nrf52dk/nrf52832
Build ok by running: west -T samples\sensor\icm42670\aml_pointing -p nrf52dk/nrf52832

Signed-off-by: Aurelie Fontaine <aurelie.fontaine@tdk.com>icm42670
  • Loading branch information
Aurelie Fontaine committed Apr 11, 2024
1 parent 9b17a95 commit e45513b
Show file tree
Hide file tree
Showing 58 changed files with 11,051 additions and 1,133 deletions.
12 changes: 12 additions & 0 deletions drivers/sensor/tdk/icm42670/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ zephyr_library()
zephyr_library_sources(
icm42670.c
icm42670_spi.c
icm42670_i2c.c
)
zephyr_library_include_directories(.)
zephyr_library_sources(imu/inv_imu_driver.c imu/inv_imu_transport.c)

zephyr_library_sources_ifdef(CONFIG_ICM42670_TRIGGER icm42670_trigger.c)

zephyr_library_sources_ifdef(CONFIG_ICM42670_APEX icm42670_apex.c)
zephyr_library_sources_ifdef(CONFIG_ICM42670_APEX imu/inv_imu_apex.c)

zephyr_library_sources_ifdef(CONFIG_ICM42670S_AML icm42670S_aml.c)
if(CONFIG_ICM42670S_AML)
zephyr_library_include_directories(./invn.algo.sw-integration.aml-42670S-gcc-arm-none-eabi-cm4-fpu-1.6.0/include)
zephyr_library_import(InvnAlgoAML_42670S ${CMAKE_CURRENT_SOURCE_DIR}/invn.algo.sw-integration.aml-42670S-gcc-arm-none-eabi-cm4-fpu-1.6.0/release/lib/libInvnAlgoAML_42670S.a)
endif()
54 changes: 54 additions & 0 deletions drivers/sensor/tdk/icm42670/Invn/InvError.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
*
* Copyright (c) [2015] by InvenSense, Inc.
*

Check failure on line 7 in drivers/sensor/tdk/icm42670/Invn/InvError.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

drivers/sensor/tdk/icm42670/Invn/InvError.h:7 trailing whitespace
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*

Check failure on line 10 in drivers/sensor/tdk/icm42670/Invn/InvError.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

drivers/sensor/tdk/icm42670/Invn/InvError.h:10 trailing whitespace
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/

/** @defgroup InvError Error code
* @brief Common error code
*
* @ingroup EmbUtils
* @{
*/

#ifndef _INV_ERROR_H_
#define _INV_ERROR_H_

/** @brief Common error code definition
*/
enum inv_error {
INV_ERROR_SUCCESS = 0, /**< no error */
INV_ERROR = -1, /**< unspecified error */
INV_ERROR_NIMPL = -2, /**< function not implemented for given arguments */
INV_ERROR_TRANSPORT = -3, /**< error occurred at transport level */
INV_ERROR_TIMEOUT = -4, /**< action did not complete in the expected time window */
INV_ERROR_SIZE = -5, /**< argument's size is not suitable to complete requested action */

Check warning on line 39 in drivers/sensor/tdk/icm42670/Invn/InvError.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_COMMENT

drivers/sensor/tdk/icm42670/Invn/InvError.h:39 line length of 103 exceeds 100 columns
INV_ERROR_OS = -6, /**< error related to OS */
INV_ERROR_IO = -7, /**< error related to IO operation */
INV_ERROR_MEM = -9, /**< not enough memory to complete requested action */
INV_ERROR_HW = -10, /**< error at HW level */
INV_ERROR_BAD_ARG = -11, /**< provided arguments are not good to perform requested action */

Check warning on line 44 in drivers/sensor/tdk/icm42670/Invn/InvError.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_COMMENT

drivers/sensor/tdk/icm42670/Invn/InvError.h:44 line length of 103 exceeds 100 columns
INV_ERROR_UNEXPECTED = -12, /**< something unexpected happened */
INV_ERROR_FILE = -13, /**< cannot access file or unexpected format */
INV_ERROR_PATH = -14, /**< invalid file path */
INV_ERROR_IMAGE_TYPE = -15, /**< error when image type is not managed */
INV_ERROR_WATCHDOG = -16, /**< error when device doesn't respond to ping */
};

#endif /* _INV_ERROR_H_ */

/** @} */
50 changes: 44 additions & 6 deletions drivers/sensor/tdk/icm42670/Kconfig
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
# ICM42670 Six-Axis Motion Tracking device configuration options
# ICM42670-P ICM42670-S Six-Axis Motion Tracking device configuration options
#
# Copyright (c) 2023 TDK Invensense
# Copyright (c) 2022 Esco Medical ApS
# Copyright (c) 2020 TDK Invensense
#
# SPDX-License-Identifier: Apache-2.0

menuconfig ICM42670
bool "ICM42670 Six-Axis Motion Tracking Device"
bool "ICM42670 6-Axis Motion Tracking Device"
default y
depends on DT_HAS_INVENSENSE_ICM42670_ENABLED
select SPI
select I2C if $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670),i2c)
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_INVENSENSE_ICM42670),spi)
help
Enable driver for ICM42670 SPI-based six-axis motion tracking device.
Enable driver for ICM42670 I2C-based or SPI-based Six-Axis Motion Tracking device.

if ICM42670

config ICM42670_APEX
bool "ICM42670 APEX features"
default n

choice APEX_FEATURES
prompt "ICM42670 APEX features"
depends on ICM42670_APEX
default ICM42670_APEX_PEDOMETER
help
Select APEX feature for ICM42670 sensor.
config ICM42670_APEX_PEDOMETER
bool "Pedometer: Tracks step count"
config ICM42670_APEX_TILT
bool "Tilt Detection: Detect the Tilt angle exceeds 35 degrees"
config ICM42670_APEX_SMD
bool "Significant Motion Detector (SMD): Detects significant motion based on accelerometer data"
config ICM42670_APEX_WOM
bool "Wake on Motion (WoM): Detects motion when accelerometer samples exceed a programmable threshold"
endchoice

menuconfig ICM42670S_AML
bool "ICM42670 Air Motion Library (AML)"
default n

if ICM42670S_AML

config ICM42670S_AML_POINTING
bool "Delta values for pointing"
config ICM42670S_AML_GESTURES
bool "Orientation of the remote and detected swipes"
config ICM42670S_AML_GYR_OFFSET
bool "Computed 3-axis raw gyroscope offsets"
config ICM42670S_AML_QUATERNION
bool "Computed W, X, Y and Z quaternion coefficients"

endif # ICM42670S_AML

choice ICM42670_TRIGGER_MODE
prompt "Trigger mode"
default ICM42670_TRIGGER_NONE
default ICM42670_TRIGGER_OWN_THREAD
help
Specify the type of triggering to be used by the driver.

Expand Down
Loading

0 comments on commit e45513b

Please sign in to comment.