Skip to content

Commit

Permalink
- Add Bosch BME6XX driver as submodule
Browse files Browse the repository at this point in the history
- Disable BME680 support in project configuration
- Rename submodule path for BMI270 sensor to align it with the other external drivers
- Remove not needed "CONFIG_INPUT" from debug config
- Move "SPI RTT Flash Loader" into "ZSWatch" menu
- Move CST816S driver into device specific directory
- Move GC9A01 driver into device specific directory
- Add default configuration menu in Kconfig
- Add default idle timeout option to Kconfig
- Remove "CONFIG_DISPLAY_FAST_WAKEUP" because it´s not needed anymore

Signed-off-by: Daniel Kampert <[email protected]>
  • Loading branch information
Kampi committed Oct 20, 2023
1 parent 1c1bc41 commit bc13b34
Show file tree
Hide file tree
Showing 26 changed files with 827 additions and 97 deletions.
7 changes: 5 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "app/src/ext_drivers/bmi270/BMI270-Sensor_API"]
path = app/src/ext_drivers/bmi270/BMI270-Sensor_API
[submodule "app/src/ext_drivers/bmi270/BMI270-Sensor-API"]
path = app/src/ext_drivers/bmi270/BMI270-Sensor-API
url = https://github.com/boschsensortec/BMI270-Sensor-API.git
[submodule "app/src/ext_drivers/bmp581/BMP5-Sensor-API"]
path = app/src/ext_drivers/bmp581/BMP5-Sensor-API
url = https://github.com/boschsensortec/BMP5-Sensor-API.git
[submodule "app/src/ext_drivers/BME68x-Sensor-API"]
path = app/src/ext_drivers/BME68x-Sensor-API
url = https://github.com/boschsensortec/BME68x-Sensor-API.git
[submodule "app/src/applications/2048/2048_lib"]
path = app/src/applications/2048/2048_lib
url = https://github.com/100askTeam/lv_lib_100ask.git
Expand Down
76 changes: 42 additions & 34 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,48 +78,56 @@ menu "ZSWatch"
endchoice
endmenu

menu "External"
config EXTERNAL_USE_BOSCH_BSEC
bool
prompt "Enable the usage of the external Bosch BSEC 2 library."
default y
endmenu

menu "Configuration"
config CONFIGURATION_IDLE_TIMEOUT_SECONDS
int
prompt "Idle timeout in seconds"
default 20
endmenu

config DISABLE_PAIRING_REQUIRED
bool
prompt "Disable encryption required for BLE connection (pairing/bonding)"
default n
help
"Disable encryption for BLE connection (pairing/bonding). Used only for debugging purposes."

config DISPLAY_FAST_WAKEUP
bool
prompt "Don't turn off the display power, just put it into sleep mode when going idle."
default n
help
"When screen goes idle, don't turn off the display power, just put it into sleep mode. This will consume more power, but will make the screen wake up faster."

endmenu
menu "SPI RTT Flash Loader"
config SPI_FLASH_LOADER
bool
prompt "Enable SPI flash loader"
default y
select USE_SEGGER_RTT
#select SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
help
"Enable SPI flash loader"

if SPI_FLASH_LOADER
config ERASE_PROGRESSIVELY
bool
depends on SPI_FLASH_LOADER
prompt "Erase sectors one by one when writing instead of full partition before starting."
default y
help
"If not writing to the full partition this will be faster"

config RTT_TRANSFER_CHANNEL
int
depends on SPI_FLASH_LOADER
prompt "The RTT channel to use for transfer of data to and form flash"
default 2
help
"If RTT logging is enabled, channel 0 is used for this, hence avoid 1 in this scenario."
endif
endmenu

menu "SPI RTT Flash Loader"
config SPI_FLASH_LOADER
bool
prompt "Enable SPI flash loader"
default y
select USE_SEGGER_RTT
#select SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
help
"Enable SPI flash loader"
if SPI_FLASH_LOADER
config ERASE_PROGRESSIVELY
bool
depends on SPI_FLASH_LOADER
prompt "Erase sectors one by one when writing instead of full partition before starting."
default y
help
"If not writing to the full partition this will be faster"

config RTT_TRANSFER_CHANNEL
int
depends on SPI_FLASH_LOADER
prompt "The RTT channel to use for transfer of data to and form flash"
default 2
help
"If RTT logging is enabled, channel 0 is used for this, hence avoid 1 in this scenario."
endif
endmenu

rsource "drivers/Kconfig"
Expand Down
4 changes: 1 addition & 3 deletions app/boards/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ CONFIG_LOG_BACKEND_RTT_MODE_BLOCK=y
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE=128
CONFIG_LOG_BLOCK_IN_THREAD=y
# End of SEGGER RTT

