mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 10:32:47 +08:00
drivers/sensors and configs/nucleo-l476g: Add support for LSM303AGR and LSM6DSL sensors
This commit is contained in:
committed by
Gregory Nutt
parent
c9b24615a6
commit
cd2ced4d9a
@@ -1,4 +1,4 @@
|
||||
/****************************************************************************
|
||||
/************************************************************************************
|
||||
* include/nuttx/sensors/ioctl.h
|
||||
*
|
||||
* Copyright (C) 2016-2018 Gregory Nutt. All rights reserved.
|
||||
@@ -31,133 +31,147 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SENSORS_IOCTL_H
|
||||
#define __INCLUDE_NUTTX_SENSORS_IOCTL_H
|
||||
|
||||
/****************************************************************************
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
/****************************************************************************
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
************************************************************************************/
|
||||
|
||||
/* IOCTL commands unique to the BH1750FVI */
|
||||
|
||||
#define SNIOC_CHRM _SNIOC(0x0001) /* Contin. H-Res Mode Arg: None */
|
||||
#define SNIOC_CHRM2 _SNIOC(0x0002) /* Contin. H-Res Mode2 Arg: None */
|
||||
#define SNIOC_CLRM _SNIOC(0x0003) /* Contin. L-Res Mode Arg: None */
|
||||
#define SNIOC_OTHRM _SNIOC(0x0004) /* One Time H-Res Mode Arg: None */
|
||||
#define SNIOC_OTHRM2 _SNIOC(0x0005) /* One Time H-Res Mode2 Arg: None */
|
||||
#define SNIOC_OTLRM _SNIOC(0x0006) /* One Time L-Res Mode Arg: None */
|
||||
#define SNIOC_CHMEATIME _SNIOC(0x0007) /* Change Meas. Time Arg: uint8_t */
|
||||
#define SNIOC_CHRM _SNIOC(0x0001) /* Contin. H-Res Mode Arg: None */
|
||||
#define SNIOC_CHRM2 _SNIOC(0x0002) /* Contin. H-Res Mode2 Arg: None */
|
||||
#define SNIOC_CLRM _SNIOC(0x0003) /* Contin. L-Res Mode Arg: None */
|
||||
#define SNIOC_OTHRM _SNIOC(0x0004) /* One Time H-Res Mode Arg: None */
|
||||
#define SNIOC_OTHRM2 _SNIOC(0x0005) /* One Time H-Res Mode2 Arg: None */
|
||||
#define SNIOC_OTLRM _SNIOC(0x0006) /* One Time L-Res Mode Arg: None */
|
||||
#define SNIOC_CHMEATIME _SNIOC(0x0007) /* Change Meas. Time Arg: uint8_t */
|
||||
|
||||
/* IOCTL commands unique to the KXTJ9 */
|
||||
|
||||
#define SNIOC_ENABLE _SNIOC(0x0008) /* Arg: None */
|
||||
#define SNIOC_DISABLE _SNIOC(0x0009) /* Arg: None */
|
||||
#define SNIOC_CONFIGURE _SNIOC(0x000a) /* Arg: enum kxtj9_odr_e value */
|
||||
#define SNIOC_ENABLE _SNIOC(0x0008) /* Arg: None */
|
||||
#define SNIOC_DISABLE _SNIOC(0x0009) /* Arg: None */
|
||||
#define SNIOC_CONFIGURE _SNIOC(0x000a) /* Arg: enum kxtj9_odr_e value */
|
||||
|
||||
/* IOCTL commands common to the LM75, LM92 (and compatible parts) */
|
||||
|
||||
#define SNIOC_READCONF _SNIOC(0x000b) /* Arg: uint8_t* pointer */
|
||||
#define SNIOC_WRITECONF _SNIOC(0x000c) /* Arg: uint8_t value */
|
||||
#define SNIOC_SHUTDOWN _SNIOC(0x000d) /* Arg: None */
|
||||
#define SNIOC_POWERUP _SNIOC(0x000e) /* Arg: None */
|
||||
#define SNIOC_FAHRENHEIT _SNIOC(0x000f) /* Arg: None */
|
||||
#define SNIOC_CENTIGRADE _SNIOC(0x0010) /* Arg: None */
|
||||
#define SNIOC_READTHYS _SNIOC(0x0011) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETHYS _SNIOC(0x0012) /* Arg: b16_t value */
|
||||
#define SNIOC_READCONF _SNIOC(0x000b) /* Arg: uint8_t* pointer */
|
||||
#define SNIOC_WRITECONF _SNIOC(0x000c) /* Arg: uint8_t value */
|
||||
#define SNIOC_SHUTDOWN _SNIOC(0x000d) /* Arg: None */
|
||||
#define SNIOC_POWERUP _SNIOC(0x000e) /* Arg: None */
|
||||
#define SNIOC_FAHRENHEIT _SNIOC(0x000f) /* Arg: None */
|
||||
#define SNIOC_CENTIGRADE _SNIOC(0x0010) /* Arg: None */
|
||||
#define SNIOC_READTHYS _SNIOC(0x0011) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETHYS _SNIOC(0x0012) /* Arg: b16_t value */
|
||||
|
||||
/* IOCTL commands unique to the LM75 */
|
||||
|
||||
#define SNIOC_READTOS _SNIOC(0x0013) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETOS _SNIOC(0x0014) /* Arg: b16_t value */
|
||||
#define SNIOC_READTOS _SNIOC(0x0013) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETOS _SNIOC(0x0014) /* Arg: b16_t value */
|
||||
|
||||
/* IOCTL commands unique to the LM92 */
|
||||
|
||||
#define SNIOC_READTCRIT _SNIOC(0x0015) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETCRIT _SNIOC(0x0016) /* Arg: b16_t value */
|
||||
#define SNIOC_READTLOW _SNIOC(0x0017) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETLOW _SNIOC(0x0018) /* Arg: b16_t value */
|
||||
#define SNIOC_READTHIGH _SNIOC(0x0019) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETHIGH _SNIOC(0x001a) /* Arg: b16_t value */
|
||||
#define SNIOC_READID _SNIOC(0x001b) /* Arg: uint16_t* pointer */
|
||||
#define SNIOC_READTCRIT _SNIOC(0x0015) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETCRIT _SNIOC(0x0016) /* Arg: b16_t value */
|
||||
#define SNIOC_READTLOW _SNIOC(0x0017) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETLOW _SNIOC(0x0018) /* Arg: b16_t value */
|
||||
#define SNIOC_READTHIGH _SNIOC(0x0019) /* Arg: b16_t* pointer */
|
||||
#define SNIOC_WRITETHIGH _SNIOC(0x001a) /* Arg: b16_t value */
|
||||
#define SNIOC_READID _SNIOC(0x001b) /* Arg: uint16_t* pointer */
|
||||
|
||||
/* IOCTL commands unique to the LSM9DS1 */
|
||||
|
||||
#define SNIOC_START _SNIOC(0x001c) /* Arg: None */
|
||||
#define SNIOC_STOP _SNIOC(0x001d) /* Arg: None */
|
||||
#define SNIOC_SETSAMPLERATE _SNIOC(0x001e) /* Arg: uint32_t value */
|
||||
#define SNIOC_SETFULLSCALE _SNIOC(0x001f) /* Arg: uint32_t value */
|
||||
#define SNIOC_START _SNIOC(0x001c) /* Arg: None */
|
||||
#define SNIOC_STOP _SNIOC(0x001d) /* Arg: None */
|
||||
#define SNIOC_SETSAMPLERATE _SNIOC(0x001e) /* Arg: uint32_t value */
|
||||
#define SNIOC_SETFULLSCALE _SNIOC(0x001f) /* Arg: uint32_t value */
|
||||
|
||||
/* IOCTL commands unique to the MB7040 */
|
||||
|
||||
#define SNIOC_MEASURE _SNIOC(0x0020) /* Arg: None */
|
||||
#define SNIOC_RANGE _SNIOC(0x0021) /* Arg: int32_t* pointer */
|
||||
#define SNIOC_CHANGEADDR _SNIOC(0x0022) /* Arg: uint8_t value */
|
||||
#define SNIOC_MEASURE _SNIOC(0x0020) /* Arg: None */
|
||||
#define SNIOC_RANGE _SNIOC(0x0021) /* Arg: int32_t* pointer */
|
||||
#define SNIOC_CHANGEADDR _SNIOC(0x0022) /* Arg: uint8_t value */
|
||||
|
||||
/* IOCTL commands unique to the MCP9844 */
|
||||
|
||||
#define SNIOC_READTEMP _SNIOC(0x0023) /* Arg: mcp9844_temp_arg_s* pointer */
|
||||
#define SNIOC_SETRESOLUTION _SNIOC(0x0024) /* Arg: uint16_t value */
|
||||
#define SNIOC_READTEMP _SNIOC(0x0023) /* Arg: mcp9844_temp_arg_s* pointer */
|
||||
#define SNIOC_SETRESOLUTION _SNIOC(0x0024) /* Arg: uint16_t value */
|
||||
|
||||
/* IOCTL commands unique to the MS58XX */
|
||||
|
||||
#define SNIOC_MEASURE _SNIOC(0x0025) /* Arg: None */
|
||||
#define SNIOC_TEMPERATURE _SNIOC(0x0026) /* Arg: int32_t* pointer */
|
||||
#define SNIOC_PRESSURE _SNIOC(0x0027) /* Arg: int32_t* pointer */
|
||||
#define SNIOC_RESET _SNIOC(0x0028) /* Arg: None */
|
||||
#define SNIOC_OVERSAMPLING _SNIOC(0x0029) /* Arg: uint16_t value */
|
||||
#define SNIOC_MEASURE _SNIOC(0x0025) /* Arg: None */
|
||||
#define SNIOC_TEMPERATURE _SNIOC(0x0026) /* Arg: int32_t* pointer */
|
||||
#define SNIOC_PRESSURE _SNIOC(0x0027) /* Arg: int32_t* pointer */
|
||||
#define SNIOC_RESET _SNIOC(0x0028) /* Arg: None */
|
||||
#define SNIOC_OVERSAMPLING _SNIOC(0x0029) /* Arg: uint16_t value */
|
||||
|
||||
/* IOCTL commands to the HTS221 & LPS25H */
|
||||
|
||||
#define SNIOC_CFGR _SNIOC(0x002a)
|
||||
#define SNIOC_GET_DEV_ID _SNIOC(0x002b)
|
||||
#define SNIOC_CFGR _SNIOC(0x002a)
|
||||
#define SNIOC_GET_DEV_ID _SNIOC(0x002b)
|
||||
|
||||
/* IOCTL commands unique to the HTS221 */
|
||||
|
||||
#define SNIOC_START_CONVERSION _SNIOC(0x002c)
|
||||
#define SNIOC_CHECK_STATUS_REG _SNIOC(0x002d)
|
||||
#define SNIOC_READ_RAW_DATA _SNIOC(0x002e)
|
||||
#define SNIOC_READ_CONVERT_DATA _SNIOC(0x002f)
|
||||
#define SNIOC_DUMP_REGS _SNIOC(0x0030)
|
||||
#define SNIOC_START_CONVERSION _SNIOC(0x002c)
|
||||
#define SNIOC_CHECK_STATUS_REG _SNIOC(0x002d)
|
||||
#define SNIOC_READ_RAW_DATA _SNIOC(0x002e)
|
||||
#define SNIOC_READ_CONVERT_DATA _SNIOC(0x002f)
|
||||
#define SNIOC_DUMP_REGS _SNIOC(0x0030)
|
||||
|
||||
/* IOCTL commands unique to the LPS25H */
|
||||
|
||||
#define SNIOC_TEMPERATURE_OUT _SNIOC(0x0031)
|
||||
#define SNIOC_PRESSURE_OUT _SNIOC(0x0032)
|
||||
#define SNIOC_SENSOR_OFF _SNIOC(0x0033)
|
||||
#define SNIOC_TEMPERATURE_OUT _SNIOC(0x0031)
|
||||
#define SNIOC_PRESSURE_OUT _SNIOC(0x0032)
|
||||
#define SNIOC_SENSOR_OFF _SNIOC(0x0033)
|
||||
|
||||
/* IOCTL commands unique to the LIS2DH */
|
||||
|
||||
#define SNIOC_WRITESETUP _SNIOC(0x0034) /* Arg: uint8_t value */
|
||||
#define SNIOC_WRITE_INT1THRESHOLD _SNIOC(0x0035) /* Arg: uint8_t value */
|
||||
#define SNIOC_WRITE_INT2THRESHOLD _SNIOC(0x0036) /* Arg: uint8_t value */
|
||||
#define SNIOC_RESET_HPFILTER _SNIOC(0x0037) /* Arg: uint8_t value */
|
||||
#define SNIOC_START_SELFTEST _SNIOC(0x0038) /* Arg: uint8_t value */
|
||||
#define SNIOC_WHO_AM_I _SNIOC(0x0039)
|
||||
#define SNIOC_READ_TEMP _SNIOC(0x003a) /* Arg: int16_t value */
|
||||
#define SNIOC_WRITESETUP _SNIOC(0x0034) /* Arg: uint8_t value */
|
||||
#define SNIOC_WRITE_INT1THRESHOLD _SNIOC(0x0035) /* Arg: uint8_t value */
|
||||
#define SNIOC_WRITE_INT2THRESHOLD _SNIOC(0x0036) /* Arg: uint8_t value */
|
||||
#define SNIOC_RESET_HPFILTER _SNIOC(0x0037) /* Arg: uint8_t value */
|
||||
#define SNIOC_START_SELFTEST _SNIOC(0x0038) /* Arg: uint8_t value */
|
||||
#define SNIOC_WHO_AM_I _SNIOC(0x0039)
|
||||
#define SNIOC_READ_TEMP _SNIOC(0x003a) /* Arg: int16_t value */
|
||||
|
||||
/* IOCTL commands unique to the MAX44009 */
|
||||
|
||||
#define SNIOC_INIT _SNIOC(0x003b)
|
||||
#define SNIOC_THRESHOLD _SNIOC(0x003c)
|
||||
#define SNIOC_INIT _SNIOC(0x003b)
|
||||
#define SNIOC_THRESHOLD _SNIOC(0x003c)
|
||||
|
||||
/* IOCTL commands unique to LIS3DH */
|
||||
|
||||
#define SNIOC_SET_POWER_MODE _SNIOC(0x003d) /* Arg: LIS3DH_POWER_xxx */
|
||||
#define SNIOC_SET_DATA_RATE _SNIOC(0x003e) /* Arg: LIS3DH_ODR_xxx */
|
||||
#define SNIOC_SET_DATA_FORMAT _SNIOC(0x003f) /* Arg: LIS3DH_FORMAT_xxx */
|
||||
#define SNIOC_SET_POWER_MODE _SNIOC(0x003d) /* Arg: LIS3DH_POWER_xxx */
|
||||
#define SNIOC_SET_DATA_RATE _SNIOC(0x003e) /* Arg: LIS3DH_ODR_xxx */
|
||||
#define SNIOC_SET_DATA_FORMAT _SNIOC(0x003f) /* Arg: LIS3DH_FORMAT_xxx */
|
||||
|
||||
/* IOCTL commands unique to T67XX */
|
||||
|
||||
#define SNIOC_SPCALIB _SNIOC(0x0040) /* Arg: uint8_t value */
|
||||
#define SNIOC_ABCLOGIC _SNIOC(0x0041) /* Arg: uint8_t value */
|
||||
#define SNIOC_SPCALIB _SNIOC(0x0040) /* Arg: uint8_t value */
|
||||
#define SNIOC_ABCLOGIC _SNIOC(0x0041) /* Arg: uint8_t value */
|
||||
|
||||
/* IOCTL commands unique to the LSM6DSL */
|
||||
|
||||
#define SNIOC_START _SNIOC(0x0042) /* Arg: None */
|
||||
#define SNIOC_STOP _SNIOC(0x0043) /* Arg: None */
|
||||
#define SNIOC_LSM6DSLSENSORREAD _SNIOC(0x0046) /* Arg: file *filep, FAR char *buffer,size_t buflen */
|
||||
#define SNIOC_START_SELFTEST _SNIOC(0x0047) /* Arg: file *filep, FAR char *buffer,size_t mode */
|
||||
|
||||
/* IOCTL commands unique to the LSM303AGR */
|
||||
|
||||
#define SNIOC_START _SNIOC(0x0049) /* Arg: None */
|
||||
#define SNIOC_STOP _SNIOC(0x0050) /* Arg: None */
|
||||
#define SNIOC_LSM303AGRSENSORREAD _SNIOC(0x0051) /* Arg: file *filep, FAR char *buffer,size_t buflen */
|
||||
#define SNIOC_START_SELFTEST _SNIOC(0x0052) /* Arg: file *filep, FAR char *buffer,size_t mode */
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_SENSORS_IOCTL_H */
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/sensors/lsm303agr.h [from the IKS01A2 MEMS board STM]
|
||||
*
|
||||
* Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
|
||||
* Author: Paul Alexander Patience <paul-a.patience@polymtl.ca>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SENSORS_LSM303AGR
|
||||
#define __INCLUDE_NUTTX_SENSORS_LSM303AGR
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/sensors/ioctl.h>
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_LSM303AGR)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Addresses ************************************************************/
|
||||
|
||||
/* https://github.com/RIOT-OS/RIOT/issues/7133 */
|
||||
|
||||
/* Accelerometer addresses */
|
||||
|
||||
#define LSM303AGRACCELERO_ADDR (0x32>>1)
|
||||
|
||||
/* Magnetometer addresses */
|
||||
|
||||
#define LSM303AGRMAGNETO_ADDR (0x3C>>1) /* 7-bit */
|
||||
|
||||
/* Register Addresses *******************************************************/
|
||||
|
||||
/* Accelerometer and magnetometer registers */
|
||||
|
||||
#define LSM303AGR_STATUS_REG_AUX_A 0x07
|
||||
#define LSM303AGR_OUT_TEMP_L_A 0x0C
|
||||
#define LSM303AGR_OUT_TEMP_H_A 0x0D
|
||||
#define LSM303AGR_INT_COUNTER_REG_A 0x0E
|
||||
#define LSM303AGR_WHO_AM_I 0x0F
|
||||
#define LSM303AGR_WHO_AM_I_VALUE 0x00
|
||||
#define LSM303AGR_TEMP_CFG_REG_A 0x1F
|
||||
#define LSM303AGR_CTRL_REG1_A 0x20
|
||||
#define LSM303AGR_CTRL_REG2_A 0x21
|
||||
#define LSM303AGR_CTRL_REG3_A 0x22
|
||||
#define LSM303AGR_CTRL_REG4_A 0x23
|
||||
#define LSM303AGR_CTRL_REG5_A 0x24
|
||||
#define LSM303AGR_CTRL_REG6_A 0x25
|
||||
#define LSM303AGR_REF_DATA_CAP_A 0x26
|
||||
#define LSM303AGR_STATUS_REG_A 0x27
|
||||
|
||||
#define LSM303AGR_STATUS_REG_A_SHIFT 0
|
||||
#define LSM303AGR_STATUS_REG_A_MASK (0 << LSM303AGR_STATUS_REG_A_SHIFT)
|
||||
#define LSM303AGR_STATUS_REG_A_ZYXDA (1 << 3)
|
||||
#define LSM303AGR_STATUS_REG_A_ZYXOR (1 << 7)
|
||||
|
||||
#define LSM303AGR_OUT_X_L_A 0x28
|
||||
#define LSM303AGR_OUT_X_H_A 0x29
|
||||
#define LSM303AGR_OUT_Y_L_A 0x2A
|
||||
#define LSM303AGR_OUT_Y_H_A 0x2B
|
||||
#define LSM303AGR_OUT_Z_L_A 0x2C
|
||||
#define LSM303AGR_OUT_Z_H_A 0x2D
|
||||
|
||||
#define LSM303AGR_OUTX_L_A_SHIFT 0
|
||||
#define LSM303AGR_OUTX_L_A_MASK (255 << LSM303AGR_OUTX_L_A_SHIFT)
|
||||
|
||||
#define LSM303AGR_FIFO_CTRL_REG_A 0x2E
|
||||
#define LSM303AGR_FIFO_SRC_REG_A 0x2F
|
||||
#define LSM303AGR_INT1_CFG_A 0x30
|
||||
#define LSM303AGR_INT1_SRC_A 0x3A
|
||||
#define LSM303AGR_INT1_THS_A 0x32
|
||||
#define LSM303AGR_INT1_DURATION_A 0x33
|
||||
#define LSM303AGR_INT2_CFG_A 0x34
|
||||
#define LSM303AGR_INT2_SRC_A 0x35
|
||||
#define LSM303AGR_INT2_THS_A 0x36
|
||||
#define LSM303AGR_INT2_DURATION_A 0x37
|
||||
#define LSM303AGR_CLICK_CFG_A 0x38
|
||||
#define LSM303AGR_CLICK_SRC_A 0x39
|
||||
#define LSM303AGR_CLICK_THS_A 0x3A
|
||||
#define LSM303AGR_TIME_LIMIT_A 0x3B
|
||||
#define LSM303AGR_TIME_LATENCY_A 0x3C
|
||||
#define LSM303AGR_TIME_WINDOW_A 0x3D
|
||||
#define LSM303AGR_Act_THS_A 0x3E
|
||||
#define LSM303AGR_Act_DUR_A 0x3F
|
||||
#define LSM303AGR_OFFSET_X_REG_L_M 0x45
|
||||
#define LSM303AGR_OFFSET_X_REG_H_M 0x46
|
||||
#define LSM303AGR_OFFSET_Y_REG_L_M 0x47
|
||||
#define LSM303AGR_OFFSET_Y_REG_H_M 0x48
|
||||
#define LSM303AGR_OFFSET_Z_REG_L_M 0x49
|
||||
#define LSM303AGR_OFFSET_Z_REG_H_M 0x4A
|
||||
#define LSM303AGR_WHO_AM_I_M 0x4F
|
||||
#define LSM303AGR_CFG_REG_A_M 0x60
|
||||
#define LSM303AGR_CFG_REG_B_M 0x61
|
||||
#define LSM303AGR_CFG_REG_C_M 0x62
|
||||
#define LSM303AGR_INT_CTRL_REG_M 0x63
|
||||
#define LSM303AGR_INT_SOURCE_REG_M 0x64
|
||||
#define LSM303AGR_INT_THS_L_REG_M 0x65
|
||||
#define LSM303AGR_INT_THS_H_REG_M 0x66
|
||||
#define LSM303AGR_STATUS_REG_M 0x67
|
||||
|
||||
#define LSM303AGR_STATUS_REG_M_SHIFT 0
|
||||
#define LSM303AGR_STATUS_REG_M_MASK (0 << LSM303AGR_STATUS_REG_M_SHIFT)
|
||||
#define LSM303AGR_STATUS_REG_M_ZYXDA (1 << 3)
|
||||
#define LSM303AGR_STATUS_REG_M_ZYXOR (1 << 7)
|
||||
|
||||
#define LSM303AGR_OUTX_L_REG_M 0x68
|
||||
#define LSM303AGR_OUTX_H_REG_M 0x69
|
||||
#define LSM303AGR_OUTY_L_REG_M 0x6A
|
||||
#define LSM303AGR_OUTY_H_REG_M 0x6B
|
||||
#define LSM303AGR_OUTZ_L_REG_M 0x6C
|
||||
#define LSM303AGR_OUTZ_H_REG_M 0x6D
|
||||
|
||||
#define LSM303AGR_OUTX_L_M_SHIFT 0
|
||||
#define LSM303AGR_OUTX_L_M_MASK (255 << LSM303AGR_OUTX_L_M_SHIFT)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct i2c_master_s;
|
||||
|
||||
/* Container for sensor data */
|
||||
|
||||
struct lsm303agr_sensor_data_s
|
||||
{
|
||||
int16_t x_data;
|
||||
int16_t y_data;
|
||||
int16_t z_data;
|
||||
uint16_t temperature;
|
||||
int16_t m_x_data;
|
||||
int16_t m_y_data;
|
||||
int16_t m_z_data;
|
||||
uint16_t timestamp;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct lsm303agr_dev_s;
|
||||
struct lsm303agr_ops_s
|
||||
{
|
||||
CODE int (*config)(FAR struct lsm303agr_dev_s *priv);
|
||||
CODE int (*start)(FAR struct lsm303agr_dev_s *priv);
|
||||
CODE int (*stop)(FAR struct lsm303agr_dev_s *priv);
|
||||
CODE int (*sensor_read)(FAR struct lsm303agr_dev_s *priv,
|
||||
FAR struct lsm303agr_sensor_data_s *sensor_data);
|
||||
CODE int (*selftest)(FAR struct lsm303agr_dev_s *priv,
|
||||
uint32_t mode);
|
||||
};
|
||||
|
||||
struct lsm303agr_dev_s
|
||||
{
|
||||
FAR struct i2c_master_s *i2c; /* I2C interface */
|
||||
uint8_t addr; /* I2C address */
|
||||
|
||||
FAR const struct lsm303agr_ops_s *ops;
|
||||
|
||||
uint8_t datareg; /* Output data register of X low byte */
|
||||
struct lsm303agr_sensor_data_s sensor_data; /* Sensor data container */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lsm303agr_sensor_register
|
||||
*
|
||||
* Description:
|
||||
* Register the lsm303agr accelerometer character device as 'devpath'.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register, e.g., "/dev/sensor0".
|
||||
* i2c - An I2C driver instance.
|
||||
* addr - The I2C address of the LSM9DS1 accelerometer.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lsm303agr_sensor_register(FAR const char *devpath,
|
||||
FAR struct i2c_master_s *i2c,uint8_t addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_I2C && CONFIG_SENSORS_LSM303AGR */
|
||||
#endif /* __INCLUDE_NUTTX_SENSORS_LSM303AGR */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user