Skip to content

Commit 8c1f94f

Browse files
committed
STM32WB : LSI clock selection when LSE is not available
1 parent 5cfee65 commit 8c1f94f

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

targets/TARGET_STM/TARGET_STM32WB/device/stm32_hal_legacy.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,9 +2929,8 @@
29292929
#define RCC_MCOSOURCE_PLLCLK_NODIV RCC_MCO1SOURCE_PLLCLK
29302930
#define RCC_MCOSOURCE_PLLCLK_DIV2 RCC_MCO1SOURCE_PLLCLK_DIV2
29312931

2932-
#if defined(STM32L4)
2932+
#if defined(STM32L4) || defined(STM32WB)
29332933
#define RCC_RTCCLKSOURCE_NO_CLK RCC_RTCCLKSOURCE_NONE
2934-
#elif defined(STM32WB) || defined(STM32G0)
29352934
#else
29362935
#define RCC_RTCCLKSOURCE_NONE RCC_RTCCLKSOURCE_NO_CLK
29372936
#endif

targets/TARGET_STM/lp_ticker.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ void lp_ticker_init(void)
113113
#else /* MBED_CONF_TARGET_LSE_AVAILABLE */
114114

115115
/* Enable LSI clock */
116+
#if TARGET_STM32WB
117+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI1;
118+
#else
116119
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
120+
#endif
117121
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
118122
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
119123

targets/TARGET_STM/mbed_overrides.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ void mbed_sdk_init()
6161
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
6262

6363
if (__HAL_RCC_GET_RTC_SOURCE() != RCC_RTCCLKSOURCE_NO_CLK) {
64+
#if TARGET_STM32WB
65+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI1;
66+
#else
6467
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
68+
#endif
6569
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
6670
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
6771
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {

targets/TARGET_STM/rtc_api.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ void rtc_init(void)
7474
error("PeriphClkInitStruct RTC failed with LSE\n");
7575
}
7676
#else /* MBED_CONF_TARGET_LSE_AVAILABLE */
77+
#if TARGET_STM32WB
78+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI1;
79+
#else
7780
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
81+
#endif
7882
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
7983
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
8084
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {

0 commit comments

Comments
 (0)