Example of LSM6DS not compilng

Hello  i tried a lot but i am unable to Compile this , its is expected examples available in sdk should compile smoothly if there are no changes in it,

 i was expecting remote support i trying from 2 days am too fustrated, pls support via zoom or google meet or linkedin :swapnilsurule,

===================================================================================

main.c :


/*
 * Copyright (c) 2020 Yestin Sun
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>

static inline float out_ev(struct sensor_value *val)
{
    return (val->val1 + (float)val->val2 / 1000000);
}

static void fetch_and_display(const struct device *dev)
{
    struct sensor_value x, y, z;
    static int trig_cnt;

    trig_cnt++;

    /* lsm6ds3 accel */
    sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
    sensor_channel_get(dev, SENSOR_CHAN_ACCEL_X, &x);
    sensor_channel_get(dev, SENSOR_CHAN_ACCEL_Y, &y);
    sensor_channel_get(dev, SENSOR_CHAN_ACCEL_Z, &z);

    printf("accel x:%f ms/2 y:%f ms/2 z:%f ms/2
",
            (double)out_ev(&x), (double)out_ev(&y), (double)out_ev(&z));

    /* lsm6ds3 gyro */
    sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
    sensor_channel_get(dev, SENSOR_CHAN_GYRO_X, &x);
    sensor_channel_get(dev, SENSOR_CHAN_GYRO_Y, &y);
    sensor_channel_get(dev, SENSOR_CHAN_GYRO_Z, &z);

    printf("gyro x:%f rad/s y:%f rad/s z:%f rad/s
",
            (double)out_ev(&x), (double)out_ev(&y), (double)out_ev(&z));

    printf("trig_cnt:%d

", trig_cnt);
}

static int set_sampling_freq(const struct device *dev)
{
    int ret = 0;
    struct sensor_value odr_attr;

    /* set accel/gyro sampling frequency to 12.5 Hz */
    odr_attr.val1 = 12.5;
    odr_attr.val2 = 0;

    ret = sensor_attr_set(dev, SENSOR_CHAN_ACCEL_XYZ,
            SENSOR_ATTR_SAMPLING_FREQUENCY, &odr_attr);
    if (ret != 0) {
        printf("Cannot set sampling frequency for accelerometer.\n");
        return ret;
    }

    ret = sensor_attr_set(dev, SENSOR_CHAN_GYRO_XYZ,
            SENSOR_ATTR_SAMPLING_FREQUENCY, &odr_attr);
    if (ret != 0) {
        printf("Cannot set sampling frequency for gyro.\n");
        return ret;
    }

    return 0;
}

#ifdef CONFIG_LSM6DSO_TRIGGER
static void trigger_handler(const struct device *dev,
                const struct sensor_trigger *trig)
{
    fetch_and_display(dev);
}

static void test_trigger_mode(const struct device *dev)
{
    struct sensor_trigger trig;

    if (set_sampling_freq(dev) != 0)
        return;

    trig.type = SENSOR_TRIG_DATA_READY;
    trig.chan = SENSOR_CHAN_ACCEL_XYZ;

    if (sensor_trigger_set(dev, &trig, trigger_handler) != 0) {
        printf("Could not set sensor type and channel\n");
        return;
    }
}

#else
static void test_polling_mode(const struct device *dev)
{
    if (set_sampling_freq(dev) != 0) {
        return;
    }

    while (1) {
        fetch_and_display(dev);
        k_sleep(K_MSEC(1000));
    }
}
#endif

int main(void)
{
    const struct device *const dev = DEVICE_DT_GET_ONE(st_lsm6dso3);

    if (!device_is_ready(dev)) {
        printk("%s: device not ready.\n", dev->name);
        return 0;
    }

#ifdef CONFIG_LSM6DSO_TRIGGER
    printf("Testing LSM6DS3 sensor in trigger mode.\n\n");
    test_trigger_mode(dev);
#else
    printf("Testing LSM6DS3 sensor in polling mode.\n\n");
    test_polling_mode(dev);
#endif
    return 0;
}

