Subversion Repositories DashDisplay

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32f1xx_hal_rcc.c
3
  * @file    stm32f1xx_hal_rcc.c
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @version V1.0.1
5
  * @version V1.0.4
6
  * @date    31-July-2015
6
  * @date    29-April-2016
7
  * @brief   RCC HAL module driver.
7
  * @brief   RCC HAL module driver.
8
  *          This file provides firmware functions to manage the following
8
  *          This file provides firmware functions to manage the following
9
  *          functionalities of the Reset and Clock Control (RCC) peripheral:
9
  *          functionalities of the Reset and Clock Control (RCC) peripheral:
10
  *           + Initialization and de-initialization functions
10
  *           + Initialization and de-initialization functions
11
  *           + Peripheral Control functions
11
  *           + Peripheral Control functions
Line 16... Line 16...
16
  ==============================================================================
16
  ==============================================================================
17
    [..]  
17
    [..]  
18
      After reset the device is running from Internal High Speed oscillator
18
      After reset the device is running from Internal High Speed oscillator
19
      (HSI 8MHz) with Flash 0 wait state, Flash prefetch buffer is enabled,
19
      (HSI 8MHz) with Flash 0 wait state, Flash prefetch buffer is enabled,
20
      and all peripherals are off except internal SRAM, Flash and JTAG.
20
      and all peripherals are off except internal SRAM, Flash and JTAG.
21
      (+) There is no prescaler on High speed (AHB) and Low speed (APB) busses;
21
      (+) There is no prescaler on High speed (AHB) and Low speed (APB) buses;
22
          all peripherals mapped on these busses are running at HSI speed.
22
          all peripherals mapped on these buses are running at HSI speed.
23
      (+) The clock for all peripherals is switched off, except the SRAM and FLASH.
23
      (+) The clock for all peripherals is switched off, except the SRAM and FLASH.
24
      (+) All GPIOs are in input floating state, except the JTAG pins which
24
      (+) All GPIOs are in input floating state, except the JTAG pins which
25
          are assigned to be used for debug purpose.
25
          are assigned to be used for debug purpose.
26
    [..] Once the device started from reset, the user application has to:
26
    [..] Once the device started from reset, the user application has to:
27
      (+) Configure the clock source to be used to drive the System clock
27
      (+) Configure the clock source to be used to drive the System clock
28
          (if the application needs higher frequency/performance)
28
          (if the application needs higher frequency/performance)
29
      (+) Configure the System clock frequency and Flash settings  
29
      (+) Configure the System clock frequency and Flash settings  
30
      (+) Configure the AHB and APB busses prescalers
30
      (+) Configure the AHB and APB buses prescalers
31
      (+) Enable the clock for the peripheral(s) to be used
31
      (+) Enable the clock for the peripheral(s) to be used
32
      (+) Configure the clock source(s) for peripherals whose clocks are not
32
      (+) Configure the clock source(s) for peripherals whose clocks are not
33
          derived from the System clock (I2S, RTC, ADC, USB OTG FS)
33
          derived from the System clock (I2S, RTC, ADC, USB OTG FS)
34
 
34
 
35
                      ##### RCC Limitations #####
35
                      ##### RCC Limitations #####
Line 48... Line 48...
48
 
48
 
49
  @endverbatim
49
  @endverbatim
50
  ******************************************************************************
50
  ******************************************************************************
51
  * @attention
51
  * @attention
52
  *
52
  *
53
  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
53
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
54
  *
54
  *
55
  * Redistribution and use in source and binary forms, with or without modification,
55
  * Redistribution and use in source and binary forms, with or without modification,
56
  * are permitted provided that the following conditions are met:
56
  * are permitted provided that the following conditions are met:
57
  *   1. Redistributions of source code must retain the above copyright notice,
57
  *   1. Redistributions of source code must retain the above copyright notice,
58
  *      this list of conditions and the following disclaimer.
58
  *      this list of conditions and the following disclaimer.
Line 73... Line 73...
73
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
73
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
74
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
74
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
75
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76
  *
76
  *
77
  ******************************************************************************  
77
  ******************************************************************************  
78
*/
78
*/
79
 
79
 
80
/* Includes ------------------------------------------------------------------*/
80
/* Includes ------------------------------------------------------------------*/
81
#include "stm32f1xx_hal.h"
81
#include "stm32f1xx_hal.h"
82
 
82
 
83
/** @addtogroup STM32F1xx_HAL_Driver
83
/** @addtogroup STM32F1xx_HAL_Driver
Line 94... Line 94...
94
/* Private typedef -----------------------------------------------------------*/
94
/* Private typedef -----------------------------------------------------------*/
95
/* Private define ------------------------------------------------------------*/
95
/* Private define ------------------------------------------------------------*/
96
/** @defgroup RCC_Private_Constants RCC Private Constants
96
/** @defgroup RCC_Private_Constants RCC Private Constants
97
 * @{
97
 * @{
98
 */
98
 */
-
 
99
/* Bits position in  in the CFGR register */
-
 
100
#define RCC_CFGR_HPRE_BITNUMBER           POSITION_VAL(RCC_CFGR_HPRE)
-
 
101
#define RCC_CFGR_PPRE1_BITNUMBER          POSITION_VAL(RCC_CFGR_PPRE1)
-
 
102
#define RCC_CFGR_PPRE2_BITNUMBER          POSITION_VAL(RCC_CFGR_PPRE2)
99
/**
103
/**
100
  * @}
104
  * @}
101
  */
