Subversion Repositories ScreenTimer

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/**
2
  ******************************************************************************
3
  * @file    stm32f0xx_ll_rcc.c
4
  * @author  MCD Application Team
5
  * @brief   RCC LL module driver.
6
  ******************************************************************************
7
  * @attention
8
  *
9
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
  * All rights reserved.</center></h2>
11
  *
12
  * This software component is licensed by ST under BSD 3-Clause license,
13
  * the "License"; You may not use this file except in compliance with the
14
  * License. You may obtain a copy of the License at:
15
  *                        opensource.org/licenses/BSD-3-Clause
16
  *
17
  ******************************************************************************
18
  */
19
 
20
#if defined(USE_FULL_LL_DRIVER)
21
 
22
/* Includes ------------------------------------------------------------------*/
23
#include "stm32f0xx_ll_rcc.h"
24
#ifdef  USE_FULL_ASSERT
25
  #include "stm32_assert.h"
26
#else
27
  #define assert_param(expr) ((void)0U)
28
#endif /* USE_FULL_ASSERT */
29
/** @addtogroup STM32F0xx_LL_Driver
30
  * @{
31
  */
32
 
33
#if defined(RCC)
34
 
35
/** @defgroup RCC_LL RCC
36
  * @{
37
  */
38
 
39
/* Private types -------------------------------------------------------------*/
40
/* Private variables ---------------------------------------------------------*/
41
 
42
/* Private constants ---------------------------------------------------------*/
43
/* Private macros ------------------------------------------------------------*/
44
/** @addtogroup RCC_LL_Private_Macros
45
  * @{
46
  */
47
#if defined(RCC_CFGR3_USART2SW) && defined(RCC_CFGR3_USART3SW)
48
#define IS_LL_RCC_USART_CLKSOURCE(__VALUE__)  (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
49
                                            || ((__VALUE__) == LL_RCC_USART2_CLKSOURCE) \
50
                                            || ((__VALUE__) == LL_RCC_USART3_CLKSOURCE))
51
#elif defined(RCC_CFGR3_USART2SW) && !defined(RCC_CFGR3_USART3SW)
52
#define IS_LL_RCC_USART_CLKSOURCE(__VALUE__)  (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
53
                                            || ((__VALUE__) == LL_RCC_USART2_CLKSOURCE))
54
#elif defined(RCC_CFGR3_USART3SW) && !defined(RCC_CFGR3_USART2SW)
55
#define IS_LL_RCC_USART_CLKSOURCE(__VALUE__)  (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
56
                                            || ((__VALUE__) == LL_RCC_USART3_CLKSOURCE))
57
#else
58
#define IS_LL_RCC_USART_CLKSOURCE(__VALUE__)  (((__VALUE__) == LL_RCC_USART1_CLKSOURCE))
59
#endif /* RCC_CFGR3_USART2SW && RCC_CFGR3_USART3SW */
60
 
61
#define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__)     ((__VALUE__) == LL_RCC_I2C1_CLKSOURCE)
62
 
63
#if defined(USB)
64
#define IS_LL_RCC_USB_CLKSOURCE(__VALUE__)    (((__VALUE__) == LL_RCC_USB_CLKSOURCE))
65
#endif /* USB */
66
 
67
#if defined(CEC)
68
#define IS_LL_RCC_CEC_CLKSOURCE(__VALUE__)    (((__VALUE__) == LL_RCC_CEC_CLKSOURCE))
69
#endif /* CEC */
70
 
71
/**
72
  * @}
73
  */
74
 
75
/* Private function prototypes -----------------------------------------------*/
76
/** @defgroup RCC_LL_Private_Functions RCC Private functions
77
  * @{
78
  */
79
uint32_t RCC_GetSystemClockFreq(void);
80
uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency);
81
uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency);
82
uint32_t RCC_PLL_GetFreqDomain_SYS(void);
83
/**
84
  * @}
85
  */
86
 
87
 
88
/* Exported functions --------------------------------------------------------*/
89
/** @addtogroup RCC_LL_Exported_Functions
90
  * @{
91
  */
92
 
93
/** @addtogroup RCC_LL_EF_Init
94
  * @{
95
  */
96
 