===========================================================================================

prj.conf
CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y


CONFIG_SENSOR_LSM6DS3=y
CONFIG_CBPRINTF_FP_SUPPORT=y

# Set trigger support options correctly

CONFIG_LSM6DSO_TRIGGER_GLOBAL_THREAD=y
CONFIG_SENSOR=y                 # Enable sensor drivers
CONFIG_LSM6DSO=y                # Enable the LSM6DSO driver
CONFIG_LSM6DSO_TRIGGER_GLOBAL_THREAD=y  # Use the global thread for trigger handling


CONFIG_I2C_NRFX=y                     # Nordic's I2C driver for nRF devices
CONFIG_I2C_NRF_TWIM=y                 # Enable I2C using the TWIM peripheral
CONFIG_GPIO=y                         # Enable GPIO support (for interrupt lines)
CONFIG_GPIO_NRFX=y                    # Nordic GPIO driver
==============================================================================================
CMakeLists.txt
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(lsm6ds3_project)

target_sources(app PRIVATE src/main.c)

=================================================================================================

Latest Error
* Executing task: nRF Connect: Build: lsm6ds3_project_5/build (active)

Building lsm6ds3_project_5
C:\Windows\system32\cmd.exe /d /s /c "west build --build-dir c:/nordic/lsm6ds3_project_5/build c:/nordic/lsm6ds3_project_5"

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: C:/nordic/lsm6ds3_project_5
-- CMake version: 3.21.0
-- Cache files will be written to: C:/ncs/v2.6.1/zephyr/.cache
-- Zephyr version: 3.5.99 (C:/ncs/v2.6.1/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52840dk_nrf52840
-- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
-- Found BOARD.dts: C:/ncs/v2.6.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
-- Found devicetree overlay: C:/nordic/lsm6ds3_project_5/nrf52840dk_nrf52840.overlay
-- Generated zephyr.dts: C:/nordic/lsm6ds3_project_5/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: C:/nordic/lsm6ds3_project_5/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: C:/nordic/lsm6ds3_project_5/build/zephyr/dts.cmake

warning: LSM6DSO (defined at drivers/sensor/lsm6dso/Kconfig:6) was assigned the value 'y' but got
the value 'n'. Check these unsatisfied dependencies: DT_HAS_ST_LSM6DSO_ENABLED (=n). See
docs.zephyrproject.org/.../kconfig.html and/or look up LSM6DSO in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.


warning: The choice symbol LSM6DSO_TRIGGER_GLOBAL_THREAD (defined at
drivers/sensor/lsm6dso/Kconfig:28) was selected (set =y), but no symbol ended up as the choice
selection. See
docs.zephyrproject.org/.../kconfig.html and/or look
up LSM6DSO_TRIGGER_GLOBAL_THREAD in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.


C:/nordic/lsm6ds3_project_5/prj.conf:5: warning: attempt to assign the value 'y' to the undefined symbol SENSOR_LSM6DS3

C:/nordic/lsm6ds3_project_5/prj.conf:18: warning: attempt to assign the value 'y # Enable I2C using the TWIM peripheral' to the undefined symbol I2C_NRF_TWIM
Parsing C:/ncs/v2.6.1/zephyr/Kconfig
Loaded configuration 'C:/ncs/v2.6.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
Merged configuration 'C:/nordic/lsm6ds3_project_5/prj.conf'

error: Aborting due to Kconfig warnings

CMake Error at C:/ncs/v2.6.1/zephyr/cmake/modules/kconfig.cmake:358 (message):
command failed with return code: 1
Call Stack (most recent call first):
C:/ncs/v2.6.1/nrf/cmake/modules/kconfig.cmake:29 (include)
C:/ncs/v2.6.1/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
C:/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
C:/ncs/v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
CMakeLists.txt:2 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe '-Bc:\nordic\lsm6ds3_project_5\build' -GNinja '-Sc:\nordic\lsm6ds3_project_5'

* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
 
Related