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   Header file of RCC HAL module.
5
  * @brief   Header file of RCC HAL module.
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
  */
35
 
19
 
36
/* Define to prevent recursive inclusion -------------------------------------*/
20
/* Define to prevent recursive inclusion -------------------------------------*/
37
#ifndef __STM32F1xx_HAL_RCC_H
21
#ifndef __STM32F1xx_HAL_RCC_H
38
#define __STM32F1xx_HAL_RCC_H
22
#define __STM32F1xx_HAL_RCC_H
39
 
23
 
40
#ifdef __cplusplus
24
#ifdef __cplusplus
41
 extern "C" {
25
extern "C" {
42
#endif
26
#endif
43
 
27
 
44
/* Includes ------------------------------------------------------------------*/
28
/* Includes ------------------------------------------------------------------*/
45
#include "stm32f1xx_hal_def.h"
29
#include "stm32f1xx_hal_def.h"
46
 
30
 
-
 
31
 
47
/** @addtogroup STM32F1xx_HAL_Driver
32
/** @addtogroup STM32F1xx_HAL_Driver
48
  * @{
33
  * @{
49
  */
34
  */
50
 
35
 
51
/** @addtogroup RCC
36
/** @addtogroup RCC
Line 56... Line 41...
56
 
41
 
57
/** @defgroup RCC_Exported_Types RCC Exported Types
42
/** @defgroup RCC_Exported_Types RCC Exported Types
58
  * @{
43
  * @{
59
  */
44
  */
60
 
45
 
61
/**
46
/**
62
  * @brief  RCC PLL configuration structure definition  
47
  * @brief  RCC PLL configuration structure definition
63
  */
48
  */
64
typedef struct
49
typedef struct
65
{
50
{
66
  uint32_t PLLState;      /*!< PLLState: The new state of the PLL.
51
  uint32_t PLLState;      /*!< PLLState: The new state of the PLL.
67
                              This parameter can be a value of @ref RCC_PLL_Config */
52
                              This parameter can be a value of @ref RCC_PLL_Config */
68
 
53
 
69
  uint32_t PLLSource;     /*!< PLLSource: PLL entry clock source.
54
  uint32_t PLLSource;     /*!< PLLSource: PLL entry clock source.
70
                              This parameter must be a value of @ref RCC_PLL_Clock_Source */          
55
                              This parameter must be a value of @ref RCC_PLL_Clock_Source */
71
 
56
 
72
  uint32_t PLLMUL;        /*!< PLLMUL: Multiplication factor for PLL VCO input clock
57
  uint32_t PLLMUL;        /*!< PLLMUL: Multiplication factor for PLL VCO input clock
73
                              This parameter must be a value of @ref RCCEx_PLL_Multiplication_Factor */
58
                              This parameter must be a value of @ref RCCEx_PLL_Multiplication_Factor */
74
} RCC_PLLInitTypeDef;
59
} RCC_PLLInitTypeDef;
75
   
60
 
76
/**
61
/**
77
  * @brief  RCC System, AHB and APB busses clock configuration structure definition  
62
  * @brief  RCC System, AHB and APB busses clock configuration structure definition
78
  */
63
  */
79
typedef struct
64
typedef struct
80
{
65
{
81
  uint32_t ClockType;             /*!< The clock to be configured.
66
  uint32_t ClockType;             /*!< The clock to be configured.
82
                                       This parameter can be a value of @ref RCC_System_Clock_Type */
67
                                       This parameter can be a value of @ref RCC_System_Clock_Type */
Line 228... Line 213...
228
#define RCC_SYSCLK_DIV512                RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
213
#define RCC_SYSCLK_DIV512                RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
229
 
214
 
230
/**
215
/**
231
  * @}
216
  * @}
232
  */
217
  */
233
 
218
 
234
/** @defgroup RCC_APB1_APB2_Clock_Source APB1 APB2 Clock Source
219
/** @defgroup RCC_APB1_APB2_Clock_Source APB1 APB2 Clock Source
235
  * @{
220
  * @{
236
  */
221
  */
237
#define RCC_HCLK_DIV1                    RCC_CFGR_PPRE1_DIV1  /*!< HCLK not divided */
222
#define RCC_HCLK_DIV1                    RCC_CFGR_PPRE1_DIV1  /*!< HCLK not divided */
238
#define RCC_HCLK_DIV2                    RCC_CFGR_PPRE1_DIV2  /*!< HCLK divided by 2 */
223
#define RCC_HCLK_DIV2                    RCC_CFGR_PPRE1_DIV2  /*!< HCLK divided by 2 */
Line 284... Line 269...
284
#define RCC_IT_HSERDY                    ((uint8_t)RCC_CIR_HSERDYF)   /*!< HSE Ready Interrupt flag */
269
#define RCC_IT_HSERDY                    ((uint8_t)RCC_CIR_HSERDYF)   /*!< HSE Ready Interrupt flag */
285
#define RCC_IT_PLLRDY                    ((uint8_t)RCC_CIR_PLLRDYF)   /*!< PLL Ready Interrupt flag */
270
#define RCC_IT_PLLRDY                    ((uint8_t)RCC_CIR_PLLRDYF)   /*!< PLL Ready Interrupt flag */
286
#define RCC_IT_CSS                       ((uint8_t)RCC_CIR_CSSF)      /*!< Clock Security System Interrupt flag */
271
#define RCC_IT_CSS                       ((uint8_t)RCC_CIR_CSSF)      /*!< Clock Security System Interrupt flag */
287
/**
272
/**
288
  * @}
273
  * @}
289
  */
274
  */
290
 
275
 
291
/** @defgroup RCC_Flag Flags
276
/** @defgroup RCC_Flag Flags
292
  *        Elements values convention: XXXYYYYYb
277
  *        Elements values convention: XXXYYYYYb
293
  *           - YYYYY  : Flag position in the register
278
  *           - YYYYY  : Flag position in the register
294
  *           - XXX  : Register index
279
  *           - XXX  : Register index
295
  *                 - 001: CR register
280
  *                 - 001: CR register
Line 329... Line 314...
329
  */
314
  */
330
 
315
 
331
/** @defgroup RCC_Peripheral_Clock_Enable_Disable Peripheral Clock Enable Disable
316
/** @defgroup RCC_Peripheral_Clock_Enable_Disable Peripheral Clock Enable Disable
332
  * @brief  Enable or disable the AHB1 peripheral clock.
317
  * @brief  Enable or disable the AHB1 peripheral clock.
333
  * @note   After reset, the peripheral clock (used for registers read/write access)
318
  * @note   After reset, the peripheral clock (used for registers read/write access)
334
  *         is disabled and the application software has to enable this clock before
319
  *         is disabled and the application software has to enable this clock before
335
  *         using it.  
320
  *         using it.
336
  * @{
321
  * @{
337
  */
322
  */
338
#define __HAL_RCC_DMA1_CLK_ENABLE()   do { \
323
#define __HAL_RCC_DMA1_CLK_ENABLE()   do { \
339
                                        __IO uint32_t tmpreg; \
324
                                        __IO uint32_t tmpreg; \
340
                                        SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN);\
325
                                        SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN);\
Line 398... Line 383...
398
  */
383
  */
399
 
384
 
400
/** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Clock Enable Disable
385
/** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Clock Enable Disable
401
  * @brief  Enable or disable the Low Speed APB (APB1) peripheral clock.
386
  * @brief  Enable or disable the Low Speed APB (APB1) peripheral clock.
402
  * @note   After reset, the peripheral clock (used for registers read/write access)
387
  * @note   After reset, the peripheral clock (used for registers read/write access)
403
  *         is disabled and the application software has to enable this clock before
388
  *         is disabled and the application software has to enable this clock before
404
  *         using it.
389
  *         using it.
405
  * @{  
390
  * @{
406
  */
391
  */
407
#define __HAL_RCC_TIM2_CLK_ENABLE()   do { \
392
#define __HAL_RCC_TIM2_CLK_ENABLE()   do { \
408
                                        __IO uint32_t tmpreg; \
393
                                        __IO uint32_t tmpreg; \
409
                                        SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
394
                                        SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
410
                                        /* Delay after an RCC peripheral clock enabling */\
395
                                        /* Delay after an RCC peripheral clock enabling */\
Line 501... Line 486...
501
  */
486
  */
502
 
487
 
503
/** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Clock Enable Disable
488
/** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Clock Enable Disable
504
  * @brief  Enable or disable the High Speed APB (APB2) peripheral clock.
489
  * @brief  Enable or disable the High Speed APB (APB2) peripheral clock.
505
  * @note   After reset, the peripheral clock (used for registers read/write access)
490
  * @note   After reset, the peripheral clock (used for registers read/write access)
506
  *         is disabled and the application software has to enable this clock before
491
  *         is disabled and the application software has to enable this clock before
507
  *         using it.
492
  *         using it.
508
  * @{  
493
  * @{
509
  */
494
  */
510
#define __HAL_RCC_AFIO_CLK_ENABLE()   do { \
495
#define __HAL_RCC_AFIO_CLK_ENABLE()   do { \
511
                                        __IO uint32_t tmpreg; \
496
                                        __IO uint32_t tmpreg; \
512
                                        SET_BIT(RCC->APB2ENR, RCC_APB2ENR_AFIOEN);\
497
                                        SET_BIT(RCC->APB2ENR, RCC_APB2ENR_AFIOEN);\
513
                                        /* Delay after an RCC peripheral clock enabling */\
498
                                        /* Delay after an RCC peripheral clock enabling */\
Line 591... Line 576...
591
#define __HAL_RCC_USART1_CLK_DISABLE()    (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
576
#define __HAL_RCC_USART1_CLK_DISABLE()    (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
592
 
577
 
593
/**
578
/**
594
  * @}
579
  * @}
595
  */
580
  */
596
 
581
 
597
/** @defgroup RCC_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
582
/** @defgroup RCC_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
598
  * @brief  Get the enable or disable status of the APB2 peripheral clock.
583
  * @brief  Get the enable or disable status of the APB2 peripheral clock.
599
  * @note   After reset, the peripheral clock (used for registers read/write access)
584
  * @note   After reset, the peripheral clock (used for registers read/write access)
600
  *         is disabled and the application software has to enable this clock before
585
  *         is disabled and the application software has to enable this clock before
601
  *         using it.
586
  *         using it.
Line 625... Line 610...
625
  * @}
610
  * @}
626
  */
611
  */
627
 
612
 
628
/** @defgroup RCC_APB1_Force_Release_Reset APB1 Force Release Reset
613
/** @defgroup RCC_APB1_Force_Release_Reset APB1 Force Release Reset
629
  * @brief  Force or release APB1 peripheral reset.
614
  * @brief  Force or release APB1 peripheral reset.
630
  * @{  
615
  * @{
631
  */
616
  */
632
#define __HAL_RCC_APB1_FORCE_RESET()       (RCC->APB2RSTR = 0xFFFFFFFFU)  
617
#define __HAL_RCC_APB1_FORCE_RESET()       (RCC->APB2RSTR = 0xFFFFFFFFU)
633
#define __HAL_RCC_TIM2_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
618
#define __HAL_RCC_TIM2_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
634
#define __HAL_RCC_TIM3_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
619
#define __HAL_RCC_TIM3_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
635
#define __HAL_RCC_WWDG_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
620
#define __HAL_RCC_WWDG_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
636
#define __HAL_RCC_USART2_FORCE_RESET()     (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
621
#define __HAL_RCC_USART2_FORCE_RESET()     (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
637
#define __HAL_RCC_I2C1_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
622
#define __HAL_RCC_I2C1_FORCE_RESET()       (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
638
 
623
 
639
#define __HAL_RCC_BKP_FORCE_RESET()        (RCC->APB1RSTR |= (RCC_APB1RSTR_BKPRST))
624
#define __HAL_RCC_BKP_FORCE_RESET()        (RCC->APB1RSTR |= (RCC_APB1RSTR_BKPRST))
640
#define __HAL_RCC_PWR_FORCE_RESET()        (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
625
#define __HAL_RCC_PWR_FORCE_RESET()        (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
641
 
626
 
642
#define __HAL_RCC_APB1_RELEASE_RESET()      (RCC->APB1RSTR = 0x00)  
627
#define __HAL_RCC_APB1_RELEASE_RESET()      (RCC->APB1RSTR = 0x00)
643
#define __HAL_RCC_TIM2_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
628
#define __HAL_RCC_TIM2_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
644
#define __HAL_RCC_TIM3_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
629
#define __HAL_RCC_TIM3_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
645
#define __HAL_RCC_WWDG_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
630
#define __HAL_RCC_WWDG_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
646
#define __HAL_RCC_USART2_RELEASE_RESET()     (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
631
#define __HAL_RCC_USART2_RELEASE_RESET()     (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
647
#define __HAL_RCC_I2C1_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C1RST))
632
#define __HAL_RCC_I2C1_RELEASE_RESET()       (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C1RST))
Line 653... Line 638...
653
  * @}
638
  * @}
