From c5d8937275e8a1c9d39e0090ca0b8e010f8793a1 Mon Sep 17 00:00:00 2001 From: tdk-opensource Date: Fri, 23 Aug 2024 13:34:53 -0700 Subject: [PATCH 1/2] CMake support improvements and bug fixes. --- CMakeLists.txt | 85 ++++++++------ doc/soniclib-v4-migration-guide.md | 1 + invn/soniclib/ch_driver.c | 3 +- invn/soniclib/details/ch_common.h | 4 +- invn/soniclib/soniclib.h | 8 +- make.ps1 | 175 +++++++++++++++-------------- 6 files changed, 153 insertions(+), 123 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5196156..bc63907 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,60 +22,66 @@ message(STATUS "CMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}") message(STATUS "") message(STATUS "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") -set(INCLUDE_SHASTA_SUPPORT OFF CACHE BOOL -"Build soniclib for shasta (ICU) targets. Default is whitney targets \ -(chx01).") - set(CHIRP_MAX_NUM_SENSORS 4 CACHE STRING "Max number of supported sensors.") -set(CHIRP_NUM_BUSES 2 CACHE STRING "Number of I2C/SPI buses used by sesnors.") -set(CHIRP_SENSOR_INT_PIN 1 CACHE STRING - "Pin used for interrupts (shasta only).") -set(CHIRP_SENSOR_TRIG_PIN 1 CACHE STRING - "Pin used for triggers (shasta only).") +set(CHIRP_NUM_BUSES 2 CACHE STRING "Number of I2C/SPI buses used by sensors.") +set(INCLUDE_SHASTA_SUPPORT OFF CACHE BOOL + "Build soniclib for shasta (ICU) targets. Default is whitney targets \ + (chx01).") +set(CHIRP_SENSOR_INT_PIN 1 CACHE STRING "Pin used for interrupts (shasta only).") +set(CHIRP_SENSOR_TRIG_PIN 1 CACHE STRING "Pin used for triggers (shasta only).") set(CHIRP_INIT_FW_TYPE "FULL" CACHE STRING -"Type of init firmware (shasta only). NO_TX_OPTIMIZATION leaves out the \ -transmit optimization feature but saves some space. NONE means no init \ -firmware. Not all firmware variants support the NONE option.") + "Type of init firmware (shasta only). NO_TX_OPTIMIZATION leaves out the \ + transmit optimization feature but saves some space. NONE means no init \ + firmware. Not all firmware variants support the NONE option.") set_property(CACHE CHIRP_INIT_FW_TYPE PROPERTY STRINGS FULL - NO_TX_OPTIMIZATION - NONE) - -set(INCLUDE_ALGO_EXTERNAL OFF CACHE BOOL -"If set, do not include gpt (rangefinder) support") + NO_TX_OPTIMIZATION + NONE) +set(CHIRP_MAIN_FW_TYPE "NONE" CACHE STRING + "Main firmware to embed (if using one of the fw supplied with Soniclib)\ + Can be one of the follwing : NONE (build with another fw),\ + GPT, CH101_GPR, CH201_GPRMT, CHX01_FREQSWEEP") +set_property(CACHE CHIRP_MAIN_FW_TYPE PROPERTY STRINGS NONE, GPT, + CH101_GPR, CH201_GPRMT, + CHX01_FREQSWEEP) +set(INCLUDE_ALGO_EXTERNAL ON CACHE BOOL + "If set, do not include gpt (rangefinder) support (deprecated)") set(CHIRP_LOG_LEVEL 4 CACHE STRING - "Define the log level to use for the Soniclib internal log messages (4 = CH_LOG_LEVEL_ERROR)") - - + "Define the log level to use for the Soniclib internal log messages \ + (4 = CH_LOG_LEVEL_ERROR)") set(RUN_UNIT_TEST OFF CACHE BOOL "If set, compile and run unit tests.") -message(RUN_UNIT_TEST "RUN_UNIT_TEST=${RUN_UNIT_TEST}") - if(RUN_UNIT_TEST) set(CMAKE_C_FLAGS --coverage) set(GCOV_LINK_FLAGS "--coverage") endif() +message(STATUS "CHIRP_MAX_NUM_SENSORS=${CHIRP_MAX_NUM_SENSORS}") +message(STATUS "CHIRP_NUM_BUSES=${CHIRP_NUM_BUSES}") +message(STATUS "CHIRP_SENSOR_INT_PIN=${CHIRP_SENSOR_INT_PIN}") +message(STATUS "CHIRP_SENSOR_TRIG_PIN=${CHIRP_SENSOR_TRIG_PIN}") + message(STATUS "CHIRP_INIT_FW_TYPE=${CHIRP_INIT_FW_TYPE}") +message(STATUS "CHIRP_MAIN_FW_TYPE=${CHIRP_MAIN_FW_TYPE}") message(STATUS "INCLUDE_ALGO_EXTERNAL=${INCLUDE_ALGO_EXTERNAL}") message(STATUS "INCLUDE_SHASTA_SUPPORT=${INCLUDE_SHASTA_SUPPORT}") message(STATUS "CHIRP_LOG_LEVEL=${CHIRP_LOG_LEVEL}") - +message(STATUS "RUN_UNIT_TEST=${RUN_UNIT_TEST}") set(SOURCES ${SRC_PATH}/chbsp_dummy.c ${SRC_PATH}/ch_api.c ${SRC_PATH}/ch_common.c ${SRC_PATH}/ch_driver.c - ${SRC_PATH}/ch_math_utils.c - ${SRC_PATH}/extra/ch_extra_display_utils.c) + ${SRC_PATH}/ch_math_utils.c) if (NOT ${CHIRP_LOG_LEVEL} EQUAL 6) # Build ch_log module if CHIRP_LOG_LEVEL isn't CH_LOG_LEVEL_DISABLE set(SOURCES ${SOURCES} - ${SRC_PATH}/ch_log.c) + ${SRC_PATH}/ch_log.c + ${SRC_PATH}/extra/ch_extra_display_utils.c) endif() if(INCLUDE_SHASTA_SUPPORT) - if (NOT INCLUDE_ALGO_EXTERNAL) + if (CHIRP_MAIN_FW_TYPE STREQUAL "GPT" OR NOT INCLUDE_ALGO_EXTERNAL) set(SOURCES ${SOURCES} ${SENS_FW_PATH}/icu_gpt/icu_gpt.c ${SENS_FW_PATH}/icu_gpt/icu_gpt_fw.c) @@ -92,33 +98,40 @@ if(INCLUDE_SHASTA_SUPPORT) endif() else() set(SOURCES ${SOURCES} + ${SRC_PATH}/ch_rangefinder.c) + if (CHIRP_MAIN_FW_TYPE STREQUAL "CH101_GPR") + set(SOURCES ${SOURCES} ${SENS_FW_PATH}/ch101/ch101_gpr.c - ${SENS_FW_PATH}/ch101/ch101_gpr_fw.c + ${SENS_FW_PATH}/ch101/ch101_gpr_fw.c) + endif() + if (CHIRP_MAIN_FW_TYPE STREQUAL "CH201_GPRMT") + set(SOURCES ${SOURCES} ${SENS_FW_PATH}/ch201/ch201_gprmt.c - ${SENS_FW_PATH}/ch201/ch201_gprmt_fw.c + ${SENS_FW_PATH}/ch201/ch201_gprmt_fw.c) + endif() + if (CHIRP_MAIN_FW_TYPE STREQUAL "CHX01_FREQSWEEP") + set(SOURCES ${SOURCES} ${SENS_FW_PATH}/chx01/chx01_freqsweep.c - ${SENS_FW_PATH}/chx01/chx01_freqsweep_fw.c - ${SRC_PATH}/ch_rangefinder.c) + ${SENS_FW_PATH}/chx01/chx01_freqsweep_fw.c) + endif() endif() - add_library(${PROJ_NAME} STATIC ${SOURCES}) - target_include_directories(${PROJ_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(${PROJ_NAME} - PRIVATE -DINVN_SONICLIB_INTERNAL_BOARD_CONFIG + PUBLIC -DINVN_SONICLIB_INTERNAL_BOARD_CONFIG -DCHIRP_MAX_NUM_SENSORS=${CHIRP_MAX_NUM_SENSORS} -DCHIRP_NUM_BUSES=${CHIRP_NUM_BUSES} -DCH_LOG_MODULE_LEVEL=${CHIRP_LOG_LEVEL}) if(INCLUDE_SHASTA_SUPPORT) target_compile_definitions(${PROJ_NAME} PUBLIC -DINCLUDE_SHASTA_SUPPORT - PRIVATE -DCHIRP_SENSOR_INT_PIN=${CHIRP_SENSOR_INT_PIN} + PUBLIC -DCHIRP_SENSOR_INT_PIN=${CHIRP_SENSOR_INT_PIN} -DCHIRP_SENSOR_TRIG_PIN=${CHIRP_SENSOR_TRIG_PIN}) else() - target_compile_definitions(${PROJ_NAME} PRIVATE -DINCLUDE_WHITNEY_SUPPORT) + target_compile_definitions(${PROJ_NAME} PUBLIC -DINCLUDE_WHITNEY_SUPPORT) endif() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json diff --git a/doc/soniclib-v4-migration-guide.md b/doc/soniclib-v4-migration-guide.md index 77676b4..045d7f3 100644 --- a/doc/soniclib-v4-migration-guide.md +++ b/doc/soniclib-v4-migration-guide.md @@ -170,6 +170,7 @@ uint8_t icu_gpt_set_static_filter(ch_dev_t *dev_ptr, uint8_t meas_num, uint16_t uint16_t icu_gpt_get_static_filter(ch_dev_t *dev_ptr, uint8_t meas_num) uint8_t icu_gpt_set_filter_update(ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t update_interval) uint8_t icu_gpt_get_filter_update(ch_dev_t *dev_ptr, uint8_t meas_num) +``` #### New API diff --git a/invn/soniclib/ch_driver.c b/invn/soniclib/ch_driver.c index a56f402..d2cc0f9 100644 --- a/invn/soniclib/ch_driver.c +++ b/invn/soniclib/ch_driver.c @@ -689,7 +689,8 @@ void chdrv_int_callback(ch_group_t *grp_ptr, uint8_t dev_num) { uint16_t last_meas_reg_addr = (uint16_t)(uintptr_t) & ((dev_ptr->sens_cfg_addr)->raw.last_measurement); chdrv_read_byte(dev_ptr, last_meas_reg_addr, &last_meas); - dev_ptr->last_measurement = last_meas; + dev_ptr->last_measurement = last_meas & ~LAST_MEASUREMENT_CONTINUOUS; + dev_ptr->is_continuous = (last_meas & LAST_MEASUREMENT_CONTINUOUS) > 0; uint8_t last_fmt; uint16_t last_fmt_reg_addr = (uint16_t)(uintptr_t) & ((dev_ptr->sens_cfg_addr)->raw.iq_output_format); diff --git a/invn/soniclib/details/ch_common.h b/invn/soniclib/details/ch_common.h index 965dbd6..7ac7499 100644 --- a/invn/soniclib/details/ch_common.h +++ b/invn/soniclib/details/ch_common.h @@ -150,7 +150,9 @@ extern "C" { #endif /* INCLUDE_WHITNEY_SUPPORT */ -#define NSEC_PER_SEC (1000000000U) +#ifndef NSEC_PER_SEC +#define NSEC_PER_SEC (1000000000U) +#endif #define PMUT_FREQUENCY_ERROR_CODE (1) // this indicates some error in the frequency measurement /* Function prototypes */ diff --git a/invn/soniclib/soniclib.h b/invn/soniclib/soniclib.h index be66ffb..5fa4b03 100644 --- a/invn/soniclib/soniclib.h +++ b/invn/soniclib/soniclib.h @@ -113,7 +113,7 @@ extern "C" { /* SonicLib API/Driver version */ #define SONICLIB_VER_MAJOR (4) /*!< SonicLib major version. */ #define SONICLIB_VER_MINOR (2) /*!< SonicLib minor version. */ -#define SONICLIB_VER_REV (1) /*!< SonicLib revision. */ +#define SONICLIB_VER_REV (5) /*!< SonicLib revision. */ #define SONICLIB_VER_SUFFIX "" /*!< SonicLib version suffix (contains pre-release info) */ /***** DO NOT MODIFY ANY VALUES BEYOND THIS POINT! *****/ @@ -3194,6 +3194,12 @@ void ch_meas_init_segment_count(ch_meas_segment_t *seg_ptr, uint16_t num_cycles, * * This function initializes the measurement segment descriptor specified by \a seg_ptr as * a receive segment. + * The number of samples of added to the segments is limited by the maximum number of rx samples + * that firmware can read and by the number of cycles a segment can store. + * The length of segment in samples is converted to a number of cycles. + * A segment have a maximum length of 65535 cycles. + * If the number of sample exceeds the limitation, define the segments manually and import them + * to a measure queue using \a ch_meas_import() */ void ch_meas_init_segment_rx(ch_meas_segment_t *seg_ptr, uint16_t num_samples, ch_odr_t odr, uint8_t gain_reduce, uint8_t atten, uint8_t int_enable); diff --git a/make.ps1 b/make.ps1 index ad155a8..e76e9e8 100644 --- a/make.ps1 +++ b/make.ps1 @@ -17,16 +17,16 @@ to build Release, MinSizeRel, RelWithDebInfo, and Debug. (shasta-only) Specify which init FW to use in the build. Options are FULL, NO_TX_OPTIMIZATION, and NONE. Default is to build all. +.PARAMETER MainFwOptions +Specify which main FW to use in the build. Options are NONE, +GPT, CH101_GPR, CH201_GPRMT, and CHX01_FREQSWEEP. Default is to build GPT is SensorType is SHASTA and all if SensorType is Whitney. + .PARAMETER CMakeToolchainFile Specify the path to the CMakeToolchain file. The deafult is arm-non-eabi-m4.cmake. .PARAMETER Generator The CMake generator to use. Default is "MinGW Makefiles". -.PARAMETER ExternalAlgoOptions - -Options to use for INCLDUE_ALGO_EXTERNAL. Must be list of OFF, ON. - .PARAMETER SensorTypes List of sensor types to build for. Options are SHASTA (ICU-x0201) and WHITNEY @@ -62,9 +62,9 @@ param( [switch]$Clean, [string[]]$BuildTypes = ("Release", "MinSizeRel", "RelWithDebInfo", "Debug"), [string[]]$InitFwOptions = ("FULL", "NO_TX_OPTIMIZATION", "NONE"), + [string[]]$MainFwOptions = ("GPT", "CH101_GPR", "CH201_GPRMT", "CHX01_FREQSWEEP", "NONE"), [string]$CMakeToolchainFile = "CMakeToolchains/arm-none-eabi-m4.cmake", [string]$Generator = "MinGW Makefiles", - [string[]]$ExternalAlgoOptions = ("OFF", "ON"), [string[]]$LogLevels = ("Disabled", "Min", "Max"), [switch]$Install, [switch]$RunTests, @@ -127,36 +127,99 @@ if ($Coverage) { } ForEach ($BuildType in $BuildTypes) { - # shasta build - if ($SensorTypes -Contains "SHASTA") { - ForEach ($InitFwOption in $InitFwOptions) { - ForEach ($ExternalAlgoOption in $ExternalAlgoOptions) { - ForEach ($LogLevel in $LogLevels) { - if ($BuildType -eq "Debug") { - Switch($LogLevel) { - "Disabled" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_DISABLE).value__} - "Min" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__} - "Max" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_TRACE).value__} - } - $LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__ - } else { - # For other builds, always use the default log level - if ($LogLevel -eq "Min") { + ForEach($SensorType in $SensorTypes) { + # shasta build + if ($SensorType -Contains "SHASTA") { + $MainFwOptions = $MainFwOptions|where{$_ -match "(GPT|NONE)"} # Keep only shasta fw + ForEach ($InitFwOption in $InitFwOptions) { + ForEach ($MainFwOption in $MainFwOptions) { + ForEach ($LogLevel in $LogLevels) { + if ($BuildType -eq "Debug") { + Switch($LogLevel) { + "Disabled" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_DISABLE).value__} + "Min" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__} + "Max" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_TRACE).value__} + } $LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__ } else { - # return # continue - continue + # For other builds, always use the default log level + if ($LogLevel -eq "Min") { + $LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__ + } else { + # return # continue + continue + } + } + $BuildConfig = "shasta_$InitFwOption`_Fw_$MainFwOption`_$BuildType`_log$LogLevel".ToLower() + $SubBuildDir = Join-Path "$BuildDir" "$BuildConfig" + cmake -G "$Generator" ` + -DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" ` + -DINCLUDE_SHASTA_SUPPORT:BOOL=ON ` + -DCMAKE_BUILD_TYPE:STRING="$BuildType" ` + -DCHIRP_INIT_FW_TYPE="$InitFwOption" ` + -B "$SubBuildDir" ` + -DCHIRP_MAIN_FW_TYPE="$MainFwOption" ` + -DCHIRP_LOG_LEVEL="$LogLevelInt" ` + -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON ` + $RUN_UNIT_TEST + if ($LASTEXITCODE) { exit $LASTEXITCODE } + try { + Build-Project "$SubBuildDir" + if ($RunTests) { + # ctest --test-dir "$SubBuildDir/test/unit_test" --output-junit "junitoutput.xml" # CMake 3.21+ + ctest --test-dir "$SubBuildDir/test/unit_test" -VV --output-on-failure --no-compress-output "-D" "ExperimentalTest" + + # Generate coverage report + python -m gcovr ` + --print-summary ` + --branches ` + --calls ` + --decisions ` + --json "$SubBuildDir/$BuildConfig`_coverage.json" --json-pretty ` + --gcov-executable "$MingwGccPath/bin/gcov.exe" ` + --root $source_dir ` + "$SubBuildDir/CMakeFiles/soniclib.dir/invn/soniclib" + } + if ($Install) { + cmake --install "$SubBuildDir" + } + } + catch { + Write-Output $_ + exit 1 } } - $BuildConfig = "shasta_$InitFwOption`_extalgo$ExternalAlgoOption`_$BuildType`_log$LogLevel".ToLower() + } + } + } + # whitney build + if ($SensorType -Contains "WHITNEY") { + ForEach ($LogLevel in $LogLevels) { + if ($BuildType -eq "Debug") { + Switch($LogLevel) { + "Disabled" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_DISABLE).value__} + "Min" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__} + "Max" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_TRACE).value__} + } + $LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__ + } else { + # For other builds, always use the default log level + if ($LogLevel -eq "Min") { + $LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__ + } else { + # return # continue + continue + } + } + $MainFwOptions = $MainFwOptions|where{$_ -match "(CH101_GPR|CH201_GPRMT|CHX01_FREQSWEEP)"} # Keep only whitney fw + ForEach ($MainFwOption in $MainFwOptions) { + $BuildConfig = "whitney_Fw_$MainFwOption`_$BuildType`_log$LogLevel".ToLower() $SubBuildDir = Join-Path "$BuildDir" "$BuildConfig" cmake -G "$Generator" ` -DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" ` - -DINCLUDE_SHASTA_SUPPORT:BOOL=ON ` -DCMAKE_BUILD_TYPE:STRING="$BuildType" ` - -DCHIRP_INIT_FW_TYPE="$InitFwOption" ` -B "$SubBuildDir" ` - -DINCLUDE_ALGO_EXTERNAL:BOOL="$ExternalAlgoOption" ` + -DCHIRP_MAIN_FW_TYPE="$MainFwOption" ` -DCHIRP_LOG_LEVEL="$LogLevelInt" ` -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON ` $RUN_UNIT_TEST @@ -165,7 +228,7 @@ ForEach ($BuildType in $BuildTypes) { Build-Project "$SubBuildDir" if ($RunTests) { # ctest --test-dir "$SubBuildDir/test/unit_test" --output-junit "junitoutput.xml" # CMake 3.21+ - ctest --test-dir "$SubBuildDir/test/unit_test" -VV --output-on-failure --no-compress-output "-D" "ExperimentalTest" + ctest --test-dir "$SubBuildDir/test/unit_test" --no-compress-output "-D" "ExperimentalTest" # Generate coverage report python -m gcovr ` @@ -176,7 +239,7 @@ ForEach ($BuildType in $BuildTypes) { --json "$SubBuildDir/$BuildConfig`_coverage.json" --json-pretty ` --gcov-executable "$MingwGccPath/bin/gcov.exe" ` --root $source_dir ` - "$SubBuildDir/CMakeFiles/soniclib.dir/invn/soniclib" + "$SubBuildDir/CMakeFiles/soniclib.dir/invn/soniclib" } if ($Install) { cmake --install "$SubBuildDir" @@ -190,62 +253,6 @@ ForEach ($BuildType in $BuildTypes) { } } } - # whitney build - if ($SensorTypes -Contains "WHITNEY") { - ForEach ($LogLevel in $LogLevels) { - if ($BuildType -eq "Debug") { - Switch($LogLevel) { - "Disabled" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_DISABLE).value__} - "Min" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__} - "Max" {$LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_TRACE).value__} - } - $LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__ - } else { - # For other builds, always use the default log level - if ($LogLevel -eq "Min") { - $LogLevelInt = ([ChLogLevels]::CH_LOG_LEVEL_ERROR).value__ - } else { - # return # continue - continue - } - } - $BuildConfig = "whitney_$BuildType`_log$LogLevel".ToLower() - $SubBuildDir = Join-Path "$BuildDir" "$BuildConfig" - cmake -G "$Generator" ` - -DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" ` - -DCMAKE_BUILD_TYPE:STRING="$BuildType" ` - -B "$SubBuildDir" ` - -DCHIRP_LOG_LEVEL="$LogLevelInt" ` - -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON ` - $RUN_UNIT_TEST - if ($LASTEXITCODE) { exit $LASTEXITCODE } - try { - Build-Project "$SubBuildDir" - if ($RunTests) { - # ctest --test-dir "$SubBuildDir/test/unit_test" --output-junit "junitoutput.xml" # CMake 3.21+ - ctest --test-dir "$SubBuildDir/test/unit_test" --no-compress-output "-D" "ExperimentalTest" - - # Generate coverage report - python -m gcovr ` - --print-summary ` - --branches ` - --calls ` - --decisions ` - --json "$SubBuildDir/$BuildConfig`_coverage.json" --json-pretty ` - --gcov-executable "$MingwGccPath/bin/gcov.exe" ` - --root $source_dir ` - "$SubBuildDir/CMakeFiles/soniclib.dir/invn/soniclib" - } - if ($Install) { - cmake --install "$SubBuildDir" - } - } - catch { - Write-Output $_ - exit 1 - } - } - } } exit 0 From 889a4498c785cf8a186af2900167ab6116b4c8ec Mon Sep 17 00:00:00 2001 From: Mitchell Kline Date: Mon, 16 Sep 2024 11:29:09 -0500 Subject: [PATCH 2/2] [README] Update readme to match the latest changes in cmake build. --- README.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0660e5f..bbd6401 100644 --- a/README.md +++ b/README.md @@ -76,12 +76,13 @@ Additionally, there are several CMake variables that control various build options. These are as follows. See the `invn/soniclib/details/chirp_board_config.h` header for details. -* `CHIRP_INIT_FW_TYPE`: One of `FULL`, `NO_TX_OPTIMIZATION`, or `NONE`. * `CHIRP_MAX_NUM_SENSORS`: Maximum number of sensors supported. * `CHIRP_NUM_BUSES`: Number of SPI/I2C buses supported. * `CHIRP_SENSOR_INT_PIN`: (ICU-x0201 only) Pin to use for interrupts. * `CHIRP_SENSOR_TRIG_PIN`: (ICU-x0201 only) Pin to use for triggers. -* `INCLUDE_SHASTA_SUPPORT`: Build for Shasta (ICU) architecture sensors. +* `CHIRP_MAIN_FW_TYPE` : Select the main firmware to build with, can be one of `NONE` (fw built externally) or one of the firmware embedded by default with Soniclib `GPT` (for shasta devices), `CH101_GPR`, `CH201_GPRMT` or `CHX01_FREQSWEEP` +* `CHIRP_INIT_FW_TYPE`: Select an init firmware to build, if necessary in one of `FULL`, `NO_TX_OPTIMIZATION`, or `NONE`. +* `CHIRP_LOG_LEVEL` : Define the log level to use for the Soniclib internal log messages These variables can be set through the CMake GUI, through command line -D options in the main CMake command, or manually through the `CMakeCache.txt` file @@ -96,10 +97,28 @@ line-continuation. ```powershell cmake -G "MinGW Makefiles" ` -DCMAKE_TOOLCHAIN_FILE="CMakeToolchains/arm-none-eabi-m4.cmake" ` - -DINCLUDE_SHASTA_SUPPORT:BOOL=ON ` + -DCHIRP_MAIN_FW_TYPE:STRING=GPT ` -DCHIRP_INIT_FW_TYPE:STRING=NO_TX_OPTIMIZATION ` -B build ``` +To build Soniclib from a parent cmake project, you can follow this example : + +```cmake +set(CHIRP_MAX_NUM_SENSORS 1 CACHE STRING "one sensor connected" FORCE) +set(CHIRP_NUM_BUSES 1 CACHE STRING "one sensor connected" FORCE) +set(INCLUDE_SHASTA_SUPPORT ON CACHE BOOL "using ICU sensors" FORCE) +set(CHIRP_SENSOR_INT_PIN 1 CACHE STRING "use INT1 in freerun mode" FORCE) +set(CHIRP_SENSOR_TRIG_PIN 1 CACHE STRING "use INT1 in freerun mode" FORCE) +set(CHIRP_INIT_FW_TYPE "NO_TX_OPTIMIZATION" CACHE STRING "using fw presencev2" FORCE) +set(CHIRP_LOG_LEVEL 2 CACHE STRING "log=info" FORCE) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/invn/soniclib/) + +... + +target_link_libraries(app PRIVATE soniclib) +``` + ## Copyright -© Copyright 2016-2023, TDK/InvenSense. All rights reserved. +© Copyright 2016-2024, TDK/InvenSense. All rights reserved.