105
  */
102
/* Private macro -------------------------------------------------------------*/
106
/* Private macro -------------------------------------------------------------*/
103
/** @defgroup RCC_Private_Macros RCC Private Macros
107
/** @defgroup RCC_Private_Macros RCC Private Macros
Line 114... Line 118...
114
 
118
 
115
/* Private variables ---------------------------------------------------------*/
119
/* Private variables ---------------------------------------------------------*/
116
/** @defgroup RCC_Private_Variables RCC Private Variables
120
/** @defgroup RCC_Private_Variables RCC Private Variables
117
  * @{
121
  * @{
118
  */
122
  */
119
const uint8_t aAPBAHBPrescTable[16]       = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
-
 
120
/**
123
/**
121
  * @}
124
  * @}
122
  */
125
  */
123
 
126
 
124
/* Private function prototypes -----------------------------------------------*/
127
/* Private function prototypes -----------------------------------------------*/
Line 182... Line 185...
182
          (+@) I2S interface on STM32F105x/STM32F107x can be derived from PLL3CLK
185
          (+@) I2S interface on STM32F105x/STM32F107x can be derived from PLL3CLK
183
          (+@) IWDG clock which is always the LSI clock.
186
          (+@) IWDG clock which is always the LSI clock.
184
 
187
 
185
      (#) For STM32F10xxx, the maximum frequency of the SYSCLK and HCLK/PCLK2 is 72 MHz, PCLK1 36 MHz.
188
      (#) For STM32F10xxx, the maximum frequency of the SYSCLK and HCLK/PCLK2 is 72 MHz, PCLK1 36 MHz.
186
          For STM32F100xx, the maximum frequency of the SYSCLK and HCLK/PCLK1/PCLK2 is 24 MHz.  
189
          For STM32F100xx, the maximum frequency of the SYSCLK and HCLK/PCLK1/PCLK2 is 24 MHz.  
187
             Depending on the SYSCLK frequency, the flash latency should be adapted accordingly:
190
          Depending on the SYSCLK frequency, the flash latency should be adapted accordingly.
-
 
191
  @endverbatim
-
 
192
  * @{
-
 
193
  */
-
 
194
 
-
 
195
/*
-
 
196
  Additional consideration on the SYSCLK based on Latency settings:
188
        +-----------------------------------------------+
197
        +-----------------------------------------------+
189
        | Latency       | SYSCLK clock frequency (MHz)  |
198
        | Latency       | SYSCLK clock frequency (MHz)  |
190
        |---------------|-------------------------------|
199
        |---------------|-------------------------------|
191
        |0WS(1CPU cycle)|       0 < SYSCLK <= 24        |
200
        |0WS(1CPU cycle)|       0 < SYSCLK <= 24        |
192
        |---------------|-------------------------------|
201
        |---------------|-------------------------------|
193
        |1WS(2CPU cycle)|      24 < SYSCLK <= 48        |
202
        |1WS(2CPU cycle)|      24 < SYSCLK <= 48        |
194
        |---------------|-------------------------------|
203
        |---------------|-------------------------------|
195
        |2WS(3CPU cycle)|      48 < SYSCLK <= 72        |
204
        |2WS(3CPU cycle)|      48 < SYSCLK <= 72        |
196
        +-----------------------------------------------+
205
        +-----------------------------------------------+
197
  @endverbatim
-
 
198
  * @{
-
 
199
  */
206
  */
200
 
207
 
201
/**
208
/**
202
  * @brief  Resets the RCC clock configuration to the default reset state.
209
  * @brief  Resets the RCC clock configuration to the default reset state.
203
  * @note   The default reset state of the clock configuration is given below:
210
  * @note   The default reset state of the clock configuration is given below:
204
  *            - HSI ON and used as system clock source
211
  *            - HSI ON and used as system clock source
205
  *            - HSE and PLL OFF
212
  *            - HSE and PLL OFF
206
  *            - AHB, APB1 and APB2 prescaler set to 1.
213
  *            - AHB, APB1 and APB2 prescaler set to 1.
207
  *            - CSS and MCO1 OFF
214
  *            - CSS and MCO1 OFF
208
  *            - All interrupts disabled
215
  *            - All interrupts disabled
209
  * @note   This function doesn't modify the configuration of the
216
  * @note   This function does not modify the configuration of the
210
  *            - Peripheral clocks  
217
  *            - Peripheral clocks
211
  *            - LSI, LSE and RTC clocks
218
  *            - LSI, LSE and RTC clocks
212
  * @retval None
219
  * @retval None
213
  */
220
  */
214
void HAL_RCC_DeInit(void)
221
void HAL_RCC_DeInit(void)
215
{
222
{
216
  /* Switch SYSCLK to HSI */
223
  /* Switch SYSCLK to HSI */
Line 233... Line 240...
233
  CLEAR_REG(RCC->CFGR2);
240
  CLEAR_REG(RCC->CFGR2);
234
 
241
 
235
#endif /* STM32F105xC || STM32F107xC || STM32F100xB || STM32F100xE */
242
#endif /* STM32F105xC || STM32F107xC || STM32F100xB || STM32F100xE */
236
  /* Disable all interrupts */
243
  /* Disable all interrupts */
237
  CLEAR_REG(RCC->CIR);
244
  CLEAR_REG(RCC->CIR);
-
 
245
 
-
 
246
  /* Update the SystemCoreClock global variable */
-
 
247
  SystemCoreClock = HSI_VALUE;
238
}
248
}
239
 
249
 
240
/**
250
/**
241
  * @brief  Initializes the RCC Oscillators according to the specified parameters in the
251
  * @brief  Initializes the RCC Oscillators according to the specified parameters in the
242
  *         RCC_OscInitTypeDef.
252
  *         RCC_OscInitTypeDef.
243
  * @param  RCC_OscInitStruct pointer to an RCC_OscInitTypeDef structure that
253
  * @param  RCC_OscInitStruct pointer to an RCC_OscInitTypeDef structure that
244
  *         contains the configuration information for the RCC Oscillators.
254
  *         contains the configuration information for the RCC Oscillators.
245
  * @note   The PLL is not disabled when used as system clock.
255
  * @note   The PLL is not disabled when used as system clock.
246
  * @note   The PLL is not disabled when USB OTG FS clock is enabled (specific to devices with USB FS)
256
  * @note   The PLL is not disabled when USB OTG FS clock is enabled (specific to devices with USB FS)
-
 
257
  * @note   Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
-
 
258
  *         supported by this macro. User should request a transition to LSE Off
-
 
259
  *         first and then LSE On or LSE Bypass.
-
 
260
  * @note   Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
-
 
261
  *         supported by this macro. User should request a transition to HSE Off
-
 
262
  *         first and then HSE On or HSE Bypass.
247
  * @retval HAL status
263
  * @retval HAL status
248
  */
264
  */
249
HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct)
265
HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct)
250
{
266
{
251
   uint32_t tickstart = 0;
267
   uint32_t tickstart = 0;
Line 269... Line 285...
269
        return HAL_ERROR;
285
        return HAL_ERROR;
270
      }
286
      }
271
    }