654
  */
639
  */
655
 
640
 
656
/** @defgroup RCC_APB2_Force_Release_Reset APB2 Force Release Reset
641
/** @defgroup RCC_APB2_Force_Release_Reset APB2 Force Release Reset
657
  * @brief  Force or release APB2 peripheral reset.
642
  * @brief  Force or release APB2 peripheral reset.
658
  * @{  
643
  * @{
659
  */
644
  */
660
#define __HAL_RCC_APB2_FORCE_RESET()       (RCC->APB2RSTR = 0xFFFFFFFFU)  
645
#define __HAL_RCC_APB2_FORCE_RESET()       (RCC->APB2RSTR = 0xFFFFFFFFU)
661
#define __HAL_RCC_AFIO_FORCE_RESET()       (RCC->APB2RSTR |= (RCC_APB2RSTR_AFIORST))
646
#define __HAL_RCC_AFIO_FORCE_RESET()       (RCC->APB2RSTR |= (RCC_APB2RSTR_AFIORST))
662
#define __HAL_RCC_GPIOA_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPARST))
647
#define __HAL_RCC_GPIOA_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPARST))
663
#define __HAL_RCC_GPIOB_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPBRST))
648
#define __HAL_RCC_GPIOB_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPBRST))
664
#define __HAL_RCC_GPIOC_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPCRST))
649
#define __HAL_RCC_GPIOC_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPCRST))
665
#define __HAL_RCC_GPIOD_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPDRST))
650
#define __HAL_RCC_GPIOD_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPDRST))
Line 667... Line 652...
667
 