97
/**
98
  * @brief  Reset the RCC clock configuration to the default reset state.
99
  * @note   The default reset state of the clock configuration is given below:
100
  *         - HSI ON and used as system clock source
101
  *         - HSE and PLL OFF
102
  *         - AHB and APB1 prescaler set to 1.
103
  *         - CSS, MCO OFF
104
  *         - All interrupts disabled
105
  * @note   This function doesn't modify the configuration of the
106
  *         - Peripheral clocks
107
  *         - LSI, LSE and RTC clocks
108
  * @retval An ErrorStatus enumeration value:
109
  *          - SUCCESS: RCC registers are de-initialized
110
  *          - ERROR: not applicable
111
  */
112
ErrorStatus LL_RCC_DeInit(void)
113
{
114
  __IO uint32_t vl_mask;
115
 
116
  /* Set HSION bit */
117
  LL_RCC_HSI_Enable();
118
 
119
  /* Wait for HSI READY bit */
120
  while(LL_RCC_HSI_IsReady() != 1U)
121
  {}
122
 
123
  /* Set HSITRIM bits to the reset value*/
124
  LL_RCC_HSI_SetCalibTrimming(0x10U);
125
 
126
  /* Reset SW, HPRE, PPRE and MCOSEL bits */
127
  vl_mask = 0xFFFFFFFFU;
128
  CLEAR_BIT(vl_mask, (RCC_CFGR_SW | RCC_CFGR_HPRE | RCC_CFGR_PPRE | RCC_CFGR_MCOSEL));
129
 
130
  /* Write new value in CFGR register */
131
  LL_RCC_WriteReg(CFGR, vl_mask);
132
 
133
  /* Wait till system clock source is ready */
134
  while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI)
135
  {}
136
 
137
  /* Read CR register */
138
  vl_mask = LL_RCC_ReadReg(CR);
139
 
140
  /* Reset HSEON, CSSON, PLLON bits */
141
  CLEAR_BIT(vl_mask, (RCC_CR_PLLON | RCC_CR_CSSON | RCC_CR_HSEON));
142
 
143
  /* Write new value in CR register */
144
  LL_RCC_WriteReg(CR, vl_mask);
145
 
146
  /* Wait for PLL READY bit to be reset */
147
  while(LL_RCC_PLL_IsReady() != 0U)
148
  {}
149
 
150
  /* Reset HSEBYP bit */
151
  LL_RCC_HSE_DisableBypass();
152
 
153
  /* Reset CFGR register */
154
  LL_RCC_WriteReg(CFGR, 0x00000000U);
155
 
156
#if defined(RCC_HSI48_SUPPORT)
157
  /* Reset CR2 register */
158
  LL_RCC_WriteReg(CR2, 0x00000000U);
159
 
160
  /* Disable HSI48 */
161
  LL_RCC_HSI48_Disable();
162
 
163
#endif /*RCC_HSI48_SUPPORT*/
164
  /* Set HSI14TRIM/HSI14ON/HSI14DIS bits to the reset value*/
165
  LL_RCC_HSI14_SetCalibTrimming(0x10U);
166
  LL_RCC_HSI14_Disable();
167
  LL_RCC_HSI14_EnableADCControl();
168
 
169
  /* Reset CFGR2 register */
170
  LL_RCC_WriteReg(CFGR2, 0x00000000U);
171
 
172
  /* Reset CFGR3 register */
173
  LL_RCC_WriteReg(CFGR3, 0x00000000U);
174
 
175
  /* Clear pending flags */
176
#if defined(RCC_HSI48_SUPPORT)
177
  vl_mask = (LL_RCC_CIR_LSIRDYC | LL_RCC_CIR_LSERDYC | LL_RCC_CIR_HSIRDYC | LL_RCC_CIR_HSERDYC |\
178
             LL_RCC_CIR_PLLRDYC | LL_RCC_CIR_HSI14RDYC | LL_RCC_CIR_HSI48RDYC | LL_RCC_CIR_CSSC);
179
#else
180
  vl_mask = (LL_RCC_CIR_LSIRDYC | LL_RCC_CIR_LSERDYC | LL_RCC_CIR_HSIRDYC | LL_RCC_CIR_HSERDYC |\
181
             LL_RCC_CIR_PLLRDYC | LL_RCC_CIR_HSI14RDYC | LL_RCC_CIR_CSSC);
182
#endif /* RCC_HSI48_SUPPORT */
183
 