CONFIG_INPUT=y
# End of SEGGER RTT
10 changes: 9 additions & 1 deletion app/drivers/display/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
zephyr_sources_ifdef(CONFIG_GC9A01 gc9a01.c)
# TODO:
# Weird compilation issue when not using
# zephyr_library()
# zephyr_library_sources(apds9306.c)
#
# -> ..add_library cannot create target "..__app__drivers__sensor" because another
# -> target with the same name already exists. The existing target is a static...
#
add_subdirectory_ifdef(CONFIG_GC9A01 gc9a01)
4 changes: 3 additions & 1 deletion app/drivers/display/Kconfig
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
rsource "Kconfig.gc9a01"
if DISPLAY
rsource "gc9a01/Kconfig"
endif
8 changes: 0 additions & 8 deletions app/drivers/display/Kconfig.gc9a01

This file was deleted.

1 change: 1 addition & 0 deletions app/drivers/display/gc9a01/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zephyr_sources(gc9a01.c)
6 changes: 6 additions & 0 deletions app/drivers/display/gc9a01/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
menuconfig GC9A01
bool "GC9A01 compatible display controller driver"
default n
select SPI
help
Enable driver for GC9A01 compatible controller.
File renamed without changes.
10 changes: 9 additions & 1 deletion app/drivers/input/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
zephyr_sources_ifdef(CONFIG_INPUT_MODIFIED_CST816S input_cst816s.c)
# TODO:
# Weird compilation issue when not using
# zephyr_library()
# zephyr_library_sources(apds9306.c)
#
# -> ..add_library cannot create target "..__app__drivers__sensor" because another
# -> target with the same name already exists. The existing target is a static...
#
add_subdirectory_ifdef(CONFIG_INPUT_MODIFIED_CST816S cst816s)
32 changes: 3 additions & 29 deletions app/drivers/input/Kconfig
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
# Copyright (c) 2020 Qingsong Gou <[email protected]>
# Copyright (c) 2022 Jakob Krantz <[email protected]>
# SPDX-License-Identifier: Apache-2.0

menuconfig INPUT_MODIFIED_CST816S
bool "Use modified out of tree CST816S capacitive touch panel driver"
default y
depends on DT_HAS_HYNITRON_CST816S_ENABLED
select I2C
help
Enable modified out of tree driver for hynitron cst816s touch panel.

if INPUT_MODIFIED_CST816S

config INPUT_CST816S_PERIOD
int "Sample period"
depends on !INPUT_CST816S_INTERRUPT
default 20
help
Sample period in milliseconds when in polling mode.

config INPUT_CST816S_INTERRUPT
bool "Interrupt support"
default y
depends on GPIO
help
Enable interrupt support (requires GPIO).

endif # INPUT_CST816S
if INPUT
rsource "cst816s/Kconfig"
endif
1 change: 1 addition & 0 deletions app/drivers/input/cst816s/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zephyr_sources(input_cst816s.c)
29 changes: 29 additions & 0 deletions app/drivers/input/cst816s/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2020 Qingsong Gou <[email protected]>
# Copyright (c) 2022 Jakob Krantz <[email protected]>
# SPDX-License-Identifier: Apache-2.0

menuconfig INPUT_MODIFIED_CST816S
bool "Use modified out of tree CST816S capacitive touch panel driver"
default y
depends on DT_HAS_HYNITRON_CST816S_ENABLED
select I2C
help
Enable modified out of tree driver for hynitron cst816s touch panel.

if INPUT_MODIFIED_CST816S

config INPUT_CST816S_PERIOD
int "Sample period"
depends on !INPUT_CST816S_INTERRUPT
default 20
help
Sample period in milliseconds when in polling mode.

config INPUT_CST816S_INTERRUPT
bool "Interrupt support"
default y
depends on GPIO
help
Enable interrupt support (requires GPIO).

endif # INPUT_CST816S
File renamed without changes.
3 changes: 2 additions & 1 deletion app/drivers/sensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
# -> ..add_library cannot create target "..__app__drivers__sensor" because another
# -> target with the same name already exists. The existing target is a static...
#
add_subdirectory_ifdef(CONFIG_APDS9306 apds9306)
add_subdirectory_ifdef(CONFIG_APDS9306 apds9306)
add_subdirectory_ifdef(CONFIG_BME68X_IAQ bme68x_iaq)
3 changes: 2 additions & 1 deletion app/drivers/sensor/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if SENSOR
rsource "apds9306/Kconfig"
endif # SENSOR
rsource "bme68x_iaq/Kconfig"
endif
47 changes: 47 additions & 0 deletions app/drivers/sensor/bme68x_iaq/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
if(CONFIG_EXTERNAL_USE_BOSCH_BSEC)
zephyr_library_compile_definitions_ifdef(CONFIG_BME68X_IAQ_SAMPLE_RATE_ULTRA_LOW_POWER
BSEC_SAMPLE_RATE=BSEC_SAMPLE_RATE_ULP
BSEC_SAMPLE_PERIOD_S=300
)

zephyr_library_compile_definitions_ifdef(CONFIG_BME68X_IAQ_SAMPLE_RATE_LOW_POWER
BSEC_SAMPLE_RATE=BSEC_SAMPLE_RATE_LP
BSEC_SAMPLE_PERIOD_S=3
)