287
    }
272
    else
288
    else
273
    {
289
    {
274
      /* Reset HSEON and HSEBYP bits before configuring the HSE --------------*/
-
 
275
      __HAL_RCC_HSE_CONFIG(RCC_HSE_OFF);
-
 
276
     
-
 
277
      /* Get Start Tick */
-
 
278
      tickstart = HAL_GetTick();
-
 
279
     
-
 
280
      /* Wait till HSE is disabled */  
-
 
281
      while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET)
-
 
282
      {
-
 
283
        if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)
-
 
284
        {
-
 
285
          return HAL_TIMEOUT;
-
 
286
        }
-
 
287
      }
-
 
288
     
-
 
289
      /* Set the new HSE configuration ---------------------------------------*/
290
      /* Set the new HSE configuration ---------------------------------------*/
290
      __HAL_RCC_HSE_CONFIG(RCC_OscInitStruct->HSEState);
291
      __HAL_RCC_HSE_CONFIG(RCC_OscInitStruct->HSEState);
291
     
292
     
292
 
293
 
293
       /* Check the HSE State */
294
       /* Check the HSE State */
Line 308... Line 309...
308
      else
309
      else
309
      {
310
      {
310
        /* Get Start Tick */
311
        /* Get Start Tick */
311
        tickstart = HAL_GetTick();
312
        tickstart = HAL_GetTick();
312
       
313
       
313
        /* Wait till HSE is bypassed or disabled */
314
        /* Wait till HSE is disabled */
314
        while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET)
315
        while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET)
315
        {
316
        {
316
           if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)
317
           if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)
317
          {
318
          {
318
            return HAL_TIMEOUT;
319
            return HAL_TIMEOUT;
Line 407... Line 408...
407
        if((HAL_GetTick() - tickstart ) > LSI_TIMEOUT_VALUE)
408
        if((HAL_GetTick() - tickstart ) > LSI_TIMEOUT_VALUE)
408
        {
409
        {
409
          return HAL_TIMEOUT;
410
          return HAL_TIMEOUT;
410
        }
411
        }
411
      }
412
      }
412
      /*  To have a fully stabilized clock in the specified range, a software temporization of 1ms
413
      /*  To have a fully stabilized clock in the specified range, a software delay of 1ms
413
          should be added.*/
414
          should be added.*/
414
      HAL_Delay(1);
415
      HAL_Delay(1);
415
    }
416
    }
416
    else
417
    else
417
    {
418
    {
Line 434... Line 435...
434
  /*------------------------------ LSE Configuration -------------------------*/
435
  /*------------------------------ LSE Configuration -------------------------*/
435
  if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE)
436
  if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE)