184
  /* Write new value in CIR register */
185
  LL_RCC_WriteReg(CIR, vl_mask);
186
 
187
  /* Disable all interrupts */
188
  LL_RCC_WriteReg(CIR, 0x00000000U);
189
 
190
  /* Clear reset flags */
191
  LL_RCC_ClearResetFlags();
192
 
193
  return SUCCESS;
194
}
195
 
196
/**
197
  * @}
198
  */
199
 
200
/** @addtogroup RCC_LL_EF_Get_Freq
201
  * @brief  Return the frequencies of different on chip clocks;  System, AHB and APB1 buses clocks
202
  *         and different peripheral clocks available on the device.
203
  * @note   If SYSCLK source is HSI, function returns values based on HSI_VALUE(**)
204
  * @note   If SYSCLK source is HSE, function returns values based on HSE_VALUE(***)
205
  * @note   If SYSCLK source is PLL, function returns values based on
206
  *         HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
207
  * @note   (**) HSI_VALUE is a defined constant but the real value may vary
208
  *              depending on the variations in voltage and temperature.
209
  * @note   (***) HSE_VALUE is a defined constant, user has to ensure that
210
  *               HSE_VALUE is same as the real frequency of the crystal used.
211
  *               Otherwise, this function may have wrong result.
212
  * @note   The result of this function could be incorrect when using fractional
213
  *         value for HSE crystal.
214
  * @note   This function can be used by the user application to compute the
215
  *         baud-rate for the communication peripherals or configure other parameters.
216
  * @{
217
  */
218
 
219
/**
220
  * @brief  Return the frequencies of different on chip clocks;  System, AHB and APB1 buses clocks
221
  * @note   Each time SYSCLK, HCLK and/or PCLK1 clock changes, this function
222
  *         must be called to update structure fields. Otherwise, any
223
  *         configuration based on this function will be incorrect.
224
  * @param  RCC_Clocks pointer to a @ref LL_RCC_ClocksTypeDef structure which will hold the clocks frequencies
225
  * @retval None
226
  */
227
void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks)
228
{
229
  /* Get SYSCLK frequency */
230
  RCC_Clocks->SYSCLK_Frequency = RCC_GetSystemClockFreq();
231
 
232
  /* HCLK clock frequency */
233
  RCC_Clocks->HCLK_Frequency   = RCC_GetHCLKClockFreq(RCC_Clocks->SYSCLK_Frequency);
234
 
235
  /* PCLK1 clock frequency */
236
  RCC_Clocks->PCLK1_Frequency  = RCC_GetPCLK1ClockFreq(RCC_Clocks->HCLK_Frequency);
237
}
238
 
239
/**
240
  * @brief  Return USARTx clock frequency
241
  * @param  USARTxSource This parameter can be one of the following values:
242
  *         @arg @ref LL_RCC_USART1_CLKSOURCE
243
  *         @arg @ref LL_RCC_USART2_CLKSOURCE (*)
244
  *         @arg @ref LL_RCC_USART3_CLKSOURCE (*)
245
  *
246
  *         (*) value not defined in all devices.
247
  * @retval USART clock frequency (in Hz)
248
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
249
  */