652
 
668
#define __HAL_RCC_TIM1_FORCE_RESET()       (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM1RST))
653
#define __HAL_RCC_TIM1_FORCE_RESET()       (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM1RST))
669
#define __HAL_RCC_SPI1_FORCE_RESET()       (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
654
#define __HAL_RCC_SPI1_FORCE_RESET()       (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
670
#define __HAL_RCC_USART1_FORCE_RESET()     (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
655
#define __HAL_RCC_USART1_FORCE_RESET()     (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
671
 
656
 
672
#define __HAL_RCC_APB2_RELEASE_RESET()      (RCC->APB2RSTR = 0x00)  
657
#define __HAL_RCC_APB2_RELEASE_RESET()      (RCC->APB2RSTR = 0x00)
673
#define __HAL_RCC_AFIO_RELEASE_RESET()       (RCC->APB2RSTR &= ~(RCC_APB2RSTR_AFIORST))
658
#define __HAL_RCC_AFIO_RELEASE_RESET()       (RCC->APB2RSTR &= ~(RCC_APB2RSTR_AFIORST))
674
#define __HAL_RCC_GPIOA_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPARST))
659
#define __HAL_RCC_GPIOA_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPARST))
675
#define __HAL_RCC_GPIOB_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPBRST))
660
#define __HAL_RCC_GPIOB_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPBRST))
676
#define __HAL_RCC_GPIOC_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPCRST))
661
#define __HAL_RCC_GPIOC_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPCRST))
677
#define __HAL_RCC_GPIOD_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPDRST))
662
#define __HAL_RCC_GPIOD_RELEASE_RESET()      (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPDRST))
Line 684... Line 669...
684
/**
669
/**
685
  * @}
670
  * @}
686
  */