436
  {
437
  {
437
    /* Check the parameters */
438
    /* Check the parameters */
438
    assert_param(IS_RCC_LSE(RCC_OscInitStruct->LSEState));
439
    assert_param(IS_RCC_LSE(RCC_OscInitStruct->LSEState));
439
   
440
 
440
    /* Enable Power Clock*/
441
    /* Enable Power Clock*/
441
    __HAL_RCC_PWR_CLK_ENABLE();
442
      __HAL_RCC_PWR_CLK_ENABLE();
442
   
443
   
443
    /* Enable write access to Backup domain */
444
      /* Enable write access to Backup domain */
444
    SET_BIT(PWR->CR, PWR_CR_DBP);
445
      SET_BIT(PWR->CR, PWR_CR_DBP);
-
 
446
     
-
 
447
      /* Wait for Backup domain Write protection disable */
-
 
448
      tickstart = HAL_GetTick();
445
 
449
 
446
    /* Wait for Backup domain Write protection disable */
-
 
447
    tickstart = HAL_GetTick();
-
 
448
   
-
 
449
    while((PWR->CR & PWR_CR_DBP) == RESET)
450
    while((PWR->CR & PWR_CR_DBP) == RESET)
450
    {
-
 
451
      if((HAL_GetTick() - tickstart ) > RCC_DBP_TIMEOUT_VALUE)
-
 
452
      {
451
      {
453
        return HAL_TIMEOUT;
-
 
454
      }      
-
 
455
    }
-
 
456
   
-
 
457
    /* Reset LSEON and LSEBYP bits before configuring the LSE ----------------*/
-
 
458
    __HAL_RCC_LSE_CONFIG(RCC_LSE_OFF);
-
 
459
   
-
 
460
    /* Get Start Tick */
-
 
461
    tickstart = HAL_GetTick();
-
 
462
   
-
 
463
    /* Wait till LSE is disabled */  
-
 
464
    while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) != RESET)
-
 
465
    {
-
 
466
      if((HAL_GetTick() - tickstart ) > RCC_LSE_TIMEOUT_VALUE)
452
        if((HAL_GetTick() - tickstart) > RCC_DBP_TIMEOUT_VALUE)
467
      {
453
        {
468
        return HAL_TIMEOUT;
454
          return HAL_TIMEOUT;
-
 
455
        }
469
      }
456
      }
470
    }
-
 
471
   
457
 
472
    /* Set the new LSE configuration -----------------------------------------*/
458
    /* Set the new LSE configuration -----------------------------------------*/
473
    __HAL_RCC_LSE_CONFIG(RCC_OscInitStruct->LSEState);
459
    __HAL_RCC_LSE_CONFIG(RCC_OscInitStruct->LSEState);
474
    /* Check the LSE State */
460
    /* Check the LSE State */
475
    if(RCC_OscInitStruct->LSEState != RCC_LSE_OFF)
461
    if(RCC_OscInitStruct->LSEState != RCC_LSE_OFF)
476
    {
462
    {
Line 692... Line 678...
692
  *          The value of this parameter depend on device used within the same series
678
  *          The value of this parameter depend on device used within the same series
693
  * @note   The SystemCoreClock CMSIS variable is used to store System Clock Frequency
679
  * @note   The SystemCoreClock CMSIS variable is used to store System Clock Frequency
694
  *         and updated by @ref HAL_RCC_GetHCLKFreq() function called within this function
680
  *         and updated by @ref HAL_RCC_GetHCLKFreq() function called within this function
695
  *
681
  *
696
  * @note   The HSI is used (enabled by hardware) as system clock source after
682
  * @note   The HSI is used (enabled by hardware) as system clock source after
697
  *         startup from Reset, wake-up from STOP and STANDBY mode, or in case
683
  *         start-up from Reset, wake-up from STOP and STANDBY mode, or in case
698
  *         of failure of the HSE used directly or indirectly as system clock
684
  *         of failure of the HSE used directly or indirectly as system clock
699
  *         (if the Clock Security System CSS is enabled).
685
  *         (if the Clock Security System CSS is enabled).
700
  *          
686
  *          
701
  * @note   A switch from one clock source to another occurs only if the target
687
  * @note   A switch from one clock source to another occurs only if the target
702
  *         clock source is ready (clock stable after startup delay or PLL locked).
688
  *         clock source is ready (clock stable after start-up delay or PLL locked).
703
  *         If a clock source which is not yet ready is selected, the switch will
689
  *         If a clock source which is not yet ready is selected, the switch will
704
  *         occur when the clock source will be ready.
690
  *         occur when the clock source will be ready.
705
  *         You can use @ref HAL_RCC_GetClockConfig() function to know which clock is
691
  *         You can use @ref HAL_RCC_GetClockConfig() function to know which clock is
706
  *         currently used as system clock source.
692
  *         currently used as system clock source.
707
  * @retval HAL status
693
  * @retval HAL status
Line 718... Line 704...
718
  /* To correctly read data from FLASH memory, the number of wait states (LATENCY)
704
  /* To correctly read data from FLASH memory, the number of wait states (LATENCY)
719
  must be correctly programmed according to the frequency of the CPU clock
705
  must be correctly programmed according to the frequency of the CPU clock
720
    (HCLK) of the device. */
706
    (HCLK) of the device. */
721
 
707
 
722
#if defined(FLASH_ACR_LATENCY)
708
#if defined(FLASH_ACR_LATENCY)
723
  /* Increasing the CPU frequency */
709
  /* Increasing the number of wait states because of higher CPU frequency */
724
  if(FLatency > (FLASH->ACR & FLASH_ACR_LATENCY))
710
  if(FLatency > (FLASH->ACR & FLASH_ACR_LATENCY))
725
  {    
711
  {    
726
    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
712
    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
727
    __HAL_FLASH_SET_LATENCY(FLatency);
713
    __HAL_FLASH_SET_LATENCY(FLatency);
728
   
714
   
Line 730... Line 716...
730
    memory by reading the FLASH_ACR register */
716
    memory by reading the FLASH_ACR register */
731
    if((FLASH->ACR & FLASH_ACR_LATENCY) != FLatency)
717
    if((FLASH->ACR & FLASH_ACR_LATENCY) != FLatency)
732
    {
718
    {
733
      return HAL_ERROR;
719
      return HAL_ERROR;
734
    }
720
    }
735
   
721
  }
-
 
722
 
736
#endif /* FLASH_ACR_LATENCY */
723
#endif /* FLASH_ACR_LATENCY */
737
    /*-------------------------- HCLK Configuration --------------------------*/
724
  /*-------------------------- HCLK Configuration --------------------------*/
738
    if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK)
725
  if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK)
739
    {
726
  {
740
      assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider));
727
    assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider));
