Skip to content

Commit

Permalink
feat!: update ST hal drivers (#102)
Browse files Browse the repository at this point in the history
* Update STM32F7 hal drivers to version 1.17.0

* Update STM32F4 hal drivers to version 1.27.1

* Update STM32WB hal drivers to version 1.16.0

* Remove std_periph_stm32f4xx

* Add STM32G4 hal drivers version 1.5.1

* add configuration and make it compile for stm32g431

* Remove unmaintained peripheral libraries: stm32f0, f2, f3

* Remove trace

* Add hal_st/std_periph/HowToImport.txt

* Refactor hal_st/std_periph/CMakeLists

* ci: add stm32g431

* Replace HALST_INCLUDE_DEFAULT_LINKER_SCRIPTS with halst_target_default_linker_scripts

* Fix previous commit

* Remove most conditional inclusion of peripherals

* Replace HALST_INCLUDE_DEFAULT_INIT by halst_default_init function

* Move ST HAL drivers from hal_st to st, remove hal_st/cmsis/cmsis_arm and hal_st/cmsis/cortex

* Remove hal_st/cmsis, add default code to hal_st/default_init/DefaultInit.cpp, remove Default_Handler from all startup code

* hal_st/default_init/CMakeLists: Rename halst_default_init to halst_target_default_init

* Align Nucleo support

* Fix startup initialization of STM32WBxx

* Make xml files used for generating tables configurable through HALST_XML_GPIO and HALST_XML_STM32

* CMakePresets: Configure the Nucleo variant for STM32WB55

* examples/blink and examples/freertos: Only include in build when building for ST

* .github/workflows/ci.yml: stm32wb55cg -> stm32wb55rg

* Move default clock initialization functions to hal_st/stm32fxxx

* hal_st/instantiations/NucleoUi: Rename Nucleo68Ui to Nucleo64WBUi

* Add initialization methods for typical Nucleo and Discovery clock settings

* Move initialization assembly to hal_st.default_init

* st/hal_driver.cmake: Add USE_FULL_LL_DRIVER definition

* Several small refactorings

* .github/workflows/ci.yml: Update stm32wb55rg to stm32wb55

* Make examples/blink suitable for NUCLEO-G431RB

* hal_st/default_init/DefaultInit: Add __assert_func to avoid pulling in _write, _close, _fstat, _isatty, _lseek, _read

* hal_st/default_init/DefaultInit: Make Default_Handler_Forwarded weak so it can be overridden

* CMakeLists: Update emil version used because the release contains a bug regarding the use of EMIL_OBJ_COPY_TOOL
  • Loading branch information
richardapeters authored Apr 14, 2023
1 parent b103541 commit 6987d83
Show file tree
Hide file tree
Showing 1,902 changed files with 1,734,922 additions and 1,004,763 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
configuration: ["RelWithDebInfo"]
gcc: [ "10.3-2021.10" ]
target: ["stm32wb55cg", "stm32f407", "stm32f429", "stm32f746", "stm32f767"]
target: ["stm32wb55", "stm32g431", "stm32f407", "stm32f429", "stm32f746", "stm32f767"]
include:
- gcc: "7-2018-q2"
configuration: "RelWithDebInfo"
Expand Down
11 changes: 10 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
"version": "0.2.0",
"configurations": [
{
"name": "Current target (stm32f767)",
"name": "stm32f767",
"cwd": "${workspaceRoot}",
"request": "launch",
"executable": "${command:cmake.launchTargetPath}",
"type": "cortex-debug",
"servertype": "jlink",
"device": "STM32F767ZI"
},
{
"name": "stm32g431",
"cwd": "${workspaceRoot}",
"request": "launch",
"executable": "${command:cmake.launchTargetPath}",
"type": "cortex-debug",
"servertype": "stlink",
"device": "STM32G431RB"
}
]
}
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ endif()

option(CMAKE_COMPILE_WARNING_AS_ERROR "Enable warnings-as-error" ON)
option(HALST_INCLUDE_DEFAULT_INIT "Include default initialization code; turn off when providing custom initialization" ON)
option(HALST_INCLUDE_DEFAULT_LINKER_SCRIPTS "Include default memory-layout and sections linker scripts; turn off when providing custom linker scripts" ON)
option(HALST_BUILD_EXAMPLES "Enable build of the examples" OFF)
option(HALST_BUILD_EXAMPLES_FREERTOS "Enable build of the FreeRTOS example" OFF)
set(HALST_XML_GPIO "" CACHE STRING "XML GPIO table")
set(HALST_XML_STM32 "" CACHE STRING "XML STM32 table")