671
  */
687
 
672
 
688
/** @defgroup RCC_HSI_Configuration HSI Configuration
673
/** @defgroup RCC_HSI_Configuration HSI Configuration
689
  * @{  
674
  * @{
690
  */
675
  */
691
 
676
 
692
/** @brief  Macros to enable or disable the Internal High Speed oscillator (HSI).
677
/** @brief  Macros to enable or disable the Internal High Speed oscillator (HSI).
693
  * @note   The HSI is stopped by hardware when entering STOP and STANDBY modes.
678
  * @note   The HSI is stopped by hardware when entering STOP and STANDBY modes.
694
  * @note   HSI can not be stopped if it is used as system clock source. In this case,
679
  * @note   HSI can not be stopped if it is used as system clock source. In this case,
695
  *         you have to select another source of the system clock then stop the HSI.  
680
  *         you have to select another source of the system clock then stop the HSI.
696
  * @note   After enabling the HSI, the application software should wait on HSIRDY
681
  * @note   After enabling the HSI, the application software should wait on HSIRDY
697
  *         flag to be set indicating that HSI clock is stable and can be used as
682
  *         flag to be set indicating that HSI clock is stable and can be used as
698
  *         system clock source.  
683
  *         system clock source.
699
  * @note   When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
684
  * @note   When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
700
  *         clock cycles.  
685
  *         clock cycles.
701
  */
686
  */
702
#define __HAL_RCC_HSI_ENABLE()  (*(__IO uint32_t *) RCC_CR_HSION_BB = ENABLE)
687
#define __HAL_RCC_HSI_ENABLE()  (*(__IO uint32_t *) RCC_CR_HSION_BB = ENABLE)
703
#define __HAL_RCC_HSI_DISABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = DISABLE)
688
#define __HAL_RCC_HSI_DISABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = DISABLE)
704
 
689
 
705
/** @brief  Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
690
/** @brief  Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
706
  * @note   The calibration is used to compensate for the variations in voltage
691
  * @note   The calibration is used to compensate for the variations in voltage
707
  *         and temperature that influence the frequency of the internal HSI RC.
692
  *         and temperature that influence the frequency of the internal HSI RC.
708
  * @param  _HSICALIBRATIONVALUE_ specifies the calibration trimming value.
693
  * @param  _HSICALIBRATIONVALUE_ specifies the calibration trimming value.
709
  *         (default is RCC_HSICALIBRATION_DEFAULT).
694
  *         (default is RCC_HSICALIBRATION_DEFAULT).
710
  *         This parameter must be a number between 0 and 0x1F.
695
  *         This parameter must be a number between 0 and 0x1F.
711
  */  
