boards/stm32f4discovery: add sensorscope config

streams the on-board LIS3DSH over USB CDC/ACM with SensorScope

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude:Claude-Fable-5
This commit is contained in:
raiden00pl 2026-07-24 15:02:15 +02:00 committed by simbit18
parent 80f88fc344
commit 4a64703a60
7 changed files with 127 additions and 23 deletions

View file

@ -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.

View file

@ -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()

View file

@ -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

View file

@ -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
@ -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:
@ -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");
spi = stm32_spibus_initialize(busno);
if (spi == NULL)
{
spiinfo("Failed to initialize SPI port\n");
return -ENODEV;
}
#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;
spi = stm32_spibus_initialize(1);
if (!spi)
{
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 ret;
snprintf(devpath, sizeof(devpath), "/dev/acc%d", devno);
return lis3dsh_register(devpath, spi, &acc0_config);
#endif
}

View file

@ -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

View file

@ -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
@ -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)

View file

@ -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
@ -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);