Subversion Repositories LedShow

Rev

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

Rev 2 Rev 9
Line 4... Line 4...
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   RCC LL module driver.
5
  * @brief   RCC LL module driver.
6
  ******************************************************************************
6
  ******************************************************************************
7
  * @attention
7
  * @attention
8
  *
8
  *
9
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
9
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
-
 
10
  * All rights reserved.</center></h2>
10
  *
11
  *
11
  * Redistribution and use in source and binary forms, with or without modification,
12
  * This software component is licensed by ST under BSD 3-Clause license,
12
  * are permitted provided that the following conditions are met:
13
  * the "License"; You may not use this file except in compliance with the
13
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
14
  *      this list of conditions and the following disclaimer.
-
 
15
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
16
  *      this list of conditions and the following disclaimer in the documentation
-
 
17
  *      and/or other materials provided with the distribution.
14
  * License. You may obtain a copy of the License at:
18
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
19
  *      may be used to endorse or promote products derived from this software
15
  *                        opensource.org/licenses/BSD-3-Clause
20
  *      without specific prior written permission.
-
 
21
  *
-
 
22
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
23
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
24
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
25
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
26
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
27
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-
 
28
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-
 
29
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
30
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
31
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
32
  *
16
  *
33
  ******************************************************************************
17
  ******************************************************************************
34
  */
18
  */
-
 
19
 
35
#if defined(USE_FULL_LL_DRIVER)
20
#if defined(USE_FULL_LL_DRIVER)
36
 
21
 
37
/* Includes ------------------------------------------------------------------*/
22
/* Includes ------------------------------------------------------------------*/
38
#include "stm32f1xx_ll_rcc.h"
23
#include "stm32f1xx_ll_rcc.h"
39
#ifdef  USE_FULL_ASSERT
24
#ifdef  USE_FULL_ASSERT
40
  #include "stm32_assert.h"
25
#include "stm32_assert.h"
41
#else
26
#else
42
  #define assert_param(expr) ((void)0U)
27
#define assert_param(expr) ((void)0U)
43
#endif /* USE_FULL_ASSERT */
28
#endif /* USE_FULL_ASSERT */
44
/** @addtogroup STM32F1xx_LL_Driver
29
/** @addtogroup STM32F1xx_LL_Driver
45
  * @{
30
  * @{
46
  */
31
  */
47
 
32
 
Line 102... Line 87...
102
 
87
 
103
/**
88
/**
104
  * @brief  Reset the RCC clock configuration to the default reset state.
89
  * @brief  Reset the RCC clock configuration to the default reset state.
105
  * @note   The default reset state of the clock configuration is given below:
90
  * @note   The default reset state of the clock configuration is given below:
106
  *         - HSI ON and used as system clock source
91
  *         - HSI ON and used as system clock source
107
  *         - HSE PLL, PLL2 & PLL3 are OFF
92
  *         - HSE PLL, PLL2 & PLL3 are OFF
108
  *         - AHB, APB1 and APB2 prescaler set to 1.
93
  *         - AHB, APB1 and APB2 prescaler set to 1.
109
  *         - CSS, MCO OFF
94
  *         - CSS, MCO OFF
110
  *         - All interrupts disabled
95
  *         - All interrupts disabled
111
  * @note   This function doesn't modify the configuration of the
96
  * @note   This function doesn't modify the configuration of the
112
  *         - Peripheral clocks
97
  *         - Peripheral clocks
Line 119... Line 104...
119
{
104
{
120
  /* Set HSION bit */
105
  /* Set HSION bit */
121
  LL_RCC_HSI_Enable();
106
  LL_RCC_HSI_Enable();
122
 
107
 
123
  /* Wait for HSI READY bit */
108
  /* Wait for HSI READY bit */
124
  while(LL_RCC_HSI_IsReady() != 1U)
109
  while (LL_RCC_HSI_IsReady() != 1U)
125
  {}
110
  {}
126
 
111
 
127
  /* Configure HSI as system clock source */
112
  /* Configure HSI as system clock source */
128
  LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
113
  LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
129
 
114
 
Line 133... Line 118...
133
 
118
 
134
  /* Reset PLLON bit */
119
  /* Reset PLLON bit */
135
  CLEAR_BIT(RCC->CR, RCC_CR_PLLON);
120
  CLEAR_BIT(RCC->CR, RCC_CR_PLLON);
136
 
121
 
137
  /* Wait for PLL READY bit to be reset */
122
  /* Wait for PLL READY bit to be reset */
138
  while(LL_RCC_PLL_IsReady() != 0U)
123
  while (LL_RCC_PLL_IsReady() != 0U)
139
  {}
124
  {}
140
 
125
 
141
  /* Reset CFGR register */
126
  /* Reset CFGR register */
142
  LL_RCC_WriteReg(CFGR, 0x00000000U);
127
  LL_RCC_WriteReg(CFGR, 0x00000000U);
143
 
128
 