696
  */
712
#define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(_HSICALIBRATIONVALUE_) \
697
#define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(_HSICALIBRATIONVALUE_) \
713
          (MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, (uint32_t)(_HSICALIBRATIONVALUE_) << RCC_CR_HSITRIM_Pos))
698
          (MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, (uint32_t)(_HSICALIBRATIONVALUE_) << RCC_CR_HSITRIM_Pos))
714
 
699
 
715
/**
700
/**
716
  * @}
701
  * @}
717
  */
702
  */
718
 
703
 
719
/** @defgroup RCC_LSI_Configuration  LSI Configuration
704
/** @defgroup RCC_LSI_Configuration  LSI Configuration
720
  * @{  
705
  * @{
721
  */
706
  */
722
 
707
 
723
/** @brief Macro to enable the Internal Low Speed oscillator (LSI).
708
/** @brief Macro to enable the Internal Low Speed oscillator (LSI).
724
  * @note   After enabling the LSI, the application software should wait on
709
  * @note   After enabling the LSI, the application software should wait on
725
  *         LSIRDY flag to be set indicating that LSI clock is stable and can
710
  *         LSIRDY flag to be set indicating that LSI clock is stable and can
726
  *         be used to clock the IWDG and/or the RTC.
711
  *         be used to clock the IWDG and/or the RTC.
727
  */
712
  */
728
#define __HAL_RCC_LSI_ENABLE()  (*(__IO uint32_t *) RCC_CSR_LSION_BB = ENABLE)
713
#define __HAL_RCC_LSI_ENABLE()  (*(__IO uint32_t *) RCC_CSR_LSION_BB = ENABLE)
729
 
714
 
730
/** @brief Macro to disable the Internal Low Speed oscillator (LSI).
715
/** @brief Macro to disable the Internal Low Speed oscillator (LSI).
731
  * @note   LSI can not be disabled if the IWDG is running.  
716
  * @note   LSI can not be disabled if the IWDG is running.
732
  * @note   When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
717
  * @note   When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
733
  *         clock cycles.
718
  *         clock cycles.
734
  */
719
  */
735
#define __HAL_RCC_LSI_DISABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = DISABLE)
720
#define __HAL_RCC_LSI_DISABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = DISABLE)
736
 
721
 
737
/**
722
/**
738
  * @}
723
  * @}
739
  */
724
  */
740
 
725
 
741
/** @defgroup RCC_HSE_Configuration HSE Configuration
726
/** @defgroup RCC_HSE_Configuration HSE Configuration
742
  * @{  
727
  * @{
743
  */
728
  */
744
 
729
 
745
/**
730
/**
746
  * @brief  Macro to configure the External High Speed oscillator (HSE).
731
  * @brief  Macro to configure the External High Speed oscillator (HSE).
747
  * @note   Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
732
  * @note   Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
Line 790... Line 775...
790
/**
775
/**
791
  * @}
776
  * @}
792
  */
777
  */
793
 
778
 
794
/** @defgroup RCC_LSE_Configuration LSE Configuration
779
/** @defgroup RCC_LSE_Configuration LSE Configuration
795
  * @{  
780
  * @{
796
  */
781
  */
797
 
782
 
798
/**
783
/**
799
  * @brief  Macro to configure the External Low Speed oscillator (LSE).
784
  * @brief  Macro to configure the External Low Speed oscillator (LSE).
800
  * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro.
785
  * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro.
801
  * @note   As the LSE is in the Backup domain and write access is denied to
786
  * @note   As the LSE is in the Backup domain and write access is denied to
802
  *         this domain after reset, you have to enable write access using
787
  *         this domain after reset, you have to enable write access using
803
  *         @ref HAL_PWR_EnableBkUpAccess() function before to configure the LSE
788
  *         @ref HAL_PWR_EnableBkUpAccess() function before to configure the LSE
804
  *         (to be done once after reset).  
789
  *         (to be done once after reset).
805
  * @note   After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
790
  * @note   After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
806
  *         software should wait on LSERDY flag to be set indicating that LSE clock
791
  *         software should wait on LSERDY flag to be set indicating that LSE clock
807
  *         is stable and can be used to clock the RTC.
792
  *         is stable and can be used to clock the RTC.
808
  * @param  __STATE__ specifies the new state of the LSE.
793
  * @param  __STATE__ specifies the new state of the LSE.
809
  *         This parameter can be one of the following values:
794
  *         This parameter can be one of the following values:
Line 838... Line 823...
838
/**
823
/**
839
  * @}
824
  * @}
840
  */