zephyr_library_compile_definitions_ifdef(CONFIG_BME68X_IAQ_SAMPLE_RATE_CONTINUOUS
BSEC_SAMPLE_RATE=BSEC_SAMPLE_RATE_CONT
BSEC_SAMPLE_PERIOD_S=1
)

#if (CONFIG_FP_HARDABI)
# if (CONFIG_CPU_CORTEX_M33)
# zephyr_library_import(bsec_lib ${ZEPHYR_BASE}/../modules/lib/bsec/src/cortex-m33/fpv5-sp-d16-hard/libalgobsec.a)
# elseif(CONFIG_CPU_CORTEX_M4)
# zephyr_library_import(bsec_lib ${ZEPHYR_BASE}/../modules/lib/bsec/src/cortex-m4/fpv4-sp-d16-hard/libalgobsec.a)
# else()
# assert(0 "Unsupported configuration.")
# endif()
#else()
# zephyr_library_compile_definitions(BME68X_DO_NOT_USE_FPU)
# if (CONFIG_CPU_CORTEX_M33 OR CONFIG_CPU_CORTEX_M4)
# zephyr_library_import(bsec_lib ${ZEPHYR_BASE}/../modules/lib/bsec/src/cortex-m4/libalgobsec.a)
# else()
# assert(0 "Unsupported configuration.")
# endif()
#endif()
#zephyr_library_sources(bme68x_iaq.c)

zephyr_sources(bme68x_iaq.c)

# Add the Bosch BSEC2 library to the project.
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/src/ext_drivers/BSEC2/algo/normal_version/inc)
set(LIB_DIR ${PROJECT_SOURCE_DIR}/src/ext_drivers/BSEC2/algo/normal_version/bin/gcc/Cortex_M4)
add_library(libalgobsec STATIC IMPORTED PRIVATE)
set_target_properties(libalgobsec PROPERTIES IMPORTED_LOCATION ${LIB_DIR}/libalgobsec.a)
target_link_libraries(app PUBLIC libalgobsec)

# Add the Bosch BME68X-Sensor-API to the project.
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/src/ext_drivers/BME68x-Sensor-API)
zephyr_sources(${PROJECT_SOURCE_DIR}/src/ext_drivers/BME68x-Sensor-API/bme68x.c)
endif()
74 changes: 74 additions & 0 deletions app/drivers/sensor/bme68x_iaq/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#
# Copyright (c) 2023 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config BME68X_IAQ
bool "Use Bosch BSEC library"
depends on !BME680
depends on SETTINGS && !SETTINGS_NONE
depends on I2C
help
Enable the use of Bosch BSEC library.
This configuration depends on the BME680 Zephyr driver being disabled.

if BME68X_IAQ

config BME68X_IAQ_SAVE_INTERVAL_MINUTES
int "Period in minutes after which BSEC state is saved to flash"
default 60

config BME68X_IAQ_THREAD_STACK_SIZE
int "BSEC thread stack size"
default 4096

config BME68X_IAQ_EXPECTED_AMBIENT_TEMP
int "Expected ambient temperature in C"
default 25

config BME68X_IAQ_TEMPERATURE_OFFSET
int "BSEC temperature offset in centidegrees"
default 200 if BOARD_THINGY91_NRF9160_NS
default 200 if BOARD_THINGY53_NRF5340_CPUAPP
default 200 if BOARD_THINGY53_NRF5340_CPUAPP_NS
default 200 if BOARD_THINGY53_NRF5340_CPUNET
default 100
help
BSEC temperature offset. To account for external heat sources on the board.
The actual value is divided by 100. This is due to the Kconfig parser
not supporting floating point types.
The default value 200 is translated to 2.0 degrees celsius offset.

choice BME68X_IAQ_SAMPLE_RATE
prompt "Bosch BSEC sample mode"
default BME68X_IAQ_SAMPLE_RATE_LOW_POWER
help
Configuration that sets how often sensor data is sampled from the BSEC library.
Each mode corresponds an internal preset that decides how often data is sampled from the
BME680.

config BME68X_IAQ_SAMPLE_RATE_ULTRA_LOW_POWER
bool "BSEC low ultra power mode"
help
Sample data from BSEC severy 300 seconds.

config BME68X_IAQ_SAMPLE_RATE_LOW_POWER
bool "BSEC low power mode"
help
Sample data from BSEC every 3 seconds.

config BME68X_IAQ_SAMPLE_RATE_CONTINUOUS
bool "BSEC continuous mode"
help
Sample data from BSEC every second.
This is a particularly power-hungry sample mode that should only be considered for
testing purposes.

endchoice # BME68X_IAQ_SAMPLE_RATE

module = BME68X_IAQ
module-str = BME68X_IAQ
source "subsys/logging/Kconfig.template.log_config"

endif # BME68X_IAQ
Loading

0 comments on commit bc13b34

Please sign in to comment.