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
7 changes: 3 additions & 4 deletions boards/st/steval_stwinbx1/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,9 @@ You should see the following confirmation on your Linux host:
usb 3-1: Manufacturer: STMicroelectronics
usb 3-1: SerialNumber: 207136863530

.. You can build and flash the provided sample application
.. (:ref:`sensortile_box_pro_sample_sensors`) that reads sensors data and outputs
.. values on the console.

You can build and flash the provided sample application
(:ref:`steval_stwinbx1_sample_sensors`) that reads sensors data and outputs
values on the console.

.. _STEVAL-STWINBX1 Development kit website:
https://www.st.com/en/evaluation-tools/steval-stwinbx1.html
Expand Down
40 changes: 40 additions & 0 deletions boards/st/steval_stwinbx1/steval_stwinbx1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,39 @@ stm32_lp_tick_source: &lptim1 {
status = "okay";
};

&spi2 {
pinctrl-0 = <&spi2_sck_pi1 &spi2_miso_pd3 &spi2_mosi_pi3>;
pinctrl-names = "default";
status = "okay";

cs-gpios = <&gpioh 6 GPIO_ACTIVE_LOW>,
<&gpioh 15 GPIO_ACTIVE_LOW>,
<&gpioi 7 GPIO_ACTIVE_LOW>;
iis2dlpc: iis2dlpc@0 {
compatible = "st,iis2dlpc";
spi-max-frequency = <DT_FREQ_M(10)>;
reg = <0>;
drdy-gpios = <&gpiof 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
drdy-int = <1>;
};

ism330dhcx: ism330dhcx@1 {
compatible = "st,ism330dhcx";
spi-max-frequency = <DT_FREQ_M(10)>;
reg = <1>;
drdy-gpios = <&gpiob 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
int-pin = <1>;
};

iis2iclx: iis2iclx@2 {
compatible = "st,iis2iclx";
spi-max-frequency = <DT_FREQ_M(10)>;
reg = <2>;
drdy-gpios = <&gpiof 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
int-pin = <2>;
};
};

&spi3 {
pinctrl-0 = <&spi3_sck_pg9 &spi3_miso_pb4 &spi3_mosi_pb5>;
pinctrl-names = "default";
Expand Down Expand Up @@ -178,6 +211,13 @@ stm32_lp_tick_source: &lptim1 {
int-gpios = <&gpiof 5 GPIO_ACTIVE_HIGH>;
status = "okay";
};

iis2mdc@1e {
compatible = "st,iis2mdc";
reg = <0x1e>;
drdy-gpios = <&gpiof 9 GPIO_ACTIVE_HIGH>;
status = "okay";
};
};

