Skip to content

Commit ee8bb5e

Browse files
committed
fix(clock): ensure selected clock is on
As example, sometimes LSIRDY bit is set while the LSI ON is not. So force LSI to ON unconditionally. Same for LSE, HSI, HSE. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent f3247f9 commit ee8bb5e

File tree

1 file changed

+5
-0
lines changed
  • libraries/SrcWrapper/src/stm32

1 file changed

+5
-0
lines changed

libraries/SrcWrapper/src/stm32/clock.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,19 @@ void enableClock(sourceClock_t source)
9595
switch (source) {
9696
case LSI_CLOCK:
9797
#ifdef RCC_FLAG_LSI1RDY
98+
__HAL_RCC_LSI1_ENABLE();
9899
if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSI1RDY) == RESET) {
99100
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI1;
100101
#else
102+
__HAL_RCC_LSI_ENABLE();
101103
if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == RESET) {
102104
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
103105
#endif
104106
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
105107
}
106108
break;
107109
case HSI_CLOCK:
110+
__HAL_RCC_HSI_ENABLE();
108111
if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET) {
109112
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
110113
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
@@ -116,6 +119,7 @@ void enableClock(sourceClock_t source)
116119
}
117120
break;
118121
case LSE_CLOCK:
122+
__HAL_RCC_LSE_CONFIG(RCC_LSE_ON);
119123
if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) {
120124
#ifdef __HAL_RCC_LSEDRIVE_CONFIG
121125
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
@@ -125,6 +129,7 @@ void enableClock(sourceClock_t source)
125129
}
126130
break;
127131
case HSE_CLOCK:
132+
__HAL_RCC_HSE_CONFIG(RCC_HSE_ON);
128133
if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET) {
129134
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
130135
RCC_OscInitStruct.HSEState = RCC_HSE_ON;

0 commit comments

Comments
 (0)