Skip to content
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

feat!: update DmaStm to support new dma peripherals in G0, G4 and WB devices #169

Merged
merged 57 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3f5905d
chore: added .cache folder to gitignore
daantimmer Jul 18, 2023
980f33a
chore: added vscode settings for compileCommands and clangd
daantimmer Jul 18, 2023
6d3f480
chore: removed peripheral address from StreamBase
daantimmer Jul 18, 2023
cd3f9ee
refactor: changed DmaStm to support stream and channel based dma peri…
daantimmer Jul 19, 2023
f174dae
chore: fixed DmaStm typos
daantimmer Jul 19, 2023
f7ceb20
refactor: reworked DmaStm configuration lists for channel based dma p…
daantimmer Jul 19, 2023
d30bc95
feat: added default clock config for g474 nucleo
daantimmer Jul 19, 2023
063ed50
refactor: reworkedexamples to match supported nucleo boards and added…
daantimmer Jul 19, 2023
861f47c
feat: added g474 linker script
daantimmer Jul 19, 2023
d760dbc
build: added stm32g474 cmake configuration
daantimmer Jul 19, 2023
a492f1b
chore: added stm32wb55 stlink-remote debug target
daantimmer Jul 19, 2023
e5bedd0
build: removed 144pin configuration from helloworld targets
daantimmer Jul 20, 2023
5370086
refactor: cleaned up NucleoUi.hpp
daantimmer Jul 20, 2023
ef1e4bf
refactor: removed old dma implementation
daantimmer Jul 20, 2023
37f4090
refactor: removed old default dma configurations
daantimmer Jul 20, 2023
6f77a0f
chore: removed obsolete comment
daantimmer Jul 20, 2023
b725141
chore: moved code to correct location in header
daantimmer Jul 20, 2023
518e2db
refactor: separated template definitions and implementations
daantimmer Jul 20, 2023
c66183b
refactor: removed incorrect include
daantimmer Jul 20, 2023
7d878f1
removed DacStm
daantimmer Sep 6, 2023
e10ee94
fixed AnalogToDigitalPinStm to work with G4 devices
daantimmer Sep 6, 2023
9c17999
Fixed using incorrect register flag to determine FIFO/RX status
daantimmer Sep 7, 2023
e534ae6
Reworked UartStmDuplexDma
daantimmer Sep 7, 2023
0319267
Added IsInterruptPending to DmaStm
daantimmer Sep 7, 2023
12cbf12
fixed incorrect uartRts/uartCts initialization
daantimmer Sep 7, 2023
d274b6d
Merge branch 'main' into feature/refactor-dmastm
daantimmer Sep 19, 2023
f86a3f7
chore: fixed missing cmakepresets build entries
daantimmer Sep 19, 2023
f898da5
chore: removed unused includes
daantimmer Sep 19, 2023
574135f
chore: refactored UartStmDma to remove duplication
daantimmer Sep 19, 2023
15048ce
chore: remove duplication from UartStmDuplexDma
daantimmer Sep 19, 2023
af4829f
chore: updated formatting
daantimmer Sep 19, 2023
180abcb
chore: revert invalid comparison change
daantimmer Sep 22, 2023
7ee0706
chore: added noexcept to DmaStm::Stream::move-ctor
daantimmer Sep 29, 2023
3bd4bc6
feat: updated intialization of dma based peripherals, moved Uart*::Co…
daantimmer Sep 29, 2023
8ec6ad8
chore: cat CMakePresets.json
daantimmer Sep 29, 2023
643e49a
chore: remove cat CMakePresets.json
daantimmer Sep 29, 2023
2c7bbd8
Merge branch 'main' into feature/refactor-dmastm
daantimmer Sep 29, 2023
90e2b8e
chore: update CMakePresets.json
daantimmer Sep 29, 2023
63ad7ab
chore: resolved comments
daantimmer Oct 6, 2023
8fc37b7
feat: add SetPierpheralTransferSize to all DMA streams
daantimmer Oct 12, 2023
e9105e6
fix: fixed SpiDataSizeConfiguratorStm not using the provided dataSize…
daantimmer Oct 12, 2023
6d053eb
fix: fxed incorrect ISR flag check to determine if the uart fifo is e…
daantimmer Oct 12, 2023
5528575
feat: added setting peripheral transfer size when changing the datasi…
daantimmer Oct 12, 2023
b6339b3
Fixed issue with ReceivedSize
daantimmer Nov 7, 2023
330773a
feat: refactored DmaStm to remove all instances of CRTP and simplifie…
daantimmer Dec 19, 2023
83fb325
Merge branch 'main' into feature/refactor-dmastm
daantimmer Dec 19, 2023
97d7633
chore: updated EchoFromCloud with new Dma structure
daantimmer Dec 19, 2023
ebef426
chore: changed 1000ms to 1ms
daantimmer Dec 19, 2023
30b4478
Merge branch 'main' into feature/refactor-dmastm
daantimmer Jan 16, 2024
24bfaa8
Merge remote-tracking branch 'origin/main' into feature/refactor-dmastm
richardapeters Jan 30, 2024
2da41cf
Merge remote-tracking branch 'origin/main' into feature/refactor-dmastm
richardapeters Feb 19, 2024
d9d26a0
hal_stl/stm32fxxx/UartStm: remove hwFlowControl from Config
richardapeters Feb 21, 2024
60a268d
hal_st/stm32fxxx: Rename DefalutClockNucleoG474RET to DefaultClockNuc…
richardapeters Feb 21, 2024
e42f8a0
Apply suggestions from code review
richardapeters Feb 21, 2024
bff2595
hal_st/stm32fxxx/QuadSpiStmDma: rename transceiveStreamBase to transc…
richardapeters Feb 21, 2024
2b51fbe
Apply suggestions from code review
richardapeters Feb 21, 2024
30384de
hal_st/instantiations/NucleoUi: Move UARTs to helloworld example
richardapeters Feb 21, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.cache
.vs/
.vscode/.cortex-debug*
build/
Expand Down
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
// Use IntelliSense to learn about possible attributes.