250
uint32_t LL_RCC_GetUSARTClockFreq(uint32_t USARTxSource)
251
{
252
  uint32_t usart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
253
 
254
  /* Check parameter */
255
  assert_param(IS_LL_RCC_USART_CLKSOURCE(USARTxSource));
256
#if defined(RCC_CFGR3_USART1SW)
257
  if (USARTxSource == LL_RCC_USART1_CLKSOURCE)
258
  {
259
    /* USART1CLK clock frequency */
260
    switch (LL_RCC_GetUSARTClockSource(USARTxSource))
261
    {
262
      case LL_RCC_USART1_CLKSOURCE_SYSCLK: /* USART1 Clock is System Clock */
263
        usart_frequency = RCC_GetSystemClockFreq();
264
        break;
265
 
266
      case LL_RCC_USART1_CLKSOURCE_HSI:    /* USART1 Clock is HSI Osc. */
267
        if (LL_RCC_HSI_IsReady())
268
        {
269
          usart_frequency = HSI_VALUE;
270
        }
271
        break;
272
 
273
      case LL_RCC_USART1_CLKSOURCE_LSE:    /* USART1 Clock is LSE Osc. */
274
        if (LL_RCC_LSE_IsReady())
275
        {
276
          usart_frequency = LSE_VALUE;
277
        }
278
        break;
279
 
280
      case LL_RCC_USART1_CLKSOURCE_PCLK1:  /* USART1 Clock is PCLK1 */
281
      default:
282
        usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
283
        break;
284
    }
285
  }
286
#endif /* RCC_CFGR3_USART1SW  */
287
 
288
#if defined(RCC_CFGR3_USART2SW)
289
  if (USARTxSource == LL_RCC_USART2_CLKSOURCE)
290
  {
291
    /* USART2CLK clock frequency */
292
    switch (LL_RCC_GetUSARTClockSource(USARTxSource))
293
    {
294
      case LL_RCC_USART2_CLKSOURCE_SYSCLK: /* USART2 Clock is System Clock */
295
        usart_frequency = RCC_GetSystemClockFreq();
296
        break;
297
 
298
      case LL_RCC_USART2_CLKSOURCE_HSI:    /* USART2 Clock is HSI Osc. */
299
        if (LL_RCC_HSI_IsReady())
300
        {
301
          usart_frequency = HSI_VALUE;
302
        }
303
        break;
304
 
305
      case LL_RCC_USART2_CLKSOURCE_LSE:    /* USART2 Clock is LSE Osc. */
306
        if (LL_RCC_LSE_IsReady())
307
        {
308
          usart_frequency = LSE_VALUE;
309
        }
310
        break;
311
 
312
      case LL_RCC_USART2_CLKSOURCE_PCLK1:  /* USART2 Clock is PCLK1 */
313
      default:
314
        usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
315
        break;
316
    }
317
  }
318
#endif /* RCC_CFGR3_USART2SW */
319
 
320
#if defined(RCC_CFGR3_USART3SW)
321
  if (USARTxSource == LL_RCC_USART3_CLKSOURCE)
322
  {
323
    /* USART3CLK clock frequency */
324
    switch (LL_RCC_GetUSARTClockSource(USARTxSource))
325
    {
326
      case LL_RCC_USART3_CLKSOURCE_SYSCLK: /* USART3 Clock is System Clock */
327
        usart_frequency = RCC_GetSystemClockFreq();
328
        break;
329
 
330
      case LL_RCC_USART3_CLKSOURCE_HSI:    /* USART3 Clock is HSI Osc. */
331
        if (LL_RCC_HSI_IsReady())
332
        {
333
          usart_frequency = HSI_VALUE;
334
        }
335
        break;
336
 
337
      case LL_RCC_USART3_CLKSOURCE_LSE:    /* USART3 Clock is LSE Osc. */
338
        if (LL_RCC_LSE_IsReady())
339
        {
340
          usart_frequency = LSE_VALUE;
341
        }
342
        break;
343
 
344
      case LL_RCC_USART3_CLKSOURCE_PCLK1:  /* USART3 Clock is PCLK1 */
345
      default:
346
        usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
347
        break;
348
    }
349
  }
350
 
351
#endif /* RCC_CFGR3_USART3SW */
352
  return usart_frequency;
353
}
354
 
355
/**
356
  * @brief  Return I2Cx clock frequency
357
  * @param  I2CxSource This parameter can be one of the following values:
358
  *         @arg @ref LL_RCC_I2C1_CLKSOURCE
359
  * @retval I2C clock frequency (in Hz)
360
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that HSI oscillator is not ready
361
  */
362
uint32_t LL_RCC_GetI2CClockFreq(uint32_t I2CxSource)
363
{
364
  uint32_t i2c_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
365
 
366
  /* Check parameter */
367
  assert_param(IS_LL_RCC_I2C_CLKSOURCE(I2CxSource));
368
 
369
  /* I2C1 CLK clock frequency */
370
  if (I2CxSource == LL_RCC_I2C1_CLKSOURCE)
371
  {
372
    switch (LL_RCC_GetI2CClockSource(I2CxSource))
373
    {
374
      case LL_RCC_I2C1_CLKSOURCE_SYSCLK: /* I2C1 Clock is System Clock */
375
        i2c_frequency = RCC_GetSystemClockFreq();
376
        break;
377
 
378
      case LL_RCC_I2C1_CLKSOURCE_HSI:    /* I2C1 Clock is HSI Osc. */
379
      default:
380
        if (LL_RCC_HSI_IsReady())
381
        {
382
          i2c_frequency = HSI_VALUE;
383
        }
384
        break;
385
    }
386
  }
387
 
388
  return i2c_frequency;
389
}
390
 