825
  */
841
 
826
 
842
/** @defgroup RCC_PLL_Configuration PLL Configuration
827
/** @defgroup RCC_PLL_Configuration PLL Configuration
843
  * @{  
828
  * @{
844
  */
829
  */
845
 
830
 
846
/** @brief Macro to enable the main PLL.
831
/** @brief Macro to enable the main PLL.
847
  * @note   After enabling the main PLL, the application software should wait on
832
  * @note   After enabling the main PLL, the application software should wait on
848
  *         PLLRDY flag to be set indicating that PLL clock is stable and can
833
  *         PLLRDY flag to be set indicating that PLL clock is stable and can
849
  *         be used as system clock source.
834
  *         be used as system clock source.
850
  * @note   The main PLL is disabled by hardware when entering STOP and STANDBY modes.
835
  * @note   The main PLL is disabled by hardware when entering STOP and STANDBY modes.
851
  */
836
  */
852
#define __HAL_RCC_PLL_ENABLE()          (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
837
#define __HAL_RCC_PLL_ENABLE()          (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
Line 856... Line 841...
856
  */
841
  */
857
#define __HAL_RCC_PLL_DISABLE()         (*(__IO uint32_t *) RCC_CR_PLLON_BB = DISABLE)
842
#define __HAL_RCC_PLL_DISABLE()         (*(__IO uint32_t *) RCC_CR_PLLON_BB = DISABLE)
858
 
843
 
859
/** @brief Macro to configure the main PLL clock source and multiplication factors.
844
/** @brief Macro to configure the main PLL clock source and multiplication factors.
860
  * @note   This function must be used only when the main PLL is disabled.
845
  * @note   This function must be used only when the main PLL is disabled.
861
  *  
846
  *
862
  * @param  __RCC_PLLSOURCE__ specifies the PLL entry clock source.
847
  * @param  __RCC_PLLSOURCE__ specifies the PLL entry clock source.
863
  *          This parameter can be one of the following values:
848
  *          This parameter can be one of the following values:
864
  *            @arg @ref RCC_PLLSOURCE_HSI_DIV2 HSI oscillator clock selected as PLL clock entry
849
  *            @arg @ref RCC_PLLSOURCE_HSI_DIV2 HSI oscillator clock selected as PLL clock entry
865
  *            @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
850
  *            @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
866
  * @param  __PLLMUL__ specifies the multiplication factor for PLL VCO output clock
851
  * @param  __PLLMUL__ specifies the multiplication factor for PLL VCO output clock
Line 882... Line 867...
882
  *             @arg @ref RCC_PLL_MUL15  PLLVCO = PLL clock entry x 15
867
  *             @arg @ref RCC_PLL_MUL15  PLLVCO = PLL clock entry x 15
883
  *             @arg @ref RCC_PLL_MUL16  PLLVCO = PLL clock entry x 16
868
  *             @arg @ref RCC_PLL_MUL16  PLLVCO = PLL clock entry x 16
884
  @endif
869
  @endif
885
  *             @arg @ref RCC_PLL_MUL8   PLLVCO = PLL clock entry x 8
870
  *             @arg @ref RCC_PLL_MUL8   PLLVCO = PLL clock entry x 8
886
  *             @arg @ref RCC_PLL_MUL9   PLLVCO = PLL clock entry x 9
871
  *             @arg @ref RCC_PLL_MUL9   PLLVCO = PLL clock entry x 9
887
  *  
872
  *
888
  */
873
  */
889
#define __HAL_RCC_PLL_CONFIG(__RCC_PLLSOURCE__, __PLLMUL__)\
874
#define __HAL_RCC_PLL_CONFIG(__RCC_PLLSOURCE__, __PLLMUL__)\
890
          MODIFY_REG(RCC->CFGR, (RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL),((__RCC_PLLSOURCE__) | (__PLLMUL__) ))
875
          MODIFY_REG(RCC->CFGR, (RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL),((__RCC_PLLSOURCE__) | (__PLLMUL__) ))
891
 
876
 
892
/** @brief  Get oscillator clock selected as PLL input clock
877
/** @brief  Get oscillator clock selected as PLL input clock
Line 900... Line 885...
900
/**
885
/**
901
  * @}
886
  * @}
902
  */
887
  */
903
 
888
 
904
/** @defgroup RCC_Get_Clock_source Get Clock source
889
/** @defgroup RCC_Get_Clock_source Get Clock source
905
  * @{  
890
  * @{
906
  */
891
  */
907
 
892
 
908
/**
893
/**
909
  * @brief  Macro to configure the system clock source.
894
  * @brief  Macro to configure the system clock source.
910
  * @param  __SYSCLKSOURCE__ specifies the system clock source.
895
  * @param  __SYSCLKSOURCE__ specifies the system clock source.
Line 928... Line 913...
928
/**
913
/**
929
  * @}
914
  * @}
930
  */