if (HALST_STANDALONE)
set(EMIL_INCLUDE_FREERTOS ${HALST_BUILD_EXAMPLES_FREERTOS})
Expand All @@ -18,13 +19,13 @@ if (HALST_STANDALONE)
FetchContent_Declare(
emil
GIT_REPOSITORY https://github.com/philips-software/embeddedinfralib.git
GIT_TAG 11f07b8add4d5c45ae930cb4145c2591e7ffbb1d # v3.1.0
GIT_TAG fd93b901fc2882334caf7bfdf54c7d0a4e4de242 # unreleased
)

FetchContent_MakeAvailable(emil)
endif()

project(hal_st LANGUAGES C CXX VERSION 1.1.0) # x-release-please-version
project(hal_st LANGUAGES C CXX ASM VERSION 1.1.0) # x-release-please-version

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED On)
Expand All @@ -39,13 +40,14 @@ else()
set(HALST_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
endif()

add_subdirectory(st)
add_subdirectory(hal_st)
add_subdirectory(hal_st_lwip)

if (HALST_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

add_subdirectory(hal_st)
add_subdirectory(hal_st_lwip)

emil_clangformat_directories(hal_st DIRECTORIES .)

if (HALST_STANDALONE)
Expand Down
29 changes: 23 additions & 6 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,28 @@
}
},
{
"name": "stm32wb55cg",
"displayName": "stm32wb55cg",
"description": "Build for stm32wb55cg",
"name": "stm32wb55",
"displayName": "stm32wb55",
"description": "Build for stm32wb55",
"inherits": "stm32",
"toolchainFile": "${sourceDir}/build/${presetName}/_deps/emil-src/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake",
"cacheVariables": {
"TARGET_CORTEX": "m4",
"TARGET_MCU_FAMILY": "stm32wbxx",
"TARGET_MCU": "stm32wb55",
"TARGET_MCU_VARIANT": "stm32wb55cg"
"TARGET_MCU_VARIANT": "stm32wb55rg"
}
},
{
"name": "stm32g431",
"displayName": "stm32g431",
"description": "Build for stm32g431",
"inherits": "stm32",
"toolchainFile": "${sourceDir}/build/${presetName}/_deps/emil-src/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake",
"cacheVariables": {
"TARGET_CORTEX": "m4",
"TARGET_MCU_FAMILY": "stm32g4xx",
"TARGET_MCU": "stm32g431"
}
},
{
Expand Down Expand Up @@ -106,9 +118,14 @@
"configurePreset": "host"
},
{
"name": "stm32wb55cg-RelWithDebInfo",
"name": "stm32wb55-RelWithDebInfo",
"configuration": "RelWithDebInfo",
"configurePreset": "stm32wb55"
},
{
"name": "stm32g431-RelWithDebInfo",
"configuration": "RelWithDebInfo",
"configurePreset": "stm32wb55cg"
"configurePreset": "stm32g431"
},
{
"name": "stm32f407-RelWithDebInfo",
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ target_link_libraries(myprogram PUBLIC
infra.event
hal_st.stm32fxxx
)
halst_target_default_linker_scripts(myprogram)
halst_target_default_init(myprogram)
```

## How to test the software
Expand Down
44 changes: 35 additions & 9 deletions examples/blink/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
if ("${TARGET_MCU}" STREQUAL "stm32f767")
add_executable(hal_st.blink Main.cpp)
target_link_libraries(hal_st.blink PRIVATE
services.util
hal_st.instantiations
)

emil_generate_artifacts(TARGET hal_st.blink LST MAP BIN HEX)
endif()
add_executable(hal_st.blink_nucleo144 Main.cpp)
set_target_properties(hal_st.blink_nucleo144 PROPERTIES EXCLUDE_FROM_ALL $<NOT:$<STREQUAL:${TARGET_MCU_VENDOR},st>>)

target_compile_definitions(hal_st.blink_nucleo144 PUBLIC
NUCLEO=Nucleo144Ui
)

target_link_libraries(hal_st.blink_nucleo144 PRIVATE
services.util
hal_st.instantiations
)

halst_target_default_linker_scripts(hal_st.blink_nucleo144)
halst_target_default_init(hal_st.blink_nucleo144)

emil_generate_artifacts(TARGET hal_st.blink_nucleo144 LST MAP BIN HEX)

######################################################################

add_executable(hal_st.blink_nucleo64 Main.cpp)
set_target_properties(hal_st.blink_nucleo64 PROPERTIES EXCLUDE_FROM_ALL $<NOT:$<STREQUAL:${TARGET_MCU_VENDOR},st>>)

target_compile_definitions(hal_st.blink_nucleo64 PUBLIC
NUCLEO=Nucleo64Ui
)

target_link_libraries(hal_st.blink_nucleo64 PRIVATE
services.util
hal_st.instantiations
)

halst_target_default_linker_scripts(hal_st.blink_nucleo64)
halst_target_default_init(hal_st.blink_nucleo64)

emil_generate_artifacts(TARGET hal_st.blink_nucleo64 LST MAP BIN HEX)
15 changes: 9 additions & 6 deletions examples/blink/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#include "hal_st/instantiations/NucleoUi.hpp"
#include "hal_st/instantiations/StmEventInfrastructure.hpp"
//#include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp"
#include "services/util/DebugLed.hpp"

extern "C" void Default_Handler()
{
hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt());
}
unsigned int hse_value = 8000000;

int main()
{
HAL_Init();

// Configure your clock here
//ConfigureDefaultClockNucleo767ZI();

static main_::StmEventInfrastructure eventInfrastructure;
static main_::NucleoF767ziUi ui;
static services::DebugLed debugLed(ui.ledBlue);
static main_::NUCLEO ui;
static services::DebugLed debugLed(ui.ledGreen);

eventInfrastructure.Run();
__builtin_unreachable();
Expand Down
13 changes: 10 additions & 3 deletions examples/freertos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
if ("${TARGET_MCU}" STREQUAL "stm32f767" AND ${HALST_BUILD_EXAMPLES_FREERTOS})
add_executable(hal_st.freertos Main.cpp)
target_link_libraries(hal_st.freertos PRIVATE
if (${HALST_BUILD_EXAMPLES_FREERTOS})
add_executable(hal_st.freertos_nucleo144 Main.cpp)
set_target_properties(hal_st.freertos_nucleo144 PROPERTIES EXCLUDE_FROM_ALL $<NOT:$<STREQUAL:${TARGET_MCU_VENDOR},st>>)

target_link_libraries(hal_st.freertos_nucleo144 PRIVATE
hal_st.instantiations
osal.thread
osal.freertos_system_time
)

halst_target_default_linker_scripts(hal_st.freertos_nucleo144)
halst_target_default_init(hal_st.freertos_nucleo144)

emil_generate_artifacts(TARGET hal_st.freertos_nucleo144 LST MAP BIN HEX)
endif()
14 changes: 8 additions & 6 deletions examples/freertos/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
#include <chrono>
#include <thread>

extern "C" void Default_Handler()
{
hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt());
}

using namespace std::chrono_literals;

extern "C" void xPortPendSVHandler();
Expand All @@ -23,8 +18,15 @@ extern "C" [[gnu::naked]] void SVC_Handler() { asm("b vPortSVCHandler"); }
extern "C" [[gnu::naked]] void PendSV_Handler() { asm("b xPortPendSVHandler"); }
extern "C" [[gnu::naked]] void SysTick_Handler() { asm("b xPortSysTickHandler"); };

unsigned int hse_value = 8000000;

int main()
{
HAL_Init();

// Configure your clock here
//ConfigureDefaultClockNucleo767ZI();

static hal::InterruptTable::WithStorage<128> interruptTable;
static hal::GpioStm gpio{ hal::pinoutTableDefaultStm, hal::analogTableDefaultStm };
static hal::TimerServiceFreeRtos timerService;
Expand All @@ -33,7 +35,7 @@ int main()

osal::Init();

static main_::NucleoF767ziUi ui;
static main_::Nucleo144Ui ui;
static hal::OutputPin pinGreen{ ui.ledGreen };

static std::thread t1([]()
Expand Down
3 changes: 1 addition & 2 deletions hal_st/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
add_subdirectory(cmsis)
add_subdirectory(std_periph)
add_subdirectory(cortex)
add_subdirectory(stm32fxxx)
add_subdirectory(synchronous_stm32fxxx)
add_subdirectory(middlewares)
add_subdirectory(instantiations)
add_subdirectory(default_init)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cmsis_device.h"
#include DEVICE_HEADER

extern "C"
{
Expand Down
5 changes: 0 additions & 5 deletions hal_st/cmsis/CMakeLists.txt

This file was deleted.

30 changes: 0 additions & 30 deletions hal_st/cmsis/cmsis_arm/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 6987d83

Please sign in to comment.