741
      MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider);
728
    MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider);
742
    }
729
  }
743
 
730
 
744
    /*------------------------- SYSCLK Configuration ---------------------------*/
731
  /*------------------------- SYSCLK Configuration ---------------------------*/
745
    if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK)
732
  if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK)
746
    {    
733
  {    
747
      assert_param(IS_RCC_SYSCLKSOURCE(RCC_ClkInitStruct->SYSCLKSource));
734
    assert_param(IS_RCC_SYSCLKSOURCE(RCC_ClkInitStruct->SYSCLKSource));
748
     
735
   
749
      /* HSE is selected as System Clock Source */
736
    /* HSE is selected as System Clock Source */
750
      if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
737
    if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
751
      {
738
    {
752
        /* Check the HSE ready flag */  
739
      /* Check the HSE ready flag */  
753
        if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)
740
      if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)
754
        {
-
 
755
          return HAL_ERROR;
-
 
756
        }
-
 
757
      }
-
 
758
      /* PLL is selected as System Clock Source */
-
 
759
      else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
-
 
760
      {
-
 
761
        /* Check the PLL ready flag */  
-
 
762
        if(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET)
-
 
763
        {
-
 
764
          return HAL_ERROR;
-
 
765
        }
-
 
766
      }
-
 
767
      /* HSI is selected as System Clock Source */
-
 
768
      else
-
 
769
      {
741
      {
770
        /* Check the HSI ready flag */  
-
 
771
        if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET)
-
 
772
        {
-
 
773
          return HAL_ERROR;
742
        return HAL_ERROR;
774
        }
-
 
775
      }
743
      }
776
      __HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct->SYSCLKSource);
-
 
777
 
744
    }
778
      /* Get Start Tick */
745
    /* PLL is selected as System Clock Source */
779
      tickstart = HAL_GetTick();
746
    else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
780
     
747
    {
-
 
748
      /* Check the PLL ready flag */  
781
      if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
749
      if(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET)
782
      {
750
      {
783
        while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSE)
-
 
784
        {
-
 
785
          if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
-
 
786
          {
-
 
787
            return HAL_TIMEOUT;
751
        return HAL_ERROR;
788
          }
-
 
789
        }
-
 
790
      }
752
      }
-
 
753
    }
-
 
754
    /* HSI is selected as System Clock Source */
-
 
755
    else
-
 
756
    {
-
 
757
      /* Check the HSI ready flag */  
791
      else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
758
      if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET)
792
      {
759
      {
793
        while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_PLLCLK)
-
 
794
        {
-
 
795
          if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
-
 
796
          {
-
 
797
            return HAL_TIMEOUT;
760
        return HAL_ERROR;
798
          }
-
 
799
        }
-
 
800
      }
761
      }
801
      else
-
 
802
      {
-
 
803
        while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSI)
-
 
804
        {
-
 
805
          if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
-
 
806
          {
-
 
807
            return HAL_TIMEOUT;
-
 
808
          }
-
 
809
        }
-
 
810
      }      
-
 
811
    }    
-
 
812
#if defined(FLASH_ACR_LATENCY)
-
 
813
  }
-
 
814
  /* Decreasing the CPU frequency */
-
 
815
  else
-
 
816
  {
-
 
817
    /*-------------------------- HCLK Configuration --------------------------*/
-
 
818
    if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK)
-
 
819
    {
-
 
820
      assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider));
-
 
821
      MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider);
-
 
822
    }
762
    }
-
 
763
    __HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct->SYSCLKSource);
-
 
764
 
-
 
765
    /* Get Start Tick */
-
 
766
    tickstart = HAL_GetTick();
823
   
767
   
824
    /*------------------------- SYSCLK Configuration -------------------------*/
-
 
825
    if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK)
-
 
826
    {    
-
 
827
      assert_param(IS_RCC_SYSCLKSOURCE(RCC_ClkInitStruct->SYSCLKSource));
-
 
828
     
-
 
829
      /* HSE is selected as System Clock Source */
-
 
830
      if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
768
    if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
831
      {
769
    {
832
        /* Check the HSE ready flag */  
-
 
833
        if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)
-
 
834
        {
-
 
835
          return HAL_ERROR;
-
 
836
        }
-
 
837
      }
-
 
838
      /* PLL is selected as System Clock Source */
-
 
839
      else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
770
      while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSE)
840
      {
-
 
841
        /* Check the PLL ready flag */  
-
 
842
        if(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET)
-
 
843
        {
-
 
844
          return HAL_ERROR;
-
 
845
        }
-
 
846
      }
-
 
847
      /* HSI is selected as System Clock Source */
-
 
848
      else
-
 
849
      {
771
      {
850
        /* Check the HSI ready flag */  
-
 
851
        if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET)
772
        if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
852
        {
773
        {
853
          return HAL_ERROR;
774
          return HAL_TIMEOUT;
854
        }
775
        }
855
      }
776
      }
856
      __HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct->SYSCLKSource);
-
 
857
     
777
    }
858
      /* Get Start Tick */
-
 
859
      tickstart = HAL_GetTick();
778
    else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
860
     
779
    {
861
      if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
780
      while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_PLLCLK)
