Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ Implemented Drivers
- hyt271
- l3gd20
- :doc:`lis2mdl`
- lis3dsh
- lsm9ds1
- ltr308
- :doc:`mpu6050`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2448,3 +2448,26 @@ nxscope_cdcacm
Configuration demonstrating NxScope stream over CDC-ACM interface.
See :doc:`/applications/examples/nxscope/index` and
:doc:`/applications/logging/nxscope/index` for more details.

sensorscope
-----------

Streams the on-board LIS3DSH accelerometer (registered as a uORB sensor at
``/dev/uorb/sensor_accel0``) over the USB CDC/ACM virtual serial port using the
SensorScope application on top of the NxScope logging protocol. The stream is
read on the host with Nxscli (https://github.com/railab/nxscli).

Read it with Nxscli::

# List the available channels: expect one FLOAT channel of dimension 3
# named "sensor_accel0" (the accelerometer X/Y/Z axes).
nxscli serial /dev/ttyACM1 pdevinfo

# Print samples of channel 0 to stdout.
nxscli serial /dev/ttyACM1 chan 0 pprinter 100

# Plot samples with nxscli-pqg plugin.
nxscli serial /dev/ttyACM1 chan 0 q_roll 100

See :doc:`/applications/system/sensorscope/index` and
:doc:`/applications/logging/nxscope/index` for more details.
2 changes: 1 addition & 1 deletion boards/arm/common/stm32/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ if(CONFIG_SENSORS_AMG88XX)
list(APPEND SRCS stm32_amg88xx.c)
endif()

if(CONFIG_LIS3DSH)
if(CONFIG_LIS3DSH OR CONFIG_SENSORS_LIS3DSH_UORB)
list(APPEND SRCS stm32_lis3dsh.c)
endif()

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/common/stm32/src/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ ifeq ($(CONFIG_SENSORS_AMG88XX),y)
CSRCS+= stm32_amg88xx.c
endif

ifeq ($(CONFIG_LIS3DSH),y)
ifneq (,$(filter y,$(CONFIG_LIS3DSH) $(CONFIG_SENSORS_LIS3DSH_UORB)))
CSRCS += stm32_lis3dsh.c
endif

Expand Down
40 changes: 22 additions & 18 deletions boards/arm/common/stm32/src/stm32_lis3dsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@
*
****************************************************************************/

#ifndef CONFIG_SENSORS_LIS3DSH_UORB
int attach_disc_lis3dsh(struct lis3dsh_config_s *config,
xcpt_t interrupt_handler)
{
return stm32_gpiosetevent(BOARD_LIS3DSH_GPIO_EXT0, true, false, false,
interrupt_handler, NULL);
}
#endif

/****************************************************************************
* Public Functions
Expand All @@ -77,10 +79,12 @@ int attach_disc_lis3dsh(struct lis3dsh_config_s *config,
* Name: board_lis3dsh_initialize
*
* Description:
* Initialize and register the LIS3DSH 3-axis accelerometer.
* Initialize and register the LIS3DSH 3-axis accelerometer as a legacy
* character device (/dev/accN), or as a uORB sensor when
* CONFIG_SENSORS_LIS3DSH_UORB is selected.
*
* Input Parameters:
* devno - The device number, used to build the device path as /dev/accN
* devno - The device number
* busno - The SPI bus number
*
* Returned Value:
Expand All @@ -90,28 +94,28 @@ int attach_disc_lis3dsh(struct lis3dsh_config_s *config,

int board_lis3dsh_initialize(int devno, int busno)
{
static struct lis3dsh_config_s acc0_config;
char devpath[12];
struct spi_dev_s *spi;
int ret;

sninfo("Initializing LIS3DSH\n");

acc0_config.irq = 22;
acc0_config.spi_devid = 0;
acc0_config.attach = &attach_disc_lis3dsh;

spi = stm32_spibus_initialize(1);
if (!spi)
spi = stm32_spibus_initialize(busno);
if (spi == NULL)
{
spiinfo("Failed to initialize SPI port\n");
ret = -ENODEV;
}
else
{
snprintf(devpath, sizeof(devpath), "/dev/acc%d", devno);
ret = lis3dsh_register(devpath, spi, &acc0_config);
return -ENODEV;
}

return ret;
#ifdef CONFIG_SENSORS_LIS3DSH_UORB
return lis3dsh_register_uorb(devno, spi);
#else
static struct lis3dsh_config_s acc0_config;
char devpath[12];

acc0_config.irq = 22;
acc0_config.spi_devid = 0;
acc0_config.attach = &attach_disc_lis3dsh;

snprintf(devpath, sizeof(devpath), "/dev/acc%d", devno);
return lis3dsh_register(devpath, spi, &acc0_config);
#endif
}
65 changes: 65 additions & 0 deletions boards/arm/stm32f4/stm32f4discovery/configs/sensorscope/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_ARCH_FPU is not set
# CONFIG_DEV_CONSOLE is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="stm32f4discovery"
CONFIG_ARCH_BOARD_COMMON=y
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP="stm32f4"
CONFIG_ARCH_CHIP_STM32=y
CONFIG_ARCH_CHIP_STM32F407VG=y
CONFIG_ARCH_CHIP_STM32F4=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL=y
CONFIG_BOARDCTL_USBDEVCTRL=y
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_CDCACM=y
CONFIG_CDCACM_RXBUFSIZE=256
CONFIG_CDCACM_TXBUFSIZE=2048
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="sensorscope_main"
CONFIG_INIT_STACKSIZE=4096
CONFIG_INTELHEX_BINARY=y
CONFIG_LOGGING_NXSCOPE=y
CONFIG_LOGGING_NXSCOPE_ACKFRAMES=y
CONFIG_LOGGING_NXSCOPE_DIVIDER=y
CONFIG_MM_REGIONS=2
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAMLOG=y
CONFIG_RAMLOG_BUFSIZE=4096
CONFIG_RAMLOG_SYSLOG=y
CONFIG_RAM_SIZE=114688
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SENSORS=y
CONFIG_SENSORS_LIS3DSH_UORB=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=27
CONFIG_START_YEAR=2013
CONFIG_STM32_JTAG_SW_ENABLE=y
CONFIG_STM32_OTGFS=y
CONFIG_STM32_PWR=y
CONFIG_STM32_SPI1=y
CONFIG_STM32_USART2=y
CONFIG_SYSTEM_READLINE=y
CONFIG_SYSTEM_SENSORSCOPE=y
CONFIG_SYSTEM_SENSORSCOPE_CDCACM=y
CONFIG_SYSTEM_SENSORSCOPE_FETCH_INTERVAL=100000
CONFIG_SYSTEM_SENSORSCOPE_SERIAL_PATH="/dev/ttyACM0"
CONFIG_SYSTEM_SENSORSCOPE_STREAMBUF_LEN=2048
CONFIG_USBDEV=y
12 changes: 11 additions & 1 deletion boards/arm/stm32f4/stm32f4discovery/src/stm32_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
#include "stm32_bh1750.h"
#endif

#ifdef CONFIG_LIS3DSH
#if defined(CONFIG_LIS3DSH) || defined(CONFIG_SENSORS_LIS3DSH_UORB)
#include "stm32_lis3dsh.h"
#endif

Expand Down Expand Up @@ -282,6 +282,16 @@ int stm32_bringup(void)
}
#endif

#ifdef CONFIG_SENSORS_LIS3DSH_UORB
/* Initialize the on-board LIS3DSH accelerometer as a uORB sensor on SPI1 */

ret = board_lis3dsh_initialize(0, 1);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: board_lis3dsh_initialize failed: %d\n", ret);
}
#endif

