Skip to content

Commit

Permalink
hard coded STM32 support
Browse files Browse the repository at this point in the history
  • Loading branch information
naichenzhao committed Nov 11, 2023
1 parent dca5be8 commit 89986a9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
46 changes: 46 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,49 @@ define(SCHEDULER)
define(LF_SOURCE_DIRECTORY)
define(LF_PACKAGE_DIRECTORY)
define(LF_FILE_SEPARATOR)



# ==========================================================
# Stuff I added
# ==========================================================

if(${CMAKE_SYSTEM_NAME} MATCHES "Stm32")
set(CPU_PARAMETERS
-mcpu=cortex-m4
-mthumb
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp )

set(MCU_FAMILY STM32F4xx )
set(MCU_MODEL STM32F446xx )

target_compile_definitions(core PRIVATE
${MCU_MODEL}
USE_HAL_DRIVER )

target_compile_options(core PRIVATE
${CPU_PARAMETERS}
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:CXX>:
-Wno-volatile
-Wold-style-cast
-Wuseless-cast
-Wsuggest-override>
$<$<CONFIG:Debug>:-Og -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0> )

set(CUBEMX_INCLUDE_DIRECTORIES
../STM_sdk/Core/Inc
../STM_sdk/Drivers/${MCU_FAMILY}_HAL_Driver/Inc
../STM_sdk/Drivers/${MCU_FAMILY}_HAL_Driver/Inc/Legacy
../STM_sdk/Drivers/CMSIS/Device/ST/${MCU_FAMILY}/Include
../STM_sdk/Drivers/CMSIS/Include )

target_include_directories(core PUBLIC
${CUBEMX_INCLUDE_DIRECTORIES} )
endif()
# ==========================================================
2 changes: 1 addition & 1 deletion core/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Nrf52")
target_compile_definitions(core PUBLIC PLATFORM_NRF52)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Zephyr")
target_compile_definitions(core PUBLIC PLATFORM_ZEPHYR)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "STM32f4")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Stm32")
target_compile_definitions(core PUBLIC PLATFORM_STM32F4)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Rp2040")
target_compile_definitions(core PUBLIC PLATFORM_RP2040)
Expand Down
2 changes: 1 addition & 1 deletion core/platform/Platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
message("Using Windows SDK version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Zephyr")
set(LF_PLATFORM_FILE lf_zephyr_support.c)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "STM32f4")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Stm32")
set(LF_PLATFORM_FILE lf_STM32f4_support.c)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Rp2040")
message("Using pico-sdk for RP2040 target")
Expand Down
4 changes: 0 additions & 4 deletions include/core/platform/lf_STM32f4_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
// I have no idea what the fuck TTY is so i guess we dont support it
#define NO_TTY

// #include <../../../STM_Core/Inc/main.h>
// #include <../../../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h>
#include <stm32f4xx_hal.h>

// src-gen/Main/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h

// Defines for formatting time in printf for pico
#define PRINTF_TAG "(" PRINTF_TIME ", " PRINTF_MICROSTEP ")"
#define PRINTF_TIME "%lld"
Expand Down

0 comments on commit 89986a9

Please sign in to comment.