mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #20504 from MrKevinWeiss/pr/feather-nrf52840-sense/generic
driver/lsm6dsxx: Allow generic LSM6DSXX driver
This commit is contained in:
commit
42b68a5a43
36
dist/tools/doccheck/exclude_simple
vendored
36
dist/tools/doccheck/exclude_simple
vendored
@ -8424,3 +8424,39 @@ warning: Member LSM6DSXX_PARAM_GYRO_FIFO_DEC (macro definition) of file lsm6dsxx
|
||||
warning: Member LSM6DSXX_PARAMS (macro definition) of file lsm6dsxx_params.h is not documented.
|
||||
warning: Member LSM6DSXX_SAUL_INFO (macro definition) of file lsm6dsxx_params.h is not documented.
|
||||
RIOTDoxygenLayout.xml:8: warning: the type 'topics' is not supported for the entry tag within a navindex! Check your layout file!
|
||||
warning: Member LSM6DSL_REG_SENSOR_SYNC_TIME_FRAME (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSOR_SYC_RES_RATIO (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_DRDY_PULSE_CFG_G (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_MASTER_CONFIG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB1_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB2_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB3_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB4_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB5_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB6_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB7_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB8_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB9_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB10_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB11_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB12_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB13_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB14_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB15_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB16_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB17_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENSORHUB18_REG (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_FUNC_SRC_2 (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_WRIST_TILT_IA (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_MASTER_CMD_CODE (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_SENS_SYNC_SPI_ERR_CODE (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_OUT_MAG_RAW_X_L (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_OUT_MAG_RAW_X_H (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_OUT_MAG_RAW_Y_L (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_OUT_MAG_RAW_Y_H (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_OUT_MAG_RAW_Z_L (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_OUT_MAG_RAW_Z_H (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_X_OFS_USR (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_Y_OFS_USR (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DSL_REG_Z_OFS_USR (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
warning: Member LSM6DS33_REG_ORIENT_CFG_G (macro definition) of file lsm6dsxx_internal.h is not documented.
|
||||
|
@ -106,6 +106,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
lsm6dsxx_params_t params; /**< driver parameters */
|
||||
uint8_t temperature_scaling_factor; /**< temperature scaling factor */
|
||||
} lsm6dsxx_t;
|
||||
|
||||
/**
|
||||
|
@ -93,70 +93,64 @@ extern "C" {
|
||||
#define LSM6DSXX_REG_MD2_CFG (0x5F)
|
||||
/** @} */
|
||||
|
||||
#if MODULE_LSM6DSL
|
||||
/**
|
||||
* @name LSM6DSL specific registers not used in implemnetation
|
||||
* @name LSM6DSL and LSM6DS3TR-C specific registers
|
||||
* @{
|
||||
*/
|
||||
#define LSM6DSXX_REG_SENSOR_SYNC_TIME_FRAME (0x04)
|
||||
#define LSM6DSXX_REG_SENSOR_SYC_RES_RATIO (0x05)
|
||||
#define LSM6DSXX_REG_DRDY_PULSE_CFG_G (0x0B)
|
||||
#define LSM6DSXX_REG_MASTER_CONFIG (0x1A)
|
||||
#define LSM6DSXX_REG_SENSORHUB1_REG (0x2E)
|
||||
#define LSM6DSXX_REG_SENSORHUB2_REG (0x2F)
|
||||
#define LSM6DSXX_REG_SENSORHUB3_REG (0x30)
|
||||
#define LSM6DSXX_REG_SENSORHUB4_REG (0x31)
|
||||
#define LSM6DSXX_REG_SENSORHUB5_REG (0x32)
|
||||
#define LSM6DSXX_REG_SENSORHUB6_REG (0x33)
|
||||
#define LSM6DSXX_REG_SENSORHUB7_REG (0x34)
|
||||
#define LSM6DSXX_REG_SENSORHUB8_REG (0x35)
|
||||
#define LSM6DSXX_REG_SENSORHUB9_REG (0x36)
|
||||
#define LSM6DSXX_REG_SENSORHUB10_REG (0x37)
|
||||
#define LSM6DSXX_REG_SENSORHUB11_REG (0x38)
|
||||
#define LSM6DSXX_REG_SENSORHUB12_REG (0x39)
|
||||
#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_2 (0x54)
|
||||
#define LSM6DSXX_REG_WRIST_TILT_IA (0x55)
|
||||
#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)
|
||||
#define LSM6DSXX_REG_OUT_MAG_RAW_X_H (0x67)
|
||||
#define LSM6DSXX_REG_OUT_MAG_RAW_Y_L (0x68)
|
||||
#define LSM6DSXX_REG_OUT_MAG_RAW_Y_H (0x69)
|
||||
#define LSM6DSXX_REG_OUT_MAG_RAW_Z_L (0x6A)
|
||||
#define LSM6DSXX_REG_OUT_MAG_RAW_Z_H (0x6B)
|
||||
#define LSM6DSXX_REG_X_OFS_USR (0x73)
|
||||
#define LSM6DSXX_REG_Y_OFS_USR (0x74)
|
||||
#define LSM6DSXX_REG_Z_OFS_USR (0x75)
|
||||
#define LSM6DSL_REG_SENSOR_SYNC_TIME_FRAME (0x04)
|
||||
#define LSM6DSL_REG_SENSOR_SYC_RES_RATIO (0x05)
|
||||
#define LSM6DSL_REG_DRDY_PULSE_CFG_G (0x0B)
|
||||
#define LSM6DSL_REG_MASTER_CONFIG (0x1A)
|
||||
#define LSM6DSL_REG_SENSORHUB1_REG (0x2E)
|
||||
#define LSM6DSL_REG_SENSORHUB2_REG (0x2F)
|
||||
#define LSM6DSL_REG_SENSORHUB3_REG (0x30)
|
||||
#define LSM6DSL_REG_SENSORHUB4_REG (0x31)
|
||||
#define LSM6DSL_REG_SENSORHUB5_REG (0x32)
|
||||
#define LSM6DSL_REG_SENSORHUB6_REG (0x33)
|
||||
#define LSM6DSL_REG_SENSORHUB7_REG (0x34)
|
||||
#define LSM6DSL_REG_SENSORHUB8_REG (0x35)
|
||||
#define LSM6DSL_REG_SENSORHUB9_REG (0x36)
|
||||
#define LSM6DSL_REG_SENSORHUB10_REG (0x37)
|
||||
#define LSM6DSL_REG_SENSORHUB11_REG (0x38)
|
||||
#define LSM6DSL_REG_SENSORHUB12_REG (0x39)
|
||||
#define LSM6DSL_REG_SENSORHUB13_REG (0x4D)
|
||||
#define LSM6DSL_REG_SENSORHUB14_REG (0x4E)
|
||||
#define LSM6DSL_REG_SENSORHUB15_REG (0x4F)
|
||||
#define LSM6DSL_REG_SENSORHUB16_REG (0x50)
|
||||
#define LSM6DSL_REG_SENSORHUB17_REG (0x51)
|
||||
#define LSM6DSL_REG_SENSORHUB18_REG (0x52)
|
||||
#define LSM6DSL_REG_FUNC_SRC_2 (0x54)
|
||||
#define LSM6DSL_REG_WRIST_TILT_IA (0x55)
|
||||
#define LSM6DSL_REG_MASTER_CMD_CODE (0x60)
|
||||
#define LSM6DSL_REG_SENS_SYNC_SPI_ERR_CODE (0x61)
|
||||
#define LSM6DSL_REG_OUT_MAG_RAW_X_L (0x66)
|
||||
#define LSM6DSL_REG_OUT_MAG_RAW_X_H (0x67)
|
||||
#define LSM6DSL_REG_OUT_MAG_RAW_Y_L (0x68)
|
||||
#define LSM6DSL_REG_OUT_MAG_RAW_Y_H (0x69)
|
||||
#define LSM6DSL_REG_OUT_MAG_RAW_Z_L (0x6A)
|
||||
#define LSM6DSL_REG_OUT_MAG_RAW_Z_H (0x6B)
|
||||
#define LSM6DSL_REG_X_OFS_USR (0x73)
|
||||
#define LSM6DSL_REG_Y_OFS_USR (0x74)
|
||||
#define LSM6DSL_REG_Z_OFS_USR (0x75)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief WHO_AM_I value for the LSM6DSL
|
||||
*/
|
||||
#define LSM6DSXX_WHO_AM_I (0b01101010)
|
||||
|
||||
|
||||
|
||||
#elif MODULE_LSM6DS33
|
||||
/**
|
||||
* @name LSM6DS33 specific registers not used in implementation
|
||||
* @name LSM6DS33 specific registers
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LSM6DSXX_REG_ORIENT_CFG_G (0x0B)
|
||||
#define LSM6DS33_REG_ORIENT_CFG_G (0x0B)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief WHO_AM_I value for the LSM6DS33
|
||||
*/
|
||||
#define LSM6DSXX_WHO_AM_I (0b01101001)
|
||||
#define LSM6DS33_WHO_AM_I (0b01101001)
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @brief WHO_AM_I value for the LSM6DSL and LSM6DS3TR-C
|
||||
*/
|
||||
#define LSM6DSL_WHO_AM_I (0b01101010)
|
||||
|
||||
/**
|
||||
* @name CTRL_x registers
|
||||
@ -183,7 +177,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief Offset for temperature calculation
|
||||
*/
|
||||
#define LSM6DSXX_TEMP_OFFSET (0x1900)
|
||||
#define LSM6DSXX_TEMP_OFFSET (25)
|
||||
|
||||
/**
|
||||
* @brief Reboot wait interval in ms (15ms)
|
||||
|
@ -71,7 +71,13 @@ int lsm6dsxx_init(lsm6dsxx_t *dev, const lsm6dsxx_params_t *params)
|
||||
return -LSM6DSXX_ERROR_BUS;
|
||||
}
|
||||
|
||||
if (tmp != LSM6DSXX_WHO_AM_I) {
|
||||
if (tmp == LSM6DS33_WHO_AM_I) {
|
||||
dev->temperature_scaling_factor = 4;
|
||||
}
|
||||
else if (tmp == LSM6DSL_WHO_AM_I) {
|
||||
dev->temperature_scaling_factor = 8;
|
||||
}
|
||||
else {
|
||||
DEBUG("[ERROR] lsm6dsxx_init: WHO_AM_I\n");
|
||||
return -LSM6DSXX_ERROR_DEV;
|
||||
}
|
||||
@ -192,8 +198,8 @@ int lsm6dsxx_read_temp(const lsm6dsxx_t *dev, int16_t *data)
|
||||
traw |= (uint16_t)tmp << 8;
|
||||
i2c_release(BUS);
|
||||
/* convert temperature to degC x 100 */
|
||||
traw += LSM6DSXX_TEMP_OFFSET;
|
||||
*data = (int16_t)(((int32_t)traw * 100) / 256);
|
||||
traw += LSM6DSXX_TEMP_OFFSET << dev->temperature_scaling_factor;
|
||||
*data = (int16_t)(((int32_t)traw * 100) >> dev->temperature_scaling_factor);
|
||||
|
||||
return LSM6DSXX_OK;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ preflash-delay: preflash
|
||||
sleep $(PREFLASH_DELAY)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter test term,$(MAKECMDGOALS)))
|
||||
ifneq (,$(filter test term test-with-config,$(MAKECMDGOALS)))
|
||||
term-delay: $(TERMDELAYDEPS)
|
||||
sleep $(TERM_DELAY)
|
||||
endif
|
||||
|
@ -1,6 +1,9 @@
|
||||
BOARD ?= feather-nrf52840-sense
|
||||
include ../Makefile.drivers_common
|
||||
|
||||
DRIVER ?= lsm6ds33
|
||||
DISABLE_MODULE += test_utils_interactive_sync
|
||||
|
||||
DRIVER ?= lsm6dsxx
|
||||
|
||||
USEMODULE += $(DRIVER)
|
||||
USEMODULE += ztimer
|
||||
|
20
tests/drivers/lsm6dsxx/tests-with-config/01-run.py
Executable file
20
tests/drivers/lsm6dsxx/tests-with-config/01-run.py
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
from testrunner import run
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect("Accelerometer x:")
|
||||
child.expect("Gyroscope x:")
|
||||
child.expect(r"Temperature \[in")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run(testfunc))
|
Loading…
Reference in New Issue
Block a user