391
#if defined(USB)
392
/**
393
  * @brief  Return USBx clock frequency
394
  * @param  USBxSource This parameter can be one of the following values:
395
  *         @arg @ref LL_RCC_USB_CLKSOURCE
396
  * @retval USB clock frequency (in Hz)
397
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI48) or PLL is not ready
398
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
399
  */
400
uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource)
401
{
402
  uint32_t usb_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
403
 
404
  /* Check parameter */
405
  assert_param(IS_LL_RCC_USB_CLKSOURCE(USBxSource));
406
 
407
  /* USBCLK clock frequency */
408
  switch (LL_RCC_GetUSBClockSource(USBxSource))
409
  {
410
    case LL_RCC_USB_CLKSOURCE_PLL:        /* PLL clock used as USB clock source */
411
      if (LL_RCC_PLL_IsReady())
412
      {
413
        usb_frequency = RCC_PLL_GetFreqDomain_SYS();
414
      }
415
      break;
416
 
417
#if defined(RCC_CFGR3_USBSW_HSI48)
418
    case LL_RCC_USB_CLKSOURCE_HSI48:      /* HSI48 clock used as USB clock source */
419
    default:
420
      if (LL_RCC_HSI48_IsReady())
421
      {
422
        usb_frequency = HSI48_VALUE;
423
      }
424
      break;
425
#else
426
    case LL_RCC_USB_CLKSOURCE_NONE:       /* No clock used as USB clock source */
427
    default:
428
      usb_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
429
      break;
430
#endif /* RCC_CFGR3_USBSW_HSI48 */
431
  }
432
 
433
  return usb_frequency;
434
}
435
#endif /* USB */
436
 
437
#if defined(CEC)
438
/**
439
  * @brief  Return CECx clock frequency
440
  * @param  CECxSource This parameter can be one of the following values:
441
  *         @arg @ref LL_RCC_CEC_CLKSOURCE
442
  * @retval CEC clock frequency (in Hz)
443
  *        @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillators (HSI or LSE) are not ready
444
  */
445
uint32_t LL_RCC_GetCECClockFreq(uint32_t CECxSource)
446
{
447
  uint32_t cec_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
448
 
449
  /* Check parameter */
450
  assert_param(IS_LL_RCC_CEC_CLKSOURCE(CECxSource));
451
 
452
  /* CECCLK clock frequency */
453
  switch (LL_RCC_GetCECClockSource(CECxSource))
454
  {
455
    case LL_RCC_CEC_CLKSOURCE_HSI_DIV244:   /* HSI / 244 clock used as CEC clock source */
456
      if (LL_RCC_HSI_IsReady())
457
      {
458
        cec_frequency = HSI_VALUE / 244U;
459
      }
460
      break;
461
 
462
    case LL_RCC_CEC_CLKSOURCE_LSE:          /* LSE clock used as CEC clock source */
463
    default:
464
      if (LL_RCC_LSE_IsReady())
465
      {
466
        cec_frequency = LSE_VALUE;
467
      }
468
      break;
469
  }
470
 
471
  return cec_frequency;
472
}
473
#endif /* CEC */
474
 
475
/**
476
  * @}
477
  */
478
 
479
/**
480
  * @}
481
  */
482
 
483
/** @addtogroup RCC_LL_Private_Functions
484
  * @{
485
  */
486
 
487
/**
488
  * @brief  Return SYSTEM clock frequency
489
  * @retval SYSTEM clock frequency (in Hz)
490
  */
