From 71169638caf8fa96a2f7ab06b808e04d2d0d3869 Mon Sep 17 00:00:00 2001 From: Miquel-HAW Date: Thu, 21 Dec 2023 12:53:45 +0100 Subject: [PATCH] drivers/lsm6dsxx: Implement common code --- drivers/Makefile.dep | 4 + drivers/lsm6dsxx/Makefile.include | 4 + drivers/lsm6dsxx/include/lsm6dsxx_internal.h | 152 +++++++++++-------- drivers/lsm6dsxx/include/lsm6dsxx_params.h | 2 + drivers/lsm6dsxx/lsm6dsxx.c | 2 + drivers/lsm6dsxx/lsm6dsxx_saul.c | 2 + tests/drivers/lsm6dsxx/Makefile | 4 +- tests/drivers/lsm6dsxx/main.c | 4 +- 8 files changed, 111 insertions(+), 63 deletions(-) diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep index 57ada70bd3..31c98b08a0 100644 --- a/drivers/Makefile.dep +++ b/drivers/Makefile.dep @@ -96,6 +96,10 @@ ifneq (,$(filter lps331ap lps2%,$(USEMODULE))) USEMODULE += lpsxxx endif +ifneq (,$(filter lsm6ds%,$(USEMODULE))) + USEMODULE += lsm6dsxx +endif + ifneq (,$(filter ltc4150_%,$(USEMODULE))) USEMODULE += ltc4150 endif diff --git a/drivers/lsm6dsxx/Makefile.include b/drivers/lsm6dsxx/Makefile.include index 0c4e5594bf..b4677d2170 100644 --- a/drivers/lsm6dsxx/Makefile.include +++ b/drivers/lsm6dsxx/Makefile.include @@ -1,2 +1,6 @@ +#include variants of lsm6dsxx drivers as pseudo modules +PSEUDOMODULES += lsm6dsl +PSEUDOMODULES += lsm6ds33 + USEMODULE_INCLUDES_lsm6dsxx := $(LAST_MAKEFILEDIR)/include USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_lsm6dsxx) diff --git a/drivers/lsm6dsxx/include/lsm6dsxx_internal.h b/drivers/lsm6dsxx/include/lsm6dsxx_internal.h index cee024800a..d0e04d1798 100644 --- a/drivers/lsm6dsxx/include/lsm6dsxx_internal.h +++ b/drivers/lsm6dsxx/include/lsm6dsxx_internal.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2017 OTA keys S.A. + * Copyright (C) 2024 HAW Hamburg. * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -16,6 +17,7 @@ * * @author Vincent Dupont * @author Sebastian Meiling + * @author Miquel Borrell * */ @@ -30,47 +32,76 @@ extern "C" { * @name LSM6DSXX registers * @{ */ -#define LSM6DSXX_REG_FUNC_CFG_ACCESS (0x01) +#define LSM6DSXX_REG_FUNC_CFG_ACCESS (0x01) +#define LSM6DSXX_REG_FIFO_CTRL1 (0x06) +#define LSM6DSXX_REG_FIFO_CTRL2 (0x07) +#define LSM6DSXX_REG_FIFO_CTRL3 (0x08) +#define LSM6DSXX_REG_FIFO_CTRL4 (0x09) +#define LSM6DSXX_REG_FIFO_CTRL5 (0x0A) +#define LSM6DSXX_REG_INT1_CTRL (0x0D) +#define LSM6DSXX_REG_INT2_CTRL (0x0E) +#define LSM6DSXX_REG_WHO_AM_I (0x0F) +#define LSM6DSXX_REG_CTRL1_XL (0x10) +#define LSM6DSXX_REG_CTRL2_G (0x11) +#define LSM6DSXX_REG_CTRL3_C (0x12) +#define LSM6DSXX_REG_CTRL4_C (0x13) +#define LSM6DSXX_REG_CTRL5_C (0x14) +#define LSM6DSXX_REG_CTRL6_C (0x15) +#define LSM6DSXX_REG_CTRL7_G (0x16) +#define LSM6DSXX_REG_CTRL8_XL (0x17) +#define LSM6DSXX_REG_CTRL9_XL (0x18) +#define LSM6DSXX_REG_CTRL10_C (0x19) +#define LSM6DSXX_REG_WAKE_UP_SRC (0x1B) +#define LSM6DSXX_REG_TAP_SRC (0x1C) +#define LSM6DSXX_REG_D6D_SRC (0x1D) +#define LSM6DSXX_REG_STATUS_REG (0x1E) +#define LSM6DSXX_REG_OUT_TEMP_L (0x20) +#define LSM6DSXX_REG_OUT_TEMP_H (0x21) +#define LSM6DSXX_REG_OUTX_L_G (0x22) +#define LSM6DSXX_REG_OUTX_H_G (0x23) +#define LSM6DSXX_REG_OUTY_L_G (0x24) +#define LSM6DSXX_REG_OUTY_H_G (0x25) +#define LSM6DSXX_REG_OUTZ_L_G (0x26) +#define LSM6DSXX_REG_OUTZ_H_G (0x27) +#define LSM6DSXX_REG_OUTX_L_XL (0x28) +#define LSM6DSXX_REG_OUTX_H_XL (0x29) +#define LSM6DSXX_REG_OUTY_L_XL (0x2A) +#define LSM6DSXX_REG_OUTY_H_XL (0x2B) +#define LSM6DSXX_REG_OUTZ_L_XL (0x2C) +#define LSM6DSXX_REG_OUTZ_H_XL (0x2D) +#define LSM6DSXX_REG_FIFO_STATUS1 (0x3A) +#define LSM6DSXX_REG_FIFO_STATUS2 (0x3B) +#define LSM6DSXX_REG_FIFO_STATUS3 (0x3C) +#define LSM6DSXX_REG_FIFO_STATUS4 (0x3D) +#define LSM6DSXX_REG_FIFO_DATA_OUT_L (0x3E) +#define LSM6DSXX_REG_FIFO_DATA_OUT_H (0x3F) +#define LSM6DSXX_REG_TIMESTAMP0_REG (0x40) +#define LSM6DSXX_REG_TIMESTAMP1_REG (0x41) +#define LSM6DSXX_REG_TIMESTAMP2_REG (0x42) +#define LSM6DSXX_REG_STEP_TIMESTAMP_L (0x49) +#define LSM6DSXX_REG_STEP_TIMESTAMP_H (0x4A) +#define LSM6DSXX_REG_STEP_COUNTER_L (0x4B) +#define LSM6DSXX_REG_STEP_COUNTER_H (0x4C) +#define LSM6DSXX_REG_FUNC_SR_1 (0x53) +#define LSM6DSXX_REG_TAP_CFG (0x58) +#define LSM6DSXX_REG_TAP_THS_6D (0x59) +#define LSM6DSXX_REG_INT_DUR2 (0x5A) +#define LSM6DSXX_REG_WAKE_UP_THS (0x5B) +#define LSM6DSXX_REG_WAKE_UP_DUR (0x5C) +#define LSM6DSXX_REG_FREE_FALL (0x5D) +#define LSM6DSXX_REG_MD1_CFG (0x5E) +#define LSM6DSXX_REG_MD2_CFG (0x5F) +/** @} */ + +#if MODULE_LSM6DSL +/** + * @name LSM6DSL specific registers not used in implemnetation + * @{ + */ #define LSM6DSXX_REG_SENSOR_SYNC_TIME_FRAME (0x04) #define LSM6DSXX_REG_SENSOR_SYC_RES_RATIO (0x05) -#define LSM6DSXX_REG_FIFO_CTRL1 (0x06) -#define LSM6DSXX_REG_FIFO_CTRL2 (0x07) -#define LSM6DSXX_REG_FIFO_CTRL3 (0x08) -#define LSM6DSXX_REG_FIFO_CTRL4 (0x09) -#define LSM6DSXX_REG_FIFO_CTRL5 (0x0A) #define LSM6DSXX_REG_DRDY_PULSE_CFG_G (0x0B) -#define LSM6DSXX_REG_INT1_CTRL (0x0D) -#define LSM6DSXX_REG_INT2_CTRL (0x0E) -#define LSM6DSXX_REG_WHO_AM_I (0x0F) -#define LSM6DSXX_REG_CTRL1_XL (0x10) -#define LSM6DSXX_REG_CTRL2_G (0x11) -#define LSM6DSXX_REG_CTRL3_C (0x12) -#define LSM6DSXX_REG_CTRL4_C (0x13) -#define LSM6DSXX_REG_CTRL5_C (0x14) -#define LSM6DSXX_REG_CTRL6_C (0x15) -#define LSM6DSXX_REG_CTRL7_G (0x16) -#define LSM6DSXX_REG_CTRL8_XL (0x17) -#define LSM6DSXX_REG_CTRL9_XL (0x18) -#define LSM6DSXX_REG_CTRL10_C (0x19) #define LSM6DSXX_REG_MASTER_CONFIG (0x1A) -#define LSM6DSXX_REG_WAKE_UP_SRC (0x1B) -#define LSM6DSXX_REG_TAP_SRC (0x1C) -#define LSM6DSXX_REG_D6D_SRC (0x1D) -#define LSM6DSXX_REG_STATUS_REG (0x1E) -#define LSM6DSXX_REG_OUT_TEMP_L (0x20) -#define LSM6DSXX_REG_OUT_TEMP_H (0x21) -#define LSM6DSXX_REG_OUTX_L_G (0x22) -#define LSM6DSXX_REG_OUTX_H_G (0x23) -#define LSM6DSXX_REG_OUTY_L_G (0x24) -#define LSM6DSXX_REG_OUTY_H_G (0x25) -#define LSM6DSXX_REG_OUTZ_L_G (0x26) -#define LSM6DSXX_REG_OUTZ_H_G (0x27) -#define LSM6DSXX_REG_OUTX_L_XL (0x28) -#define LSM6DSXX_REG_OUTX_H_XL (0x29) -#define LSM6DSXX_REG_OUTY_L_XL (0x2A) -#define LSM6DSXX_REG_OUTY_H_XL (0x2B) -#define LSM6DSXX_REG_OUTZ_L_XL (0x2C) -#define LSM6DSXX_REG_OUTZ_H_XL (0x2D) #define LSM6DSXX_REG_SENSORHUB1_REG (0x2E) #define LSM6DSXX_REG_SENSORHUB2_REG (0x2F) #define LSM6DSXX_REG_SENSORHUB3_REG (0x30) @@ -83,36 +114,14 @@ extern "C" { #define LSM6DSXX_REG_SENSORHUB10_REG (0x37) #define LSM6DSXX_REG_SENSORHUB11_REG (0x38) #define LSM6DSXX_REG_SENSORHUB12_REG (0x39) -#define LSM6DSXX_REG_FIFO_STATUS1 (0x3A) -#define LSM6DSXX_REG_FIFO_STATUS2 (0x3B) -#define LSM6DSXX_REG_FIFO_STATUS3 (0x3C) -#define LSM6DSXX_REG_FIFO_STATUS4 (0x3D) -#define LSM6DSXX_REG_FIFO_DATA_OUT_L (0x3E) -#define LSM6DSXX_REG_FIFO_DATA_OUT_H (0x3F) -#define LSM6DSXX_REG_TIMESTAMP0_REG (0x40) -#define LSM6DSXX_REG_TIMESTAMP1_REG (0x41) -#define LSM6DSXX_REG_TIMESTAMP2_REG (0x42) -#define LSM6DSXX_REG_STEP_TIMESTAMP_L (0x49) -#define LSM6DSXX_REG_STEP_TIMESTAMP_H (0x4A) -#define LSM6DSXX_REG_STEP_COUNTER_L (0x4B) -#define LSM6DSXX_REG_STEP_COUNTER_H (0x4C) #define LSM6DSXX_REG_SENSORHUB13_REG (0x4D) #define LSM6DSXX_REG_SENSORHUB14_REG (0x4E) #define LSM6DSXX_REG_SENSORHUB15_REG (0x4F) #define LSM6DSXX_REG_SENSORHUB16_REG (0x50) #define LSM6DSXX_REG_SENSORHUB17_REG (0x51) #define LSM6DSXX_REG_SENSORHUB18_REG (0x52) -#define LSM6DSXX_REG_FUNC_SRC_1 (0x53) #define LSM6DSXX_REG_FUNC_SRC_2 (0x54) #define LSM6DSXX_REG_WRIST_TILT_IA (0x55) -#define LSM6DSXX_REG_TAP_CFG (0x58) -#define LSM6DSXX_REG_TAP_THS_6D (0x59) -#define LSM6DSXX_REG_INT_DUR2 (0x5A) -#define LSM6DSXX_REG_WAKE_UP_THS (0x5B) -#define LSM6DSXX_REG_WAKE_UP_DUR (0x5C) -#define LSM6DSXX_REG_FREE_FALL (0x5D) -#define LSM6DSXX_REG_MD1_CFG (0x5E) -#define LSM6DSXX_REG_MD2_CFG (0x5F) #define LSM6DSXX_REG_MASTER_CMD_CODE (0x60) #define LSM6DSXX_REG_SENS_SYNC_SPI_ERR_CODE (0x61) #define LSM6DSXX_REG_OUT_MAG_RAW_X_L (0x66) @@ -126,8 +135,29 @@ extern "C" { #define LSM6DSXX_REG_Z_OFS_USR (0x75) /** @} */ -/** WHO_AM_I value */ -#define LSM6DSXX_WHO_AM_I (0b01101010) +/** + * @brief WHO_AM_I value + */ +#define LSM6DSXX_WHO_AM_I (0b01101010) /*b-l475e-iot01a board=0b01101010*/ + + + +#elif MODULE_LSM6DS33 +/** + * @name LSM6DS33 specific registers not used in implementation + * @{ + */ + +#define LSM6DSXX_REG_ORIENT_CFG_G (0x0B) + +/** @} */ + +/** + * @brief WHO_AM_I value + */ +#define LSM6DSXX_WHO_AM_I (0b01101001 ) /* In feather board value=0b01101001 */ + +#endif /** * @name CTRL_x registers diff --git a/drivers/lsm6dsxx/include/lsm6dsxx_params.h b/drivers/lsm6dsxx/include/lsm6dsxx_params.h index 894f72b6b7..ffb7825cdb 100644 --- a/drivers/lsm6dsxx/include/lsm6dsxx_params.h +++ b/drivers/lsm6dsxx/include/lsm6dsxx_params.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2017 OTA keys S.A. + * Copyright (C) 2024 HAW Hamburg. * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -15,6 +16,7 @@ * @brief Default configuration for LSM6DSXX devices * * @author Vincent Dupont + * @author Miquel Borrell * */ diff --git a/drivers/lsm6dsxx/lsm6dsxx.c b/drivers/lsm6dsxx/lsm6dsxx.c index b06843cc52..f96c0d7c96 100644 --- a/drivers/lsm6dsxx/lsm6dsxx.c +++ b/drivers/lsm6dsxx/lsm6dsxx.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2017 OTA keys S.A. + * Copyright (C) 2024 HAW Hamburg. * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -16,6 +17,7 @@ * * @author Vincent Dupont * @author Sebastian Meiling + * @author Miquel Borrell * * @} */ diff --git a/drivers/lsm6dsxx/lsm6dsxx_saul.c b/drivers/lsm6dsxx/lsm6dsxx_saul.c index 03ebf1af3c..74a6f66165 100644 --- a/drivers/lsm6dsxx/lsm6dsxx_saul.c +++ b/drivers/lsm6dsxx/lsm6dsxx_saul.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2017 OTA keys S.A. + * Copyright (C) 2024 HAW Hamburg. * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -16,6 +17,7 @@ * * @author Vincent Dupont * @author Sebastian Meiling + * @author Miquel Borrell * * @} */ diff --git a/tests/drivers/lsm6dsxx/Makefile b/tests/drivers/lsm6dsxx/Makefile index 4372e94131..71a02c98fc 100644 --- a/tests/drivers/lsm6dsxx/Makefile +++ b/tests/drivers/lsm6dsxx/Makefile @@ -1,6 +1,8 @@ include ../Makefile.drivers_common -USEMODULE += lsm6dsxx +DRIVER ?= lsm6ds33 + +USEMODULE += $(DRIVER) USEMODULE += ztimer USEMODULE += ztimer_msec diff --git a/tests/drivers/lsm6dsxx/main.c b/tests/drivers/lsm6dsxx/main.c index bd10cdef25..c6bb124e9f 100644 --- a/tests/drivers/lsm6dsxx/main.c +++ b/tests/drivers/lsm6dsxx/main.c @@ -1,10 +1,11 @@ /* * Copyright (C) 2017 OTA keys S.A. - * 2017 HAW Hamburg + * Copyright (C) 2024 HAW Hamburg. * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. + * */ /** @@ -16,6 +17,7 @@ * * @author Vincent Dupont * @author Sebastian Meiling + * @author Miquel Borrell * * @} */