Using Zephyr sensor driver - LPS22HB

Greetings

I have been going through the BLE fundamentals course, and I am currently on Lesson 4 exercise 1, which entails creating custom services. I have went through the exercise and can see it working perfectly. 

However, I am trying to add the sensor drivers for the LPS22HB pressure sensor. I would like to experiment with sending the pressure readings as a custom service. I have included the sensor.h file to main.c and added the following KConfig defines to my prj.conf file, for the pressure sensor:

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Logger module
CONFIG_LOG=y

# Button and LED library
CONFIG_DK_LIBRARY=y

# Bluetooth LE
CONFIG_BT=y

CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="MY_LBS1"

# Increase stack size for the main thread and System Workqueue
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2048


# KConfig defines for LPS22HB pressure sensor
CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_SENSOR=y
CONFIG_LPS22HB=y
CONFIG_DT_HAS_ST_LPS22HB_PRESS_ENABLED=y









After adding these changes, I get the following error: CMake Error at C:/ncs/v2.6.0/zephyr/cmake/modules/kconfig.cmake:358 (message):

There are also warnings shown in the KConfig file for the last 2 lines: 

CONFIG_LPS22HB was assigned the value y, but got the value n. Missing dependencies:
DT_HAS_ST_LPS22HB_PRESS_ENABLED

Symbol CONFIG_DT_HAS_ST_LPS22HB_PRESS_ENABLED cannot be set (has no prompt)

What am I doing incorrectly?

Parents
  • Hi,

    Did you make sure that you defined the device in a .dts overlay file?

    CONFIG_LPS22HB needs CONFIG_DT_HAS_ST_LPS22HB_PRESS_ENABLED which is automatically generated if a device with that matching compatible is present in the compiled .dts.

    I was able to get the same error as you if I didn't mention the device in the .dts and the error went away by adding

    &i2c0 {
    	status = "okay";
    	pinctrl-0 = <&i2c0_default>;
    	pinctrl-1 = <&i2c0_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	my_lps: my_lps@1c {
    		compatible="st,lps22hb";
    		status="okay";
    		reg=<0x1c>;
    	};
    };

Reply
  • Hi,

    Did you make sure that you defined the device in a .dts overlay file?

    CONFIG_LPS22HB needs CONFIG_DT_HAS_ST_LPS22HB_PRESS_ENABLED which is automatically generated if a device with that matching compatible is present in the compiled .dts.

    I was able to get the same error as you if I didn't mention the device in the .dts and the error went away by adding

    &i2c0 {
    	status = "okay";
    	pinctrl-0 = <&i2c0_default>;
    	pinctrl-1 = <&i2c0_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	my_lps: my_lps@1c {
    		compatible="st,lps22hb";
    		status="okay";
    		reg=<0x1c>;
    	};
    };

Children
No Data
Related