samples: bme280: enable the appropriate bus by default
I personally don't find it very useful to have to maintain prj.conf and prj_spi.conf for this sample. The information we need to make this application "just work" with regards to the bus is available in the devicetree, and Kconfig can now access it using dt_compat_on_bus(). Do so, enabling I2C and SPI appropriately when a sensor of the right type is on either of those buses. If no sensors are enabled, the user gets the build-time error message in main.c about no devices being found. This approach is prone to the "stuck symbol" Kconfig problem covered in our documentation, so a pristine build is necessary to change the default settings from a previous build. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
1d1ed154da
commit
24260e6c3a
|
@ -10,4 +10,17 @@ config LOG_PRINTK
|
|||
config SENSOR_LOG_LEVEL
|
||||
default 4
|
||||
|
||||
# Workaround for not being able to have commas in macro arguments
|
||||
DT_COMPAT_BOSCH_BME280 := bosch,bme280
|
||||
|
||||
# Enable SPI support by default if there are any BME280 sensors
|
||||
# on a SPI bus.
|
||||
config SPI
|
||||
default $(dt_compat_on_bus,$(DT_COMPAT_BOSCH_BME280),spi)
|
||||
|
||||
# Enable I2C support by default if there are any BME280 sensors
|
||||
# on an I2C bus.
|
||||
config I2C
|
||||
default $(dt_compat_on_bus,$(DT_COMPAT_BOSCH_BME280),i2c)
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
CONFIG_I2C=y
|
||||
CONFIG_SENSOR=y
|
||||
CONFIG_BME280=y
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
CONFIG_SPI=y
|
||||
CONFIG_SENSOR=y
|
||||
CONFIG_BME280=y
|
Loading…
Reference in a new issue