Line 178... Line 163...
178
/** @addtogroup RCC_LL_EF_Get_Freq
163
/** @addtogroup RCC_LL_EF_Get_Freq
179
  * @brief  Return the frequencies of different on chip clocks;  System, AHB, APB1 and APB2 buses clocks
164
  * @brief  Return the frequencies of different on chip clocks;  System, AHB, APB1 and APB2 buses clocks
180
  *         and different peripheral clocks available on the device.
165
  *         and different peripheral clocks available on the device.
181
  * @note   If SYSCLK source is HSI, function returns values based on HSI_VALUE(**)
166
  * @note   If SYSCLK source is HSI, function returns values based on HSI_VALUE(**)
182
  * @note   If SYSCLK source is HSE, function returns values based on HSE_VALUE(***)
167
  * @note   If SYSCLK source is HSE, function returns values based on HSE_VALUE(***)
183
  * @note   If SYSCLK source is PLL, function returns values based on
168
  * @note   If SYSCLK source is PLL, function returns values based on
184
  *         HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
169
  *         HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
185
  * @note   (**) HSI_VALUE is a defined constant but the real value may vary
170
  * @note   (**) HSI_VALUE is a defined constant but the real value may vary
186
  *              depending on the variations in voltage and temperature.
171
  *              depending on the variations in voltage and temperature.
187
  * @note   (***) HSE_VALUE is a defined constant, user has to ensure that
172
  * @note   (***) HSE_VALUE is a defined constant, user has to ensure that
188
  *               HSE_VALUE is same as the real frequency of the crystal used.
173
  *               HSE_VALUE is same as the real frequency of the crystal used.
189
  *               Otherwise, this function may have wrong result.
174
  *               Otherwise, this function may have wrong result.
190
  * @note   The result of this function could be incorrect when using fractional
175
  * @note   The result of this function could be incorrect when using fractional
Line 267... Line 252...
267
  assert_param(IS_LL_RCC_USB_CLKSOURCE(USBxSource));
252
  assert_param(IS_LL_RCC_USB_CLKSOURCE(USBxSource));
268
 
253
 
269
  /* USBCLK clock frequency */
254
  /* USBCLK clock frequency */
270
  switch (LL_RCC_GetUSBClockSource(USBxSource))
255
  switch (LL_RCC_GetUSBClockSource(USBxSource))
271
  {
256
  {
272
#if defined(RCC_CFGR_USBPRE)  
257
#if defined(RCC_CFGR_USBPRE)
273
    case LL_RCC_USB_CLKSOURCE_PLL:        /* PLL clock used as USB clock source */
258
    case LL_RCC_USB_CLKSOURCE_PLL:        /* PLL clock used as USB clock source */
274
      if (LL_RCC_PLL_IsReady())
259
      if (LL_RCC_PLL_IsReady())
275
      {
260
      {
276
        usb_frequency = RCC_PLL_GetFreqDomain_SYS();
261
        usb_frequency = RCC_PLL_GetFreqDomain_SYS();
277
      }
262
      }
Line 284... Line 269...
284
        usb_frequency = (RCC_PLL_GetFreqDomain_SYS() * 3U) / 2U;
269
        usb_frequency = (RCC_PLL_GetFreqDomain_SYS() * 3U) / 2U;
285
      }
270
      }
286
      break;
271
      break;
287
#endif /* RCC_CFGR_USBPRE */
272
#endif /* RCC_CFGR_USBPRE */
288
#if defined(RCC_CFGR_OTGFSPRE)
273
#if defined(RCC_CFGR_OTGFSPRE)
289
    /* USBCLK = PLLVCO/2
274
    /* USBCLK = PLLVCO/2
290
              = (2 x PLLCLK) / 2
275
              = (2 x PLLCLK) / 2
291
              = PLLCLK */
276
              = PLLCLK */
292
    case LL_RCC_USB_CLKSOURCE_PLL_DIV_2:        /* PLL clock used as USB clock source */
277
    case LL_RCC_USB_CLKSOURCE_PLL_DIV_2:        /* PLL clock used as USB clock source */
293
      if (LL_RCC_PLL_IsReady())
278
      if (LL_RCC_PLL_IsReady())
294
      {
279
      {
295
        usb_frequency = RCC_PLL_GetFreqDomain_SYS();
280
        usb_frequency = RCC_PLL_GetFreqDomain_SYS();
296
      }
281
      }
297
      break;
282
      break;
298
 
283
 
299
    /* USBCLK = PLLVCO/3
284
    /* USBCLK = PLLVCO/3
300
              = (2 x PLLCLK) / 3 */
285
              = (2 x PLLCLK) / 3 */
301
    case LL_RCC_USB_CLKSOURCE_PLL_DIV_3:        /* PLL clock divided by 3 used as USB clock source */
286
    case LL_RCC_USB_CLKSOURCE_PLL_DIV_3:        /* PLL clock divided by 3 used as USB clock source */
302
    default:
287
    default:
303
      if (LL_RCC_PLL_IsReady())
288
      if (LL_RCC_PLL_IsReady())
304
      {
289
      {