-
-
Notifications
You must be signed in to change notification settings - Fork 48
Cmake & Code formatting #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
danielnilsson9
wants to merge
3
commits into
master
Choose a base branch
from
cmake
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| LineEnding: LF | ||
| UseTab: Never | ||
| IndentWidth: 4 | ||
| ColumnLimit: 120 | ||
|
|
||
| IndentCaseLabels: false | ||
| BreakBeforeBraces: Allman | ||
| AllowShortIfStatementsOnASingleLine: false | ||
| AllowShortFunctionsOnASingleLine: false | ||
| AlignConsecutiveMacros: | ||
| Enabled: true | ||
| AcrossEmptyLines: true | ||
| AcrossComments: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| end_of_line = crlf | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| charset = utf-8 | ||
| indent_style = tab | ||
| indent_style = space | ||
| indent_size = 4 | ||
| trim_trailing_whitespace = true | ||
|
|
||
| [*.md] | ||
| trim_trailing_whitespace = false | ||
| trim_trailing_whitespace = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Disable git line ending conversion | ||
| * -text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: check-yaml | ||
| - id: end-of-file-fixer | ||
| - id: trailing-whitespace | ||
| args: [--markdown-linebreak-ext=md] | ||
| - id: check-added-large-files | ||
| - id: mixed-line-ending | ||
| args: [--fix=lf] | ||
| exclude: '^drawings/' | ||
| - repo: https://github.com/pre-commit/mirrors-clang-format | ||
| rev: v18.1.8 | ||
| hooks: | ||
| - id: clang-format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .vs | ||
| .vscode | ||
| build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| cmake_minimum_required(VERSION 3.15) | ||
|
|
||
| project(bbs-fw C) | ||
|
|
||
| set(TARGET_CONTROLLER "BBSHD" CACHE STRING "Target controller: BBSHD,BBS02,TSDZ2,TSDZ8") | ||
|
|
||
| if (${TARGET_CONTROLLER} STREQUAL "BBSHD") | ||
| add_link_options(--xram-size 3840) | ||
| endif() | ||
|
|
||
| if (${TARGET_CONTROLLER} STREQUAL "BBS02") | ||
| add_link_options(--xram-size 1792) | ||
| endif() | ||
|
|
||
| if (${TARGET_CONTROLLER} STREQUAL "TSDZ2") | ||
| add_subdirectory(lib/stm8s) | ||
| endif() | ||
|
|
||
| set(SOURCE_FILES | ||
| "src/adc.h" | ||
| "src/app.c" | ||
| "src/app.h" | ||
| "src/battery.c" | ||
| "src/battery.h" | ||
| "src/cfgstore.c" | ||
| "src/cfgstore.h" | ||
| "src/eeprom.h" | ||
| "src/eventlog.c" | ||
| "src/eventlog.h" | ||
| "src/extcom.c" | ||
| "src/extcom.h" | ||
| "src/fwconfig.h" | ||
| "src/interrupt.h" | ||
| "src/lights.h" | ||
| "src/main.c" | ||
| "src/motor.h" | ||
| "src/sensors.h" | ||
| "src/system.h" | ||
| "src/throttle.c" | ||
| "src/throttle.h" | ||
| "src/timers.h" | ||
| "src/uart.h" | ||
| "src/util.h" | ||
| "src/version.h" | ||
| "src/watchdog.h" | ||
| ) | ||
|
|
||
| if (${TARGET_CONTROLLER} STREQUAL "BBSHD" OR ${TARGET_CONTROLLER} STREQUAL "BBS02") | ||
| list(APPEND SOURCE_FILES | ||
| "src/bbsx/adc.c" | ||
| "src/bbsx/cpu.h" | ||
| "src/bbsx/eeprom.c" | ||
| "src/bbsx/interrupt.h" | ||
| "src/bbsx/lights.c" | ||
| "src/bbsx/motor.c" | ||
| "src/bbsx/pins.h" | ||
| "src/bbsx/sensors.c" | ||
| "src/bbsx/stc15.h" | ||
| "src/bbsx/system.c" | ||
| "src/bbsx/timers.c" | ||
| "src/bbsx/timers.h" | ||
| "src/bbsx/uart_motor.h" | ||
| "src/bbsx/uart.c" | ||
| "src/bbsx/watchdog.c" | ||
| ) | ||
| endif() | ||
|
|
||
| if (${TARGET_CONTROLLER} STREQUAL "TSDZ2") | ||
| list(APPEND SOURCE_FILES | ||
| "src/tsdz2/adc.c" | ||
| "src/tsdz2/cpu.h" | ||
| "src/tsdz2/eeprom.c" | ||
| "src/tsdz2/interrupt.h" | ||
| "src/tsdz2/lights.c" | ||
| "src/tsdz2/motor.c" | ||
| "src/tsdz2/pins.h" | ||
| "src/tsdz2/sensors.c" | ||
| "src/tsdz2/stm8.h" | ||
| "src/tsdz2/system.c" | ||
| "src/tsdz2/timers.c" | ||
| "src/tsdz2/timers.h" | ||
| "src/tsdz2/torquesensor.c" | ||
| "src/tsdz2/uart.c" | ||
| "src/tsdz2/watchdog.c" | ||
| ) | ||
| endif() | ||
|
|
||
| add_executable(bbs-fw ${SOURCE_FILES}) | ||
|
|
||
| target_compile_definitions(bbs-fw PRIVATE ${TARGET_CONTROLLER}) | ||
| target_include_directories(bbs-fw PRIVATE src) | ||
|
|
||
| if (${TARGET_CONTROLLER} STREQUAL "TSDZ2") | ||
| target_link_libraries(bbs-fw stm8s) | ||
| endif() | ||
|
|
||
|
|
||
| # Generate hex file (SDCC) | ||
| if (${CMAKE_C_COMPILER} STREQUAL "sdcc" OR ${TARGET_CONTROLLER} STREQUAL "BBS02" OR ${TARGET_CONTROLLER} STREQUAL "TSDZ2") | ||
| add_custom_command( | ||
| POST_BUILD | ||
| COMMENT Generating bbs-fw.hex | ||
| TARGET bbs-fw | ||
| COMMAND packihx bbs-fw.ihx > bbs-fw.hex | ||
| ) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { | ||
| "version": 6, | ||
| "cmakeMinimumRequired": { | ||
| "major": 3, | ||
| "minor": 15, | ||
| "patch": 0 | ||
| }, | ||
| "configurePresets": [ | ||
| { | ||
| "name": "bbshd-release", | ||
| "displayName": "BBSHD", | ||
| "description": "Build for BBSHD", | ||
| "generator": "Ninja", | ||
| "binaryDir": "${sourceDir}/build/bbshd-release", | ||
| "toolchainFile": "${sourceDir}/cmake/sdcc-8051-toolchain.cmake", | ||
| "cacheVariables": { | ||
| "CMAKE_BUILD_TYPE": "Release", | ||
| "TARGET_CONTROLLER": { | ||
| "type": "STRING", | ||
| "value": "BBSHD" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "name": "bbs02-release", | ||
| "displayName": "BBS02", | ||
| "description": "Build for BBS02", | ||
| "generator": "Ninja", | ||
| "binaryDir": "${sourceDir}/build/bbs02-release", | ||
| "toolchainFile": "${sourceDir}/cmake/sdcc-8051-toolchain.cmake", | ||
| "cacheVariables": { | ||
| "CMAKE_BUILD_TYPE": "Release", | ||
| "TARGET_CONTROLLER": { | ||
| "type": "STRING", | ||
| "value": "BBS02" | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "name": "tsdz2-release", | ||
| "displayName": "TSDZ2", | ||
| "description": "Build for TSDZ2", | ||
| "generator": "Ninja", | ||
| "binaryDir": "${sourceDir}/build/tsdz2-release", | ||
| "toolchainFile": "${sourceDir}/cmake/sdcc-stm8-toolchain.cmake", | ||
| "cacheVariables": { | ||
| "CMAKE_BUILD_TYPE": "Release", | ||
| "TARGET_CONTROLLER": { | ||
| "type": "STRING", | ||
| "value": "TSDZ2" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "buildPresets": [ | ||
| { | ||
| "name": "bbshd-release", | ||
| "configurePreset": "bbshd-release" | ||
| }, | ||
| { | ||
| "name": "tsdz2-release", | ||
| "configurePreset": "tsdz2-release" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # the name of the target operating system | ||
| set(CMAKE_SYSTEM_NAME Generic) | ||
| set(CMAKE_SYSTEM_PROCESSOR 8051) | ||
|
|
||
| set(CMAKE_C_FLAGS_INIT "-mmcs51 --model-large --std-sdcc11 -Ddouble=float") | ||
| set(CMAKE_EXE_LINKER_FLAGS_INIT "") | ||
|
|
||
| set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
|
|
||
| # which compilers to use for C and ASM | ||
| set(CMAKE_C_COMPILER sdcc) | ||
|
|
||
| find_program (SDCC NAMES sdcc) | ||
| get_filename_component(SDCC_BIN_DIR ${SDCC} DIRECTORY) | ||
| get_filename_component(SDCC_PATH_DIR ${SDCC_BIN_DIR} DIRECTORY) | ||
|
|
||
| # here is the target environment is located | ||
| set(CMAKE_FIND_ROOT_PATH ${SDCC_PATH_DIR}/usr/share/sdcc) | ||
|
|
||
| # adjust the default behaviour of the FIND_XXX() commands: | ||
| # search headers and libraries in the target environment, search | ||
| # programs in the host environment | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
|
|
||
| set(CMAKE_ASM_OUTPUT_EXTENSION ".rel") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # the name of the target operating system | ||
| set(CMAKE_SYSTEM_NAME Generic) | ||
| set(CMAKE_SYSTEM_PROCESSOR stm8) | ||
|
|
||
| set(CMAKE_C_FLAGS_INIT "-mstm8 --std-sdcc11 -Ddouble=float") | ||
| set(CMAKE_EXE_LINKER_FLAGS_INIT "") | ||
|
|
||
| set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
|
|
||
| # which compilers to use for C and ASM | ||
| set(CMAKE_C_COMPILER sdcc) | ||
| set(CMAKE_ASM_COMPILER sdasstm8) | ||
|
|
||
| find_program (SDCC NAMES sdcc) | ||
| get_filename_component(SDCC_BIN_DIR ${SDCC} DIRECTORY) | ||
| get_filename_component(SDCC_PATH_DIR ${SDCC_BIN_DIR} DIRECTORY) | ||
|
|
||
| # here is the target environment is located | ||
| set(CMAKE_FIND_ROOT_PATH ${SDCC_PATH_DIR}/usr/share/sdcc) | ||
|
|
||
| # adjust the default behaviour of the FIND_XXX() commands: | ||
| # search headers and libraries in the target environment, search | ||
| # programs in the host environment | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
|
|
||
| set(CMAKE_ASM_OUTPUT_EXTENSION ".rel") | ||
|
|
||
| set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_ASM_COMPILER} -o <OBJECT> <SOURCE>") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| DisableFormat: true | ||
| SortIncludes: Never |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
|
|
||
| add_library(stm8s INTERFACE | ||
| "include/stm8/stm8s_adc1.h" | ||
| "include/stm8/stm8s_adc2.h" | ||
| "include/stm8/stm8s_awu.h" | ||
| "include/stm8/stm8s_beep.h" | ||
| "include/stm8/stm8s_can.h" | ||
| "include/stm8/stm8s_clk.h" | ||
| "include/stm8/stm8s_exti.h" | ||
| "include/stm8/stm8s_flash.h" | ||
| "include/stm8/stm8s_gpio.h" | ||
| "include/stm8/stm8s_i2c.h" | ||
| "include/stm8/stm8s_itc.h" | ||
| "include/stm8/stm8s_iwdg.h" | ||
| "include/stm8/stm8s_rst.h" | ||
| "include/stm8/stm8s_spi.h" | ||
| "include/stm8/stm8s_tim1.h" | ||
| "include/stm8/stm8s_tim2.h" | ||
| "include/stm8/stm8s_tim3.h" | ||
| "include/stm8/stm8s_tim4.h" | ||
| "include/stm8/stm8s_tim5.h" | ||
| "include/stm8/stm8s_tim6.h" | ||
| "include/stm8/stm8s_uart1.h" | ||
| "include/stm8/stm8s_uart2.h" | ||
| "include/stm8/stm8s_uart3.h" | ||
| "include/stm8/stm8s_uart4.h" | ||
| "include/stm8/stm8s_wwdg.h" | ||
| "include/stm8/stm8s.h" | ||
| ) | ||
|
|
||
| target_include_directories(stm8s INTERFACE include) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't look further into the file, but should this line have BBSHD too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ye that's wrong, thanks!