Skip to content

Commit cf7e1eb

Browse files
committed
moved to STM32WL up folder
1 parent 4e121a7 commit cf7e1eb

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

targets/TARGET_STM/TARGET_STM32WL/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ target_sources(mbed-stm32wl
1616
pwmout_device.c
1717
serial_device.c
1818
spi_api.c
19+
system_clock.c
1920
)
2021

2122
target_include_directories(mbed-stm32wl
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* mbed Microcontroller Library
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
******************************************************************************
4+
*
5+
* Copyright (c) 2021 STMicroelectronics.
6+
* All rights reserved.
7+
*
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
12+
*
13+
******************************************************************************
14+
*/
15+
16+
/**
17+
* This file configures the system clock as follows:
18+
*-----------------------------------------------------------------------------
19+
* System clock source | HSE (external 32 MHz clock)
20+
*-----------------------------------------------------------------------------
21+
* SYSCLK(MHz) | 48
22+
* AHBCLK (MHz) | 48
23+
* APB1CLK (MHz) | 48
24+
* APB2CLK (MHz) | 48
25+
* USB capable | NO
26+
*-----------------------------------------------------------------------------
27+
**/
28+
29+
#include "mbed_assert.h"
30+
#include "objects.h"
31+
32+
/**
33+
* @brief Configures the System clock source, PLL Multiplier and Divider factors, AHB/APBx prescalers
34+
* @note This function should be called only once the RCC clock configuration
35+
* is reset to the default reset state (done in SystemInit() function).
36+
* @param None
37+
* @retval None
38+
*/
39+
40+
MBED_WEAK void SetSysClock(void)
41+
{
42+
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
43+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
44+
45+
/** Configure the main internal regulator output voltage
46+
*/
47+
__HAL_RCC_PWR_CLK_ENABLE();
48+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
49+
/** Initializes the CPU, AHB and APB busses clocks
50+
*/
51+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
52+
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
53+
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
54+
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11;
55+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
56+
MBED_ASSERT(HAL_RCC_OscConfig(&RCC_OscInitStruct) == HAL_OK);
57+
/** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
58+
*/
59+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK3 | RCC_CLOCKTYPE_HCLK
60+
| RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1
61+
| RCC_CLOCKTYPE_PCLK2;
62+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
63+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
64+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
65+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
66+
RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
67+
MBED_ASSERT(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) == HAL_OK);
68+
/* Peripheral clock enable */
69+
}

0 commit comments

Comments
 (0)