From 77d37d88a4f8b9edf22f1c5a1f31e007a6267abc Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Thu, 19 Dec 2024 00:44:49 +0300 Subject: [PATCH 1/2] do not use spi in v3 by default, use it only with mpu9250 --- Src/drivers/mpu9250/CMakeLists.txt | 8 ++++++++ Src/platform/stm32g0b1/CMakeLists.txt | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Src/drivers/mpu9250/CMakeLists.txt b/Src/drivers/mpu9250/CMakeLists.txt index 9cd2c32..9b8acc7 100644 --- a/Src/drivers/mpu9250/CMakeLists.txt +++ b/Src/drivers/mpu9250/CMakeLists.txt @@ -1,6 +1,14 @@ # Copyright (C) 2023 Dmitry Ponomarev # Distributed under the terms of the GPL v3 license, available in the file LICENSE. +# Include guard +if(SRC_DRIVERS_MPU9250_DIR) + return() +endif() +set(SRC_DRIVERS_MPU9250_DIR ${CMAKE_CURRENT_LIST_DIR}) + list(APPEND APPLICATION_SOURCES ${CMAKE_CURRENT_LIST_DIR}/mpu9250.cpp ) + +include(${ROOT_DIR}/Src/peripheral/spi/CMakeLists.txt) diff --git a/Src/platform/stm32g0b1/CMakeLists.txt b/Src/platform/stm32g0b1/CMakeLists.txt index f1787c0..de62ca2 100644 --- a/Src/platform/stm32g0b1/CMakeLists.txt +++ b/Src/platform/stm32g0b1/CMakeLists.txt @@ -6,7 +6,6 @@ cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH PLATFORM_DIR) cmake_path(GET PLATFORM_DIR PARENT_PATH SRC_DIR) cmake_path(GET SRC_DIR PARENT_PATH ROOT_DIR) -include(${ROOT_DIR}/Src/peripheral/spi/CMakeLists.txt) include(${ROOT_DIR}/Src/peripheral/adc/CMakeLists.txt) set(EXECUTABLE ${PROJECT_NAME}.out) From 3841b173851f419b1a857893d66d128965b2704a Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Thu, 19 Dec 2024 00:58:02 +0300 Subject: [PATCH 2/2] move NUM_OF_CAN_BUSES from toolchain to the root cmake file --- CMakeLists.txt | 8 ++++---- cmake/Toolchain-arm-none-eabi.cmake | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcce0ab..8c8e634 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,15 +31,15 @@ elseif(USE_PLATFORM_NODE_V3) set(APP_PLATFORM stm32g0b1) set(PLATFORM_NAME v3) include(${CMAKE_DIR}/stm32g0b1.cmake) + add_compile_definitions(CYPHAL_NUM_OF_CAN_BUSES=2) else() message(SEND_ERROR "Platform Error: Either v2 (stm32f103), v3 (stm32g0) or SITL (Linux) should be specified.") endif() # Option 2. Choose the protocol -if(CAN_PROTOCOL STREQUAL "dronecan" OR CAN_PROTOCOL STREQUAL "cyphal" OR CAN_PROTOCOL STREQUAL "both") - set(APPLICATION_DIR ${ROOT_DIR}/Src/applications/${CAN_PROTOCOL}) -else() - message(SEND_ERROR "CAN_PROTOCOL is unknown.") +set(APPLICATION_DIR ${ROOT_DIR}/Src/applications/${CAN_PROTOCOL}) +if(NOT (EXISTS ${APPLICATION_DIR} AND IS_DIRECTORY ${APPLICATION_DIR})) + message(FATAL_ERROR "CAN_PROTOCOL '${CAN_PROTOCOL}' is unknown.") endif() # Set build dir based on hardware version and protocol diff --git a/cmake/Toolchain-arm-none-eabi.cmake b/cmake/Toolchain-arm-none-eabi.cmake index b3d126b..247aafa 100644 --- a/cmake/Toolchain-arm-none-eabi.cmake +++ b/cmake/Toolchain-arm-none-eabi.cmake @@ -29,6 +29,4 @@ set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${TARGET_ARCHITECTURE} -mthumb -lc -lm -lnosys add_compile_definitions( USE_HAL_DRIVER ${CPU} - CYPHAL_NUM_OF_CAN_BUSES=2 - NUM_OF_CAN_BUSES=2 )