mirror of
https://github.com/apache/nuttx.git
synced 2026-09-20 21:06:58 +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
@@ -454,10 +454,10 @@ o SMP
|
||||
Title: CORTEX-A GIC SGI INTERRUPT MASKING
|
||||
Description: In the ARMv7-A GICv2 architecture, the inter-processor
|
||||
interrupts (SGIs) are non maskable and will occur even if
|
||||
interrupts are disabled. This addes a lot of complexity
|
||||
interrupts are disabled. This adde a lot of complexity
|
||||
to the ARMV7-A critical section design.
|
||||
|
||||
Masayuki Ishakawa has suggest the use of the GICv2 ICCMPR
|
||||
Masayuki Ishakawa has suggested the use of the GICv2 ICCMPR
|
||||
register to control SGI interrupts. This register (much like
|
||||
the ARMv7-M BASEPRI register) can be used to mask interrupts
|
||||
by interrupt priority. Since SGIs may be assigned priorities
|
||||
|
||||
@@ -120,6 +120,18 @@
|
||||
#define GPIO_USART2_RTS GPIO_USART2_RTS_2
|
||||
#define GPIO_USART2_CTS GPIO_USART2_CTS_2
|
||||
|
||||
/* USART3:
|
||||
* RXD: PA10 CN9 pin 3, CN10 pin 33
|
||||
* PC5 CN5 pin 9, CN10 pin 6
|
||||
* PC11 CN7 pin 2
|
||||
* TXD: PA9 CN5 pin 1, CN10 pin 21
|
||||
* PC4 CN9 pin 3, CN10 pin 34
|
||||
* PC10 CN7 pin 1
|
||||
*/
|
||||
|
||||
#define GPIO_USART3_RX GPIO_USART3_RX_3 /* PC11 */
|
||||
#define GPIO_USART3_TX GPIO_USART3_TX_3 /* PC10 */
|
||||
|
||||
#define GPIO_UART4_RX GPIO_UART4_RX_1 /* PA1 */
|
||||
#define GPIO_UART4_TX GPIO_UART4_TX_1 /* PA0 */
|
||||
|
||||
|
||||
@@ -81,6 +81,18 @@ ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
||||
CSRCS += stm32_qencoder.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_HTS221),y)
|
||||
CSRCS += stm32_hts221.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_LSM6DSL),y)
|
||||
CSRCS += stm32_lsm6dsl.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_LSM303AGR),y)
|
||||
CSRCS += stm32_lsm303agr.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PWM),y)
|
||||
CSRCS += stm32_pwm.c
|
||||
endif
|
||||
|
||||
@@ -267,6 +267,10 @@
|
||||
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN1)
|
||||
#define GPIO_INT1 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTB | GPIO_PIN2)
|
||||
|
||||
#define GPIO_HTS221_INT (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTA | GPIO_PIN10)
|
||||
#define GPIO_LSM6DSL_INT1 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTB | GPIO_PIN4)
|
||||
#define GPIO_LSM6DSL_INT2 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTB | GPIO_PIN5)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
@@ -64,6 +64,12 @@
|
||||
# include "stm32l4_rtc.h"
|
||||
#endif
|
||||
|
||||
#include "stm32l4_i2c.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -204,10 +210,6 @@ int board_app_initialize(uintptr_t arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize CAN and register the CAN driver.
|
||||
* Added by: Ben vd Veen (DisruptiveNL) -- www.nuttx.nl
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CAN
|
||||
ret = stm32l4_can_setup();
|
||||
if (ret < 0)
|
||||
@@ -332,9 +334,29 @@ int board_app_initialize(uintptr_t arg)
|
||||
#endif
|
||||
#endif /* CONFIG_SENSORS_QENCODER */
|
||||
|
||||
/* Initialize CAN and register the CAN driver.
|
||||
* Added by: Ben vd Veen (DisruptiveNL) -- www.nuttx.nl
|
||||
*/
|
||||
#ifdef CONFIG_SENSORS_HTS221
|
||||
ret = stm32l4_hts221_initialize("/dev/hts221");
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: Failed to initialize HTC221 driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_LSM6DSL
|
||||
ret = stm32l4_lsm6dsl_initialize("/dev/lsm6dsl0");
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: Failed to initialize LSM6DSL driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_LSM303AGR
|
||||
ret = stm32l4_lsm303agr_initialize("/dev/lsm303mag0");
|
||||
if (ret < 0)
|
||||
{
|
||||
serr("ERROR: Failed to initialize LSM303AGR driver: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEV_GPIO
|
||||
ret = stm32l4_gpio_initialize();
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*****************************************************************************
|
||||
* configs/stm32l476rg/src/stm32_lsm303agr.c
|
||||
*
|
||||
* Copyright (C) 2018 Greg Nutt. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include "stm32l4.h"
|
||||
#include <nucleo-l476rg.h>
|
||||
#include <nuttx/sensors/lsm303agr.h>
|
||||
|
||||
/*****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STM32L4_I2C1
|
||||
# error "LSM303AGR driver requires CONFIG_STM32L4_I2C1 to be enabled"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: stm32_lsm303agr_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize I2C-based LSM303AGR.
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_lsm303agr_initialize(char *devpath)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret = OK;
|
||||
|
||||
sninfo("INFO: Initializing LMS303AGR sensor over I2C\n");
|
||||
|
||||
#if defined(CONFIG_STM32L4_I2C1)
|
||||
i2c = stm32l4_i2cbus_initialize(1);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = lsm303agr_sensor_register("/dev/lsm303mag0", i2c, LSM303AGRMAGNETO_ADDR);
|
||||
if (ret < 0)
|
||||
{
|
||||
snerr("ERROR: Failed to initialize LMS303AGR magneto driver %s\n", devpath);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
sninfo("INFO: LMS303AGR sensor has been initialized successfully\n");
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*****************************************************************************
|
||||
* configs/stm32l476rg/src/stm32_lsm6dsl.c
|
||||
*
|
||||
* Copyright (C) 2018 Greg Nutt. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include "stm32l4.h"
|
||||
#include <nucleo-l476rg.h>
|
||||
#include <nuttx/sensors/lsm6dsl.h>
|
||||
|
||||
/*****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STM32L4_I2C1
|
||||
# error "LSM6DSL driver requires CONFIG_STM32L4_I2C1 to be enabled"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: stm32_lsm6dsl_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize I2C-based LSM6DSL.
|
||||
****************************************************************************/
|
||||
|
||||
int stm32l4_lsm6dsl_initialize(char *devpath)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret = OK;
|
||||
|
||||
sninfo("Initializing LMS6DSL!\n");
|
||||
|
||||
/* Configure the GPIO interrupt */
|
||||
|
||||
stm32l4_configgpio(GPIO_HTS221_INT); /* IS THE SAME AS HTS221 FOR IKS01_A2 SHIELD */
|
||||
|
||||
#if defined(CONFIG_STM32L4_I2C1)
|
||||
i2c = stm32l4_i2cbus_initialize(1);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
sninfo("INFO: Initializing LMS6DSL accelero-gyro sensor over I2C%d\n", ret);
|
||||
|
||||
ret = lsm6dsl_sensor_register("/dev/lsm6dsl0", i2c, LSM6DSLACCEL_ADDR1);
|
||||
if (ret < 0)
|
||||
{
|
||||
snerr("ERROR: Failed to initialize LMS6DSL accelero-gyro driver %s\n", devpath);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
sninfo("INFO: LMS6DSL sensor has been initialized successfully\n");
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -185,6 +185,32 @@ config SENSORS_LSM330SPI
|
||||
---help---
|
||||
Enable driver support for the STMicro LSM330 on SPI.
|
||||
|
||||
config SENSORS_LSM303AGR
|
||||
bool "STMicro LSM303AGR support"
|
||||
default n
|
||||
select I2C
|
||||
---help---
|
||||
Enable driver support for the STMicro LSM303AGR.
|
||||
|
||||
config LSM303AGR_I2C_FREQUENCY
|
||||
int "LSM303AGR I2C frequency"
|
||||
default 400000
|
||||
range 1 400000
|
||||
depends on SN_LSM303AGR
|
||||
|
||||
config SENSORS_LSM6DSL
|
||||
bool "STMicro LSM6DSL support"
|
||||
default n
|
||||
select I2C
|
||||
---help---
|
||||
Enable driver support for the STMicro LSM6DSL.
|
||||
|
||||
config LSM6DSL_I2C_FREQUENCY
|
||||
int "LSM6DSL I2C frequency"
|
||||
default 400000
|
||||
range 1 400000
|
||||
depends on SN_LSM6DSL
|
||||
|
||||
config SENSORS_LSM9DS1
|
||||
bool "STMicro LSM9DS1 support"
|
||||
default n
|
||||
|
||||
@@ -69,6 +69,14 @@ ifeq ($(CONFIG_LIS331DL),y)
|
||||
CSRCS += lis331dl.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_LSM303AGR),y)
|
||||
CSRCS += lsm303agr.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_LSM6DSL),y)
|
||||
CSRCS += lsm6dsl.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_LSM9DS1),y)
|
||||
CSRCS += lsm9ds1.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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