STM32L4xx_HAL_Driver  1.14.0
De-initialization function

Functions

ErrorStatus LL_RCC_DeInit (void)
 Reset the RCC clock configuration to the default reset state. More...
 

Detailed Description

Function Documentation

◆ LL_RCC_DeInit()

ErrorStatus LL_RCC_DeInit ( void  )

Reset the RCC clock configuration to the default reset state.

Note
The default reset state of the clock configuration is given below:
  • MSI ON and used as system clock source
  • HSE, HSI, PLL, PLLSAI1 and PLLSAI2 OFF
  • AHB, APB1 and APB2 prescaler set to 1.
  • CSS, MCO OFF
  • All interrupts disabled
This function doesn't modify the configuration of the
  • Peripheral clocks
  • LSI, LSE and RTC clocks
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RCC registers are de-initialized
  • ERROR: not applicable

Definition at line 192 of file stm32l4xx_ll_rcc.c.

193 {
194  __IO uint32_t vl_mask;
195 
196  /* Set MSION bit */
198 
199  /* Insure MSIRDY bit is set before writing default MSIRANGE value */
200  while (LL_RCC_MSI_IsReady() == 0U)
201  {
202  }
203 
204  /* Set MSIRANGE default value */
205  LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_6);
206 
207  /* Set MSITRIM bits to the reset value*/
209 
210  /* Set HSITRIM bits to the reset value*/
212 
213  /* Reset CFGR register */
214  LL_RCC_WriteReg(CFGR, 0x00000000U);
215 
216  /* Read CR register */
217  vl_mask = LL_RCC_ReadReg(CR);
218 
219  /* Reset HSION, HSIKERON, HSIASFS, HSEON, PLLON bits */
220  CLEAR_BIT(vl_mask,
221  (RCC_CR_HSION | RCC_CR_HSIASFS | RCC_CR_HSIKERON | RCC_CR_HSEON | RCC_CR_PLLON));
222 
223 #if defined(RCC_PLLSAI1_SUPPORT)
224  /* Reset PLLSAI1ON bit */
225  CLEAR_BIT(vl_mask, RCC_CR_PLLSAI1ON);
226 #endif /*RCC_PLLSAI1_SUPPORT*/
227 
228 #if defined(RCC_PLLSAI2_SUPPORT)
229  /* Reset PLLSAI2ON bit */
230  CLEAR_BIT(vl_mask, RCC_CR_PLLSAI2ON);
231 #endif /*RCC_PLLSAI2_SUPPORT*/
232 
233  /* Write new value in CR register */
234  LL_RCC_WriteReg(CR, vl_mask);
235 
236 #if defined(RCC_PLLSAI2_SUPPORT)
237  /* Wait for PLLRDY, PLLSAI1RDY and PLLSAI2RDY bits to be reset */
238  while(READ_BIT(RCC->CR, RCC_CR_PLLRDY | RCC_CR_PLLSAI1RDY | RCC_CR_PLLSAI2RDY) != 0U)
239  {
240  }
241 #elif defined(RCC_PLLSAI1_SUPPORT)
242  /* Wait for PLLRDY and PLLSAI1RDY to be reset */
243  while(READ_BIT(RCC->CR, RCC_CR_PLLRDY | RCC_CR_PLLSAI1RDY) != 0U)
244  {
245  }
246 #else
247  /* Wait for PLLRDY bit to be reset */
248  while(READ_BIT(RCC->CR, RCC_CR_PLLRDY) != 0U)
249  {
250  }
251 #endif
252 
253  /* Reset PLLCFGR register */
254  LL_RCC_WriteReg(PLLCFGR, 16U << RCC_PLLCFGR_PLLN_Pos);
255 
256 #if defined(RCC_PLLSAI1_SUPPORT)
257  /* Reset PLLSAI1CFGR register */
258  LL_RCC_WriteReg(PLLSAI1CFGR, 16U << RCC_PLLSAI1CFGR_PLLSAI1N_Pos);
259 #endif /*RCC_PLLSAI1_SUPPORT*/
260 
261 #if defined(RCC_PLLSAI2_SUPPORT)
262  /* Reset PLLSAI2CFGR register */
263  LL_RCC_WriteReg(PLLSAI2CFGR, 16U << RCC_PLLSAI2CFGR_PLLSAI2N_Pos);
264 #endif /*RCC_PLLSAI2_SUPPORT*/
265 
266  /* Reset HSEBYP bit */
268 
269  /* Disable all interrupts */
270  LL_RCC_WriteReg(CIER, 0x00000000U);
271 
272  /* Clear all interrupt flags */
273  vl_mask = RCC_CICR_LSIRDYC | RCC_CICR_LSERDYC | RCC_CICR_MSIRDYC | RCC_CICR_HSIRDYC | RCC_CICR_HSERDYC | RCC_CICR_PLLRDYC | \
274  RCC_CICR_CSSC | RCC_CICR_LSECSSC;
275 #if defined(RCC_HSI48_SUPPORT)
276  vl_mask |= RCC_CICR_HSI48RDYC;
277 #endif
278 #if defined(RCC_PLLSAI1_SUPPORT)
279  vl_mask |= RCC_CICR_PLLSAI1RDYC;
280 #endif
281 #if defined(RCC_PLLSAI2_SUPPORT)
282  vl_mask |= RCC_CICR_PLLSAI2RDYC;
283 #endif
284  LL_RCC_WriteReg(CICR, vl_mask);
285 
286  /* Clear reset flags */
288 
289  return SUCCESS;
290 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__STATIC_INLINE void LL_RCC_HSE_DisableBypass(void)
Disable HSE external oscillator (HSE Bypass) CR HSEBYP LL_RCC_HSE_DisableBypass. ...
__STATIC_INLINE uint32_t LL_RCC_MSI_IsReady(void)
Check if MSI oscillator Ready CR MSIRDY LL_RCC_MSI_IsReady.
__STATIC_INLINE void LL_RCC_MSI_Enable(void)
Enable MSI oscillator CR MSION LL_RCC_MSI_Enable.
__STATIC_INLINE void LL_RCC_HSI_SetCalibTrimming(uint32_t Value)
Set HSI Calibration trimming.
__STATIC_INLINE void LL_RCC_MSI_SetRange(uint32_t Range)
Configure the Internal Multi Speed oscillator (MSI) clock range in run mode. CR MSIRANGE LL_RCC_MSI_...
__STATIC_INLINE void LL_RCC_MSI_SetCalibTrimming(uint32_t Value)
Set MSI Calibration trimming.
__STATIC_INLINE void LL_RCC_ClearResetFlags(void)
Set RMVF bit to clear the reset flags. CSR RMVF LL_RCC_ClearResetFlags.