862
      {
781
      {
863
        while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSE)
782
        if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
864
        {
783
        {
865
          if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
-
 
866
          {
-
 
867
            return HAL_TIMEOUT;
784
          return HAL_TIMEOUT;
868
          }
-
 
869
        }
785
        }
870
      }
786
      }
-
 
787
    }
-
 
788
    else
-
 
789
    {
871
      else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
790
      while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSI)
872
      {
791
      {
873
        while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_PLLCLK)
792
        if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
874
        {
793
        {
875
          if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
-
 
876
          {
-
 
877
            return HAL_TIMEOUT;
794
          return HAL_TIMEOUT;
878
          }
-
 
879
        }
795
        }
880
      }
796
      }
881
      else
797
    }      
882
      {
798
  }    
883
        while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSI)
799
#if defined(FLASH_ACR_LATENCY)
884
        {
-
 
885
          if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
800
  /* Decreasing the number of wait states because of lower CPU frequency */
886
          {
-
 
887
            return HAL_TIMEOUT;
801
  if(FLatency < (FLASH->ACR & FLASH_ACR_LATENCY))
888
          }
-
 
889
        }
-
 
890
      }      
-
 
891
    }
802
  {    
892
   
-
 
893
    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
803
    /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
894
    __HAL_FLASH_SET_LATENCY(FLatency);
804
    __HAL_FLASH_SET_LATENCY(FLatency);
895
   
805
   
896
    /* Check that the new number of wait states is taken into account to access the Flash
806
    /* Check that the new number of wait states is taken into account to access the Flash
897
    memory by reading the FLASH_ACR register */
807
    memory by reading the FLASH_ACR register */
898
    if((FLASH->ACR & FLASH_ACR_LATENCY) != FLatency)
808
    if((FLASH->ACR & FLASH_ACR_LATENCY) != FLatency)
899
    {
809
    {
900
      return HAL_ERROR;
810
      return HAL_ERROR;
901
    }
811
    }
902
  }
812
  }    
903
#endif /* FLASH_ACR_LATENCY */
813
#endif /* FLASH_ACR_LATENCY */
904
 
814
 
905
  /*-------------------------- PCLK1 Configuration ---------------------------*/
815
  /*-------------------------- PCLK1 Configuration ---------------------------*/
906
  if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_PCLK1) == RCC_CLOCKTYPE_PCLK1)
816
  if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_PCLK1) == RCC_CLOCKTYPE_PCLK1)
907
  {
817
  {
908
    assert_param(IS_RCC_PCLK(RCC_ClkInitStruct->APB1CLKDivider));
818
    assert_param(IS_RCC_PCLK(RCC_ClkInitStruct->APB1CLKDivider));
909
    MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE1, RCC_ClkInitStruct->APB1CLKDivider);
819
    MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE1, RCC_ClkInitStruct->APB1CLKDivider);
Line 914... Line 824...
914
  {
824
  {
915
    assert_param(IS_RCC_PCLK(RCC_ClkInitStruct->APB2CLKDivider));
825
    assert_param(IS_RCC_PCLK(RCC_ClkInitStruct->APB2CLKDivider));
916
    MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE2, ((RCC_ClkInitStruct->APB2CLKDivider) << 3));
826
    MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE2, ((RCC_ClkInitStruct->APB2CLKDivider) << 3));
917
  }
827
  }
918
 
828
 
-
 
829
  /* Update the SystemCoreClock global variable */
-
 
830
  SystemCoreClock = HAL_RCC_GetSysClockFreq() >> AHBPrescTable[(RCC->CFGR & RCC_CFGR_HPRE)>> RCC_CFGR_HPRE_BITNUMBER];
-
 
831
 
919
  /* Configure the source of time base considering new system clocks settings*/
832
  /* Configure the source of time base considering new system clocks settings*/
920
  HAL_InitTick (TICK_INT_PRIORITY);
833
  HAL_InitTick (TICK_INT_PRIORITY);
921
 
834
 
922
  return HAL_OK;
835
  return HAL_OK;
923
}
836
}
924
 
837
 
925
/**
838
/**
926
  * @}
839
  * @}
927
  */
840
  */
928
 
841
 
