Skip to content

Commit bb1338d

Browse files
authored
Merge pull request #11525 from jeromecoutant/PR_LSI
STM32WB/STM32H7 : LSI selection when LSE is not available
2 parents e6d9d51 + 8c1f94f commit bb1338d

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_rcc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ typedef struct
430430
/** @defgroup RCC_RTC_Clock_Source RCC RTC Clock Source
431431
* @{
432432
*/
433+
/* MBED */
434+
#define RCC_RTCCLKSOURCE_NO_CLK (0x00000000U)
435+
/* MBED */
433436
#define RCC_RTCCLKSOURCE_LSE (0x00000100U)
434437
#define RCC_RTCCLKSOURCE_LSI (0x00000200U)
435438
#define RCC_RTCCLKSOURCE_HSE_DIV2 (0x00002300U)

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)