Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 0 additions & 207 deletions .cproject

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ jobs:
- uses: actions/checkout@v4

- name: Install ARM toolchain
run: sudo apt-get install gcc-arm-none-eabi binutils-arm-none-eabi
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: 15.2.Rel1

- name: Install CMake
uses: ssrobins/install-cmake@v1
with:
version: 4.0.2
version: 4.3.3

- name: Build firmware
id: build
Expand Down
2 changes: 1 addition & 1 deletion .idea/alim-controller.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/debugServers/Config.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/debugServers/ST_LINK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 82 additions & 55 deletions .idea/editor.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/OCD_alim_controller.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions .mxproject

Large diffs are not rendered by default.

Empty file removed .osx.project
Empty file.
57 changes: 29 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: fix-byte-order-marker
stages: ['commit']
- id: check-case-conflict
stages: ['commit']
- id: check-executables-have-shebangs
stages: ['commit']
- id: check-shebang-scripts-are-executable
stages: ['commit']
- id: check-json
stages: ['commit']
- id: pretty-format-json
stages: ['commit']
- id: check-xml
stages: ['commit']
- id: check-yaml
stages: ['commit']
args:
- "--allow-multiple-documents"
- id: check-merge-conflict
stages: ['commit']
- id: end-of-file-fixer
exclude: '.*\.idea/.*|robots.iml'
stages: ['commit']
- id: trailing-whitespace
stages: ['commit']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: fix-byte-order-marker
stages: ['pre-commit']
- id: check-case-conflict
stages: ['pre-commit']
- id: check-executables-have-shebangs
stages: ['pre-commit']
- id: check-shebang-scripts-are-executable
stages: ['pre-commit']
- id: check-json
stages: ['pre-commit']
- id: pretty-format-json
stages: ['pre-commit']
exclude: 'CMakePresets.json'
- id: check-xml
stages: ['pre-commit']
- id: check-yaml
stages: ['pre-commit']
args:
- "--allow-multiple-documents"
- id: check-merge-conflict
stages: ['pre-commit']
- id: end-of-file-fixer
exclude: '.*\.idea/.*'
stages: ['pre-commit']
- id: trailing-whitespace
stages: ['pre-commit']
32 changes: 0 additions & 32 deletions .project

This file was deleted.

12 changes: 6 additions & 6 deletions Core/Inc/itm_log.h → App/Inc/itm_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ extern "C" {

#define LOG_LEVEL_MIN LOG_WARN_LEVEL

#define LOG_DEBUG(msg) println(msg, LOG_DEBUG_LEVEL)
#define LOG_INFO(msg) println(msg, LOG_INFO_LEVEL)
#define LOG_WARN(msg) println(msg, LOG_WARN_LEVEL)
#define LOG_ERROR(msg) println(msg, LOG_ERROR_LEVEL)
#define LOG_DEBUG(msg) itmPrintLn(msg, LOG_DEBUG_LEVEL)
#define LOG_INFO(msg) itmPrintLn(msg, LOG_INFO_LEVEL)
#define LOG_WARN(msg) itmPrintLn(msg, LOG_WARN_LEVEL)
#define LOG_ERROR(msg) itmPrintLn(msg, LOG_ERROR_LEVEL)

void print(char _char, uint8_t level);
void itmPrint(char _char, uint8_t level);

void println(const char *msg, uint8_t level);
void itmPrintLn(const char *msg, uint8_t level);

#ifdef __cplusplus
}
Expand Down
8 changes: 4 additions & 4 deletions Core/Src/itm_log.c → App/Src/itm_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <string.h>