#ifdef CONFIG_LEDS_MAX7219
ret = stm32_max7219init("/dev/numdisp0");
if (ret < 0)
Expand Down
6 changes: 4 additions & 2 deletions boards/arm/stm32f4/stm32f4discovery/src/stm32_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ void weak_function stm32_spidev_initialize(void)
stm32_configgpio(GPIO_W5500_INTR);
#endif

#if defined(CONFIG_STM32_SPI1) && defined(CONFIG_SENSORS_LIS3MDL)
#if defined(CONFIG_STM32_SPI1) && (defined(CONFIG_SENSORS_LIS3MDL) || \
defined(CONFIG_SENSORS_LIS3DSH_UORB) || defined(CONFIG_LIS3DSH))
stm32_configgpio(GPIO_CS_MEMS); /* MEMS chip select */
#endif

Expand Down Expand Up @@ -189,7 +190,8 @@ void stm32_spi1select(struct spi_dev_s *dev, uint32_t devid,
}
#endif

#if defined (CONFIG_SENSORS_LIS3MDL)
#if defined(CONFIG_SENSORS_LIS3MDL) || defined(CONFIG_SENSORS_LIS3DSH_UORB) || \
defined(CONFIG_LIS3DSH)
if (devid == SPIDEV_ACCELEROMETER(0))
{
stm32_gpiowrite(GPIO_CS_MEMS, !selected);
Expand Down
4 changes: 4 additions & 0 deletions drivers/sensors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ if(CONFIG_SENSORS)
endif()
endif()

if(CONFIG_SENSORS_LIS3DSH_UORB)
list(APPEND SRCS lis3dsh_uorb.c)
endif()

if(CONFIG_LIS3DSH)
list(APPEND SRCS lis3dsh.c)
endif()
Expand Down
33 changes: 33 additions & 0 deletions drivers/sensors/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,39 @@ config LIS3DSH
---help---
Enable driver support for the STMicro LIS3DSH 3-Axis accelerometer.

config SENSORS_LIS3DSH_UORB
bool "STMicro LIS3DSH 3-Axis accelerometer support (UORB)"
default n
select SPI
---help---
Enable UORB driver support for the STMicro LIS3DSH 3-Axis
accelerometer. Registers /dev/uorb/sensor_accelN.

if SENSORS_LIS3DSH_UORB

config SENSORS_LIS3DSH_UORB_POLL
bool "Enable polling worker thread"
default n
---help---
Enables polling of sensor.

config SENSORS_LIS3DSH_UORB_POLL_INTERVAL
int "Polling interval in microseconds"
depends on SENSORS_LIS3DSH_UORB_POLL
default 100000
range 0 4294967295
---help---
The interval until a new sensor measurement will be triggered.

config SENSORS_LIS3DSH_UORB_STACKSIZE
int "Worker thread stack size"
depends on SENSORS_LIS3DSH_UORB_POLL
default 1024
---help---
The stack size for the worker thread.

endif # SENSORS_LIS3DSH_UORB

config LIS3DH
bool "STMicro LIS3DH 3-Axis accelerometer support"
default n
Expand Down
4 changes: 4 additions & 0 deletions drivers/sensors/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ else
endif
endif

ifeq ($(CONFIG_SENSORS_LIS3DSH_UORB),y)
CSRCS += lis3dsh_uorb.c
endif

ifeq ($(CONFIG_LIS3DSH),y)
CSRCS += lis3dsh.c
endif
Expand Down
Loading
Loading