&timers5 {
Expand Down
6 changes: 3 additions & 3 deletions drivers/sensor/st/iis2iclx/iis2iclx.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int iis2iclx_freq_to_odr_val(uint16_t freq)
size_t i;

for (i = 0; i < ARRAY_SIZE(iis2iclx_odr_map); i++) {
if (freq == iis2iclx_odr_map[i]) {
if (freq <= iis2iclx_odr_map[i]) {
return i;
}
}
Expand All @@ -50,7 +50,7 @@ static int iis2iclx_odr_to_freq_val(uint16_t odr)
return iis2iclx_odr_map[ARRAY_SIZE(iis2iclx_odr_map) - 1];
}

static const uint16_t iis2iclx_accel_fs_map[] = {500, 3000, 1000, 2000};
static const uint16_t iis2iclx_accel_fs_map[] = {500, 3000, 1000, 2000}; /* fs in mg */
static const uint16_t iis2iclx_accel_fs_sens[] = {1, 8, 2, 4};

static int iis2iclx_accel_range_to_fs_val(int32_t range)
Expand Down Expand Up @@ -130,7 +130,7 @@ static int iis2iclx_accel_range_set(const struct device *dev, int32_t range)
int fs;
struct iis2iclx_data *data = dev->data;

fs = iis2iclx_accel_range_to_fs_val(range);
fs = iis2iclx_accel_range_to_fs_val(range * 1000); /* pass range in mg */
if (fs < 0) {
return fs;
}
Expand Down
10 changes: 10 additions & 0 deletions samples/boards/steval_stwinbx1/sensors/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(steval_stwinbx1)

target_sources(app PRIVATE src/main.c)
79 changes: 79 additions & 0 deletions samples/boards/steval_stwinbx1/sensors/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.. _steval_stwinbx1_sample_sensors:

STWIN.box on-board sensors test
###############################

Overview
********
This sample provides an example of how to read sensors data
from the STWIN.box board.

This sample enables all sensors of STWIN.box board, and then
periodically reads and displays data on the console from the following
sensors:

- STTS22H: Digital temperature sensor
- IIS2MDC: 3-axis magnetometer
- ISM330DHCX: IMU, 3D accelerometer and 3D gyroscope with Machine Learning Core and Finite State Machine
- IIS2DLPC: high-performance ultra-low-power 3-axis accelerometer for industrial applications
- IIS2ICLX: high-accuracy, high-resolution, low-power, 2-axis digital inclinometer with Machine Learning Core

Requirements
************

The application requires a STWIN.box board connected to the PC
through USB. The board shows up as a USB CDC class standard device.

References
**********

- :ref:`steval_stwinbx1_board`

Building and Running
********************

Build and flash the sample in the following way:

.. zephyr-app-commands::
:zephyr-app: samples/boards/steval_stwinbx1/sensors
:board: steval_stwinbx1
:goals: build flash

Please note that flashing the board requires a few preliminary steps described
in :ref:`steval_stwinbx1_board`.

Then, power cycle the board by disconnecting and reconnecting the USB cable.
Run your favorite terminal program to listen for output.

.. code-block:: console
$ minicom -D <tty_device> -b 115200
Replace :code:`<tty_device>` with the correct device path automatically created on
the host after the STWIN.box board gets connected to it,
usually :code:`/dev/ttyUSBx` or :code:`/dev/ttyACMx` (with x being 0, 1, 2, ...).
The ``-b`` option sets baud rate ignoring the value from config.

Sample Output
=============

The sample code outputs sensors data on the STWIN.box console.

.. code-block:: console
STWIN.box dashboard
STTS22H: Temperature: 24.4 C
IIS2DLPC: Accel (m.s-2): x: -5.590, y: -0.536, z: 8.040
IIS2MDC: Magn (gauss): x: 0.420, y: -0.116, z: -0.103
IIS2MDC: Temperature: 21.0 C
ISM330DHCX: Accel (m.s-2): x: 0.000, y: 5.704, z: 7.982
ISM330DHCX: Gyro (dps): x: 0.026, y: -0.006, z: -0.008
IIS2ICLX: Accel (m.s-2): x: -0.157, y: 5.699
1:: iis2dlpc trig 2021
1:: iis2mdc trig 993
1:: ism330dhcx acc trig 4447
1:: ism330dhcx gyr trig 2223
1:: iis2iclx trig 2091
<repeats endlessly every 2s>
16 changes: 16 additions & 0 deletions samples/boards/steval_stwinbx1/sensors/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CONFIG_LOG=y
CONFIG_PRINTK=y
CONFIG_SPI=y
CONFIG_I2C=y
CONFIG_GPIO=y

# config sensors
CONFIG_SENSOR=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y
CONFIG_STTS22H_TRIGGER_NONE=y
CONFIG_IIS2MDC_TRIGGER_OWN_THREAD=y
CONFIG_IIS2DLPC_TRIGGER_OWN_THREAD=y
CONFIG_ISM330DHCX_TRIGGER_OWN_THREAD=y
CONFIG_IIS2ICLX_TRIGGER_OWN_THREAD=y

CONFIG_CBPRINTF_FP_SUPPORT=y
12 changes: 12 additions & 0 deletions samples/boards/steval_stwinbx1/sensors/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sample:
description: STWIN.box board testing
name: STWIN.box board test
tests:
sample.board.steval_stwinbx1.sensors:
harness: sensor
platform_allow: steval_stwinbx1
tags: sensors
depends_on:
- i2c
- spi
- gpio
Loading