diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt index 113758140..a0ec8eff1 100644 --- a/firmware/CMakeLists.txt +++ b/firmware/CMakeLists.txt @@ -41,7 +41,6 @@ if(NOT PROJECT_NAME) endif() # Check that the project and platform folders exist. - set(DIR_PROJECT "${CMAKE_CURRENT_SOURCE_DIR}/projects/${PROJECT}") assert_exists(DIR PATH ${DIR_PROJECT} START "Verifying ${PROJECT} is a project" @@ -70,6 +69,7 @@ assert_exists(FILE PATH ${MCAL_CONF_FILE} ) include(${MCAL_CONF_FILE}) # Should define MCAL + if(NOT DEFINED MCAL) message(FATAL_ERROR "Expected MCAL to be defined in \"${MCAL_CONF_FILE}\".") endif() @@ -89,22 +89,18 @@ assert_exists(FILE PATH ${POSTBUILD_FILE} ${POSTBUILD_FILE} "\nand leave it empty." ) -# Sets the compiler, linker, etc based on the mcal's Toolchain.cmake file -set(TOOLCHAIN_FILE "${DIR_MCAL}/Toolchain.cmake") -assert_exists(FILE PATH ${TOOLCHAIN_FILE} - START "Finding MCAL toolchain file" - PASS "Found" - FAIL "Not found. If no toolchain setup is required, create the file\n" - ${TOOLCHAIN_FILE} "\nand leave it empty." -) - list(POP_BACK CMAKE_MESSAGE_INDENT) message(CHECK_PASS "Success") # Options are parsed. Start building message(STATUS "Building \"${PROJECT}\" for \"${PLATFORM}\" with mcal \"${MCAL}\".") -set(CMAKE_TOOLCHAIN_FILE ${TOOLCHAIN_FILE}) +# clangd export settings +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF) + +project(${PROJECT_NAME}) + enable_language(C CXX ASM) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) @@ -114,14 +110,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) set(CMAKE_CXX_EXTENSIONS ON) -project(${PROJECT_NAME}) - -# clangd export settings -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF) - add_executable(main) -add_library(bindings) add_subdirectory(shared) # provides "shared" (library) add_subdirectory(${DIR_MCAL}) # provides "mcal-" (library) @@ -130,13 +119,5 @@ add_subdirectory(${DIR_PROJECT}) # modifies "main" (executable) add_subdirectory(${DIR_PLATFORM}) # modifies "bindings" (library) target_link_libraries(main PRIVATE shared) -target_link_libraries(main PRIVATE bindings) - -# Only link/include RTOS if the project supports RTOS -# The project needs to provide an underlying OS target -# in the platform/${PLATFORM_NAME}/CMakeLists.txt -if(TARGET os) - target_link_libraries(main PRIVATE os) -endif() include("${POSTBUILD_FILE}") diff --git a/firmware/cmake/build_cubemx.cmake b/firmware/cmake/build_cubemx.cmake index f24afbe1b..4ec64d0b4 100644 --- a/firmware/cmake/build_cubemx.cmake +++ b/firmware/cmake/build_cubemx.cmake @@ -1,120 +1,21 @@ # Blake Freer -# April 13, 2023 -# This file is included in the cubemx/CMakeLists.txt file of all projects' +# November 2024 + +# Generate code from CubeMX. The Makefile modifies the toolchain to fit our +# system. +# This file is included in the mcal_conf.cmake file of all projects' # platforms that use the stm32f767 mcal -message(STATUS "Generating from CubeMX and adding custom targets.") execute_process( - # Calls generate_cubemx.mk in the context of this file, which is adjacent to - # the board_config.ioc file. - COMMAND ${CMAKE_MAKE_PROGRAM} "--file=${CMAKE_SOURCE_DIR}/cmake/generate_cubemx.mk" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND make "--file=${CMAKE_SOURCE_DIR}/cmake/generate_cubemx.mk" + WORKING_DIRECTORY ${DIR_PLATFORM}/cubemx RESULT_VARIABLE status ) if(status AND NOT status EQUAL 0) message(FATAL_ERROR - "Failed to generate from CubeMX. You should manually 'Generate Code' \ - before building." + "${out} Failed to generate from CubeMX. You should manually 'Generate Code' before building." ) endif() -set(CUSTOM_MAKEFILE "${CMAKE_CURRENT_SOURCE_DIR}/CustomMakefile.mk") - -message(STATUS "Building CubeMX objects with the auto-generated Makefile") -execute_process( - # Build all cubemx sources to their objects. This target is added to the - # cubemx Makefile by generate_cubemx.mk. - COMMAND ${CMAKE_MAKE_PROGRAM} "objects" "--file=${CUSTOM_MAKEFILE}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) - -function(extract_make_variable output makefile var_name) - # Get a variable from a Makefile - # This requires the Makefile to have the following target & recipe - # - # %.value: - # @echo $($*) - # - # generate_cubemx.mk appends this target to the cubemx Makefile - # See custom_cubemx_targets.mk - execute_process( - COMMAND ${CMAKE_MAKE_PROGRAM} "--file=${makefile}" "${var_name}.value" "--no-print-directory" - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND_ECHO STDOUT - OUTPUT_VARIABLE value - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - message(VERBOSE "The make variable ${var_name} has the value \"${value}\"") - set(${output} ${value} PARENT_SCOPE) -endfunction() - -# Get C_INCLUDES, split string to a list, and remove the -I prefix -extract_make_variable(include_str "${CUSTOM_MAKEFILE}" "C_INCLUDES") -separate_arguments(C_INCLUDES NATIVE_COMMAND ${include_str}) -list(TRANSFORM C_INCLUDES REPLACE "^-I" "") - -# Get Global #defines -extract_make_variable(c_def_str "${CUSTOM_MAKEFILE}" "C_DEFS") -separate_arguments(C_DEFS NATIVE_COMMAND ${c_def_str}) -list(TRANSFORM C_DEFS REPLACE "^-D" "") - -# Get MCU which includes the CPU name (cortex-m7), floating point unit, etc -extract_make_variable(MCU "${CUSTOM_MAKEFILE}" "MCU") -separate_arguments(MCU NATIVE_COMMAND ${MCU}) - -# Get the linker flags. These are needed since we manually link the objects -# instead of using the cubemx Makefile. -extract_make_variable(ldflags_str "${CUSTOM_MAKEFILE}" "LDFLAGS") -separate_arguments(LDFLAGS NATIVE_COMMAND ${ldflags_str}) -# Need to fully specify the link script path -list(TRANSFORM LDFLAGS REPLACE "^-T" "-T${CMAKE_CURRENT_SOURCE_DIR}/") -# Cannot have "build/" in front of the map output. -list(TRANSFORM LDFLAGS REPLACE "Map=.*\\.map" "Map=${CMAKE_PROJECT_NAME}.map") - -# Prepare the driver target -add_library(driver) -set_target_properties(driver PROPERTIES LINKER_LANGUAGE C) # required since the source files are object files - -# The sources are all the object files compiled with the CubeMX Makefile -FILE(GLOB OBJ_DRIVER CONFIGURE_DEPENDS "build/*.o") -target_sources(driver PUBLIC ${OBJ_DRIVER}) - -# Apply the Makefile settings to the targets -target_include_directories(driver PUBLIC ${C_INCLUDES}) -target_compile_definitions(driver PUBLIC ${C_DEFS}) - -target_compile_options(driver -PUBLIC - ${MCU} - -fdata-sections - -ffunction-sections - -Wall - -Wextra - -Wpedantic - -Wshadow - -Wdouble-promotion - -Wformat=2 -Wformat-truncation - -Wundef - -fno-common - -Wno-unused-parameter - -Wno-missing-field-initializers - $<$: - -Wno-old-style-cast - -Wno-useless-cast - -Wconversion - -Wno-volatile - -Wsuggest-override> - $<$:-Og -g3 -ggdb> - $<$:-Og -g0> -) - -# Notice that the linker settings are set for the "main" target. -target_link_options(main -PRIVATE - ${LDFLAGS} - $<$,10.3.1>:-Wl,--no-warn-rwx-segments> - -Wl,--start-group - -Wl,--end-group - -Wl,--print-memory-usage -) +set(CMAKE_TOOLCHAIN_FILE "${DIR_PLATFORM}/cubemx/cmake/racecar-toolchain.cmake") \ No newline at end of file diff --git a/firmware/cmake/custom_cubemx_targets.mk b/firmware/cmake/custom_cubemx_targets.mk deleted file mode 100644 index 728c26442..000000000 --- a/firmware/cmake/custom_cubemx_targets.mk +++ /dev/null @@ -1,17 +0,0 @@ - -# The following targets are appended to the end of the autogenerated Makefile -# from CubeMX. - -# Add a recipe for building the sources to objects without linking them. -# This is used by build_cubemx.cmake -objects: $(OBJECTS) - - -# Add a recipe for printing any Makefile variable to stdout -# This is used by build_cubemx.cmake. -# Example -# $ make LIBS.value -# -lc -lm -lnosys - -%.value: - @echo $($*) diff --git a/firmware/cmake/custom_toolchain.sh b/firmware/cmake/custom_toolchain.sh new file mode 100644 index 000000000..d0be65158 --- /dev/null +++ b/firmware/cmake/custom_toolchain.sh @@ -0,0 +1,14 @@ +# Modify the CubeMX-generated toolchain file to work with out build system. +# These commands are not in the Makefile since Make messes with the ${} characters +# in the `sed` replacement string. + +# CubeMX forces CMake to skip its automatic compiler detection, which messes +# with our clangd setup. Comment out the lines that do this. +sed -E '/set\(CMAKE.*COMPILER_FORCED.*$/s/^/# /g' $1 > tmp.txt +mv tmp.txt $1 + +# CubeMX incorrectly assumes that our top-level CMakeLists.txt is in the same +# directory as the .ioc file. This means that the linker script directory is wrong. +# Find the "-T ** .ld" line and replace the CMAKE variable with the current directory. +sed -E "/-T.*\.ld/s|\\\$\{CMAKE_SOURCE_DIR\}|${PWD}|g" $1 > tmp.txt +mv tmp.txt $1 \ No newline at end of file diff --git a/firmware/cmake/generate_cubemx.mk b/firmware/cmake/generate_cubemx.mk index 0402195bd..a0a0d3dc5 100644 --- a/firmware/cmake/generate_cubemx.mk +++ b/firmware/cmake/generate_cubemx.mk @@ -9,6 +9,7 @@ endif # Find the JAVA which is installed with CubeMX. Spaces in path are escaped. space := $(subst ,, ) +# Known bug: Expanding CUBEMX_JAVA twice does not work. ifeq ($(shell uname), Darwin) # MacOS CUBEMX_JAVA := $(dir $(subst $(space),\$(space),$(CUBEMX_PATH)))jre/Contents/Home/bin/java @@ -17,8 +18,6 @@ else CUBEMX_JAVA := $(dir $(subst $(space),\$(space),$(CUBEMX_PATH)))jre/bin/java endif -# Known bug: Expanding CUBEMX_JAVA twice does not work. - IOC_FILE = board_config.ioc CUBEMX_GEN_SCRIPT = cubemx_script.txt @@ -29,18 +28,17 @@ CUSTOM_TARGETS_FILE = $(BUILD_SYS_DIR)custom_cubemx_targets.mk CUBEMX_GEN_SCRIPT_TEMPLATE := $(BUILD_SYS_DIR)generate_cubemx_script.txt.template -# Copy the CubeMX makefile and custom targets into a new makefile -CustomMakefile.mk: Makefile $(CUSTOM_TARGETS_FILE) - @echo "Creating $@ from [$^]" - cat Makefile > $@ - cat $(CUSTOM_TARGETS_FILE) >> $@ +cmake/racecar-toolchain.cmake: cmake/gcc-arm-none-eabi.cmake + @echo "Modifying autogen toolchain file." + cp $< $@ + . $(BUILD_SYS_DIR)custom_toolchain.sh $@ # This recipe will execute whenever IOC_FILE has a newer timestamp than the -# Makefile, i.e. whenever IOC_FILE has been updated but new code has not been -# generated. -Makefile: $(IOC_FILE) $(CUBEMX_GEN_SCRIPT_TEMPLATE) +# generated toolchain file, i.e. whenever IOC_FILE has been updated but new code +# has not been generated. +cmake/gcc-arm-none-eabi.cmake: $(IOC_FILE) $(CUBEMX_GEN_SCRIPT_TEMPLATE) @echo "Autogenerating from CubeMX. If you don't want to do this, you must manually 'Generate Code' before building." -# Create an file containing commands to generate the cubemx code. +# Create a file containing commands to generate the cubemx code. sed -e 's/IOC_FILE/$(IOC_FILE)/g' $(CUBEMX_GEN_SCRIPT_TEMPLATE) > $(CUBEMX_GEN_SCRIPT) # Run the cubemx program to generate code. diff --git a/firmware/mcal/cli/Toolchain.cmake b/firmware/mcal/cli/Toolchain.cmake deleted file mode 100644 index 9a35781ba..000000000 --- a/firmware/mcal/cli/Toolchain.cmake +++ /dev/null @@ -1,3 +0,0 @@ -# Blake Freer -# December 23, 2023 -# No cmake instructions as the default PC compiler should work. \ No newline at end of file diff --git a/firmware/mcal/linux/Toolchain.cmake b/firmware/mcal/linux/Toolchain.cmake deleted file mode 100644 index 954bbc632..000000000 --- a/firmware/mcal/linux/Toolchain.cmake +++ /dev/null @@ -1,3 +0,0 @@ -# Blake Freer -# November 8, 2024 -# No cmake instructions as the default Linux compiler should work. \ No newline at end of file diff --git a/firmware/mcal/raspi/Toolchain.cmake b/firmware/mcal/raspi/Toolchain.cmake deleted file mode 100644 index c08544058..000000000 --- a/firmware/mcal/raspi/Toolchain.cmake +++ /dev/null @@ -1,3 +0,0 @@ -# Samuel Parent -# January 16, 2024 -# No cmake instructions as the default RASPI compiler should work. \ No newline at end of file diff --git a/firmware/mcal/stm32f767/Toolchain.cmake b/firmware/mcal/stm32f767/Toolchain.cmake deleted file mode 100644 index 00b6b2c1d..000000000 --- a/firmware/mcal/stm32f767/Toolchain.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Blake Freer -# December 23, 2023 - -set(CMAKE_SYSTEM_NAME Generic) -set(CMAKE_SYSTEM_PROCESSOR arm) - -set(CMAKE_C_FLAGS_INIT - "-fdata-sections -ffunction-sections -Wl,--gc-sections") -set(CMAKE_CXX_FLAGS_INIT - "${CMAKE_C_FLAGS_INIT} -fno-rtti -fno-exceptions -fno-threadsafe-statics") - -set(TOOLCHAIN_PREFIX arm-none-eabi-) -set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) -set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) -set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) -set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy) -set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size) -set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump) - -set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf") -set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") -set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf") - -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) diff --git a/firmware/projects/Demo/AnalogPWM/CMakeLists.txt b/firmware/projects/Demo/AnalogPWM/CMakeLists.txt index d528587c7..9ad805078 100644 --- a/firmware/projects/Demo/AnalogPWM/CMakeLists.txt +++ b/firmware/projects/Demo/AnalogPWM/CMakeLists.txt @@ -1 +1 @@ -target_sources(main PUBLIC main.cc) \ No newline at end of file +target_sources(main PRIVATE main.cc) \ No newline at end of file diff --git a/firmware/projects/Demo/AnalogPWM/platforms/cli/CMakeLists.txt b/firmware/projects/Demo/AnalogPWM/platforms/cli/CMakeLists.txt index 6748669b7..d897c2265 100644 --- a/firmware/projects/Demo/AnalogPWM/platforms/cli/CMakeLists.txt +++ b/firmware/projects/Demo/AnalogPWM/platforms/cli/CMakeLists.txt @@ -1,3 +1,2 @@ -target_sources(bindings PRIVATE bindings.cc) - -target_link_libraries(bindings PUBLIC mcal-cli) \ No newline at end of file +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-cli) \ No newline at end of file diff --git a/firmware/projects/Demo/BasicIO/CMakeLists.txt b/firmware/projects/Demo/BasicIO/CMakeLists.txt index 813273573..2eb865530 100644 --- a/firmware/projects/Demo/BasicIO/CMakeLists.txt +++ b/firmware/projects/Demo/BasicIO/CMakeLists.txt @@ -7,10 +7,5 @@ target_sources(main PRIVATE main.cc) -target_include_directories(main - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/inc -) - # Notice that we don't include any mcal/ or platform /subdirectory in this CMake # file. The master CMakeLists handles platform selection and library linking. \ No newline at end of file diff --git a/firmware/projects/Demo/BasicIO/bindings.h b/firmware/projects/Demo/BasicIO/bindings.h new file mode 100644 index 000000000..04aa10534 --- /dev/null +++ b/firmware/projects/Demo/BasicIO/bindings.h @@ -0,0 +1,12 @@ +#pragma once + +#include "shared/periph/gpio.h" + +namespace bindings { + +extern shared::periph::DigitalInput& button_di; +extern shared::periph::DigitalOutput& indicator_do; + +extern void Initialize(); + +} // namespace bindings \ No newline at end of file diff --git a/firmware/projects/Demo/BasicIO/inc/app.h b/firmware/projects/Demo/BasicIO/inc/app.h deleted file mode 100644 index b0829ecc8..000000000 --- a/firmware/projects/Demo/BasicIO/inc/app.h +++ /dev/null @@ -1,38 +0,0 @@ -/// @author Blake Freer -/// @date 2023-12-25 - -#pragma once - -#include "shared/periph/gpio.h" - -class Button { -private: - shared::periph::DigitalInput& di_; - -public: - Button(shared::periph::DigitalInput& di) : di_(di){}; - - bool Read() { - return di_.Read(); - } -}; - -class Indicator { -private: -public: - shared::periph::DigitalOutput& dig_output_; - Indicator(shared::periph::DigitalOutput& dig_output) - : dig_output_(dig_output) {} - - void Set(bool value) { - dig_output_.Set(value); - } - - void High() { - dig_output_.SetHigh(); - } - - void Low() { - dig_output_.SetLow(); - } -}; \ No newline at end of file diff --git a/firmware/projects/Demo/BasicIO/main.cc b/firmware/projects/Demo/BasicIO/main.cc index 1f1138373..d4702ccaa 100644 --- a/firmware/projects/Demo/BasicIO/main.cc +++ b/firmware/projects/Demo/BasicIO/main.cc @@ -1,16 +1,7 @@ /// @author Blake Freer /// @date 2023-12-25 -#include "app.h" - -namespace bindings { -extern shared::periph::DigitalInput& button_di; -extern shared::periph::DigitalOutput& indicator_do; -extern void Initialize(); -} // namespace bindings - -Button button{bindings::button_di}; -Indicator indicator{bindings::indicator_do}; +#include "bindings.h" bool btn_value; @@ -18,8 +9,8 @@ int main(void) { bindings::Initialize(); while (1) { - btn_value = button.Read(); - indicator.Set(btn_value); + btn_value = bindings::button_di.Read(); + bindings::indicator_do.Set(btn_value); } return 0; diff --git a/firmware/projects/Demo/BasicIO/platforms/cli/CMakeLists.txt b/firmware/projects/Demo/BasicIO/platforms/cli/CMakeLists.txt index 18364aa65..d897c2265 100644 --- a/firmware/projects/Demo/BasicIO/platforms/cli/CMakeLists.txt +++ b/firmware/projects/Demo/BasicIO/platforms/cli/CMakeLists.txt @@ -1,3 +1,2 @@ -target_sources(bindings PRIVATE bindings.cc) - -target_link_libraries(bindings PRIVATE mcal-cli) \ No newline at end of file +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-cli) \ No newline at end of file diff --git a/firmware/projects/Demo/BasicIO/platforms/cli/bindings.cc b/firmware/projects/Demo/BasicIO/platforms/cli/bindings.cc index 06eba3713..77e066133 100644 --- a/firmware/projects/Demo/BasicIO/platforms/cli/bindings.cc +++ b/firmware/projects/Demo/BasicIO/platforms/cli/bindings.cc @@ -3,6 +3,7 @@ #include +#include "../../bindings.h" #include "mcal/cli/periph/gpio.h" #include "shared/periph/gpio.h" @@ -15,8 +16,8 @@ DigitalOutput indicator_do{"Indicator"}; namespace bindings { -const shared::periph::DigitalInput& button_di = mcal::button_di; -const shared::periph::DigitalOutput& indicator_do = mcal::indicator_do; +shared::periph::DigitalInput& button_di = mcal::button_di; +shared::periph::DigitalOutput& indicator_do = mcal::indicator_do; void Initialize() { std::cout << "Initializing CLI..." << std::endl; diff --git a/firmware/projects/Demo/BasicIO/platforms/stm32f767/CMakeLists.txt b/firmware/projects/Demo/BasicIO/platforms/stm32f767/CMakeLists.txt index 502587310..175ce8b62 100644 --- a/firmware/projects/Demo/BasicIO/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/Demo/BasicIO/platforms/stm32f767/CMakeLists.txt @@ -1,4 +1,5 @@ -add_subdirectory(cubemx) +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-stm32f767) -target_sources(bindings PUBLIC bindings.cc) -target_link_libraries(bindings PUBLIC driver mcal-stm32f767) \ No newline at end of file +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PRIVATE stm32cubemx) diff --git a/firmware/projects/Demo/BasicIO/platforms/stm32f767/bindings.cc b/firmware/projects/Demo/BasicIO/platforms/stm32f767/bindings.cc index a48409e07..1108c3740 100644 --- a/firmware/projects/Demo/BasicIO/platforms/stm32f767/bindings.cc +++ b/firmware/projects/Demo/BasicIO/platforms/stm32f767/bindings.cc @@ -6,6 +6,7 @@ #include "main.h" // fw includes +#include "../../bindings.h" #include "mcal/stm32f767/periph/gpio.h" #include "shared/periph/gpio.h" @@ -25,8 +26,8 @@ DigitalOutput indicator_do{LedPin_GPIO_Port, LedPin_Pin}; } // namespace mcal namespace bindings { -const shared::periph::DigitalInput& button_di = mcal::button_di; -const shared::periph::DigitalOutput& indicator_do = mcal::indicator_do; +shared::periph::DigitalInput& button_di = mcal::button_di; +shared::periph::DigitalOutput& indicator_do = mcal::indicator_do; void Initialize() { SystemClock_Config(); diff --git a/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/.gitignore index d5b8871de..ba5839a74 100644 --- a/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/.gitignore @@ -1,4 +1,3 @@ * !*.ioc -!.gitignore -!CMakeLists.txt \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/board_config.ioc index ed4537699..e71422099 100644 --- a/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/Demo/BasicIO/platforms/stm32f767/cubemx/board_config.ioc @@ -69,7 +69,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= diff --git a/firmware/projects/Demo/BasicIO/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/Demo/BasicIO/platforms/stm32f767/mcal_conf.cmake index ba7d7a47b..c50430884 100644 --- a/firmware/projects/Demo/BasicIO/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/Demo/BasicIO/platforms/stm32f767/mcal_conf.cmake @@ -1,3 +1,4 @@ # This file determines which mcal folder is included so that the mcal library # can be linked to `bindings`. -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/Blink/platforms/cli/CMakeLists.txt b/firmware/projects/Demo/Blink/platforms/cli/CMakeLists.txt index 6748669b7..d897c2265 100644 --- a/firmware/projects/Demo/Blink/platforms/cli/CMakeLists.txt +++ b/firmware/projects/Demo/Blink/platforms/cli/CMakeLists.txt @@ -1,3 +1,2 @@ -target_sources(bindings PRIVATE bindings.cc) - -target_link_libraries(bindings PUBLIC mcal-cli) \ No newline at end of file +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-cli) \ No newline at end of file diff --git a/firmware/projects/Demo/Blink/platforms/linux/CMakeLists.txt b/firmware/projects/Demo/Blink/platforms/linux/CMakeLists.txt index b9b7a2e6e..8ecab6906 100644 --- a/firmware/projects/Demo/Blink/platforms/linux/CMakeLists.txt +++ b/firmware/projects/Demo/Blink/platforms/linux/CMakeLists.txt @@ -1,4 +1,2 @@ -target_sources(bindings PRIVATE bindings.cc) -target_include_directories(bindings PRIVATE ${DIR_PROJECT}) - -target_link_libraries(bindings PRIVATE mcal-linux) \ No newline at end of file +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-linux) \ No newline at end of file diff --git a/firmware/projects/Demo/Blink/platforms/linux/bindings.cc b/firmware/projects/Demo/Blink/platforms/linux/bindings.cc index ae74aa0ea..98eff9f44 100644 --- a/firmware/projects/Demo/Blink/platforms/linux/bindings.cc +++ b/firmware/projects/Demo/Blink/platforms/linux/bindings.cc @@ -1,6 +1,6 @@ #include -#include "bindings.h" +#include "../../bindings.h" #include "mcal/linux/periph/digital_output.h" #include "shared/periph/gpio.h" diff --git a/firmware/projects/Demo/Blink/platforms/stm32f767/CMakeLists.txt b/firmware/projects/Demo/Blink/platforms/stm32f767/CMakeLists.txt index c2040064c..175ce8b62 100644 --- a/firmware/projects/Demo/Blink/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/Demo/Blink/platforms/stm32f767/CMakeLists.txt @@ -1,7 +1,5 @@ -target_sources(bindings PRIVATE bindings.cc) -target_include_directories(bindings PRIVATE ${DIR_PROJECT}) +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-stm32f767) -target_link_libraries(bindings PUBLIC mcal-stm32f767) - -add_subdirectory(cubemx) # provides "driver" -target_link_libraries(bindings PUBLIC driver) \ No newline at end of file +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PRIVATE stm32cubemx) diff --git a/firmware/projects/Demo/Blink/platforms/stm32f767/bindings.cc b/firmware/projects/Demo/Blink/platforms/stm32f767/bindings.cc index 8f1601da3..8422857bf 100644 --- a/firmware/projects/Demo/Blink/platforms/stm32f767/bindings.cc +++ b/firmware/projects/Demo/Blink/platforms/stm32f767/bindings.cc @@ -4,7 +4,7 @@ #include "stm32f7xx_hal.h" // project includes -#include "bindings.h" +#include "../../bindings.h" #include "mcal/stm32f767/periph/gpio.h" #include "shared/periph/gpio.h" diff --git a/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/.gitignore index d5b8871de..ba5839a74 100644 --- a/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/.gitignore @@ -1,4 +1,3 @@ * !*.ioc -!.gitignore -!CMakeLists.txt \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/board_config.ioc index c5938a0b0..b66a76296 100644 --- a/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/Demo/Blink/platforms/stm32f767/cubemx/board_config.ioc @@ -63,7 +63,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= diff --git a/firmware/projects/Demo/Blink/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/Demo/Blink/platforms/stm32f767/mcal_conf.cmake index 7c5404f10..adbaa3186 100644 --- a/firmware/projects/Demo/Blink/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/Demo/Blink/platforms/stm32f767/mcal_conf.cmake @@ -1 +1,2 @@ -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Receive/platforms/cli/CMakeLists.txt b/firmware/projects/Demo/CAN/Receive/platforms/cli/CMakeLists.txt index 4af50232f..430876bf9 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/cli/CMakeLists.txt +++ b/firmware/projects/Demo/CAN/Receive/platforms/cli/CMakeLists.txt @@ -1,6 +1,2 @@ -target_sources(bindings -PRIVATE - bindings.cc -) - -target_link_libraries(bindings PUBLIC mcal-cli) +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-cli) diff --git a/firmware/projects/Demo/CAN/Receive/platforms/cli/bindings.cc b/firmware/projects/Demo/CAN/Receive/platforms/cli/bindings.cc index c67b96b87..5d7870dcb 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/cli/bindings.cc +++ b/firmware/projects/Demo/CAN/Receive/platforms/cli/bindings.cc @@ -5,6 +5,7 @@ #include #include +#include "../../bindings.h" #include "mcal/cli/periph/can.h" #include "mcal/cli/periph/gpio.h" #include "shared/periph/can.h" diff --git a/firmware/projects/Demo/CAN/Receive/platforms/linux/CMakeLists.txt b/firmware/projects/Demo/CAN/Receive/platforms/linux/CMakeLists.txt index b9b7a2e6e..58bff247f 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/linux/CMakeLists.txt +++ b/firmware/projects/Demo/CAN/Receive/platforms/linux/CMakeLists.txt @@ -1,4 +1,2 @@ target_sources(bindings PRIVATE bindings.cc) -target_include_directories(bindings PRIVATE ${DIR_PROJECT}) - target_link_libraries(bindings PRIVATE mcal-linux) \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Receive/platforms/linux/bindings.cc b/firmware/projects/Demo/CAN/Receive/platforms/linux/bindings.cc index 516427fca..436463c10 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/linux/bindings.cc +++ b/firmware/projects/Demo/CAN/Receive/platforms/linux/bindings.cc @@ -2,7 +2,7 @@ #include -#include "bindings.h" +#include "../../bindings.h" #include "mcal/linux/periph/can.h" #include "mcal/linux/periph/digital_output.h" diff --git a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/CMakeLists.txt b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/CMakeLists.txt index 9c6fae02f..175ce8b62 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/CMakeLists.txt @@ -1,4 +1,5 @@ -add_subdirectory(cubemx) +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-stm32f767) -target_sources(bindings PUBLIC bindings.cc) -target_link_libraries(bindings PUBLIC driver mcal-stm32f767) +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PRIVATE stm32cubemx) diff --git a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/bindings.cc b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/bindings.cc index 4c833b385..3eec00cc2 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/bindings.cc +++ b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/bindings.cc @@ -7,6 +7,7 @@ #include "main.h" // fw includes +#include "../../bindings.h" #include "mcal/stm32f767/periph/can.h" #include "mcal/stm32f767/periph/gpio.h" #include "shared/periph/can.h" diff --git a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/.gitignore index d5b8871de..ba5839a74 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/.gitignore @@ -1,4 +1,3 @@ * !*.ioc -!.gitignore -!CMakeLists.txt \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/board_config.ioc index 0a40e8432..77d335e6b 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/cubemx/board_config.ioc @@ -82,7 +82,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= diff --git a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/mcal_conf.cmake index ba7d7a47b..c50430884 100644 --- a/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/Demo/CAN/Receive/platforms/stm32f767/mcal_conf.cmake @@ -1,3 +1,4 @@ # This file determines which mcal folder is included so that the mcal library # can be linked to `bindings`. -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Send/platforms/cli/CMakeLists.txt b/firmware/projects/Demo/CAN/Send/platforms/cli/CMakeLists.txt index 4af50232f..430876bf9 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/cli/CMakeLists.txt +++ b/firmware/projects/Demo/CAN/Send/platforms/cli/CMakeLists.txt @@ -1,6 +1,2 @@ -target_sources(bindings -PRIVATE - bindings.cc -) - -target_link_libraries(bindings PUBLIC mcal-cli) +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-cli) diff --git a/firmware/projects/Demo/CAN/Send/platforms/cli/bindings.cc b/firmware/projects/Demo/CAN/Send/platforms/cli/bindings.cc index 64d3fdc72..e654ba72b 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/cli/bindings.cc +++ b/firmware/projects/Demo/CAN/Send/platforms/cli/bindings.cc @@ -4,6 +4,7 @@ #include #include +#include "../../bindings.h" #include "mcal/cli/periph/can.h" #include "mcal/cli/periph/gpio.h" #include "shared/periph/can.h" diff --git a/firmware/projects/Demo/CAN/Send/platforms/linux/CMakeLists.txt b/firmware/projects/Demo/CAN/Send/platforms/linux/CMakeLists.txt index b9b7a2e6e..8ecab6906 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/linux/CMakeLists.txt +++ b/firmware/projects/Demo/CAN/Send/platforms/linux/CMakeLists.txt @@ -1,4 +1,2 @@ -target_sources(bindings PRIVATE bindings.cc) -target_include_directories(bindings PRIVATE ${DIR_PROJECT}) - -target_link_libraries(bindings PRIVATE mcal-linux) \ No newline at end of file +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-linux) \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Send/platforms/linux/bindings.cc b/firmware/projects/Demo/CAN/Send/platforms/linux/bindings.cc index a164e557e..c5ccf0b39 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/linux/bindings.cc +++ b/firmware/projects/Demo/CAN/Send/platforms/linux/bindings.cc @@ -2,7 +2,7 @@ #include -#include "bindings.h" +#include "../../bindings.h" #include "mcal/linux/periph/can.h" #include "mcal/linux/periph/digital_input.h" diff --git a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/CMakeLists.txt b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/CMakeLists.txt index 9c6fae02f..175ce8b62 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/CMakeLists.txt @@ -1,4 +1,5 @@ -add_subdirectory(cubemx) +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-stm32f767) -target_sources(bindings PUBLIC bindings.cc) -target_link_libraries(bindings PUBLIC driver mcal-stm32f767) +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PRIVATE stm32cubemx) diff --git a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/.gitignore index d5b8871de..ba5839a74 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/.gitignore @@ -1,4 +1,3 @@ * !*.ioc -!.gitignore -!CMakeLists.txt \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/board_config.ioc index ff4f59ecb..00f8002c8 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/cubemx/board_config.ioc @@ -83,7 +83,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= diff --git a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/mcal_conf.cmake index ba7d7a47b..c50430884 100644 --- a/firmware/projects/Demo/CAN/Send/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/Demo/CAN/Send/platforms/stm32f767/mcal_conf.cmake @@ -1,3 +1,4 @@ # This file determines which mcal folder is included so that the mcal library # can be linked to `bindings`. -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/CANErrors/CMakeLists.txt b/firmware/projects/Demo/CANErrors/CMakeLists.txt index f089022d5..e16729213 100644 --- a/firmware/projects/Demo/CANErrors/CMakeLists.txt +++ b/firmware/projects/Demo/CANErrors/CMakeLists.txt @@ -6,15 +6,7 @@ include("${CMAKE_SOURCE_DIR}/cmake/cangen.cmake") -target_sources(main - PRIVATE - main.cc -) - -target_include_directories(main - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/inc -) +target_sources(main PRIVATE main.cc) # Notice that we don't include any mcal/ subdirectory in this CMake file. # The master CMakeLists handles platform selection and library linking. \ No newline at end of file diff --git a/firmware/projects/Demo/CANErrors/main.cc b/firmware/projects/Demo/CANErrors/main.cc index 3fd35ffc3..6533eccaa 100644 --- a/firmware/projects/Demo/CANErrors/main.cc +++ b/firmware/projects/Demo/CANErrors/main.cc @@ -3,10 +3,10 @@ #include -#include "app.h" #include "bindings.h" -#include "shared/comms/can/can_bus.h" #include "generated/can/error_msg_registry.h" +#include "inc/app.h" +#include "shared/comms/can/can_bus.h" // Initializing can bus that sends the error message generated::can::ErrorMsgRegistry error_can_registry{}; diff --git a/firmware/projects/Demo/CANErrors/platforms/cli/CMakeLists.txt b/firmware/projects/Demo/CANErrors/platforms/cli/CMakeLists.txt index 6748669b7..d897c2265 100644 --- a/firmware/projects/Demo/CANErrors/platforms/cli/CMakeLists.txt +++ b/firmware/projects/Demo/CANErrors/platforms/cli/CMakeLists.txt @@ -1,3 +1,2 @@ -target_sources(bindings PRIVATE bindings.cc) - -target_link_libraries(bindings PUBLIC mcal-cli) \ No newline at end of file +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-cli) \ No newline at end of file diff --git a/firmware/projects/Demo/CANErrors/platforms/cli/bindings.cc b/firmware/projects/Demo/CANErrors/platforms/cli/bindings.cc index 53df07dd2..3580596dc 100644 --- a/firmware/projects/Demo/CANErrors/platforms/cli/bindings.cc +++ b/firmware/projects/Demo/CANErrors/platforms/cli/bindings.cc @@ -4,31 +4,30 @@ #include #include -#include "mcal/cli/periph/can.h" -#include "shared/periph/can.h" - #include "../../generated/can/error_can_messages.h" +#include "mcal/cli/periph/can.h" #include "shared/comms/can/can_bus.h" +#include "shared/periph/can.h" namespace mcal { - using namespace cli::periph; +using namespace cli::periph; - CanBase error_can_base{"vcan0"}; -} +CanBase error_can_base{"vcan0"}; +} // namespace mcal namespace bindings { - shared::periph::CanBase& error_can_base = mcal::error_can_base; +shared::periph::CanBase& error_can_base = mcal::error_can_base; - // Simulates a sleep, waiting for inputted ticks ms - void TickBlocking(uint32_t ticks) { - std::chrono::milliseconds duration(ticks); +// Simulates a sleep, waiting for inputted ticks ms +void TickBlocking(uint32_t ticks) { + std::chrono::milliseconds duration(ticks); - std::this_thread::sleep_for(duration); - } + std::this_thread::sleep_for(duration); +} - // Initializes the can/CLI outputs - void Initialize() { - mcal::error_can_base.Setup(); - std::cout << "Initializing CLI..." << std::endl; - } -} \ No newline at end of file +// Initializes the can/CLI outputs +void Initialize() { + mcal::error_can_base.Setup(); + std::cout << "Initializing CLI..." << std::endl; +} +} // namespace bindings \ No newline at end of file diff --git a/firmware/projects/Demo/Mapper/CMakeLists.txt b/firmware/projects/Demo/Mapper/CMakeLists.txt index 9fb6d16d2..ddec79df5 100644 --- a/firmware/projects/Demo/Mapper/CMakeLists.txt +++ b/firmware/projects/Demo/Mapper/CMakeLists.txt @@ -4,15 +4,7 @@ # The target executable 'main' is created in the master CMakeLists. Do not change its name. # We only need to add the source code files and include directories. -target_sources(main -PRIVATE - main.cc -) - -target_include_directories(main -PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/inc -) +target_sources(main PRIVATE main.cc) # Notice that we don't include any mcal/ subdirectory in this CMake file. # The master CMakeLists handles platform selection and library linking. \ No newline at end of file diff --git a/firmware/projects/Demo/Mapper/main.cc b/firmware/projects/Demo/Mapper/main.cc index c44e4c6a1..38c03b585 100644 --- a/firmware/projects/Demo/Mapper/main.cc +++ b/firmware/projects/Demo/Mapper/main.cc @@ -3,7 +3,7 @@ #include // for demo only, will not work on other platforms -#include "app.h" +#include "inc/app.h" #include "shared/util/mappers/clamper.h" #include "shared/util/mappers/linear_map.h" #include "shared/util/mappers/mapper.h" diff --git a/firmware/projects/Demo/Mapper/platforms/cli/CMakeLists.txt b/firmware/projects/Demo/Mapper/platforms/cli/CMakeLists.txt index 737cc3e31..4d73cf964 100644 --- a/firmware/projects/Demo/Mapper/platforms/cli/CMakeLists.txt +++ b/firmware/projects/Demo/Mapper/platforms/cli/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(bindings -PRIVATE - bindings.cc -) \ No newline at end of file +# Empty - this project just runs in the CLI via main diff --git a/firmware/projects/Demo/Mapper/platforms/cli/bindings.cc b/firmware/projects/Demo/Mapper/platforms/cli/bindings.cc deleted file mode 100644 index 2cd8fb77b..000000000 --- a/firmware/projects/Demo/Mapper/platforms/cli/bindings.cc +++ /dev/null @@ -1,6 +0,0 @@ -/// @author Blake Freer -/// @date 2023-12-25 - -#include - -namespace bindings {} // namespace bindings diff --git a/firmware/projects/Demo/RTOS/CMakeLists.txt b/firmware/projects/Demo/RTOS/CMakeLists.txt index 613c83eb8..7631d082e 100644 --- a/firmware/projects/Demo/RTOS/CMakeLists.txt +++ b/firmware/projects/Demo/RTOS/CMakeLists.txt @@ -6,15 +6,7 @@ # add_subdirectory(platforms/stm32f767) # provides "bindings" (library) -target_sources(main -PRIVATE -main.cc -) - -target_include_directories(main -PRIVATE -${CMAKE_CURRENT_SOURCE_DIR}/inc -) +target_sources(main PRIVATE main.cc) # Notice that we don't include any mcal/ subdirectory in this CMake file. # The master CMakeLists handles platform selection and library linking. \ No newline at end of file diff --git a/firmware/projects/Demo/RTOS/main.cc b/firmware/projects/Demo/RTOS/main.cc index dfb1a0b18..e94d166a8 100644 --- a/firmware/projects/Demo/RTOS/main.cc +++ b/firmware/projects/Demo/RTOS/main.cc @@ -4,7 +4,7 @@ #include #include -#include "app.h" +#include "inc/app.h" #include "shared/os/fifo.h" #include "shared/os/mutex.h" #include "shared/os/os.h" diff --git a/firmware/projects/Demo/RTOS/platforms/stm32f767/CMakeLists.txt b/firmware/projects/Demo/RTOS/platforms/stm32f767/CMakeLists.txt index 35476d3e5..c7cae4fd9 100644 --- a/firmware/projects/Demo/RTOS/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/Demo/RTOS/platforms/stm32f767/CMakeLists.txt @@ -1,11 +1,5 @@ -# Blake Freer -# January 8, 2024 +target_sources(main PRIVATE bindings.cc os.cc) +target_link_libraries(main PRIVATE mcal-stm32f767) -add_subdirectory(cubemx) - -target_sources(bindings PUBLIC bindings.cc) -target_link_libraries(bindings PUBLIC driver mcal-stm32f767) - -add_library(os) -target_sources(os PUBLIC os.cc) -target_link_libraries(os PUBLIC driver mcal-stm32f767) \ No newline at end of file +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PRIVATE stm32cubemx) \ No newline at end of file diff --git a/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/.gitignore index d5b8871de..ba5839a74 100644 --- a/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/.gitignore @@ -1,4 +1,3 @@ * !*.ioc -!.gitignore -!CMakeLists.txt \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/board_config.ioc index 24bc3ed16..e106e6e22 100644 --- a/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/Demo/RTOS/platforms/stm32f767/cubemx/board_config.ioc @@ -92,7 +92,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= diff --git a/firmware/projects/Demo/RTOS/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/Demo/RTOS/platforms/stm32f767/mcal_conf.cmake index ba7d7a47b..adbaa3186 100644 --- a/firmware/projects/Demo/RTOS/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/Demo/RTOS/platforms/stm32f767/mcal_conf.cmake @@ -1,3 +1,2 @@ -# This file determines which mcal folder is included so that the mcal library -# can be linked to `bindings`. -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/FrontController/CMakeLists.txt b/firmware/projects/FrontController/CMakeLists.txt index bfabbdec0..e05d23543 100644 --- a/firmware/projects/FrontController/CMakeLists.txt +++ b/firmware/projects/FrontController/CMakeLists.txt @@ -6,19 +6,9 @@ include("${CMAKE_SOURCE_DIR}/cmake/cangen.cmake") -target_sources(main - PRIVATE - main.cc -) - -target_include_directories(main -PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/inc - ${CMAKE_CURRENT_SOURCE_DIR}/generated/can -) +target_sources(main PRIVATE main.cc) # Compile and link the control system files. - add_library(controls) set(CTRL_SYS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vehicle_control_system/src/vehicle_control_system-autogen/controller_autogen_ert_rtw") @@ -27,13 +17,9 @@ target_include_directories(controls PUBLIC ${CTRL_SYS_DIR}) FILE(GLOB SRC_CONTROLS CONFIGURE_DEPENDS "${CTRL_SYS_DIR}/*.cpp") message(STATUS "Controls sources: ${SRC_CONTROLS}") -target_sources(controls -PUBLIC - ${SRC_CONTROLS} -) +target_sources(controls PUBLIC ${SRC_CONTROLS}) target_link_libraries(main PUBLIC controls) - # Notice that we don't include any mcal/ subdirectory in this CMake file. # The master CMakeLists handles platform selection and library linking. \ No newline at end of file diff --git a/firmware/projects/FrontController/inc/bindings.h b/firmware/projects/FrontController/bindings.h similarity index 100% rename from firmware/projects/FrontController/inc/bindings.h rename to firmware/projects/FrontController/bindings.h diff --git a/firmware/projects/FrontController/inc/app.h b/firmware/projects/FrontController/inc/app.h index 0f530dca9..ea3ebb991 100644 --- a/firmware/projects/FrontController/inc/app.h +++ b/firmware/projects/FrontController/inc/app.h @@ -8,6 +8,7 @@ #include #include +#include "../generated/can/veh_can_messages.h" #include "app.h" #include "shared/comms/can/can_bus.h" #include "shared/comms/can/can_msg.h" @@ -17,7 +18,6 @@ #include "shared/util/mappers/linear_map.h" #include "shared/util/mappers/mapper.h" #include "shared/util/moving_average.h" -#include "veh_can_messages.h" class AnalogInput { static constexpr size_t kMovingAverageLength = 20; diff --git a/firmware/projects/FrontController/main.cc b/firmware/projects/FrontController/main.cc index 82f885d80..598080a27 100644 --- a/firmware/projects/FrontController/main.cc +++ b/firmware/projects/FrontController/main.cc @@ -1,19 +1,19 @@ /// @author Blake Freer /// @date 2024-02-24 -#include "app.h" #include "bindings.h" #include "generated/can/pt_can_messages.h" #include "generated/can/pt_msg_registry.h" #include "generated/can/veh_can_messages.h" #include "generated/can/veh_msg_registry.h" +#include "inc/app.h" +#include "inc/simulink.h" #include "shared/comms/can/can_bus.h" #include "shared/os/os.h" #include "shared/periph/adc.h" #include "shared/periph/gpio.h" #include "shared/util/mappers/linear_map.h" #include "shared/util/mappers/mapper.h" -#include "simulink.h" /*************************************************************** CAN diff --git a/firmware/projects/FrontController/platforms/stm32f767/CMakeLists.txt b/firmware/projects/FrontController/platforms/stm32f767/CMakeLists.txt index 515a5bd75..c7cae4fd9 100644 --- a/firmware/projects/FrontController/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/FrontController/platforms/stm32f767/CMakeLists.txt @@ -1,13 +1,5 @@ -# Blake Freer -# January 8, 2024 +target_sources(main PRIVATE bindings.cc os.cc) +target_link_libraries(main PRIVATE mcal-stm32f767) -add_subdirectory(cubemx) - -target_sources(bindings PUBLIC bindings.cc) -target_link_libraries(bindings PUBLIC driver mcal-stm32f767) - -target_include_directories(bindings PUBLIC ${DIR_PROJECT}/inc) # access to bindings.h - -add_library(os) -target_sources(os PUBLIC os.cc) -target_link_libraries(os PUBLIC driver mcal-stm32f767) \ No newline at end of file +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PRIVATE stm32cubemx) \ No newline at end of file diff --git a/firmware/projects/FrontController/platforms/stm32f767/bindings.cc b/firmware/projects/FrontController/platforms/stm32f767/bindings.cc index 4533e17c8..dc81a7cf0 100644 --- a/firmware/projects/FrontController/platforms/stm32f767/bindings.cc +++ b/firmware/projects/FrontController/platforms/stm32f767/bindings.cc @@ -12,7 +12,7 @@ #include "tim.h" // fw imports -#include "bindings.h" +#include "../../bindings.h" #include "mcal/stm32f767/periph/adc.h" #include "mcal/stm32f767/periph/can.h" #include "mcal/stm32f767/periph/gpio.h" diff --git a/firmware/projects/FrontController/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/FrontController/platforms/stm32f767/cubemx/.gitignore index d5b8871de..ba5839a74 100644 --- a/firmware/projects/FrontController/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/FrontController/platforms/stm32f767/cubemx/.gitignore @@ -1,4 +1,3 @@ * !*.ioc -!.gitignore -!CMakeLists.txt \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/FrontController/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/FrontController/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/FrontController/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/FrontController/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/FrontController/platforms/stm32f767/cubemx/board_config.ioc index 8d408d90f..198143446 100644 --- a/firmware/projects/FrontController/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/FrontController/platforms/stm32f767/cubemx/board_config.ioc @@ -244,7 +244,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= diff --git a/firmware/projects/FrontController/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/FrontController/platforms/stm32f767/mcal_conf.cmake index ba7d7a47b..c50430884 100644 --- a/firmware/projects/FrontController/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/FrontController/platforms/stm32f767/mcal_conf.cmake @@ -1,3 +1,4 @@ # This file determines which mcal folder is included so that the mcal library # can be linked to `bindings`. -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/LVController/CMakeLists.txt b/firmware/projects/LVController/CMakeLists.txt index 9d58d2406..4436507da 100644 --- a/firmware/projects/LVController/CMakeLists.txt +++ b/firmware/projects/LVController/CMakeLists.txt @@ -6,16 +6,7 @@ include("${CMAKE_SOURCE_DIR}/cmake/cangen.cmake") -target_sources(main - PRIVATE - main.cc -) - -target_include_directories(main -PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/inc - ${CMAKE_CURRENT_SOURCE_DIR}/generated/can -) +target_sources(main PRIVATE main.cc) # Notice that we don't include any mcal/ subdirectory in this CMake file. # The master CMakeLists handles platform selection and library linking. \ No newline at end of file diff --git a/firmware/projects/LVController/inc/bindings.h b/firmware/projects/LVController/bindings.h similarity index 100% rename from firmware/projects/LVController/inc/bindings.h rename to firmware/projects/LVController/bindings.h diff --git a/firmware/projects/LVController/inc/app.h b/firmware/projects/LVController/inc/app.h index ce695b8db..19df58634 100644 --- a/firmware/projects/LVController/inc/app.h +++ b/firmware/projects/LVController/inc/app.h @@ -3,14 +3,13 @@ #include -#include "bindings.h" +#include "../generated/can/veh_can_messages.h" #include "shared/comms/can/can_bus.h" #include "shared/os/mutex.h" #include "shared/periph/gpio.h" #include "shared/periph/pwm.h" #include "shared/util/mappers/clamper.h" #include "shared/util/mappers/mapper.h" -#include "veh_can_messages.h" class StateBroadcaster { public: @@ -151,7 +150,7 @@ class DCDC : public Subsystem { shared::periph::DigitalOutput& led_output) : Subsystem(enable_output), valid_input_(valid_input), - led_(led_output){}; + led_(led_output) {}; bool CheckValid() { bool is_valid = valid_input_.Read(); diff --git a/firmware/projects/LVController/main.cc b/firmware/projects/LVController/main.cc index 24652fbc6..1ba799cfa 100644 --- a/firmware/projects/LVController/main.cc +++ b/firmware/projects/LVController/main.cc @@ -4,9 +4,9 @@ #include #include -#include "app.h" #include "bindings.h" #include "generated/can/veh_msg_registry.h" +#include "inc/app.h" #include "shared/comms/can/can_bus.h" #include "shared/periph/gpio.h" #include "shared/periph/pwm.h" diff --git a/firmware/projects/LVController/platforms/cli/CMakeLists.txt b/firmware/projects/LVController/platforms/cli/CMakeLists.txt index 54d4ec523..d897c2265 100644 --- a/firmware/projects/LVController/platforms/cli/CMakeLists.txt +++ b/firmware/projects/LVController/platforms/cli/CMakeLists.txt @@ -1,8 +1,2 @@ -target_sources(bindings -PRIVATE - bindings.cc -) - -target_include_directories(bindings PRIVATE ${DIR_PROJECT}/inc) - -target_link_libraries(bindings PUBLIC mcal-cli) \ No newline at end of file +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-cli) \ No newline at end of file diff --git a/firmware/projects/LVController/platforms/cli/bindings.cc b/firmware/projects/LVController/platforms/cli/bindings.cc index 341d63bf9..8ddcb9316 100644 --- a/firmware/projects/LVController/platforms/cli/bindings.cc +++ b/firmware/projects/LVController/platforms/cli/bindings.cc @@ -7,7 +7,7 @@ #include #include -#include "bindings.h" +#include "../../bindings.h" #include "mcal/cli/periph/can.h" #include "mcal/cli/periph/gpio.h" #include "mcal/cli/periph/pwm.h" @@ -15,7 +15,6 @@ #include "shared/periph/gpio.h" #include "shared/util/mappers/identity.h" - // clang-format off namespace mcal { using namespace mcal::cli::periph; diff --git a/firmware/projects/LVController/platforms/stm32f767/CMakeLists.txt b/firmware/projects/LVController/platforms/stm32f767/CMakeLists.txt index 3f03cc6ec..8bece04b5 100644 --- a/firmware/projects/LVController/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/LVController/platforms/stm32f767/CMakeLists.txt @@ -1,18 +1,5 @@ -# Blake Freer -# January 8, 2024 +target_sources(main PRIVATE bindings.cc) +target_link_libraries(main PRIVATE mcal-stm32f767) -target_sources(bindings -PUBLIC - bindings.cc -) - -target_include_directories(bindings PUBLIC ${DIR_PROJECT}/inc) # access to app.h - -add_subdirectory(cubemx) - -# must be public so that the 'main' executable can see its headers when including bindings.h -target_link_libraries(bindings PUBLIC driver mcal-stm32f767) - -add_library(os) -target_sources(os PUBLIC os.cc) -target_link_libraries(os PUBLIC mcal-stm32f767 driver) \ No newline at end of file +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PRIVATE stm32cubemx) \ No newline at end of file diff --git a/firmware/projects/LVController/platforms/stm32f767/bindings.cc b/firmware/projects/LVController/platforms/stm32f767/bindings.cc index 3fe02fb5d..56d848f0e 100644 --- a/firmware/projects/LVController/platforms/stm32f767/bindings.cc +++ b/firmware/projects/LVController/platforms/stm32f767/bindings.cc @@ -17,6 +17,7 @@ #include "tim.h" // Firmware +#include "../../bindings.h" #include "mcal/stm32f767/periph/gpio.h" #include "mcal/stm32f767/periph/pwm.h" #include "shared/periph/gpio.h" diff --git a/firmware/projects/LVController/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/LVController/platforms/stm32f767/cubemx/.gitignore index b67b3e37b..ba5839a74 100644 --- a/firmware/projects/LVController/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/LVController/platforms/stm32f767/cubemx/.gitignore @@ -1,6 +1,3 @@ * !*.ioc -!.gitignore -!README -!CMakeLists.txt -!generate.mk \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/LVController/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/LVController/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/LVController/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/LVController/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/LVController/platforms/stm32f767/cubemx/board_config.ioc index ced65428f..ae3e7776f 100644 --- a/firmware/projects/LVController/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/LVController/platforms/stm32f767/cubemx/board_config.ioc @@ -16,9 +16,6 @@ CAN3.CalculateTimeBit=2000 CAN3.CalculateTimeQuantum=125.0 CAN3.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS2,BS1,ABOM CAN3.Prescaler=2 -FREERTOS.FootprintOK=true -FREERTOS.IPParameters=Tasks01,FootprintOK -FREERTOS.Tasks01=TaskCheckDCDC,24,128,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL;TaskMainLoop,8,128,StartTask02,As weak,NULL,Dynamic,NULL,NULL File.Version=6 GPIO.groupedBy=Group By Peripherals KeepUserPlacement=false @@ -27,13 +24,12 @@ Mcu.Family=STM32F7 Mcu.IP0=ADC1 Mcu.IP1=CAN3 Mcu.IP2=CORTEX_M7 -Mcu.IP3=FREERTOS -Mcu.IP4=NVIC -Mcu.IP5=RCC -Mcu.IP6=SYS -Mcu.IP7=TIM1 -Mcu.IP8=TIM2 -Mcu.IPNb=9 +Mcu.IP3=NVIC +Mcu.IP4=RCC +Mcu.IP5=SYS +Mcu.IP6=TIM1 +Mcu.IP7=TIM2 +Mcu.IPNb=8 Mcu.Name=STM32F767ZITx Mcu.Package=LQFP144 Mcu.Pin0=PE2 @@ -64,41 +60,37 @@ Mcu.Pin30=PB3 Mcu.Pin31=PB4 Mcu.Pin32=PE0 Mcu.Pin33=PE1 -Mcu.Pin34=VP_FREERTOS_VS_CMSIS_V2 -Mcu.Pin35=VP_SYS_VS_tim4 -Mcu.Pin36=VP_TIM1_VS_ClockSourceINT -Mcu.Pin37=VP_TIM2_VS_ClockSourceINT +Mcu.Pin34=VP_SYS_VS_tim4 +Mcu.Pin35=VP_TIM1_VS_ClockSourceINT +Mcu.Pin36=VP_TIM2_VS_ClockSourceINT Mcu.Pin4=PC2 Mcu.Pin5=PC3 Mcu.Pin6=PA0/WKUP Mcu.Pin7=PA4 Mcu.Pin8=PC4 Mcu.Pin9=PC5 -Mcu.PinsNb=38 +Mcu.PinsNb=37 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F767ZITx MxCube.Version=6.12.0 MxDb.Version=DB.6.0.120 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.CAN3_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.CAN3_RX0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.ForceEnableDMAVector=true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false\:false +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false\:false -NVIC.SavedPendsvIrqHandlerGenerated=true -NVIC.SavedSvcallIrqHandlerGenerated=true -NVIC.SavedSystickIrqHandlerGenerated=true -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true\:false -NVIC.TIM2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true -NVIC.TIM4_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false +NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.TIM4_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true NVIC.TimeBase=TIM4_IRQn NVIC.TimeBaseIP=TIM4 -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false PA0/WKUP.GPIOParameters=GPIO_Label PA0/WKUP.GPIO_Label=FAN_PWM PA0/WKUP.Locked=true @@ -264,7 +256,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= @@ -320,8 +312,6 @@ SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 SH.S_TIM2_CH1_ETR.ConfNb=1 TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM2.IPParameters=Channel-PWM Generation1 CH1 -VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2 -VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2 VP_SYS_VS_tim4.Mode=TIM4 VP_SYS_VS_tim4.Signal=SYS_VS_tim4 VP_TIM1_VS_ClockSourceINT.Mode=Internal @@ -329,4 +319,3 @@ VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT VP_TIM2_VS_ClockSourceINT.Mode=Internal VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT board=custom -rtos.0.ip=FREERTOS diff --git a/firmware/projects/LVController/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/LVController/platforms/stm32f767/mcal_conf.cmake index 7c5404f10..adbaa3186 100644 --- a/firmware/projects/LVController/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/LVController/platforms/stm32f767/mcal_conf.cmake @@ -1 +1,2 @@ -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/LVController/platforms/stm32f767/os.cc b/firmware/projects/LVController/platforms/stm32f767/os.cc deleted file mode 100644 index 5f90ecbb0..000000000 --- a/firmware/projects/LVController/platforms/stm32f767/os.cc +++ /dev/null @@ -1,27 +0,0 @@ -/// @author Matteo Tullo -/// @date 2024-02-01 - -#include "cmsis_os2.h" -#include "mcal/stm32f767/os/tick.h" - -extern "C" { -/** - * This requires extern since it is not declared in a header, only defined - * in cubemx/../freertos.c - */ -void MX_FREERTOS_Init(void); -} - -namespace os { -void InitializeKernel(void) { - // TODO: Implement error handling - osKernelInitialize(); - MX_FREERTOS_Init(); -} - -void StartKernel(void) { - // TODO: Implement error handling - osKernelStart(); -} - -} // namespace os diff --git a/firmware/projects/TMS/CMakeLists.txt b/firmware/projects/TMS/CMakeLists.txt index d68ee666a..4436507da 100644 --- a/firmware/projects/TMS/CMakeLists.txt +++ b/firmware/projects/TMS/CMakeLists.txt @@ -6,16 +6,7 @@ include("${CMAKE_SOURCE_DIR}/cmake/cangen.cmake") -target_sources(main - PRIVATE - main.cc -) - -target_include_directories(main - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/inc - ${CMAKE_CURRENT_SOURCE_DIR}/generated/can -) +target_sources(main PRIVATE main.cc) # Notice that we don't include any mcal/ subdirectory in this CMake file. # The master CMakeLists handles platform selection and library linking. \ No newline at end of file diff --git a/firmware/projects/TMS/inc/app.h b/firmware/projects/TMS/inc/app.h index ed8a60832..760ee2a4d 100644 --- a/firmware/projects/TMS/inc/app.h +++ b/firmware/projects/TMS/inc/app.h @@ -8,6 +8,7 @@ #include #include +#include "../generated/can/veh_can_messages.h" #include "shared/comms/can/can_bus.h" #include "shared/periph/adc.h" #include "shared/periph/gpio.h" @@ -16,7 +17,6 @@ #include "shared/util/mappers/linear_map.h" #include "shared/util/mappers/mapper.h" #include "shared/util/moving_average.h" -#include "veh_can_messages.h" /*************************************************************** App-level objects diff --git a/firmware/projects/TMS/main.cc b/firmware/projects/TMS/main.cc index 345b4af80..6a4107bc0 100644 --- a/firmware/projects/TMS/main.cc +++ b/firmware/projects/TMS/main.cc @@ -4,8 +4,10 @@ #include #include -#include "app.h" #include "bindings.h" +#include "generated/can/veh_can_messages.h" +#include "generated/can/veh_msg_registry.h" +#include "inc/app.h" #include "shared/comms/can/can_bus.h" #include "shared/os/tick.h" #include "shared/periph/adc.h" @@ -16,8 +18,6 @@ #include "shared/util/mappers/linear_map.h" #include "shared/util/mappers/lookup_table.h" #include "shared/util/mappers/mapper.h" -#include "veh_can_messages.h" -#include "veh_msg_registry.h" namespace os { extern void Tick(uint32_t ticks); diff --git a/firmware/projects/TMS/platforms/stm32f767/CMakeLists.txt b/firmware/projects/TMS/platforms/stm32f767/CMakeLists.txt index 3f38732c8..5a1132b15 100644 --- a/firmware/projects/TMS/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/TMS/platforms/stm32f767/CMakeLists.txt @@ -1,12 +1,5 @@ -# Blake Freer -# January 8, 2024 +target_sources(main PRIVATE bindings.cc os.cc) +target_link_libraries(main PUBLIC mcal-stm32f767) -add_subdirectory(cubemx) - -target_sources(bindings PUBLIC bindings.cc) -target_include_directories(bindings PUBLIC ${DIR_PROJECT}) -target_link_libraries(bindings PUBLIC driver mcal-stm32f767) - -add_library(os) -target_sources(os PUBLIC os.cc) -target_link_libraries(os PUBLIC driver mcal-stm32f767) \ No newline at end of file +add_subdirectory(cubemx/cmake/stm32cubemx) +target_link_libraries(main PUBLIC stm32cubemx) \ No newline at end of file diff --git a/firmware/projects/TMS/platforms/stm32f767/bindings.cc b/firmware/projects/TMS/platforms/stm32f767/bindings.cc index a78bdd24b..226a1e1fe 100644 --- a/firmware/projects/TMS/platforms/stm32f767/bindings.cc +++ b/firmware/projects/TMS/platforms/stm32f767/bindings.cc @@ -15,7 +15,7 @@ #include "tim.h" // fw imports -#include "bindings.h" +#include "../../bindings.h" #include "mcal/stm32f767/periph/adc.h" #include "mcal/stm32f767/periph/gpio.h" #include "mcal/stm32f767/periph/pwm.h" diff --git a/firmware/projects/TMS/platforms/stm32f767/cubemx/.gitignore b/firmware/projects/TMS/platforms/stm32f767/cubemx/.gitignore index d5b8871de..ba5839a74 100644 --- a/firmware/projects/TMS/platforms/stm32f767/cubemx/.gitignore +++ b/firmware/projects/TMS/platforms/stm32f767/cubemx/.gitignore @@ -1,4 +1,3 @@ * !*.ioc -!.gitignore -!CMakeLists.txt \ No newline at end of file +!.gitignore \ No newline at end of file diff --git a/firmware/projects/TMS/platforms/stm32f767/cubemx/CMakeLists.txt b/firmware/projects/TMS/platforms/stm32f767/cubemx/CMakeLists.txt deleted file mode 100644 index 4786834bb..000000000 --- a/firmware/projects/TMS/platforms/stm32f767/cubemx/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file diff --git a/firmware/projects/TMS/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/TMS/platforms/stm32f767/cubemx/board_config.ioc index 0d1a7569b..310b8c2b9 100644 --- a/firmware/projects/TMS/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/TMS/platforms/stm32f767/cubemx/board_config.ioc @@ -152,7 +152,7 @@ ProjectManager.ProjectName=board_config ProjectManager.ProjectStructure= ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile +ProjectManager.TargetToolchain=CMake ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= diff --git a/firmware/projects/TMS/platforms/stm32f767/mcal_conf.cmake b/firmware/projects/TMS/platforms/stm32f767/mcal_conf.cmake index ba7d7a47b..adbaa3186 100644 --- a/firmware/projects/TMS/platforms/stm32f767/mcal_conf.cmake +++ b/firmware/projects/TMS/platforms/stm32f767/mcal_conf.cmake @@ -1,3 +1,2 @@ -# This file determines which mcal folder is included so that the mcal library -# can be linked to `bindings`. -set(MCAL stm32f767) \ No newline at end of file +set(MCAL stm32f767) +include(${CMAKE_SOURCE_DIR}/cmake/build_cubemx.cmake) \ No newline at end of file