Check warning on line 2 in .vscode/launch.json

View workflow job for this annotation

GitHub Actions / Linter

[MegaLinter] reported by reviewdog 🐶 Raw Output: .vscode/launch.json:2:- // Use IntelliSense to learn about possible attributes. .vscode/launch.json:3:- // Hover to view descriptions of existing attributes. .vscode/launch.json:4:- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 .vscode/launch.json:5:- "version": "0.2.0", .vscode/launch.json:6:- "configurations": [ .vscode/launch.json:7:- { .vscode/launch.json:8:- "name": "stm32f767", .vscode/launch.json:9:- "cwd": "${workspaceFolder}", .vscode/launch.json:10:- "executable": "${command:cmake.launchTargetPath}", .vscode/launch.json:11:- "request": "launch", .vscode/launch.json:12:- "type": "cortex-debug", .vscode/launch.json:13:- "device": "STM32F767ZI", .vscode/launch.json:14:- "servertype": "external", .vscode/launch.json:15:- "showDevDebugOutput": "both", .vscode/launch.json:16:- "gdbTarget": "host.docker.internal:2331", .vscode/launch.json:17:- "overrideLaunchCommands": [ .vscode/launch.json:18:- "monitor reset", .vscode/launch.json:19:- "-target-download", .vscode/launch.json:20:- "monitor reset" .vscode/launch.json:21:- ], .vscode/launch.json:22:- "overrideRestartCommands": [ "monitor reset" ] .vscode/launch.json:23:- }, .vscode/launch.json:24:- { .vscode/launch.json:25:- "name": "stm32f767 without container", .vscode/launch.json:26:- "cwd": "${workspaceRoot}", .vscode/launch.json:27:- "request": "launch", .vscode/launch.json:28:- "executable": "${command:cmake.launchTargetPath}", .vscode/launch.json:29:- "type": "cortex-debug", .vscode/launch.json:30:- "servertype": "jlink", .vscode/launch.json:31:- "device": "STM32F767ZI" .vscode/launch.json:32:- }, .vscode/launch.json:33:- { .vscode/launch.json:34:- "name": "stm32g431 without container", .vscode/launch.json:35:- "cwd": "${workspaceRoot}", .vscode/launch.json:36:- "request": "launch", .vscode/launch.json:37:- "executable": "${command:cmake.launchTargetPath}", .vscode/launch.json:38:- "type": "cortex-debug", .vscode/launch.json:39:- "servertype": "jlink", .vscode/launch.json:40:- "device": "STM32G431RB" .vscode/launch.json:41:- }, .vscode/launch.json:42:- { .vscode/launch.json:43:- "name": "stm32g070 without container", .vscode/launch.json:44:- "cwd": "${workspaceRoot}", .vscode/launch.json:45:- "request": "launch", .vscode/launch.json:46:- "executable": "${command:cmake.launchTargetPath}", .vscode/launch.json:47:- "type": "cortex-debug", .vscode/launch.json:48:- "servertype": "jlink", .vscode/launch.json:49:- "device": "STM32G070RB" .vscode/launch.json:50:- }, .vscode/launch.json:51:- { .vscode/launch.json:52:- "name": "stm32wb55rg", .vscode/launch.json:53:- "cwd": "${workspaceFolder}", .vscode/launch.json:54:- "executable": "${command:cmake.launchTargetPath}", .vscode/launch.json:55:- "request": "launch", .vscode/launch.json:56:- "type": "cortex-debug", .vscode/launch.json:57:- "device": "STM32WB55RG", .vscode/launch.json:58:- "servertype": "external", .vscode/launch.json:59:- "runToEntryPoint": "main", .vscode/launch.json:60:- "showDevDebugOutput": "both", .vscode/launch.json:61:- "gdbTarget": "host.docker.internal:61234", .vscode/launch.json:62:- "overrideLaunchCommands": [ .vscode/launch.json:63:- "monitor reset", .vscode/launch.json:64:- "-target-download", .vscode/launch.json:65:- "monitor reset" .vscode/launch.json:66:- ], .vscode/launch.json:67:- "overrideRestartCommands": [ .vscode/launch.json:68:-
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
Expand Down Expand Up @@ -47,6 +47,26 @@
"type": "cortex-debug",
"servertype": "jlink",
"device": "STM32G070RB"
},
{
"name": "stm32wb55rg",
"cwd": "${workspaceFolder}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"device": "STM32WB55RG",
"servertype": "external",
"runToEntryPoint": "main",
"showDevDebugOutput": "both",
"gdbTarget": "host.docker.internal:61234",
"overrideLaunchCommands": [
"monitor reset",
"-target-download",
"monitor reset"
],
"overrideRestartCommands": [
"monitor reset"
]
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cmake.copyCompileCommands": "${workspaceFolder}/build/compile_commands.json",
"sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json",
"clangd.arguments": ["--query-driver=/**/arm-none-eabi-*"],
"C_Cpp.autoAddFileAssociations": false
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (HALST_STANDALONE)
FetchContent_Declare(
emil
GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git
GIT_TAG 419f636bd76f2c0ee2f7524ca548e724bf479e27 # unreleased
GIT_TAG 16dde0b5e8a10acae790e00e1cbb75e891f5925f # unreleased
)

FetchContent_MakeAvailable(emil)
Expand Down
15 changes: 14 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install",
"cacheVariables": {
"HALST_BUILD_EXAMPLES": true
"HALST_BUILD_EXAMPLES": true,
"CMAKE_EXPORT_COMPILE_COMMANDS": "On"
}
},
{
Expand Down Expand Up @@ -134,6 +135,18 @@
"HALST_BUILD_EXAMPLES_FREERTOS": true,
"FREERTOS_CONFIG_FILE_DIRECTORY": "${sourceDir}/examples/freertos/config"
}
},
{
"name": "stm32g474",
"displayName": "stm32g474",
"description": "Build for stm32g474",
"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": "stm32g474"
}
}
],
"buildPresets": [
Expand Down
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(blink)
add_subdirectory(freertos)
add_subdirectory(helloworld)
17 changes: 14 additions & 3 deletions examples/blink/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
add_executable(hal_st.blink_nucleo144 Main.cpp)
emil_build_for(hal_st.blink_nucleo144 TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_BUILD_EXAMPLES)
emil_build_for(hal_st.blink_nucleo144
TARGET_MCU stm32f429
TARGET_MCU stm32f746
TARGET_MCU stm32f767
PREREQUISITE_BOOL HALST_BUILD_EXAMPLES
)

target_compile_definitions(hal_st.blink_nucleo144 PUBLIC
NUCLEO=Nucleo144Ui
Expand All @@ -18,10 +23,16 @@ emil_generate_artifacts(TARGET hal_st.blink_nucleo144 LST MAP BIN HEX)
######################################################################

add_executable(hal_st.blink_nucleo64 Main.cpp)
emil_build_for(hal_st.blink_nucleo64 TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_BUILD_EXAMPLES)
emil_build_for(hal_st.blink_nucleo64
TARGET_MCU stm32g431
TARGET_MCU stm32g474
TARGET_MCU stm32wb55
PREREQUISITE_BOOL HALST_BUILD_EXAMPLES
)

target_compile_definitions(hal_st.blink_nucleo64 PUBLIC
NUCLEO=Nucleo64Ui
$<$<NOT:$<STREQUAL:${TARGET_MCU},stm32wb55>>:NUCLEO=Nucleo64Ui>
$<$<STREQUAL:${TARGET_MCU},stm32wb55>:NUCLEO=Nucleo64WBUi>
)

target_link_libraries(hal_st.blink_nucleo64 PRIVATE
Expand Down
21 changes: 21 additions & 0 deletions examples/helloworld/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
add_executable(hal_st.helloworld_nucleo64 Main.cpp)
emil_build_for(hal_st.helloworld_nucleo64
TARGET_MCU stm32g474
TARGET_MCU stm32wb55
PREREQUISITE_BOOL HALST_BUILD_EXAMPLES
)

target_compile_definitions(hal_st.helloworld_nucleo64 PUBLIC
$<$<NOT:$<STREQUAL:${TARGET_MCU},stm32wb55>>:NUCLEO=Nucleo64Ui>
$<$<STREQUAL:${TARGET_MCU},stm32wb55>:NUCLEO=Nucleo64WBUi>
)

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

halst_target_default_linker_scripts(hal_st.helloworld_nucleo64)
halst_target_default_init(hal_st.helloworld_nucleo64)

emil_generate_artifacts(TARGET hal_st.helloworld_nucleo64 LST MAP BIN HEX)
51 changes: 51 additions & 0 deletions examples/helloworld/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "hal/interfaces/Gpio.hpp"
daantimmer marked this conversation as resolved.
Show resolved Hide resolved
#include "hal_st/instantiations/NucleoUi.hpp"
#include "hal_st/instantiations/StmEventInfrastructure.hpp"
#include "infra/timer/Timer.hpp"
#include "services/tracer/GlobalTracer.hpp"
#include "services/tracer/StreamWriterOnSerialCommunication.hpp"
#include "services/tracer/Tracer.hpp"
#include "services/tracer/TracerWithDateTime.hpp"
#include "services/util/DebugLed.hpp"
#include <array>
#include <chrono>

unsigned int hse_value = 24'000'000;

int main()
{
HAL_Init();

static main_::StmEventInfrastructure eventInfrastructure;
static main_::NUCLEO ui;
static services::DebugLed debugLed(ui.ledGreen);
static hal::DmaStm dmaStm;

#if defined(STM32G0) || defined(STM32G4)
static hal::GpioPinStm stLinkUartTxPin{ hal::Port::A, 2 };
static hal::GpioPinStm stLinkUartRxPin{ hal::Port::A, 3 };
static hal::DmaStm::TransmitStream transmitStream{ dmaStm, hal::DmaChannelId{ 1, 1, DMA_REQUEST_USART2_TX } };
static hal::UartStmDma stLinkUartDma{ transmitStream, 2, stLinkUartTxPin, stLinkUartRxPin };
#endif

#if defined(STM32WB)
static hal::GpioPinStm stLinkUartTxPin{ hal::Port::B, 6 };
static hal::GpioPinStm stLinkUartRxPin{ hal::Port::B, 7 };
static hal::DmaStm::TransmitStream transmitStream{ dmaStm, hal::DmaChannelId{ 1, 1, DMA_REQUEST_USART1_TX } };
static hal::UartStmDma stLinkUartDma{ transmitStream, 1, stLinkUartTxPin, stLinkUartRxPin };
#endif

static services::StreamWriterOnSerialCommunication::WithStorage<64> streamWriterOnSerialCommunication{ stLinkUartDma };
static infra::TextOutputStream::WithErrorPolicy textOutputStream{ streamWriterOnSerialCommunication };
static services::TracerWithDateTime tracerWithDateTime{ textOutputStream };

services::SetGlobalTracerInstance(tracerWithDateTime);

static infra::TimerRepeating timerRepeating{ std::chrono::seconds{ 1 }, []
{
services::GlobalTracer().Trace() << "Hello World !";
} };

eventInfrastructure.Run();
__builtin_unreachable();
}
2 changes: 2 additions & 0 deletions hal_st/instantiations/NucleoUi.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef HAL_ST_NUCLEO_UI_HPP
#define HAL_ST_NUCLEO_UI_HPP

#include "hal_st/stm32fxxx/DmaStm.hpp"
#include "hal_st/stm32fxxx/GpioStm.hpp"
#include "hal_st/stm32fxxx/UartStmDma.hpp"

namespace main_
{
Expand Down
13 changes: 5 additions & 8 deletions hal_st/stm32fxxx/AnalogToDigitalPinStm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,20 @@ namespace hal
{
ADC_ChannelConfTypeDef channelConfig;
channelConfig.Channel = adcChannel[analogPin.AdcChannel(adc.index + 1)];
#if !defined(STM32WB)
channelConfig.Rank = 1;
#else
#if defined(STM32WB) || defined(STM32G0) || defined(STM32G4)
channelConfig.Rank = ADC_REGULAR_RANK_1;
#else
channelConfig.Rank = 1;
#endif
#if defined(STM32F0) || defined(STM32F3)
channelConfig.SamplingTime = ADC_SAMPLETIME_7CYCLES_5;
#elif defined(STM32WB)
#elif defined(STM32WB) || defined(STM32G4)
channelConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
channelConfig.Offset = 0;
channelConfig.OffsetNumber = ADC_OFFSET_NONE;
channelConfig.SingleDiff = ADC_SINGLE_ENDED;
#elif defined(STM32G0)
channelConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES_5;
#elif defined(STM32G4)
channelConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES_5;
channelConfig.Offset = 0;
#else
channelConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
channelConfig.Offset = 0;
Expand Down Expand Up @@ -100,7 +97,7 @@ namespace hal
#if !defined(STM32F3)
handle.Init.DMAContinuousRequests = DISABLE;
#endif
#if defined(STM32WB)
#if defined(STM32WB) || defined(STM32G0) || defined(STM32G4)
handle.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
#elif !defined(STM32F3)
handle.Init.EOCSelection = DISABLE;
Expand Down
5 changes: 5 additions & 0 deletions hal_st/stm32fxxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ target_sources(hal_st.stm32fxxx PRIVATE
$<$<STREQUAL:${TARGET_MCU},stm32g070>:DefaultClockNucleoG070RB.hpp>
$<$<STREQUAL:${TARGET_MCU},stm32g431>:DefaultClockNucleoG431RB.cpp>
$<$<STREQUAL:${TARGET_MCU},stm32g431>:DefaultClockNucleoG431RB.hpp>
$<$<STREQUAL:${TARGET_MCU},stm32g474>:DefaultClockNucleoG474RE.cpp>
$<$<STREQUAL:${TARGET_MCU},stm32g474>:DefaultClockNucleoG474RE.hpp>
$<$<STREQUAL:${TARGET_MCU},stm32wb55>:DefaultClockNucleoWB55RG.cpp>
$<$<STREQUAL:${TARGET_MCU},stm32wb55>:DefaultClockNucleoWB55RG.hpp>
DigitalToAnalogPinStm.cpp
Expand Down Expand Up @@ -111,6 +113,9 @@ if (TARGET_MCU_VENDOR STREQUAL st)
elseif (TARGET_MCU STREQUAL stm32g431)
set(gpio_xml "${CMAKE_CURRENT_SOURCE_DIR}/ip/GPIO-STM32G43x_gpio_v1_0_Modes.xml")
set(mcu_xml "${CMAKE_CURRENT_SOURCE_DIR}/mcu/STM32G431R(6-8-B)Tx.xml")
elseif (TARGET_MCU STREQUAL stm32g474)
set(gpio_xml "${CMAKE_CURRENT_SOURCE_DIR}/ip/GPIO-STM32G47x_gpio_v1_0_Modes.xml")
set(mcu_xml "${CMAKE_CURRENT_SOURCE_DIR}/mcu/STM32G474R(B-C-E)Tx.xml")
elseif (TARGET_MCU_VARIANT STREQUAL stm32wb55rg)
set(gpio_xml "${CMAKE_CURRENT_SOURCE_DIR}/ip/GPIO-STM32WB55x_gpio_v1_0_Modes.xml")
set(mcu_xml "${CMAKE_CURRENT_SOURCE_DIR}/mcu/STM32WB55RGVx.xml")
Expand Down
47 changes: 47 additions & 0 deletions hal_st/stm32fxxx/DefaultClockNucleoG474RE.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include DEVICE_HEADER
#include "hal_st/stm32fxxx/DefaultClockNucleoG474RE.hpp"

/* The system Clock is configured as follows:
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 170,000,000
* HCLK(Hz) = 170,000,000
* AHB Prescaler = 1
* APB1 Prescaler = 1
* APB2 Prescaler = 1
* HSI Frequency(Hz) = 24MHz
* VDD(V) = 3.3
* Main regulator output voltage = Scale1 mode
*/
void ConfigureDefaultClockNucleo474RE()
{
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };

/** Configure the main internal regulator output voltage
*/
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);

/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV6;
RCC_OscInitStruct.PLL.PLLN = 85;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
HAL_RCC_OscConfig(&RCC_OscInitStruct);

/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
}
6 changes: 6 additions & 0 deletions hal_st/stm32fxxx/DefaultClockNucleoG474RE.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef HAL_ST_DEFAULT_CLOCK_HPP
#define HAL_ST_DEFAULT_CLOCK_HPP

void ConfigureDefaultClockNucleo474RE();

#endif
Loading
Loading