929
/** @defgroup RCC_Exported_Functions_Group2 Peripheral Control functions
842
/** @defgroup RCC_Exported_Functions_Group2 Peripheral Control functions
930
  *  @brief   RCC clocks control functions
843
  *  @brief   RCC clocks control functions
931
  *
844
  *
932
  @verbatim  
845
  @verbatim  
933
  ===============================================================================
846
  ===============================================================================
934
                  ##### Peripheral Control functions #####
847
                  ##### Peripheral Control functions #####
935
  ===============================================================================  
848
  ===============================================================================  
Line 944... Line 857...
944
/**
857
/**
945
  * @brief  Selects the clock source to output on MCO pin.
858
  * @brief  Selects the clock source to output on MCO pin.
946
  * @note   MCO pin should be configured in alternate function mode.
859
  * @note   MCO pin should be configured in alternate function mode.
947
  * @param  RCC_MCOx specifies the output direction for the clock source.
860
  * @param  RCC_MCOx specifies the output direction for the clock source.
948
  *          This parameter can be one of the following values:
861
  *          This parameter can be one of the following values:
949
  *            @arg RCC_MCO Clock source to output on MCO1 pin(PA8).
862
  *            @arg @ref RCC_MCO1 Clock source to output on MCO1 pin(PA8).
950
  * @param  RCC_MCOSource specifies the clock source to output.
863
  * @param  RCC_MCOSource specifies the clock source to output.
951
  *          This parameter can be one of the following values:
864
  *          This parameter can be one of the following values:
952
  *            @arg RCC_MCO1SOURCE_NOCLOCK No clock selected
865
  *            @arg @ref RCC_MCO1SOURCE_NOCLOCK     No clock selected as MCO clock
953
  *            @arg RCC_MCO1SOURCE_SYSCLK System clock selected
866
  *            @arg @ref RCC_MCO1SOURCE_SYSCLK      System clock selected as MCO clock
954
  *            @arg RCC_MCO1SOURCE_HSI HSI oscillator clock selected
867
  *            @arg @ref RCC_MCO1SOURCE_HSI         HSI selected as MCO clock
955
  *            @arg RCC_MCO1SOURCE_HSE HSE oscillator clock selected
868
  *            @arg @ref RCC_MCO1SOURCE_HSE         HSE selected as MCO clock
-
 
869
  @if STM32F105xC
-
 
870
  *            @arg @ref RCC_MCO1SOURCE_PLLCLK       PLL clock divided by 2 selected as MCO source
-
 
871
  *            @arg @ref RCC_MCO1SOURCE_PLL2CLK      PLL2 clock selected as MCO source
-
 
872
  *            @arg @ref RCC_MCO1SOURCE_PLL3CLK_DIV2 PLL3 clock divided by 2 selected as MCO source
-
 
873
  *            @arg @ref RCC_MCO1SOURCE_EXT_HSE      XT1 external 3-25 MHz oscillator clock selected as MCO source
-
 
874
  *            @arg @ref RCC_MCO1SOURCE_PLL3CLK      PLL3 clock selected as MCO source
-
 
875
  @endif
-
 
876
  @if STM32F107xC
956
  *            @arg RCC_MCO1SOURCE_PLLCLK PLL clock divided by 2 selected as MCO source
877
  *            @arg @ref RCC_MCO1SOURCE_PLLCLK       PLL clock divided by 2 selected as MCO source
957
  *            @arg RCC_MCO1SOURCE_PLL2CLK PLL2 clock selected as MCO source (only for connectivity line devices)
878
  *            @arg @ref RCC_MCO1SOURCE_PLL2CLK      PLL2 clock selected as MCO source
958
  *            @arg RCC_MCO1SOURCE_PLL3CLK_DIV2 PLL3 clock divided by 2 selected as MCO source (only for connectivity line devices)
879
  *            @arg @ref RCC_MCO1SOURCE_PLL3CLK_DIV2 PLL3 clock divided by 2 selected as MCO source
959
  *            @arg RCC_MCO1SOURCE_EXT_HSE XT1 external 3-25 MHz oscillator clock selected as MCO source (only for connectivity line devices)
880
  *            @arg @ref RCC_MCO1SOURCE_EXT_HSE XT1  external 3-25 MHz oscillator clock selected as MCO source
960
  *            @arg RCC_MCO1SOURCE_PLL3CLK PLL3 clock selected as MCO source (only for connectivity line devices)
881
  *            @arg @ref RCC_MCO1SOURCE_PLL3CLK      PLL3 clock selected as MCO source
-
 
882
  @endif
961
  * @param  RCC_MCODiv specifies the MCO DIV.
883
  * @param  RCC_MCODiv specifies the MCO DIV.
962
  *          This parameter can be one of the following values:
884
  *          This parameter can be one of the following values:
963
  *            @arg RCC_MCODIV_1 no division applied to MCO clock
885
  *            @arg @ref RCC_MCODIV_1 no division applied to MCO clock
964
  * @retval None
886
  * @retval None
965
  */
887
  */
966
void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv)
888
void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv)
967
{
889
{
968
  GPIO_InitTypeDef gpio = {0};
890
  GPIO_InitTypeDef gpio = {0};
Line 970... Line 892...
970
  /* Check the parameters */
892
  /* Check the parameters */
971
  assert_param(IS_RCC_MCO(RCC_MCOx));
893
  assert_param(IS_RCC_MCO(RCC_MCOx));
972
  assert_param(IS_RCC_MCODIV(RCC_MCODiv));
894
  assert_param(IS_RCC_MCODIV(RCC_MCODiv));
973
  assert_param(IS_RCC_MCO1SOURCE(RCC_MCOSource));
895
  assert_param(IS_RCC_MCO1SOURCE(RCC_MCOSource));
974
 
896
 
-
 
897
  /* Configure the MCO1 pin in alternate function mode */
-
 
898
  gpio.Mode      = GPIO_MODE_AF_PP;
-
 
899
  gpio.Speed     = GPIO_SPEED_FREQ_HIGH;
-
 
900
  gpio.Pull      = GPIO_NOPULL;
-
 
901
  gpio.Pin       = MCO1_PIN;
-
 
902
 
975
  /* MCO Clock Enable */
903
  /* MCO1 Clock Enable */
976
  MCO1_CLK_ENABLE();
904
  MCO1_CLK_ENABLE();
977
 
905
 
978
  /* Configure the MCO1 pin in alternate function mode */
-
 
979
  gpio.Pin = MCO1_PIN;
-
 
980
  gpio.Mode = GPIO_MODE_AF_PP;
-
 
981
  gpio.Speed = GPIO_SPEED_HIGH;
-
 
982
  gpio.Pull = GPIO_NOPULL;
-
 
983
  HAL_GPIO_Init(MCO1_GPIO_PORT, &gpio);
906
  HAL_GPIO_Init(MCO1_GPIO_PORT, &gpio);
984
 
907
 
985
  /* Configure the MCO clock source */
908
  /* Configure the MCO clock source */
986
  __HAL_RCC_MCO1_CONFIG(RCC_MCOSource, RCC_MCODiv);
909
  __HAL_RCC_MCO1_CONFIG(RCC_MCOSource, RCC_MCODiv);
987
}
910
}
Line 1029... Line 952...
1029
  *                  