915
  */
931
 
916
 
932
/** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
917
/** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
933
  * @{  
918
  * @{
934
  */
919
  */
935
 
920
 
936
#if   defined(RCC_CFGR_MCO_3)
921
#if   defined(RCC_CFGR_MCO_3)
937
/** @brief  Macro to configure the MCO clock.
922
/** @brief  Macro to configure the MCO clock.
938
  * @param  __MCOCLKSOURCE__ specifies the MCO clock source.
923
  * @param  __MCOCLKSOURCE__ specifies the MCO clock source.
939
  *         This parameter can be one of the following values:
924
  *         This parameter can be one of the following values:
Line 971... Line 956...
971
 
956
 
972
/**
957
/**
973
  * @}
958
  * @}
974
  */
959
  */
975
 
960
 
976
  /** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
961
/** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
977
  * @{  
962
* @{
978
  */
963
*/
979
 
964
 
980
/** @brief Macro to configure the RTC clock (RTCCLK).
965
/** @brief Macro to configure the RTC clock (RTCCLK).
981
  * @note   As the RTC clock configuration bits are in the Backup domain and write
966
  * @note   As the RTC clock configuration bits are in the Backup domain and write
982
  *         access is denied to this domain after reset, you have to enable write
967
  *         access is denied to this domain after reset, you have to enable write
983
  *         access using the Power Backup Access macro before to configure
968
  *         access using the Power Backup Access macro before to configure
984
  *         the RTC clock source (to be done once after reset).    
969
  *         the RTC clock source (to be done once after reset).
985
  * @note   Once the RTC clock is configured it can't be changed unless the  
970
  * @note   Once the RTC clock is configured it can't be changed unless the
986
  *         Backup domain is reset using @ref __HAL_RCC_BACKUPRESET_FORCE() macro, or by
971
  *         Backup domain is reset using @ref __HAL_RCC_BACKUPRESET_FORCE() macro, or by
987
  *         a Power On Reset (POR).
972
  *         a Power On Reset (POR).
988
  *
973
  *
989
  * @param  __RTC_CLKSOURCE__ specifies the RTC clock source.
974
  * @param  __RTC_CLKSOURCE__ specifies the RTC clock source.
990
  *          This parameter can be one of the following values:
975
  *          This parameter can be one of the following values:
Line 993... Line 978...
993
  *             @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
978
  *             @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
994
  *             @arg @ref RCC_RTCCLKSOURCE_HSE_DIV128 HSE divided by 128 selected as RTC clock
979
  *             @arg @ref RCC_RTCCLKSOURCE_HSE_DIV128 HSE divided by 128 selected as RTC clock
995
  * @note   If the LSE or LSI is used as RTC clock source, the RTC continues to
980
  * @note   If the LSE or LSI is used as RTC clock source, the RTC continues to
996
  *         work in STOP and STANDBY modes, and can be used as wakeup source.
981
  *         work in STOP and STANDBY modes, and can be used as wakeup source.
997
  *         However, when the HSE clock is used as RTC clock source, the RTC
982
  *         However, when the HSE clock is used as RTC clock source, the RTC
998
  *         cannot be used in STOP and STANDBY modes.    
983
  *         cannot be used in STOP and STANDBY modes.
999
  * @note   The maximum input clock frequency for RTC is 1MHz (when using HSE as
984
  * @note   The maximum input clock frequency for RTC is 1MHz (when using HSE as
1000
  *         RTC clock source).
985
  *         RTC clock source).
1001
  */
986
  */
1002
#define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) MODIFY_REG(RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
987
#define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) MODIFY_REG(RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
1003
                                                   
-
 
-
 
988
 
1004
/** @brief Macro to get the RTC clock source.
989
/** @brief Macro to get the RTC clock source.
1005
  * @retval The clock source can be one of the following values:
990
  * @retval The clock source can be one of the following values:
1006
  *            @arg @ref RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock
991
  *            @arg @ref RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock
1007
  *            @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock
992
  *            @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock
1008
  *            @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
993
  *            @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
Line 1209... Line 1194...
1209
  * @{
1194
  * @{
1210
  */
1195
  */
1211
 
1196
 
1212
/** @defgroup RCC_Timeout RCC Timeout
1197
/** @defgroup RCC_Timeout RCC Timeout
1213
  * @{
1198
  * @{
1214
  */
1199
  */
1215
 
1200
 