491
uint32_t RCC_GetSystemClockFreq(void)
492
{
493
  uint32_t frequency = 0U;
494
 
495
  /* Get SYSCLK source -------------------------------------------------------*/
496
  switch (LL_RCC_GetSysClkSource())
497
  {
498
    case LL_RCC_SYS_CLKSOURCE_STATUS_HSI:  /* HSI used as system clock  source */
499
      frequency = HSI_VALUE;
500
      break;
501
 
502
    case LL_RCC_SYS_CLKSOURCE_STATUS_HSE:  /* HSE used as system clock  source */
503
      frequency = HSE_VALUE;
504
      break;
505
 
506
    case LL_RCC_SYS_CLKSOURCE_STATUS_PLL:  /* PLL used as system clock  source */
507
      frequency = RCC_PLL_GetFreqDomain_SYS();
508
      break;
509
 
510
#if defined(RCC_HSI48_SUPPORT)
511
    case LL_RCC_SYS_CLKSOURCE_STATUS_HSI48:/* HSI48 used as system clock  source */
512
      frequency = HSI48_VALUE;
513
      break;
514
#endif /* RCC_HSI48_SUPPORT */
515
 
516
    default:
517
      frequency = HSI_VALUE;
518
      break;
519
  }
520
 
521
  return frequency;
522
}
523
 
524
/**
525
  * @brief  Return HCLK clock frequency
526
  * @param  SYSCLK_Frequency SYSCLK clock frequency
527
  * @retval HCLK clock frequency (in Hz)
528
  */
529
uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency)
530
{
531
  /* HCLK clock frequency */
532
  return __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, LL_RCC_GetAHBPrescaler());
533
}
534
 
535
/**
536
  * @brief  Return PCLK1 clock frequency
537
  * @param  HCLK_Frequency HCLK clock frequency
538
  * @retval PCLK1 clock frequency (in Hz)
539
  */
540
uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency)
541
{
542
  /* PCLK1 clock frequency */
543
  return __LL_RCC_CALC_PCLK1_FREQ(HCLK_Frequency, LL_RCC_GetAPB1Prescaler());
544
}
545
/**
546
  * @brief  Return PLL clock frequency used for system domain
547
  * @retval PLL clock frequency (in Hz)
548
  */
549
uint32_t RCC_PLL_GetFreqDomain_SYS(void)
550
{
551
  uint32_t pllinputfreq = 0U, pllsource = 0U;
552
 
553
  /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL divider) * PLL Multiplicator */
554
 
555
  /* Get PLL source */
556
  pllsource = LL_RCC_PLL_GetMainSource();
557
 
558
  switch (pllsource)
559
  {
560
#if defined(RCC_PLLSRC_PREDIV1_SUPPORT)
561
    case LL_RCC_PLLSOURCE_HSI:       /* HSI used as PLL clock source */
562
      pllinputfreq = HSI_VALUE;
563
#else
564
    case LL_RCC_PLLSOURCE_HSI_DIV_2: /* HSI used as PLL clock source */
565
      pllinputfreq = HSI_VALUE / 2U;
566
#endif /* RCC_PLLSRC_PREDIV1_SUPPORT */
567
      break;
568
 
569
#if defined(RCC_HSI48_SUPPORT)
570
    case LL_RCC_PLLSOURCE_HSI48:     /* HSI48 used as PLL clock source */
571
      pllinputfreq = HSI48_VALUE;
572
      break;
573
#endif /* RCC_HSI48_SUPPORT */
574
 
575
    case LL_RCC_PLLSOURCE_HSE:       /* HSE used as PLL clock source */
576
      pllinputfreq = HSE_VALUE;
577
      break;
578
 
579
    default:
580
#if defined(RCC_PLLSRC_PREDIV1_SUPPORT)
581
      pllinputfreq = HSI_VALUE;
582
#else
583
      pllinputfreq = HSI_VALUE / 2U;
584
#endif /* RCC_PLLSRC_PREDIV1_SUPPORT */
585
      break;
586
  }
587
#if defined(RCC_PLLSRC_PREDIV1_SUPPORT)
588
  return __LL_RCC_CALC_PLLCLK_FREQ(pllinputfreq, LL_RCC_PLL_GetMultiplicator(), LL_RCC_PLL_GetPrediv());
589
#else
590
  return __LL_RCC_CALC_PLLCLK_FREQ((pllinputfreq / (LL_RCC_PLL_GetPrediv() + 1U)), LL_RCC_PLL_GetMultiplicator());
591
#endif /* RCC_PLLSRC_PREDIV1_SUPPORT */
592
}
593
/**
594
  * @}
595
  */
596
 
597
/**
598
  * @}
599
  */
600
 
601
#endif /* defined(RCC) */
602
 
603
/**
604
  * @}
605
  */
606
 
607
#endif /* USE_FULL_LL_DRIVER */
608
 
609
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/