952
  *                  
1030
  * @note   The result of this function could be not correct when using fractional
953
  * @note   The result of this function could be not correct when using fractional
1031
  *         value for HSE crystal.
954
  *         value for HSE crystal.
1032
  *          
955
  *          
1033
  * @note   This function can be used by the user application to compute the
956
  * @note   This function can be used by the user application to compute the
1034
  *         baudrate for the communication peripherals or configure other parameters.
957
  *         baud-rate for the communication peripherals or configure other parameters.
1035
  *          
958
  *          
1036
  * @note   Each time SYSCLK changes, this function must be called to update the
959
  * @note   Each time SYSCLK changes, this function must be called to update the
1037
  *         right SYSCLK value. Otherwise, any configuration based on this function will be incorrect.
960
  *         right SYSCLK value. Otherwise, any configuration based on this function will be incorrect.
1038
  *        
961
  *        
1039
  * @retval SYSCLK frequency
962
  * @retval SYSCLK frequency
Line 1132... Line 1055...
1132
  *         and updated within this function
1055
  *         and updated within this function
1133
  * @retval HCLK frequency
1056
  * @retval HCLK frequency
1134
  */
1057
  */
1135
uint32_t HAL_RCC_GetHCLKFreq(void)
1058
uint32_t HAL_RCC_GetHCLKFreq(void)
1136
{
1059
{
1137
  SystemCoreClock = HAL_RCC_GetSysClockFreq() >> aAPBAHBPrescTable[(RCC->CFGR & RCC_CFGR_HPRE)>> POSITION_VAL(RCC_CFGR_HPRE)];
-
 
1138
  return SystemCoreClock;
1060
  return SystemCoreClock;
1139
}
1061
}
1140
 
1062
 
1141
/**
1063
/**
1142
  * @brief  Returns the PCLK1 frequency    
1064
  * @brief  Returns the PCLK1 frequency    
Line 1145... Line 1067...
1145
  * @retval PCLK1 frequency
1067
  * @retval PCLK1 frequency
1146
  */
1068
  */
1147
uint32_t HAL_RCC_GetPCLK1Freq(void)
1069
uint32_t HAL_RCC_GetPCLK1Freq(void)
1148
{
1070
{
1149
  /* Get HCLK source and Compute PCLK1 frequency ---------------------------*/
1071
  /* Get HCLK source and Compute PCLK1 frequency ---------------------------*/
1150
  return (HAL_RCC_GetHCLKFreq() >> aAPBAHBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE1)>> POSITION_VAL(RCC_CFGR_PPRE1)]);
1072
  return (HAL_RCC_GetHCLKFreq() >> APBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE1) >> RCC_CFGR_PPRE1_BITNUMBER]);
1151
}    
1073
}    
1152
 
1074
 
1153
/**
1075
/**
1154
  * @brief  Returns the PCLK2 frequency    
1076
  * @brief  Returns the PCLK2 frequency    
1155
  * @note   Each time PCLK2 changes, this function must be called to update the
1077
  * @note   Each time PCLK2 changes, this function must be called to update the
Line 1157... Line 1079...
1157
  * @retval PCLK2 frequency
1079
  * @retval PCLK2 frequency
1158
  */
1080
  */
1159
uint32_t HAL_RCC_GetPCLK2Freq(void)
1081
uint32_t HAL_RCC_GetPCLK2Freq(void)
1160
{
1082
{
1161
  /* Get HCLK source and Compute PCLK2 frequency ---------------------------*/
1083
  /* Get HCLK source and Compute PCLK2 frequency ---------------------------*/
1162
  return (HAL_RCC_GetHCLKFreq()>> aAPBAHBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE2)>> POSITION_VAL(RCC_CFGR_PPRE2)]);
1084
  return (HAL_RCC_GetHCLKFreq()>> APBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE2) >> RCC_CFGR_PPRE2_BITNUMBER]);
1163
}
1085
}
1164
 
1086
 
1165
/**
1087
/**
1166
  * @brief  Configures the RCC_OscInitStruct according to the internal
1088
  * @brief  Configures the RCC_OscInitStruct according to the internal
1167
  * RCC configuration registers.
1089
  * RCC configuration registers.
Line 1232... Line 1154...
1232
  else
1154
  else
1233
  {
1155
  {
1234
    RCC_OscInitStruct->LSIState = RCC_LSI_OFF;
1156
    RCC_OscInitStruct->LSIState = RCC_LSI_OFF;
1235
  }
1157
  }
1236
 
1158
 
-
 
1159
 
1237
  /* Get the PLL configuration -----------------------------------------------*/
1160
  /* Get the PLL configuration -----------------------------------------------*/
1238
  if((RCC->CR &RCC_CR_PLLON) == RCC_CR_PLLON)
1161
  if((RCC->CR &RCC_CR_PLLON) == RCC_CR_PLLON)
1239
  {
1162
  {
1240
    RCC_OscInitStruct->PLL.PLLState = RCC_PLL_ON;
1163
    RCC_OscInitStruct->PLL.PLLState = RCC_PLL_ON;
1241
  }
1164
  }