1216
/* Disable Backup domain write protection state change timeout */
1201
/* Disable Backup domain write protection state change timeout */
1217
#define RCC_DBP_TIMEOUT_VALUE          100U    /* 100 ms */
1202
#define RCC_DBP_TIMEOUT_VALUE          100U    /* 100 ms */
1218
/* LSE state change timeout */
1203
/* LSE state change timeout */
1219
#define RCC_LSE_TIMEOUT_VALUE          LSE_STARTUP_TIMEOUT
1204
#define RCC_LSE_TIMEOUT_VALUE          LSE_STARTUP_TIMEOUT
1220
#define CLOCKSWITCH_TIMEOUT_VALUE      5000    /* 5 s    */
1205
#define CLOCKSWITCH_TIMEOUT_VALUE      5000    /* 5 s    */
Line 1224... Line 1209...
1224
#define PLL_TIMEOUT_VALUE              2U      /* 2 ms (minimum Tick + 1) */
1209
#define PLL_TIMEOUT_VALUE              2U      /* 2 ms (minimum Tick + 1) */
1225
 
1210
 
1226
/**
1211
/**
1227
  * @}
1212
  * @}
1228
  */
1213
  */
1229
 
1214
 
1230
/** @defgroup RCC_Register_Offset Register offsets
1215
/** @defgroup RCC_Register_Offset Register offsets
1231
  * @{
1216
  * @{
1232
  */
1217
  */
1233
#define RCC_OFFSET                (RCC_BASE - PERIPH_BASE)
1218
#define RCC_OFFSET                (RCC_BASE - PERIPH_BASE)
1234
#define RCC_CR_OFFSET             0x00U
1219
#define RCC_CR_OFFSET             0x00U
Line 1292... Line 1277...
1292
#define RCC_BDCR_BDRST_BB         ((uint32_t)(PERIPH_BB_BASE + (RCC_BDCR_OFFSET_BB * 32U) + (RCC_BDRST_BIT_NUMBER * 4U)))
1277
#define RCC_BDCR_BDRST_BB         ((uint32_t)(PERIPH_BB_BASE + (RCC_BDCR_OFFSET_BB * 32U) + (RCC_BDRST_BIT_NUMBER * 4U)))
1293
 
1278
 
1294
/**
1279
/**
1295
  * @}
1280
  * @}
1296
  */
1281
  */
1297
 
1282
 
1298
/* CR register byte 2 (Bits[23:16]) base address */
1283
/* CR register byte 2 (Bits[23:16]) base address */
1299
#define RCC_CR_BYTE2_ADDRESS          ((uint32_t)(RCC_BASE + RCC_CR_OFFSET + 0x02U))
1284
#define RCC_CR_BYTE2_ADDRESS          ((uint32_t)(RCC_BASE + RCC_CR_OFFSET + 0x02U))
1300
 
1285
 
1301
/* CIR register byte 1 (Bits[15:8]) base address */
1286
/* CIR register byte 1 (Bits[15:8]) base address */
1302
#define RCC_CIR_BYTE1_ADDRESS     ((uint32_t)(RCC_BASE + RCC_CIR_OFFSET + 0x01U))
1287
#define RCC_CIR_BYTE1_ADDRESS     ((uint32_t)(RCC_BASE + RCC_CIR_OFFSET + 0x01U))
Line 1363... Line 1348...
1363
                               ((__HCLK__) == RCC_SYSCLK_DIV512))
1348
                               ((__HCLK__) == RCC_SYSCLK_DIV512))
1364
#define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
1349
#define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
1365
                               ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
1350
                               ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
1366
                               ((__PCLK__) == RCC_HCLK_DIV16))
1351
                               ((__PCLK__) == RCC_HCLK_DIV16))
1367
#define IS_RCC_MCO(__MCO__)  ((__MCO__) == RCC_MCO)
1352
#define IS_RCC_MCO(__MCO__)  ((__MCO__) == RCC_MCO)
1368
#define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1)) 
1353
#define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1))
1369
#define IS_RCC_RTCCLKSOURCE(__SOURCE__)  (((__SOURCE__) == RCC_RTCCLKSOURCE_NO_CLK) || \
1354
#define IS_RCC_RTCCLKSOURCE(__SOURCE__)  (((__SOURCE__) == RCC_RTCCLKSOURCE_NO_CLK) || \
1370
                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
1355
                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
1371
                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
1356
                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
1372
                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV128))
1357
                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV128))
1373
 
1358
 
Line 1380... Line 1365...
1380
  */
1365
  */
1381
 
1366
 
1382
/**
1367
/**
1383
  * @}
1368
  * @}
1384
  */
1369
  */
1385
 
1370
 
1386
#ifdef __cplusplus
1371
#ifdef __cplusplus
1387
}
1372
}
1388
#endif
1373
#endif
1389
 
1374
 
1390
#endif /* __STM32F1xx_HAL_RCC_H */
1375
#endif /* __STM32F1xx_HAL_RCC_H */