void print(char _char, uint8_t level) {
void itmPrint(char _char, uint8_t level) {
#ifdef DEBUG_MODE
while (ITM->PORT[level].u32 == 0UL) {
__NOP();
Expand All @@ -15,14 +15,14 @@ void print(char _char, uint8_t level) {
#endif
}

void println(const char *msg, uint8_t level) {
void itmPrintLn(const char *msg, uint8_t level) {
#ifdef DEBUG_MODE
if (msg == NULL || level > 31 || level < LOG_LEVEL_MIN) {
return;
}
for (int i = 0; i < strlen(msg); i++) {
print(msg[i], level);
itmPrint(msg[i], level);
}
print('\n', level);
itmPrint('\n', level);
#endif
}
142 changes: 78 additions & 64 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,89 +1,103 @@
#THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
cmake_minimum_required(VERSION 4.0)

# specify cross-compilers and tools
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_AR arm-none-eabi-ar)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
set(SIZE arm-none-eabi-size)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

# project settings
project(alim-controller C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
cmake_minimum_required(VERSION 3.22)

#
# This file is generated only once,
# and is not re-generated if converter is called multiple times.
#
# User is free to modify the file as much as necessary
#

# Setup compiler settings
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)

# Define FIRMWARE_VERSION
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(TIMESTAMP VERSION "%Y.%m.%d")
string(TIMESTAMP VERSION_SHORT "%Y%m%d")
add_definitions(-DFIRMWARE_VERSION="${VERSION}-${GIT_HASH}" -DVERSION_SHORT="${VERSION_SHORT}")

#Uncomment for hardware floating point
add_compile_definitions(ARM_MATH_CM4;ARM_MATH_MATRIX_CHECK;ARM_MATH_ROUNDING)
add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)

#Uncomment for software floating point
#add_compile_options(-mfloat-abi=soft)
# Define the build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

add_compile_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0)
# Set the project name
set(CMAKE_PROJECT_NAME alim-controller)

# uncomment to mitigate c++17 absolute addresses warnings
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")
# Enable compile command to ease indexing with e.g. clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

# Enable assembler files preprocessing
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-x$<SEMICOLON>assembler-with-cpp>)
# Core project settings
project(${CMAKE_PROJECT_NAME})
message("Build type: " ${CMAKE_BUILD_TYPE})

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Maximum optimization for speed")
add_compile_options(-Ofast)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
message(STATUS "Maximum optimization for speed, debug info included")
add_compile_options(-Ofast -g)
add_definitions(-DDEBUG_MODE)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
message(STATUS "Maximum optimization for size")
add_compile_options(-Os)
else ()
message(STATUS "Minimal optimization, debug info included")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Debug build: Enabling debug symbols and disabling optimizations")
add_compile_options(-Og -g)
add_definitions(-DDEBUG_MODE)
else()
message("Release build: Enabling optimizations and stripping symbols")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -s")
endif ()

include_directories(Core/Inc Drivers/STM32G4xx_HAL_Driver/Inc Drivers/STM32G4xx_HAL_Driver/Inc/Legacy Middlewares/Third_Party/FreeRTOS/Source/include Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F Drivers/CMSIS/Device/ST/STM32G4xx/Include Drivers/CMSIS/Include Core/ThreadSafe)
# Enable CMake support for ASM and C languages
enable_language(C ASM)

add_definitions(-DDEBUG -DUSE_HAL_DRIVER -DSTM32G474xx -DSTM32_THREAD_SAFE_STRATEGY=4)
# Create an executable object type
add_executable(${CMAKE_PROJECT_NAME})

file(GLOB_RECURSE SOURCES "Core/*.*" "Middlewares/*.*" "Drivers/*.*")
# Add STM32CubeMX generated sources
add_subdirectory(cmake/stm32cubemx)

set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32G474RETX_FLASH.ld)
# Link directories setup
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined library search paths
)

add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
add_link_options(-mcpu=cortex-m4 -mthumb -mthumb-interwork)
add_link_options(-T ${LINKER_SCRIPT})
# Collect user sources and includes from the App folder
file(GLOB_RECURSE APP_SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_LIST_DIR}/App/Src/*.c"
)
file(GLOB_RECURSE APP_HEADERS CONFIGURE_DEPENDS
"${CMAKE_CURRENT_LIST_DIR}/App/Inc/*.h"
)
set(APP_INCLUDE_DIRS "")
foreach(_header ${APP_HEADERS})
get_filename_component(_dir ${_header} DIRECTORY)
list(APPEND APP_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES APP_INCLUDE_DIRS)

# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
${APP_SOURCES}
)

# Uncomment to enable semihosting
#add_link_options(-specs=rdimon.specs -lrdimon)
# Add include paths
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
${APP_INCLUDE_DIRS}
)

add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
# Add project symbols (macros)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined symbols
FIRMWARE_VERSION="${VERSION}-${GIT_HASH}"
VERSION_SHORT="${VERSION_SHORT}"
)

set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
# Remove wrong libob.a library dependency when using cpp files
list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES ob)

add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMENT "Building ${HEX_FILE}
Building ${BIN_FILE}")
# Add linked libraries
target_link_libraries(${CMAKE_PROJECT_NAME}
stm32cubemx

# Add user defined libraries
)
Loading
Loading