meh
Fork of mbed by
TARGET_NUCLEO_L053R8/stm32l0xx_hal_rcc.h@84:0b3ab51c8877, 2014-05-19 (annotated)
- Committer:
- bogdanm
- Date:
- Mon May 19 18:14:09 2014 +0100
- Revision:
- 84:0b3ab51c8877
- Child:
- 85:024bf7f99721
Release 84 of the mbed library
Main changes:
- added LPC11U68 to the official build
- Bug fixes and new features for ST Nucleo boards
- I2C fixes for Freescale targets
- Added nRF51822 exporters
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 84:0b3ab51c8877 | 1 | /** |
bogdanm | 84:0b3ab51c8877 | 2 | ****************************************************************************** |
bogdanm | 84:0b3ab51c8877 | 3 | * @file stm32l0xx_hal_rcc.h |
bogdanm | 84:0b3ab51c8877 | 4 | * @author MCD Application Team |
bogdanm | 84:0b3ab51c8877 | 5 | * @version V1.0.0 |
bogdanm | 84:0b3ab51c8877 | 6 | * @date 22-April-2014 |
bogdanm | 84:0b3ab51c8877 | 7 | * @brief Header file of RCC HAL module. |
bogdanm | 84:0b3ab51c8877 | 8 | ****************************************************************************** |
bogdanm | 84:0b3ab51c8877 | 9 | * @attention |
bogdanm | 84:0b3ab51c8877 | 10 | * |
bogdanm | 84:0b3ab51c8877 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
bogdanm | 84:0b3ab51c8877 | 12 | * |
bogdanm | 84:0b3ab51c8877 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 84:0b3ab51c8877 | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 84:0b3ab51c8877 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 84:0b3ab51c8877 | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 84:0b3ab51c8877 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 84:0b3ab51c8877 | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 84:0b3ab51c8877 | 19 | * and/or other materials provided with the distribution. |
bogdanm | 84:0b3ab51c8877 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 84:0b3ab51c8877 | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 84:0b3ab51c8877 | 22 | * without specific prior written permission. |
bogdanm | 84:0b3ab51c8877 | 23 | * |
bogdanm | 84:0b3ab51c8877 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 84:0b3ab51c8877 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 84:0b3ab51c8877 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 84:0b3ab51c8877 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 84:0b3ab51c8877 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 84:0b3ab51c8877 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 84:0b3ab51c8877 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 84:0b3ab51c8877 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 84:0b3ab51c8877 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 84:0b3ab51c8877 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 84:0b3ab51c8877 | 34 | * |
bogdanm | 84:0b3ab51c8877 | 35 | ****************************************************************************** |
bogdanm | 84:0b3ab51c8877 | 36 | */ |
bogdanm | 84:0b3ab51c8877 | 37 | |
bogdanm | 84:0b3ab51c8877 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 84:0b3ab51c8877 | 39 | #ifndef __STM32L0xx_HAL_RCC_H |
bogdanm | 84:0b3ab51c8877 | 40 | #define __STM32L0xx_HAL_RCC_H |
bogdanm | 84:0b3ab51c8877 | 41 | |
bogdanm | 84:0b3ab51c8877 | 42 | #ifdef __cplusplus |
bogdanm | 84:0b3ab51c8877 | 43 | extern "C" { |
bogdanm | 84:0b3ab51c8877 | 44 | #endif |
bogdanm | 84:0b3ab51c8877 | 45 | |
bogdanm | 84:0b3ab51c8877 | 46 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 84:0b3ab51c8877 | 47 | #include "stm32l0xx_hal_def.h" |
bogdanm | 84:0b3ab51c8877 | 48 | |
bogdanm | 84:0b3ab51c8877 | 49 | /** @addtogroup STM32L0xx_HAL_Driver |
bogdanm | 84:0b3ab51c8877 | 50 | * @{ |
bogdanm | 84:0b3ab51c8877 | 51 | */ |
bogdanm | 84:0b3ab51c8877 | 52 | |
bogdanm | 84:0b3ab51c8877 | 53 | /** @addtogroup RCC |
bogdanm | 84:0b3ab51c8877 | 54 | * @{ |
bogdanm | 84:0b3ab51c8877 | 55 | */ |
bogdanm | 84:0b3ab51c8877 | 56 | |
bogdanm | 84:0b3ab51c8877 | 57 | /* Exported types ------------------------------------------------------------*/ |
bogdanm | 84:0b3ab51c8877 | 58 | |
bogdanm | 84:0b3ab51c8877 | 59 | /** |
bogdanm | 84:0b3ab51c8877 | 60 | * @brief RCC PLL configuration structure definition |
bogdanm | 84:0b3ab51c8877 | 61 | */ |
bogdanm | 84:0b3ab51c8877 | 62 | typedef struct |
bogdanm | 84:0b3ab51c8877 | 63 | { |
bogdanm | 84:0b3ab51c8877 | 64 | uint32_t PLLState; /*!< The new state of the PLL. |
bogdanm | 84:0b3ab51c8877 | 65 | This parameter can be a value of @ref RCC_PLL_Config */ |
bogdanm | 84:0b3ab51c8877 | 66 | |
bogdanm | 84:0b3ab51c8877 | 67 | uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source. |
bogdanm | 84:0b3ab51c8877 | 68 | This parameter must be a value of @ref RCC_PLL_Clock_Source */ |
bogdanm | 84:0b3ab51c8877 | 69 | |
bogdanm | 84:0b3ab51c8877 | 70 | uint32_t PLLMUL; /*!< PLLMUL: Multiplication factor for PLL VCO output clock |
bogdanm | 84:0b3ab51c8877 | 71 | This parameter must of RCC_PLLMultiplication_Factor */ |
bogdanm | 84:0b3ab51c8877 | 72 | |
bogdanm | 84:0b3ab51c8877 | 73 | uint32_t PLLDIV; /*!< PLLDIV: Division factor for main system clock (SYSCLK) |
bogdanm | 84:0b3ab51c8877 | 74 | This parameter must be a value of @ref RCC_PLLDivider_Factor */ |
bogdanm | 84:0b3ab51c8877 | 75 | |
bogdanm | 84:0b3ab51c8877 | 76 | }RCC_PLLInitTypeDef; |
bogdanm | 84:0b3ab51c8877 | 77 | |
bogdanm | 84:0b3ab51c8877 | 78 | /** |
bogdanm | 84:0b3ab51c8877 | 79 | * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition |
bogdanm | 84:0b3ab51c8877 | 80 | */ |
bogdanm | 84:0b3ab51c8877 | 81 | typedef struct |
bogdanm | 84:0b3ab51c8877 | 82 | { |
bogdanm | 84:0b3ab51c8877 | 83 | uint32_t OscillatorType; /*!< The oscillators to be configured. |
bogdanm | 84:0b3ab51c8877 | 84 | This parameter can be a value of @ref RCC_Oscillator_Type */ |
bogdanm | 84:0b3ab51c8877 | 85 | |
bogdanm | 84:0b3ab51c8877 | 86 | uint32_t HSEState; /*!< The new state of the HSE. |
bogdanm | 84:0b3ab51c8877 | 87 | This parameter can be a value of @ref RCC_HSE_Config */ |
bogdanm | 84:0b3ab51c8877 | 88 | |
bogdanm | 84:0b3ab51c8877 | 89 | uint32_t LSEState; /*!< The new state of the LSE. |
bogdanm | 84:0b3ab51c8877 | 90 | This parameter can be a value of @ref RCC_LSE_Config */ |
bogdanm | 84:0b3ab51c8877 | 91 | |
bogdanm | 84:0b3ab51c8877 | 92 | uint32_t HSIState; /*!< The new state of the HSI. |
bogdanm | 84:0b3ab51c8877 | 93 | This parameter can be a value of @ref RCC_HSI_Config */ |
bogdanm | 84:0b3ab51c8877 | 94 | |
bogdanm | 84:0b3ab51c8877 | 95 | uint32_t HSICalibrationValue; /*!< The calibration trimming value. |
bogdanm | 84:0b3ab51c8877 | 96 | This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */ |
bogdanm | 84:0b3ab51c8877 | 97 | |
bogdanm | 84:0b3ab51c8877 | 98 | uint32_t LSIState; /*!< The new state of the LSI. |
bogdanm | 84:0b3ab51c8877 | 99 | This parameter can be a value of @ref RCC_LSI_Config */ |
bogdanm | 84:0b3ab51c8877 | 100 | |
bogdanm | 84:0b3ab51c8877 | 101 | uint32_t HSI48State; /*!< The new state of the HSI48. |
bogdanm | 84:0b3ab51c8877 | 102 | This parameter can be a value of @ref RCC_HSI48_Config */ |
bogdanm | 84:0b3ab51c8877 | 103 | |
bogdanm | 84:0b3ab51c8877 | 104 | uint32_t MSIState; /*!< The new state of the MSI. |
bogdanm | 84:0b3ab51c8877 | 105 | This parameter can be a value of @ref RCC_MSI_Config */ |
bogdanm | 84:0b3ab51c8877 | 106 | |
bogdanm | 84:0b3ab51c8877 | 107 | uint32_t MSICalibrationValue; /*!< The calibration trimming value. |
bogdanm | 84:0b3ab51c8877 | 108 | This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */ |
bogdanm | 84:0b3ab51c8877 | 109 | |
bogdanm | 84:0b3ab51c8877 | 110 | uint32_t MSIClockRange; /*!< The MSI frequency range. |
bogdanm | 84:0b3ab51c8877 | 111 | This parameter can be a value of @ref RCC_MSI_Clock_Range */ |
bogdanm | 84:0b3ab51c8877 | 112 | |
bogdanm | 84:0b3ab51c8877 | 113 | RCC_PLLInitTypeDef PLL; /*!< PLL structure parameters */ |
bogdanm | 84:0b3ab51c8877 | 114 | |
bogdanm | 84:0b3ab51c8877 | 115 | }RCC_OscInitTypeDef; |
bogdanm | 84:0b3ab51c8877 | 116 | |
bogdanm | 84:0b3ab51c8877 | 117 | /** |
bogdanm | 84:0b3ab51c8877 | 118 | * @brief RCC System, AHB and APB busses clock configuration structure definition |
bogdanm | 84:0b3ab51c8877 | 119 | */ |
bogdanm | 84:0b3ab51c8877 | 120 | typedef struct |
bogdanm | 84:0b3ab51c8877 | 121 | { |
bogdanm | 84:0b3ab51c8877 | 122 | uint32_t ClockType; /*!< The clock to be configured. |
bogdanm | 84:0b3ab51c8877 | 123 | This parameter can be a value of @ref RCC_System_Clock_Type */ |
bogdanm | 84:0b3ab51c8877 | 124 | |
bogdanm | 84:0b3ab51c8877 | 125 | uint32_t SYSCLKSource; /*!< The clock source (SYSCLKS) used as system clock. |
bogdanm | 84:0b3ab51c8877 | 126 | This parameter can be a value of @ref RCC_System_Clock_Source */ |
bogdanm | 84:0b3ab51c8877 | 127 | |
bogdanm | 84:0b3ab51c8877 | 128 | uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK). |
bogdanm | 84:0b3ab51c8877 | 129 | This parameter can be a value of @ref RCC_AHB_Clock_Source */ |
bogdanm | 84:0b3ab51c8877 | 130 | |
bogdanm | 84:0b3ab51c8877 | 131 | uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK). |
bogdanm | 84:0b3ab51c8877 | 132 | This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */ |
bogdanm | 84:0b3ab51c8877 | 133 | |
bogdanm | 84:0b3ab51c8877 | 134 | uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK). |
bogdanm | 84:0b3ab51c8877 | 135 | This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */ |
bogdanm | 84:0b3ab51c8877 | 136 | |
bogdanm | 84:0b3ab51c8877 | 137 | }RCC_ClkInitTypeDef; |
bogdanm | 84:0b3ab51c8877 | 138 | |
bogdanm | 84:0b3ab51c8877 | 139 | /* Exported constants --------------------------------------------------------*/ |
bogdanm | 84:0b3ab51c8877 | 140 | /** @defgroup RCC_Exported_Constants |
bogdanm | 84:0b3ab51c8877 | 141 | * @{ |
bogdanm | 84:0b3ab51c8877 | 142 | */ |
bogdanm | 84:0b3ab51c8877 | 143 | |
bogdanm | 84:0b3ab51c8877 | 144 | /** @defgroup RCC_BitAddress_AliasRegion |
bogdanm | 84:0b3ab51c8877 | 145 | * @brief RCC registers bit address in the alias region |
bogdanm | 84:0b3ab51c8877 | 146 | * @{ |
bogdanm | 84:0b3ab51c8877 | 147 | */ |
bogdanm | 84:0b3ab51c8877 | 148 | #define RCC_OFFSET (RCC_BASE - PERIPH_BASE) |
bogdanm | 84:0b3ab51c8877 | 149 | /* --- CR Register ---*/ |
bogdanm | 84:0b3ab51c8877 | 150 | /* Alias word address of HSION bit */ |
bogdanm | 84:0b3ab51c8877 | 151 | #define RCC_CR_OFFSET (RCC_OFFSET + 0x00) |
bogdanm | 84:0b3ab51c8877 | 152 | /* --- CFGR Register ---*/ |
bogdanm | 84:0b3ab51c8877 | 153 | /* Alias word address of I2SSRC bit */ |
bogdanm | 84:0b3ab51c8877 | 154 | #define RCC_CFGR_OFFSET (RCC_OFFSET + 0x08) |
bogdanm | 84:0b3ab51c8877 | 155 | /* --- CSR Register ---*/ |
bogdanm | 84:0b3ab51c8877 | 156 | #define RCC_CSR_OFFSET (RCC_OFFSET + 0x74) |
bogdanm | 84:0b3ab51c8877 | 157 | |
bogdanm | 84:0b3ab51c8877 | 158 | /* CR register byte 3 (Bits[23:16]) base address */ |
bogdanm | 84:0b3ab51c8877 | 159 | #define CR_BYTE2_ADDRESS ((uint32_t)0x40023802) |
bogdanm | 84:0b3ab51c8877 | 160 | |
bogdanm | 84:0b3ab51c8877 | 161 | /* CIER register byte 0 (Bits[0:8]) base address */ |
bogdanm | 84:0b3ab51c8877 | 162 | #define CIER_BYTE0_ADDRESS ((uint32_t)(RCC_BASE + 0x10 + 0x00)) |
bogdanm | 84:0b3ab51c8877 | 163 | |
bogdanm | 84:0b3ab51c8877 | 164 | #define LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT |
bogdanm | 84:0b3ab51c8877 | 165 | #define DBP_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */ |
bogdanm | 84:0b3ab51c8877 | 166 | |
bogdanm | 84:0b3ab51c8877 | 167 | /** |
bogdanm | 84:0b3ab51c8877 | 168 | * @} |
bogdanm | 84:0b3ab51c8877 | 169 | */ |
bogdanm | 84:0b3ab51c8877 | 170 | |
bogdanm | 84:0b3ab51c8877 | 171 | /** @defgroup RCC_Oscillator_Type |
bogdanm | 84:0b3ab51c8877 | 172 | * @{ |
bogdanm | 84:0b3ab51c8877 | 173 | */ |
bogdanm | 84:0b3ab51c8877 | 174 | #define RCC_OSCILLATORTYPE_NONE ((uint32_t)0x00000000) |
bogdanm | 84:0b3ab51c8877 | 175 | #define RCC_OSCILLATORTYPE_HSE ((uint32_t)0x00000001) |
bogdanm | 84:0b3ab51c8877 | 176 | #define RCC_OSCILLATORTYPE_HSI ((uint32_t)0x00000002) |
bogdanm | 84:0b3ab51c8877 | 177 | #define RCC_OSCILLATORTYPE_LSE ((uint32_t)0x00000004) |
bogdanm | 84:0b3ab51c8877 | 178 | #define RCC_OSCILLATORTYPE_LSI ((uint32_t)0x00000008) |
bogdanm | 84:0b3ab51c8877 | 179 | #define RCC_OSCILLATORTYPE_MSI ((uint32_t)0x00000010) |
bogdanm | 84:0b3ab51c8877 | 180 | #define RCC_OSCILLATORTYPE_HSI48 ((uint32_t)0x00000020) |
bogdanm | 84:0b3ab51c8877 | 181 | |
bogdanm | 84:0b3ab51c8877 | 182 | #define IS_RCC_OSCILLATORTYPE(OSCILLATOR) (((OSCILLATOR) == RCC_OSCILLATORTYPE_NONE) || \ |
bogdanm | 84:0b3ab51c8877 | 183 | ((OSCILLATOR) == RCC_OSCILLATORTYPE_HSE) || \ |
bogdanm | 84:0b3ab51c8877 | 184 | ((OSCILLATOR) == RCC_OSCILLATORTYPE_HSI) || \ |
bogdanm | 84:0b3ab51c8877 | 185 | ((OSCILLATOR) == RCC_OSCILLATORTYPE_LSE) || \ |
bogdanm | 84:0b3ab51c8877 | 186 | ((OSCILLATOR) == RCC_OSCILLATORTYPE_LSI) || \ |
bogdanm | 84:0b3ab51c8877 | 187 | ((OSCILLATOR) == RCC_OSCILLATORTYPE_MSI) || \ |
bogdanm | 84:0b3ab51c8877 | 188 | ((OSCILLATOR) == RCC_OSCILLATORTYPE_HSI48)) |
bogdanm | 84:0b3ab51c8877 | 189 | /** |
bogdanm | 84:0b3ab51c8877 | 190 | * @} |
bogdanm | 84:0b3ab51c8877 | 191 | */ |
bogdanm | 84:0b3ab51c8877 | 192 | |
bogdanm | 84:0b3ab51c8877 | 193 | /** @defgroup RCC_HSE_Config |
bogdanm | 84:0b3ab51c8877 | 194 | * @{ |
bogdanm | 84:0b3ab51c8877 | 195 | */ |
bogdanm | 84:0b3ab51c8877 | 196 | #define RCC_HSE_OFF ((uint32_t)0x00000000) |
bogdanm | 84:0b3ab51c8877 | 197 | #define RCC_HSE_ON RCC_CR_HSEON |
bogdanm | 84:0b3ab51c8877 | 198 | #define RCC_HSE_BYPASS ((uint32_t)(RCC_CR_HSEBYP | RCC_CR_HSEON)) |
bogdanm | 84:0b3ab51c8877 | 199 | |
bogdanm | 84:0b3ab51c8877 | 200 | #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \ |
bogdanm | 84:0b3ab51c8877 | 201 | ((HSE) == RCC_HSE_BYPASS)) |
bogdanm | 84:0b3ab51c8877 | 202 | /** |
bogdanm | 84:0b3ab51c8877 | 203 | * @} |
bogdanm | 84:0b3ab51c8877 | 204 | */ |
bogdanm | 84:0b3ab51c8877 | 205 | |
bogdanm | 84:0b3ab51c8877 | 206 | /** @defgroup RCC_LSE_Config |
bogdanm | 84:0b3ab51c8877 | 207 | * @{ |
bogdanm | 84:0b3ab51c8877 | 208 | */ |
bogdanm | 84:0b3ab51c8877 | 209 | #define RCC_LSE_OFF ((uint32_t)0x00000000) |
bogdanm | 84:0b3ab51c8877 | 210 | #define RCC_LSE_ON RCC_CSR_LSEON |
bogdanm | 84:0b3ab51c8877 | 211 | #define RCC_LSE_BYPASS ((uint32_t)(RCC_CSR_LSEBYP | RCC_CSR_LSEON)) |
bogdanm | 84:0b3ab51c8877 | 212 | |
bogdanm | 84:0b3ab51c8877 | 213 | #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \ |
bogdanm | 84:0b3ab51c8877 | 214 | ((LSE) == RCC_LSE_BYPASS)) |
bogdanm | 84:0b3ab51c8877 | 215 | /** |
bogdanm | 84:0b3ab51c8877 | 216 | * @} |
bogdanm | 84:0b3ab51c8877 | 217 | */ |
bogdanm | 84:0b3ab51c8877 | 218 | |
bogdanm | 84:0b3ab51c8877 | 219 | /** @defgroup RCC_HSI_Config |
bogdanm | 84:0b3ab51c8877 | 220 | * @{ |
bogdanm | 84:0b3ab51c8877 | 221 | */ |
bogdanm | 84:0b3ab51c8877 | 222 | #define RCC_HSI_OFF ((uint8_t)0x00) |
bogdanm | 84:0b3ab51c8877 | 223 | #define RCC_HSI_ON ((uint8_t)0x01) |
bogdanm | 84:0b3ab51c8877 | 224 | #define RCC_HSI_DIV4 ((uint8_t)0x09) |
bogdanm | 84:0b3ab51c8877 | 225 | #define IS_RCC_HSI(HSI) (((HSI) == RCC_HSI_OFF) || ((HSI) == RCC_HSI_ON) || \ |
bogdanm | 84:0b3ab51c8877 | 226 | ((HSI) == RCC_HSI_DIV4)) |
bogdanm | 84:0b3ab51c8877 | 227 | |
bogdanm | 84:0b3ab51c8877 | 228 | /** |
bogdanm | 84:0b3ab51c8877 | 229 | * @} |
bogdanm | 84:0b3ab51c8877 | 230 | */ |
bogdanm | 84:0b3ab51c8877 | 231 | |
bogdanm | 84:0b3ab51c8877 | 232 | /** @defgroup RCC_MSI_Clock_Range |
bogdanm | 84:0b3ab51c8877 | 233 | * @{ |
bogdanm | 84:0b3ab51c8877 | 234 | */ |
bogdanm | 84:0b3ab51c8877 | 235 | |
bogdanm | 84:0b3ab51c8877 | 236 | #define RCC_MSIRANGE_0 RCC_ICSCR_MSIRANGE_0 /*!< MSI = 65.536 KHz */ |
bogdanm | 84:0b3ab51c8877 | 237 | #define RCC_MSIRANGE_1 RCC_ICSCR_MSIRANGE_1 /*!< MSI = 131.072 KHz */ |
bogdanm | 84:0b3ab51c8877 | 238 | #define RCC_MSIRANGE_2 RCC_ICSCR_MSIRANGE_2 /*!< MSI = 262.144 KHz */ |
bogdanm | 84:0b3ab51c8877 | 239 | #define RCC_MSIRANGE_3 RCC_ICSCR_MSIRANGE_3 /*!< MSI = 524.288 KHz */ |
bogdanm | 84:0b3ab51c8877 | 240 | #define RCC_MSIRANGE_4 RCC_ICSCR_MSIRANGE_4 /*!< MSI = 1.048 MHz */ |
bogdanm | 84:0b3ab51c8877 | 241 | #define RCC_MSIRANGE_5 RCC_ICSCR_MSIRANGE_5 /*!< MSI = 2.097 MHz */ |
bogdanm | 84:0b3ab51c8877 | 242 | #define RCC_MSIRANGE_6 RCC_ICSCR_MSIRANGE_6 /*!< MSI = 4.194 MHz */ |
bogdanm | 84:0b3ab51c8877 | 243 | |
bogdanm | 84:0b3ab51c8877 | 244 | #define IS_RCC_MSI_CLOCK_RANGE(RANGE) (((RANGE) == RCC_MSIRANGE_0) || \ |
bogdanm | 84:0b3ab51c8877 | 245 | ((RANGE) == RCC_MSIRANGE_1) || \ |
bogdanm | 84:0b3ab51c8877 | 246 | ((RANGE) == RCC_MSIRANGE_2) || \ |
bogdanm | 84:0b3ab51c8877 | 247 | ((RANGE) == RCC_MSIRANGE_3) || \ |
bogdanm | 84:0b3ab51c8877 | 248 | ((RANGE) == RCC_MSIRANGE_4) || \ |
bogdanm | 84:0b3ab51c8877 | 249 | ((RANGE) == RCC_MSIRANGE_5) || \ |
bogdanm | 84:0b3ab51c8877 | 250 | ((RANGE) == RCC_MSIRANGE_6)) |
bogdanm | 84:0b3ab51c8877 | 251 | |
bogdanm | 84:0b3ab51c8877 | 252 | /** |
bogdanm | 84:0b3ab51c8877 | 253 | * @} |
bogdanm | 84:0b3ab51c8877 | 254 | */ |
bogdanm | 84:0b3ab51c8877 | 255 | |
bogdanm | 84:0b3ab51c8877 | 256 | /** @defgroup RCC_LSI_Config |
bogdanm | 84:0b3ab51c8877 | 257 | * @{ |
bogdanm | 84:0b3ab51c8877 | 258 | */ |
bogdanm | 84:0b3ab51c8877 | 259 | #define RCC_LSI_OFF ((uint8_t)0x00) |
bogdanm | 84:0b3ab51c8877 | 260 | #define RCC_LSI_ON ((uint8_t)0x01) |
bogdanm | 84:0b3ab51c8877 | 261 | |
bogdanm | 84:0b3ab51c8877 | 262 | #define IS_RCC_LSI(LSI) (((LSI) == RCC_LSI_OFF) || ((LSI) == RCC_LSI_ON)) |
bogdanm | 84:0b3ab51c8877 | 263 | /** |
bogdanm | 84:0b3ab51c8877 | 264 | * @} |
bogdanm | 84:0b3ab51c8877 | 265 | */ |
bogdanm | 84:0b3ab51c8877 | 266 | |
bogdanm | 84:0b3ab51c8877 | 267 | |
bogdanm | 84:0b3ab51c8877 | 268 | /** @defgroup RCC_MSI_Config |
bogdanm | 84:0b3ab51c8877 | 269 | * @{ |
bogdanm | 84:0b3ab51c8877 | 270 | */ |
bogdanm | 84:0b3ab51c8877 | 271 | #define RCC_MSI_OFF ((uint8_t)0x00) |
bogdanm | 84:0b3ab51c8877 | 272 | #define RCC_MSI_ON ((uint8_t)0x01) |
bogdanm | 84:0b3ab51c8877 | 273 | |
bogdanm | 84:0b3ab51c8877 | 274 | #define IS_RCC_MSI(MSI) (((MSI) == RCC_MSI_OFF) || ((MSI) == RCC_MSI_ON)) |
bogdanm | 84:0b3ab51c8877 | 275 | /** |
bogdanm | 84:0b3ab51c8877 | 276 | * @} |
bogdanm | 84:0b3ab51c8877 | 277 | */ |
bogdanm | 84:0b3ab51c8877 | 278 | |
bogdanm | 84:0b3ab51c8877 | 279 | /** @defgroup RCC_HSI48_Config |
bogdanm | 84:0b3ab51c8877 | 280 | * @{ |
bogdanm | 84:0b3ab51c8877 | 281 | */ |
bogdanm | 84:0b3ab51c8877 | 282 | #define RCC_HSI48_OFF ((uint8_t)0x00) |
bogdanm | 84:0b3ab51c8877 | 283 | #define RCC_HSI48_ON ((uint8_t)0x01) |
bogdanm | 84:0b3ab51c8877 | 284 | |
bogdanm | 84:0b3ab51c8877 | 285 | #define IS_RCC_HSI48(HSI48) (((HSI48) == RCC_HSI48_OFF) || ((HSI48) == RCC_HSI48_ON)) |
bogdanm | 84:0b3ab51c8877 | 286 | /** |
bogdanm | 84:0b3ab51c8877 | 287 | * @} |
bogdanm | 84:0b3ab51c8877 | 288 | */ |
bogdanm | 84:0b3ab51c8877 | 289 | |
bogdanm | 84:0b3ab51c8877 | 290 | /** @defgroup RCC_PLL_Config |
bogdanm | 84:0b3ab51c8877 | 291 | * @{ |
bogdanm | 84:0b3ab51c8877 | 292 | */ |
bogdanm | 84:0b3ab51c8877 | 293 | #define RCC_PLL_NONE ((uint8_t)0x00) |
bogdanm | 84:0b3ab51c8877 | 294 | #define RCC_PLL_OFF ((uint8_t)0x01) |
bogdanm | 84:0b3ab51c8877 | 295 | #define RCC_PLL_ON ((uint8_t)0x02) |
bogdanm | 84:0b3ab51c8877 | 296 | |
bogdanm | 84:0b3ab51c8877 | 297 | #define IS_RCC_PLL(PLL) (((PLL) == RCC_PLL_NONE) ||((PLL) == RCC_PLL_OFF) || ((PLL) == RCC_PLL_ON)) |
bogdanm | 84:0b3ab51c8877 | 298 | /** |
bogdanm | 84:0b3ab51c8877 | 299 | * @} |
bogdanm | 84:0b3ab51c8877 | 300 | */ |
bogdanm | 84:0b3ab51c8877 | 301 | |
bogdanm | 84:0b3ab51c8877 | 302 | /** @defgroup RCC_PLL_Clock_Source |
bogdanm | 84:0b3ab51c8877 | 303 | * @{ |
bogdanm | 84:0b3ab51c8877 | 304 | */ |
bogdanm | 84:0b3ab51c8877 | 305 | #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI |
bogdanm | 84:0b3ab51c8877 | 306 | #define RCC_PLLSOURCE_HSE RCC_CFGR_PLLSRC_HSE |
bogdanm | 84:0b3ab51c8877 | 307 | |
bogdanm | 84:0b3ab51c8877 | 308 | #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \ |
bogdanm | 84:0b3ab51c8877 | 309 | ((SOURCE) == RCC_PLLSOURCE_HSE)) |
bogdanm | 84:0b3ab51c8877 | 310 | |
bogdanm | 84:0b3ab51c8877 | 311 | /** |
bogdanm | 84:0b3ab51c8877 | 312 | * @} |
bogdanm | 84:0b3ab51c8877 | 313 | */ |
bogdanm | 84:0b3ab51c8877 | 314 | |
bogdanm | 84:0b3ab51c8877 | 315 | /** @defgroup RCC_PLLMultiplication_Factor |
bogdanm | 84:0b3ab51c8877 | 316 | * @{ |
bogdanm | 84:0b3ab51c8877 | 317 | */ |
bogdanm | 84:0b3ab51c8877 | 318 | |
bogdanm | 84:0b3ab51c8877 | 319 | #define RCC_PLLMUL_3 RCC_CFGR_PLLMUL3 |
bogdanm | 84:0b3ab51c8877 | 320 | #define RCC_PLLMUL_4 RCC_CFGR_PLLMUL4 |
bogdanm | 84:0b3ab51c8877 | 321 | #define RCC_PLLMUL_6 RCC_CFGR_PLLMUL6 |
bogdanm | 84:0b3ab51c8877 | 322 | #define RCC_PLLMUL_8 RCC_CFGR_PLLMUL8 |
bogdanm | 84:0b3ab51c8877 | 323 | #define RCC_PLLMUL_12 RCC_CFGR_PLLMUL12 |
bogdanm | 84:0b3ab51c8877 | 324 | #define RCC_PLLMUL_16 RCC_CFGR_PLLMUL16 |
bogdanm | 84:0b3ab51c8877 | 325 | #define RCC_PLLMUL_24 RCC_CFGR_PLLMUL24 |
bogdanm | 84:0b3ab51c8877 | 326 | #define RCC_PLLMUL_32 RCC_CFGR_PLLMUL32 |
bogdanm | 84:0b3ab51c8877 | 327 | #define RCC_PLLMUL_48 RCC_CFGR_PLLMUL48 |
bogdanm | 84:0b3ab51c8877 | 328 | #define IS_RCC_PLL_MUL(MUL) (((MUL) == RCC_PLLMUL_3) || ((MUL) == RCC_PLLMUL_4) || \ |
bogdanm | 84:0b3ab51c8877 | 329 | ((MUL) == RCC_PLLMUL_6) || ((MUL) == RCC_PLLMUL_8) || \ |
bogdanm | 84:0b3ab51c8877 | 330 | ((MUL) == RCC_PLLMUL_12) || ((MUL) == RCC_PLLMUL_16) || \ |
bogdanm | 84:0b3ab51c8877 | 331 | ((MUL) == RCC_PLLMUL_24) || ((MUL) == RCC_PLLMUL_32) || \ |
bogdanm | 84:0b3ab51c8877 | 332 | ((MUL) == RCC_PLLMUL_48)) |
bogdanm | 84:0b3ab51c8877 | 333 | /** |
bogdanm | 84:0b3ab51c8877 | 334 | * @} |
bogdanm | 84:0b3ab51c8877 | 335 | */ |
bogdanm | 84:0b3ab51c8877 | 336 | |
bogdanm | 84:0b3ab51c8877 | 337 | /** @defgroup RCC_PLLDivider_Factor |
bogdanm | 84:0b3ab51c8877 | 338 | * @{ |
bogdanm | 84:0b3ab51c8877 | 339 | */ |
bogdanm | 84:0b3ab51c8877 | 340 | |
bogdanm | 84:0b3ab51c8877 | 341 | #define RCC_PLLDIV_2 RCC_CFGR_PLLDIV2 |
bogdanm | 84:0b3ab51c8877 | 342 | #define RCC_PLLDIV_3 RCC_CFGR_PLLDIV3 |
bogdanm | 84:0b3ab51c8877 | 343 | #define RCC_PLLDIV_4 RCC_CFGR_PLLDIV4 |
bogdanm | 84:0b3ab51c8877 | 344 | #define IS_RCC_PLL_DIV(DIV) (((DIV) == RCC_PLLDIV_2) || ((DIV) == RCC_PLLDIV_3) || \ |
bogdanm | 84:0b3ab51c8877 | 345 | ((DIV) == RCC_PLLDIV_4)) |
bogdanm | 84:0b3ab51c8877 | 346 | /** |
bogdanm | 84:0b3ab51c8877 | 347 | * @} |
bogdanm | 84:0b3ab51c8877 | 348 | */ |
bogdanm | 84:0b3ab51c8877 | 349 | |
bogdanm | 84:0b3ab51c8877 | 350 | /** @defgroup RCC_System_Clock_Type |
bogdanm | 84:0b3ab51c8877 | 351 | * @{ |
bogdanm | 84:0b3ab51c8877 | 352 | */ |
bogdanm | 84:0b3ab51c8877 | 353 | #define RCC_CLOCKTYPE_SYSCLK ((uint32_t)0x00000001) |
bogdanm | 84:0b3ab51c8877 | 354 | #define RCC_CLOCKTYPE_HCLK ((uint32_t)0x00000002) |
bogdanm | 84:0b3ab51c8877 | 355 | #define RCC_CLOCKTYPE_PCLK1 ((uint32_t)0x00000004) |
bogdanm | 84:0b3ab51c8877 | 356 | #define RCC_CLOCKTYPE_PCLK2 ((uint32_t)0x00000008) |
bogdanm | 84:0b3ab51c8877 | 357 | |
bogdanm | 84:0b3ab51c8877 | 358 | #define IS_RCC_CLOCKTYPE(CLK) ((1 <= (CLK)) && ((CLK) <= 15)) |
bogdanm | 84:0b3ab51c8877 | 359 | /** |
bogdanm | 84:0b3ab51c8877 | 360 | * @} |
bogdanm | 84:0b3ab51c8877 | 361 | */ |
bogdanm | 84:0b3ab51c8877 | 362 | |
bogdanm | 84:0b3ab51c8877 | 363 | /** @defgroup RCC_System_Clock_Source |
bogdanm | 84:0b3ab51c8877 | 364 | * @{ |
bogdanm | 84:0b3ab51c8877 | 365 | */ |
bogdanm | 84:0b3ab51c8877 | 366 | #define RCC_SYSCLKSOURCE_MSI RCC_CFGR_SW_MSI |
bogdanm | 84:0b3ab51c8877 | 367 | #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI |
bogdanm | 84:0b3ab51c8877 | 368 | #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE |
bogdanm | 84:0b3ab51c8877 | 369 | #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL |
bogdanm | 84:0b3ab51c8877 | 370 | |
bogdanm | 84:0b3ab51c8877 | 371 | #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \ |
bogdanm | 84:0b3ab51c8877 | 372 | ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \ |
bogdanm | 84:0b3ab51c8877 | 373 | ((SOURCE) == RCC_SYSCLKSOURCE_MSI) || \ |
bogdanm | 84:0b3ab51c8877 | 374 | ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK)) |
bogdanm | 84:0b3ab51c8877 | 375 | /** |
bogdanm | 84:0b3ab51c8877 | 376 | * @} |
bogdanm | 84:0b3ab51c8877 | 377 | */ |
bogdanm | 84:0b3ab51c8877 | 378 | |
bogdanm | 84:0b3ab51c8877 | 379 | /** @defgroup RCC_AHB_Clock_Source |
bogdanm | 84:0b3ab51c8877 | 380 | * @{ |
bogdanm | 84:0b3ab51c8877 | 381 | */ |
bogdanm | 84:0b3ab51c8877 | 382 | #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1 |
bogdanm | 84:0b3ab51c8877 | 383 | #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2 |
bogdanm | 84:0b3ab51c8877 | 384 | #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4 |
bogdanm | 84:0b3ab51c8877 | 385 | #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8 |
bogdanm | 84:0b3ab51c8877 | 386 | #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16 |
bogdanm | 84:0b3ab51c8877 | 387 | #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64 |
bogdanm | 84:0b3ab51c8877 | 388 | #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128 |
bogdanm | 84:0b3ab51c8877 | 389 | #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256 |
bogdanm | 84:0b3ab51c8877 | 390 | #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512 |
bogdanm | 84:0b3ab51c8877 | 391 | |
bogdanm | 84:0b3ab51c8877 | 392 | #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_DIV1) || ((HCLK) == RCC_SYSCLK_DIV2) || \ |
bogdanm | 84:0b3ab51c8877 | 393 | ((HCLK) == RCC_SYSCLK_DIV4) || ((HCLK) == RCC_SYSCLK_DIV8) || \ |
bogdanm | 84:0b3ab51c8877 | 394 | ((HCLK) == RCC_SYSCLK_DIV16) || ((HCLK) == RCC_SYSCLK_DIV64) || \ |
bogdanm | 84:0b3ab51c8877 | 395 | ((HCLK) == RCC_SYSCLK_DIV128) || ((HCLK) == RCC_SYSCLK_DIV256) || \ |
bogdanm | 84:0b3ab51c8877 | 396 | ((HCLK) == RCC_SYSCLK_DIV512)) |
bogdanm | 84:0b3ab51c8877 | 397 | /** |
bogdanm | 84:0b3ab51c8877 | 398 | * @} |
bogdanm | 84:0b3ab51c8877 | 399 | */ |
bogdanm | 84:0b3ab51c8877 | 400 | |
bogdanm | 84:0b3ab51c8877 | 401 | /** @defgroup RCC_APB1_APB2_Clock_Source |
bogdanm | 84:0b3ab51c8877 | 402 | * @{ |
bogdanm | 84:0b3ab51c8877 | 403 | */ |
bogdanm | 84:0b3ab51c8877 | 404 | #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1 |
bogdanm | 84:0b3ab51c8877 | 405 | #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2 |
bogdanm | 84:0b3ab51c8877 | 406 | #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4 |
bogdanm | 84:0b3ab51c8877 | 407 | #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8 |
bogdanm | 84:0b3ab51c8877 | 408 | #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16 |
bogdanm | 84:0b3ab51c8877 | 409 | |
bogdanm | 84:0b3ab51c8877 | 410 | #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_DIV1) || ((PCLK) == RCC_HCLK_DIV2) || \ |
bogdanm | 84:0b3ab51c8877 | 411 | ((PCLK) == RCC_HCLK_DIV4) || ((PCLK) == RCC_HCLK_DIV8) || \ |
bogdanm | 84:0b3ab51c8877 | 412 | ((PCLK) == RCC_HCLK_DIV16)) |
bogdanm | 84:0b3ab51c8877 | 413 | /** |
bogdanm | 84:0b3ab51c8877 | 414 | * @} |
bogdanm | 84:0b3ab51c8877 | 415 | */ |
bogdanm | 84:0b3ab51c8877 | 416 | |
bogdanm | 84:0b3ab51c8877 | 417 | /** @defgroup RCC_RTC_Clock_Source |
bogdanm | 84:0b3ab51c8877 | 418 | * @{ |
bogdanm | 84:0b3ab51c8877 | 419 | */ |
bogdanm | 84:0b3ab51c8877 | 420 | #define RCC_RTCCLKSOURCE_LSE RCC_CSR_RTCSEL_LSE |
bogdanm | 84:0b3ab51c8877 | 421 | #define RCC_RTCCLKSOURCE_LSI RCC_CSR_RTCSEL_LSI |
bogdanm | 84:0b3ab51c8877 | 422 | #define RCC_RTCCLKSOURCE_HSE_DIV2 RCC_CSR_RTCSEL_HSE |
bogdanm | 84:0b3ab51c8877 | 423 | #define RCC_RTCCLKSOURCE_HSE_DIV4 ((uint32_t)RCC_CSR_RTCSEL_HSE | RCC_CR_RTCPRE_0) |
bogdanm | 84:0b3ab51c8877 | 424 | #define RCC_RTCCLKSOURCE_HSE_DIV8 ((uint32_t)RCC_CSR_RTCSEL_HSE | RCC_CR_RTCPRE_1) |
bogdanm | 84:0b3ab51c8877 | 425 | #define RCC_RTCCLKSOURCE_HSE_DIV16 ((uint32_t)RCC_CSR_RTCSEL_HSE | RCC_CR_RTCPRE) |
bogdanm | 84:0b3ab51c8877 | 426 | #define IS_RCC_RTCCLK_SOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSOURCE_LSE) || \ |
bogdanm | 84:0b3ab51c8877 | 427 | ((SOURCE) == RCC_RTCCLKSOURCE_LSI) || \ |
bogdanm | 84:0b3ab51c8877 | 428 | ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV2) || \ |
bogdanm | 84:0b3ab51c8877 | 429 | ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV4) || \ |
bogdanm | 84:0b3ab51c8877 | 430 | ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV8) || \ |
bogdanm | 84:0b3ab51c8877 | 431 | ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV16)) |
bogdanm | 84:0b3ab51c8877 | 432 | /** |
bogdanm | 84:0b3ab51c8877 | 433 | * @} |
bogdanm | 84:0b3ab51c8877 | 434 | */ |
bogdanm | 84:0b3ab51c8877 | 435 | |
bogdanm | 84:0b3ab51c8877 | 436 | /** @defgroup RCC_MCO_Clock_Source |
bogdanm | 84:0b3ab51c8877 | 437 | * @{ |
bogdanm | 84:0b3ab51c8877 | 438 | */ |
bogdanm | 84:0b3ab51c8877 | 439 | #define RCC_MCO1SOURCE_NOCLOCK ((uint8_t)0x00) |
bogdanm | 84:0b3ab51c8877 | 440 | #define RCC_MCO1SOURCE_SYSCLK ((uint8_t)0x01) |
bogdanm | 84:0b3ab51c8877 | 441 | #define RCC_MCO1SOURCE_HSI ((uint8_t)0x02) |
bogdanm | 84:0b3ab51c8877 | 442 | #define RCC_MCO1SOURCE_MSI ((uint8_t)0x03) |
bogdanm | 84:0b3ab51c8877 | 443 | #define RCC_MCO1SOURCE_HSE ((uint8_t)0x04) |
bogdanm | 84:0b3ab51c8877 | 444 | #define RCC_MCO1SOURCE_PLLCLK ((uint8_t)0x05) |
bogdanm | 84:0b3ab51c8877 | 445 | #define RCC_MCO1SOURCE_LSI ((uint8_t)0x06) |
bogdanm | 84:0b3ab51c8877 | 446 | #define RCC_MCO1SOURCE_LSE ((uint8_t)0x07) |
bogdanm | 84:0b3ab51c8877 | 447 | #define RCC_MCO1SOURCE_HSI48 ((uint8_t)0x08) |
bogdanm | 84:0b3ab51c8877 | 448 | |
bogdanm | 84:0b3ab51c8877 | 449 | #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_NOCLOCK) || ((SOURCE) == RCC_MCO1SOURCE_SYSCLK) || \ |
bogdanm | 84:0b3ab51c8877 | 450 | ((SOURCE) == RCC_MCO1SOURCE_HSI) || ((SOURCE) == RCC_MCO1SOURCE_MSI) || \ |
bogdanm | 84:0b3ab51c8877 | 451 | ((SOURCE) == RCC_MCO1SOURCE_HSE) || ((SOURCE) == RCC_MCO1SOURCE_PLLCLK) || \ |
bogdanm | 84:0b3ab51c8877 | 452 | ((SOURCE) == RCC_MCO1SOURCE_LSI) || ((SOURCE) == RCC_MCO1SOURCE_LSE) || \ |
bogdanm | 84:0b3ab51c8877 | 453 | ((SOURCE) == RCC_MCO1SOURCE_HSI48)) |
bogdanm | 84:0b3ab51c8877 | 454 | /** |
bogdanm | 84:0b3ab51c8877 | 455 | * @} |
bogdanm | 84:0b3ab51c8877 | 456 | */ |
bogdanm | 84:0b3ab51c8877 | 457 | |
bogdanm | 84:0b3ab51c8877 | 458 | /** @defgroup RCC_MCOPrescaler |
bogdanm | 84:0b3ab51c8877 | 459 | * @{ |
bogdanm | 84:0b3ab51c8877 | 460 | */ |
bogdanm | 84:0b3ab51c8877 | 461 | |
bogdanm | 84:0b3ab51c8877 | 462 | #define RCC_MCODIV_1 RCC_CFGR_MCO_PRE_1 |
bogdanm | 84:0b3ab51c8877 | 463 | #define RCC_MCODIV_2 RCC_CFGR_MCO_PRE_2 |
bogdanm | 84:0b3ab51c8877 | 464 | #define RCC_MCODIV_4 RCC_CFGR_MCO_PRE_4 |
bogdanm | 84:0b3ab51c8877 | 465 | #define RCC_MCODIV_8 RCC_CFGR_MCO_PRE_8 |
bogdanm | 84:0b3ab51c8877 | 466 | #define RCC_MCODIV_16 RCC_CFGR_MCO_PRE_16 |
bogdanm | 84:0b3ab51c8877 | 467 | |
bogdanm | 84:0b3ab51c8877 | 468 | #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1) || \ |
bogdanm | 84:0b3ab51c8877 | 469 | ((DIV) == RCC_MCODIV_2) || \ |
bogdanm | 84:0b3ab51c8877 | 470 | ((DIV) == RCC_MCODIV_4) || \ |
bogdanm | 84:0b3ab51c8877 | 471 | ((DIV) == RCC_MCODIV_8) || \ |
bogdanm | 84:0b3ab51c8877 | 472 | ((DIV) == RCC_MCODIV_16)) |
bogdanm | 84:0b3ab51c8877 | 473 | /** |
bogdanm | 84:0b3ab51c8877 | 474 | * @} |
bogdanm | 84:0b3ab51c8877 | 475 | */ |
bogdanm | 84:0b3ab51c8877 | 476 | |
bogdanm | 84:0b3ab51c8877 | 477 | /** @defgroup RCC_MCO_Index |
bogdanm | 84:0b3ab51c8877 | 478 | * @{ |
bogdanm | 84:0b3ab51c8877 | 479 | */ |
bogdanm | 84:0b3ab51c8877 | 480 | #define RCC_MCO1 ((uint32_t)0x00000000) |
bogdanm | 84:0b3ab51c8877 | 481 | #define RCC_MCO2 ((uint32_t)0x00000001) |
bogdanm | 84:0b3ab51c8877 | 482 | |
bogdanm | 84:0b3ab51c8877 | 483 | #define IS_RCC_MCO(MCOx) (((MCOx) == RCC_MCO1) || ((MCOx) == RCC_MCO2)) |
bogdanm | 84:0b3ab51c8877 | 484 | /** |
bogdanm | 84:0b3ab51c8877 | 485 | * @} |
bogdanm | 84:0b3ab51c8877 | 486 | */ |
bogdanm | 84:0b3ab51c8877 | 487 | |
bogdanm | 84:0b3ab51c8877 | 488 | /** @defgroup RCC_Interrupt |
bogdanm | 84:0b3ab51c8877 | 489 | * @{ |
bogdanm | 84:0b3ab51c8877 | 490 | */ |
bogdanm | 84:0b3ab51c8877 | 491 | #define RCC_IT_LSIRDY RCC_CIFR_LSIRDYF |
bogdanm | 84:0b3ab51c8877 | 492 | #define RCC_IT_LSERDY RCC_CIFR_LSERDYF |
bogdanm | 84:0b3ab51c8877 | 493 | #define RCC_IT_HSIRDY RCC_CIFR_HSIRDYF |
bogdanm | 84:0b3ab51c8877 | 494 | #define RCC_IT_HSERDY RCC_CIFR_HSERDYF |
bogdanm | 84:0b3ab51c8877 | 495 | #define RCC_IT_PLLRDY RCC_CIFR_PLLRDYF |
bogdanm | 84:0b3ab51c8877 | 496 | #define RCC_IT_MSIRDY RCC_CIFR_MSIRDYF |
bogdanm | 84:0b3ab51c8877 | 497 | #define RCC_IT_HSI48RDY RCC_CIFR_HSI48RDYF |
bogdanm | 84:0b3ab51c8877 | 498 | #define RCC_IT_LSECSS RCC_CIFR_LSECSSF |
bogdanm | 84:0b3ab51c8877 | 499 | #define RCC_IT_CSS RCC_CIFR_CSSF |
bogdanm | 84:0b3ab51c8877 | 500 | |
bogdanm | 84:0b3ab51c8877 | 501 | #define IS_RCC_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \ |
bogdanm | 84:0b3ab51c8877 | 502 | ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \ |
bogdanm | 84:0b3ab51c8877 | 503 | ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_MSIRDY) || \ |
bogdanm | 84:0b3ab51c8877 | 504 | ((IT) == RCC_IT_HSI48RDY) || ((IT) == RCC_IT_LSECSS)) |
bogdanm | 84:0b3ab51c8877 | 505 | |
bogdanm | 84:0b3ab51c8877 | 506 | #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \ |
bogdanm | 84:0b3ab51c8877 | 507 | ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \ |
bogdanm | 84:0b3ab51c8877 | 508 | ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_MSIRDY) || \ |
bogdanm | 84:0b3ab51c8877 | 509 | ((IT) == RCC_IT_CSS) || ((IT) == RCC_IT_HSI48RDY) || \ |
bogdanm | 84:0b3ab51c8877 | 510 | ((IT) == RCC_IT_LSECSS)) |
bogdanm | 84:0b3ab51c8877 | 511 | |
bogdanm | 84:0b3ab51c8877 | 512 | #define IS_RCC_CLEAR_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \ |
bogdanm | 84:0b3ab51c8877 | 513 | ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \ |
bogdanm | 84:0b3ab51c8877 | 514 | ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_MSIRDY) || \ |
bogdanm | 84:0b3ab51c8877 | 515 | ((IT) == RCC_IT_CSS) || ((IT) == RCC_IT_HSI48RDY) || \ |
bogdanm | 84:0b3ab51c8877 | 516 | ((IT) == RCC_IT_LSECSS)) |
bogdanm | 84:0b3ab51c8877 | 517 | |
bogdanm | 84:0b3ab51c8877 | 518 | /** |
bogdanm | 84:0b3ab51c8877 | 519 | * @} |
bogdanm | 84:0b3ab51c8877 | 520 | */ |
bogdanm | 84:0b3ab51c8877 | 521 | |
bogdanm | 84:0b3ab51c8877 | 522 | /** @defgroup RCC_Flag |
bogdanm | 84:0b3ab51c8877 | 523 | * Elements values convention: 0XXYYYYYb |
bogdanm | 84:0b3ab51c8877 | 524 | * - YYYYY : Flag position in the register |
bogdanm | 84:0b3ab51c8877 | 525 | * - 0XX : Register index |
bogdanm | 84:0b3ab51c8877 | 526 | * - 01: CR register |
bogdanm | 84:0b3ab51c8877 | 527 | * - 10: CSR register |
bogdanm | 84:0b3ab51c8877 | 528 | * - 11: CRRCR register |
bogdanm | 84:0b3ab51c8877 | 529 | * @{ |
bogdanm | 84:0b3ab51c8877 | 530 | */ |
bogdanm | 84:0b3ab51c8877 | 531 | /* Flags in the CR register */ |
bogdanm | 84:0b3ab51c8877 | 532 | #define RCC_FLAG_HSIRDY ((uint8_t)0x22) |
bogdanm | 84:0b3ab51c8877 | 533 | #define RCC_FLAG_HSIDIV ((uint8_t)0x24) |
bogdanm | 84:0b3ab51c8877 | 534 | #define RCC_FLAG_MSIRDY ((uint8_t)0x29) |
bogdanm | 84:0b3ab51c8877 | 535 | #define RCC_FLAG_HSERDY ((uint8_t)0x31) |
bogdanm | 84:0b3ab51c8877 | 536 | #define RCC_FLAG_PLLRDY ((uint8_t)0x39) |
bogdanm | 84:0b3ab51c8877 | 537 | |
bogdanm | 84:0b3ab51c8877 | 538 | /* Flags in the CSR register */ |
bogdanm | 84:0b3ab51c8877 | 539 | #define RCC_FLAG_LSERDY ((uint8_t)0x49) |
bogdanm | 84:0b3ab51c8877 | 540 | #define RCC_FLAG_LSECSS ((uint8_t)0x4E) |
bogdanm | 84:0b3ab51c8877 | 541 | #define RCC_FLAG_LSIRDY ((uint8_t)0x41) |
bogdanm | 84:0b3ab51c8877 | 542 | #define RCC_FLAG_FIREWALLRST ((uint8_t)0x58) |
bogdanm | 84:0b3ab51c8877 | 543 | #define RCC_FLAG_OBLRST ((uint8_t)0x59) |
bogdanm | 84:0b3ab51c8877 | 544 | #define RCC_FLAG_PINRST ((uint8_t)0x5A) |
bogdanm | 84:0b3ab51c8877 | 545 | #define RCC_FLAG_PORRST ((uint8_t)0x5B) |
bogdanm | 84:0b3ab51c8877 | 546 | #define RCC_FLAG_SFTRST ((uint8_t)0x5C) |
bogdanm | 84:0b3ab51c8877 | 547 | #define RCC_FLAG_IWDGRST ((uint8_t)0x5D) |
bogdanm | 84:0b3ab51c8877 | 548 | #define RCC_FLAG_WWDGRST ((uint8_t)0x5E) |
bogdanm | 84:0b3ab51c8877 | 549 | #define RCC_FLAG_LPWRRST ((uint8_t)0x5F) |
bogdanm | 84:0b3ab51c8877 | 550 | |
bogdanm | 84:0b3ab51c8877 | 551 | /* Flags in the CRRCR register */ |
bogdanm | 84:0b3ab51c8877 | 552 | #define RCC_FLAG_HSI48RDY ((uint8_t)0x61) |
bogdanm | 84:0b3ab51c8877 | 553 | |
bogdanm | 84:0b3ab51c8877 | 554 | |
bogdanm | 84:0b3ab51c8877 | 555 | |
bogdanm | 84:0b3ab51c8877 | 556 | #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F) |
bogdanm | 84:0b3ab51c8877 | 557 | /** |
bogdanm | 84:0b3ab51c8877 | 558 | * @} |
bogdanm | 84:0b3ab51c8877 | 559 | */ |
bogdanm | 84:0b3ab51c8877 | 560 | |
bogdanm | 84:0b3ab51c8877 | 561 | /** |
bogdanm | 84:0b3ab51c8877 | 562 | * @} |
bogdanm | 84:0b3ab51c8877 | 563 | */ |
bogdanm | 84:0b3ab51c8877 | 564 | /* Exported macro ------------------------------------------------------------*/ |
bogdanm | 84:0b3ab51c8877 | 565 | /** @defgroup RCC_Exported macro |
bogdanm | 84:0b3ab51c8877 | 566 | * @{ |
bogdanm | 84:0b3ab51c8877 | 567 | */ |
bogdanm | 84:0b3ab51c8877 | 568 | |
bogdanm | 84:0b3ab51c8877 | 569 | /** @brief Enable or disable the AHB peripheral clock. |
bogdanm | 84:0b3ab51c8877 | 570 | * @note After reset, the peripheral clock (used for registers read/write access) |
bogdanm | 84:0b3ab51c8877 | 571 | * is disabled and the application software has to enable this clock before |
bogdanm | 84:0b3ab51c8877 | 572 | * using it. |
bogdanm | 84:0b3ab51c8877 | 573 | */ |
bogdanm | 84:0b3ab51c8877 | 574 | #define __DMA1_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_DMA1EN)) |
bogdanm | 84:0b3ab51c8877 | 575 | #define __MIF_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_MIFEN)) |
bogdanm | 84:0b3ab51c8877 | 576 | #define __CRC_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_CRCEN)) |
bogdanm | 84:0b3ab51c8877 | 577 | |
bogdanm | 84:0b3ab51c8877 | 578 | |
bogdanm | 84:0b3ab51c8877 | 579 | #define __DMA1_CLK_DISABLE() (RCC->AHBENR &= ~ (RCC_AHBENR_DMA1EN)) |
bogdanm | 84:0b3ab51c8877 | 580 | #define __MIF_CLK_DISABLE() (RCC->AHBENR &= ~ (RCC_AHBENR_MIFEN)) |
bogdanm | 84:0b3ab51c8877 | 581 | #define __CRC_CLK_DISABLE() (RCC->AHBENR &= ~ (RCC_AHBENR_CRCEN)) |
bogdanm | 84:0b3ab51c8877 | 582 | |
bogdanm | 84:0b3ab51c8877 | 583 | |
bogdanm | 84:0b3ab51c8877 | 584 | /** @brief Enable or disable the IOPORT peripheral clock. |
bogdanm | 84:0b3ab51c8877 | 585 | * @note After reset, the peripheral clock (used for registers read/write access) |
bogdanm | 84:0b3ab51c8877 | 586 | * is disabled and the application software has to enable this clock before |
bogdanm | 84:0b3ab51c8877 | 587 | * using it. |
bogdanm | 84:0b3ab51c8877 | 588 | */ |
bogdanm | 84:0b3ab51c8877 | 589 | #define __GPIOA_CLK_ENABLE() (RCC->IOPENR |= (RCC_IOPENR_GPIOAEN)) |
bogdanm | 84:0b3ab51c8877 | 590 | #define __GPIOB_CLK_ENABLE() (RCC->IOPENR |= (RCC_IOPENR_GPIOBEN)) |
bogdanm | 84:0b3ab51c8877 | 591 | #define __GPIOC_CLK_ENABLE() (RCC->IOPENR |= (RCC_IOPENR_GPIOCEN)) |
bogdanm | 84:0b3ab51c8877 | 592 | #define __GPIOD_CLK_ENABLE() (RCC->IOPENR |= (RCC_IOPENR_GPIODEN)) |
bogdanm | 84:0b3ab51c8877 | 593 | #define __GPIOH_CLK_ENABLE() (RCC->IOPENR |= (RCC_IOPENR_GPIOHEN)) |
bogdanm | 84:0b3ab51c8877 | 594 | |
bogdanm | 84:0b3ab51c8877 | 595 | #define __GPIOA_CLK_DISABLE() (RCC->IOPENR &= ~(RCC_IOPENR_GPIOAEN)) |
bogdanm | 84:0b3ab51c8877 | 596 | #define __GPIOB_CLK_DISABLE() (RCC->IOPENR &= ~(RCC_IOPENR_GPIOBEN)) |
bogdanm | 84:0b3ab51c8877 | 597 | #define __GPIOC_CLK_DISABLE() (RCC->IOPENR &= ~(RCC_IOPENR_GPIOCEN)) |
bogdanm | 84:0b3ab51c8877 | 598 | #define __GPIOD_CLK_DISABLE() (RCC->IOPENR &= ~(RCC_IOPENR_GPIODEN)) |
bogdanm | 84:0b3ab51c8877 | 599 | #define __GPIOH_CLK_DISABLE() (RCC->IOPENR &= ~(RCC_IOPENR_GPIOHEN)) |
bogdanm | 84:0b3ab51c8877 | 600 | |
bogdanm | 84:0b3ab51c8877 | 601 | |
bogdanm | 84:0b3ab51c8877 | 602 | /** @brief Enable or disable the Low Speed APB (APB1) peripheral clock. |
bogdanm | 84:0b3ab51c8877 | 603 | * @note After reset, the peripheral clock (used for registers read/write access) |
bogdanm | 84:0b3ab51c8877 | 604 | * is disabled and the application software has to enable this clock before |
bogdanm | 84:0b3ab51c8877 | 605 | * using it. |
bogdanm | 84:0b3ab51c8877 | 606 | */ |
bogdanm | 84:0b3ab51c8877 | 607 | #define __WWDG_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_WWDGEN)) |
bogdanm | 84:0b3ab51c8877 | 608 | #define __PWR_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_PWREN)) |
bogdanm | 84:0b3ab51c8877 | 609 | |
bogdanm | 84:0b3ab51c8877 | 610 | #define __WWDG_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_WWDGEN)) |
bogdanm | 84:0b3ab51c8877 | 611 | #define __PWR_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_PWREN)) |
bogdanm | 84:0b3ab51c8877 | 612 | |
bogdanm | 84:0b3ab51c8877 | 613 | /** @brief Enable or disable the High Speed APB (APB2) peripheral clock. |
bogdanm | 84:0b3ab51c8877 | 614 | * @note After reset, the peripheral clock (used for registers read/write access) |
bogdanm | 84:0b3ab51c8877 | 615 | * is disabled and the application software has to enable this clock before |
bogdanm | 84:0b3ab51c8877 | 616 | * using it. |
bogdanm | 84:0b3ab51c8877 | 617 | */ |
bogdanm | 84:0b3ab51c8877 | 618 | #define __SYSCFG_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_SYSCFGEN)) |
bogdanm | 84:0b3ab51c8877 | 619 | #define __DBGMCU_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_DBGMCUEN)) |
bogdanm | 84:0b3ab51c8877 | 620 | |
bogdanm | 84:0b3ab51c8877 | 621 | #define __SYSCFG_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_SYSCFGEN)) |
bogdanm | 84:0b3ab51c8877 | 622 | #define __DBGMCU_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_DBGMCUEN)) |
bogdanm | 84:0b3ab51c8877 | 623 | |
bogdanm | 84:0b3ab51c8877 | 624 | /** @brief Force or release AHB peripheral reset. |
bogdanm | 84:0b3ab51c8877 | 625 | */ |
bogdanm | 84:0b3ab51c8877 | 626 | #define __AHB_FORCE_RESET() (RCC->AHBRSTR = 0xFFFFFFFF) |
bogdanm | 84:0b3ab51c8877 | 627 | #define __DMA1_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_DMA1RST)) |
bogdanm | 84:0b3ab51c8877 | 628 | #define __MIF_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_MIFRST)) |
bogdanm | 84:0b3ab51c8877 | 629 | #define __CRC_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_CRCRST)) |
bogdanm | 84:0b3ab51c8877 | 630 | |
bogdanm | 84:0b3ab51c8877 | 631 | #define __AHB_RELEASE_RESET() (RCC->AHBRSTR = 0x00) |
bogdanm | 84:0b3ab51c8877 | 632 | #define __CRC_RELEASE_RESET() (RCC->AHBRSTR &= ~ (RCC_AHBRSTR_CRCRST)) |
bogdanm | 84:0b3ab51c8877 | 633 | #define __DMA1_RELEASE_RESET() (RCC->AHBRSTR &= ~ (RCC_AHBRSTR_DMA1RST)) |
bogdanm | 84:0b3ab51c8877 | 634 | #define __MIF_RELEASE_RESET() (RCC->AHBRSTR &= ~ (RCC_AHBRSTR_MIFRST)) |
bogdanm | 84:0b3ab51c8877 | 635 | |
bogdanm | 84:0b3ab51c8877 | 636 | |
bogdanm | 84:0b3ab51c8877 | 637 | /** @brief Force or release IOPORT peripheral reset. |
bogdanm | 84:0b3ab51c8877 | 638 | */ |
bogdanm | 84:0b3ab51c8877 | 639 | #define __IOP_FORCE_RESET() (RCC->IOPRSTR = 0xFFFFFFFF) |
bogdanm | 84:0b3ab51c8877 | 640 | #define __GPIOA_FORCE_RESET() (RCC->IOPRSTR |= (RCC_IOPRSTR_GPIOARST)) |
bogdanm | 84:0b3ab51c8877 | 641 | #define __GPIOB_FORCE_RESET() (RCC->IOPRSTR |= (RCC_IOPRSTR_GPIOBRST)) |
bogdanm | 84:0b3ab51c8877 | 642 | #define __GPIOC_FORCE_RESET() (RCC->IOPRSTR |= (RCC_IOPRSTR_GPIOCRST)) |
bogdanm | 84:0b3ab51c8877 | 643 | #define __GPIOD_FORCE_RESET() (RCC->IOPRSTR |= (RCC_IOPRSTR_GPIODRST)) |
bogdanm | 84:0b3ab51c8877 | 644 | #define __GPIOH_FORCE_RESET() (RCC->IOPRSTR |= (RCC_IOPRSTR_GPIOHRST)) |
bogdanm | 84:0b3ab51c8877 | 645 | |
bogdanm | 84:0b3ab51c8877 | 646 | #define __IOP_RELEASE_RESET() (RCC->IOPRSTR = 0x00) |
bogdanm | 84:0b3ab51c8877 | 647 | #define __GPIOA_RELEASE_RESET() (RCC->IOPRSTR &= ~(RCC_IOPRSTR_GPIOARST)) |
bogdanm | 84:0b3ab51c8877 | 648 | #define __GPIOB_RELEASE_RESET() (RCC->IOPRSTR &= ~(RCC_IOPRSTR_GPIOBRST)) |
bogdanm | 84:0b3ab51c8877 | 649 | #define __GPIOC_RELEASE_RESET() (RCC->IOPRSTR &= ~(RCC_IOPRSTR_GPIOCRST)) |
bogdanm | 84:0b3ab51c8877 | 650 | #define __GPIOD_RELEASE_RESET() (RCC->IOPRSTR &= ~(RCC_IOPRSTR_GPIODRST)) |
bogdanm | 84:0b3ab51c8877 | 651 | #define __GPIOH_RELEASE_RESET() (RCC->IOPRSTR &= ~(RCC_IOPRSTR_GPIOHRST)) |
bogdanm | 84:0b3ab51c8877 | 652 | |
bogdanm | 84:0b3ab51c8877 | 653 | /** @brief Force or release APB1 peripheral reset. |
bogdanm | 84:0b3ab51c8877 | 654 | */ |
bogdanm | 84:0b3ab51c8877 | 655 | #define __APB1_FORCE_RESET() (RCC->APB1RSTR = 0xFFFFFFFF) |
bogdanm | 84:0b3ab51c8877 | 656 | #define __WWDG_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST)) |
bogdanm | 84:0b3ab51c8877 | 657 | #define __PWR_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST)) |
bogdanm | 84:0b3ab51c8877 | 658 | |
bogdanm | 84:0b3ab51c8877 | 659 | #define __APB1_RELEASE_RESET() (RCC->APB1RSTR = 0x00) |
bogdanm | 84:0b3ab51c8877 | 660 | #define __WWDG_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_WWDGRST)) |
bogdanm | 84:0b3ab51c8877 | 661 | #define __PWR_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_PWRRST)) |
bogdanm | 84:0b3ab51c8877 | 662 | |
bogdanm | 84:0b3ab51c8877 | 663 | /** @brief Force or release APB2 peripheral reset. |
bogdanm | 84:0b3ab51c8877 | 664 | */ |
bogdanm | 84:0b3ab51c8877 | 665 | #define __APB2_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFF) |
bogdanm | 84:0b3ab51c8877 | 666 | #define __DBGMCU_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_DBGMCURST)) |
bogdanm | 84:0b3ab51c8877 | 667 | #define __SYSCFG_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SYSCFGRST)) |
bogdanm | 84:0b3ab51c8877 | 668 | |
bogdanm | 84:0b3ab51c8877 | 669 | #define __APB2_RELEASE_RESET() (RCC->APB2RSTR = 0x00) |
bogdanm | 84:0b3ab51c8877 | 670 | #define __DBGMCU_RELEASE_RESET() (RCC->APB2RSTR &= ~ (RCC_APB2RSTR_DBGMCURST)) |
bogdanm | 84:0b3ab51c8877 | 671 | #define __SYSCFG_RELEASE_RESET() (RCC->APB2RSTR &= ~ (RCC_APB2RSTR_SYSCFGRST)) |
bogdanm | 84:0b3ab51c8877 | 672 | |
bogdanm | 84:0b3ab51c8877 | 673 | /** @brief Enable or disable the AHB peripheral clock during Low Power (Sleep) mode. |
bogdanm | 84:0b3ab51c8877 | 674 | * @note Peripheral clock gating in SLEEP mode can be used to further reduce |
bogdanm | 84:0b3ab51c8877 | 675 | * power consumption. |
bogdanm | 84:0b3ab51c8877 | 676 | * @note After wakeup from SLEEP mode, the peripheral clock is enabled again. |
bogdanm | 84:0b3ab51c8877 | 677 | * @note By default, all peripheral clocks are enabled during SLEEP mode. |
bogdanm | 84:0b3ab51c8877 | 678 | */ |
bogdanm | 84:0b3ab51c8877 | 679 | #define __CRC_CLK_SLEEP_ENABLE() (RCC->AHBSMENR |= (RCC_AHBSMENR_CRCSMEN)) |
bogdanm | 84:0b3ab51c8877 | 680 | #define __MIF_CLK_SLEEP_ENABLE() (RCC->AHBSMENR |= (RCC_AHBSMENR_MIFSMEN)) |
bogdanm | 84:0b3ab51c8877 | 681 | #define __SRAM_CLK_SLEEP_ENABLE() (RCC->AHBSMENR |= (RCC_AHBSMENR_SRAMSMEN)) |
bogdanm | 84:0b3ab51c8877 | 682 | #define __DMA1_CLK_SLEEP_ENABLE() (RCC->AHBSMENR |= (RCC_AHBSMENR_DMA1SMEN)) |
bogdanm | 84:0b3ab51c8877 | 683 | |
bogdanm | 84:0b3ab51c8877 | 684 | #define __CRC_CLK_SLEEP_DISABLE() (RCC->AHBSMENR &= ~ (RCC_AHBSMENR_CRCSMEN)) |
bogdanm | 84:0b3ab51c8877 | 685 | #define __MIF_CLK_SLEEP_DISABLE() (RCC->AHBSMENR &= ~ (RCC_AHBSMENR_MIFSMEN)) |
bogdanm | 84:0b3ab51c8877 | 686 | #define __SRAM_CLK_SLEEP_DISABLE() (RCC->AHBSMENR &= ~ (RCC_AHBSMENR_SRAMSMEN)) |
bogdanm | 84:0b3ab51c8877 | 687 | #define __DMA1_CLK_SLEEP_DISABLE() (RCC->AHBSMENR &= ~ (RCC_AHBSMENR_DMA1SMEN)) |
bogdanm | 84:0b3ab51c8877 | 688 | |
bogdanm | 84:0b3ab51c8877 | 689 | /** @brief Enable or disable the IOPORT peripheral clock during Low Power (Sleep) mode. |
bogdanm | 84:0b3ab51c8877 | 690 | * @note Peripheral clock gating in SLEEP mode can be used to further reduce |
bogdanm | 84:0b3ab51c8877 | 691 | * power consumption. |
bogdanm | 84:0b3ab51c8877 | 692 | * @note After wakeup from SLEEP mode, the peripheral clock is enabled again. |
bogdanm | 84:0b3ab51c8877 | 693 | * @note By default, all peripheral clocks are enabled during SLEEP mode. |
bogdanm | 84:0b3ab51c8877 | 694 | */ |
bogdanm | 84:0b3ab51c8877 | 695 | |
bogdanm | 84:0b3ab51c8877 | 696 | #define __GPIOA_CLK_SLEEP_ENABLE() (RCC->IOPSMENR |= (RCC_IOPSMENR_GPIOASMEN)) |
bogdanm | 84:0b3ab51c8877 | 697 | #define __GPIOB_CLK_SLEEP_ENABLE() (RCC->IOPSMENR |= (RCC_IOPSMENR_GPIOBSMEN)) |
bogdanm | 84:0b3ab51c8877 | 698 | #define __GPIOC_CLK_SLEEP_ENABLE() (RCC->IOPSMENR |= (RCC_IOPSMENR_GPIOCSMEN)) |
bogdanm | 84:0b3ab51c8877 | 699 | #define __GPIOD_CLK_SLEEP_ENABLE() (RCC->IOPSMENR |= (RCC_IOPSMENR_GPIODSMEN)) |
bogdanm | 84:0b3ab51c8877 | 700 | #define __GPIOH_CLK_SLEEP_ENABLE() (RCC->IOPSMENR |= (RCC_IOPSMENR_GPIOHSMEN)) |
bogdanm | 84:0b3ab51c8877 | 701 | |
bogdanm | 84:0b3ab51c8877 | 702 | #define __GPIOA_CLK_SLEEP_DISABLE() (RCC->IOPSMENR &= ~(RCC_IOPSMENR_GPIOASMEN)) |
bogdanm | 84:0b3ab51c8877 | 703 | #define __GPIOB_CLK_SLEEP_DISABLE() (RCC->IOPSMENR &= ~(RCC_IOPSMENR_GPIOBSMEN)) |
bogdanm | 84:0b3ab51c8877 | 704 | #define __GPIOC_CLK_SLEEP_DISABLE() (RCC->IOPSMENR &= ~(RCC_IOPSMENR_GPIOCSMEN)) |
bogdanm | 84:0b3ab51c8877 | 705 | #define __GPIOD_CLK_SLEEP_DISABLE() (RCC->IOPSMENR &= ~(RCC_IOPSMENR_GPIODSMEN)) |
bogdanm | 84:0b3ab51c8877 | 706 | #define __GPIOH_CLK_SLEEP_DISABLE() (RCC->IOPSMENR &= ~(RCC_IOPSMENR_GPIOHSMEN)) |
bogdanm | 84:0b3ab51c8877 | 707 | |
bogdanm | 84:0b3ab51c8877 | 708 | /** @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode. |
bogdanm | 84:0b3ab51c8877 | 709 | * @note Peripheral clock gating in SLEEP mode can be used to further reduce |
bogdanm | 84:0b3ab51c8877 | 710 | * power consumption. |
bogdanm | 84:0b3ab51c8877 | 711 | * @note After wakeup from SLEEP mode, the peripheral clock is enabled again. |
bogdanm | 84:0b3ab51c8877 | 712 | * @note By default, all peripheral clocks are enabled during SLEEP mode. |
bogdanm | 84:0b3ab51c8877 | 713 | */ |
bogdanm | 84:0b3ab51c8877 | 714 | #define __WWDG_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_WWDGSMEN)) |
bogdanm | 84:0b3ab51c8877 | 715 | #define __PWR_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_PWRSMEN)) |
bogdanm | 84:0b3ab51c8877 | 716 | |
bogdanm | 84:0b3ab51c8877 | 717 | #define __WWDG_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_WWDGSMEN)) |
bogdanm | 84:0b3ab51c8877 | 718 | #define __PWR_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_PWRSMEN)) |
bogdanm | 84:0b3ab51c8877 | 719 | |
bogdanm | 84:0b3ab51c8877 | 720 | /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode. |
bogdanm | 84:0b3ab51c8877 | 721 | * @note Peripheral clock gating in SLEEP mode can be used to further reduce |
bogdanm | 84:0b3ab51c8877 | 722 | * power consumption. |
bogdanm | 84:0b3ab51c8877 | 723 | * @note After wakeup from SLEEP mode, the peripheral clock is enabled again. |
bogdanm | 84:0b3ab51c8877 | 724 | * @note By default, all peripheral clocks are enabled during SLEEP mode. |
bogdanm | 84:0b3ab51c8877 | 725 | */ |
bogdanm | 84:0b3ab51c8877 | 726 | #define __SYSCFG_CLK_SLEEP_ENABLE() (RCC->APB2SMENR |= (RCC_APB2SMENR_SYSCFGSMEN)) |
bogdanm | 84:0b3ab51c8877 | 727 | #define __DBGMCU_CLK_SLEEP_ENABLE() (RCC->APB2SMENR |= (RCC_APB2SMENR_DBGMCUSMEN)) |
bogdanm | 84:0b3ab51c8877 | 728 | |
bogdanm | 84:0b3ab51c8877 | 729 | #define __SYSCFG_CLK_SLEEP_DISABLE() (RCC->APB2SMENR &= ~ (RCC_APB2SMENR_SYSCFGSMEN)) |
bogdanm | 84:0b3ab51c8877 | 730 | #define __DBGMCU_CLK_SLEEP_DISABLE() (RCC->APB2SMENR &= ~ (RCC_APB2SMENR_DBGMCUSMEN)) |
bogdanm | 84:0b3ab51c8877 | 731 | |
bogdanm | 84:0b3ab51c8877 | 732 | /** @brief Macro to enable or disable the Internal High Speed oscillator (HSI). |
bogdanm | 84:0b3ab51c8877 | 733 | * @note After enabling the HSI, the application software should wait on |
bogdanm | 84:0b3ab51c8877 | 734 | * HSIRDY flag to be set indicating that HSI clock is stable and can |
bogdanm | 84:0b3ab51c8877 | 735 | * be used to clock the PLL and/or system clock. |
bogdanm | 84:0b3ab51c8877 | 736 | * @note HSI can not be stopped if it is used directly or through the PLL |
bogdanm | 84:0b3ab51c8877 | 737 | * as system clock. In this case, you have to select another source |
bogdanm | 84:0b3ab51c8877 | 738 | * of the system clock then stop the HSI. |
bogdanm | 84:0b3ab51c8877 | 739 | * @note The HSI is stopped by hardware when entering STOP and STANDBY modes. |
bogdanm | 84:0b3ab51c8877 | 740 | * @param __STATE__: specifies the new state of the HSI. |
bogdanm | 84:0b3ab51c8877 | 741 | * This parameter can be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 742 | * @arg RCC_HSI_OFF: turn OFF the HSI oscillator |
bogdanm | 84:0b3ab51c8877 | 743 | * @arg RCC_HSI_ON: turn ON the HSI oscillator |
bogdanm | 84:0b3ab51c8877 | 744 | * @arg RCC_HSI_DIV4: turn ON the HSI oscillator and divide it by 4 |
bogdanm | 84:0b3ab51c8877 | 745 | * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator |
bogdanm | 84:0b3ab51c8877 | 746 | * clock cycles. |
bogdanm | 84:0b3ab51c8877 | 747 | */ |
bogdanm | 84:0b3ab51c8877 | 748 | #define __HAL_RCC_HSI_CONFIG(__STATE__) \ |
bogdanm | 84:0b3ab51c8877 | 749 | MODIFY_REG(RCC->CR, RCC_CR_HSION|RCC_CR_HSIDIVEN, (uint32_t)(__STATE__)) |
bogdanm | 84:0b3ab51c8877 | 750 | |
bogdanm | 84:0b3ab51c8877 | 751 | /** @brief Macros to enable or disable the Internal High Speed oscillator (HSI). |
bogdanm | 84:0b3ab51c8877 | 752 | * @note The HSI is stopped by hardware when entering STOP and STANDBY modes. |
bogdanm | 84:0b3ab51c8877 | 753 | * It is used (enabled by hardware) as system clock source after startup |
bogdanm | 84:0b3ab51c8877 | 754 | * from Reset, wakeup from STOP and STANDBY mode, or in case of failure |
bogdanm | 84:0b3ab51c8877 | 755 | * of the HSE used directly or indirectly as system clock (if the Clock |
bogdanm | 84:0b3ab51c8877 | 756 | * Security System CSS is enabled). |
bogdanm | 84:0b3ab51c8877 | 757 | * @note HSI can not be stopped if it is used as system clock source. In this case, |
bogdanm | 84:0b3ab51c8877 | 758 | * you have to select another source of the system clock then stop the HSI. |
bogdanm | 84:0b3ab51c8877 | 759 | * @note After enabling the HSI, the application software should wait on HSIRDY |
bogdanm | 84:0b3ab51c8877 | 760 | * flag to be set indicating that HSI clock is stable and can be used as |
bogdanm | 84:0b3ab51c8877 | 761 | * system clock source. |
bogdanm | 84:0b3ab51c8877 | 762 | * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator |
bogdanm | 84:0b3ab51c8877 | 763 | * clock cycles. |
bogdanm | 84:0b3ab51c8877 | 764 | */ |
bogdanm | 84:0b3ab51c8877 | 765 | #define __HAL_RCC_HSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSION) |
bogdanm | 84:0b3ab51c8877 | 766 | #define __HAL_RCC_HSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSION) |
bogdanm | 84:0b3ab51c8877 | 767 | |
bogdanm | 84:0b3ab51c8877 | 768 | /** |
bogdanm | 84:0b3ab51c8877 | 769 | * @brief Macros to enable or disable the Internal Multi Speed oscillator (MSI). |
bogdanm | 84:0b3ab51c8877 | 770 | * @note The MSI is stopped by hardware when entering STOP and STANDBY modes. |
bogdanm | 84:0b3ab51c8877 | 771 | * It is used (enabled by hardware) as system clock source after |
bogdanm | 84:0b3ab51c8877 | 772 | * startup from Reset, wakeup from STOP and STANDBY mode, or in case |
bogdanm | 84:0b3ab51c8877 | 773 | * of failure of the HSE used directly or indirectly as system clock |
bogdanm | 84:0b3ab51c8877 | 774 | * (if the Clock Security System CSS is enabled). |
bogdanm | 84:0b3ab51c8877 | 775 | * @note MSI can not be stopped if it is used as system clock source. |
bogdanm | 84:0b3ab51c8877 | 776 | * In this case, you have to select another source of the system |
bogdanm | 84:0b3ab51c8877 | 777 | * clock then stop the MSI. |
bogdanm | 84:0b3ab51c8877 | 778 | * @note After enabling the MSI, the application software should wait on |
bogdanm | 84:0b3ab51c8877 | 779 | * MSIRDY flag to be set indicating that MSI clock is stable and can |
bogdanm | 84:0b3ab51c8877 | 780 | * be used as system clock source. |
bogdanm | 84:0b3ab51c8877 | 781 | * @note When the MSI is stopped, MSIRDY flag goes low after 6 MSI oscillator |
bogdanm | 84:0b3ab51c8877 | 782 | * clock cycles. |
bogdanm | 84:0b3ab51c8877 | 783 | */ |
bogdanm | 84:0b3ab51c8877 | 784 | #define __HAL_RCC_MSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_MSION) |
bogdanm | 84:0b3ab51c8877 | 785 | #define __HAL_RCC_MSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_MSION) |
bogdanm | 84:0b3ab51c8877 | 786 | |
bogdanm | 84:0b3ab51c8877 | 787 | /** |
bogdanm | 84:0b3ab51c8877 | 788 | * @brief Macro to enable or disable the Internal High Speed oscillator for USB (HSI48). |
bogdanm | 84:0b3ab51c8877 | 789 | * @note After enabling the HSI48, the application software should wait on |
bogdanm | 84:0b3ab51c8877 | 790 | * HSI48RDY flag to be set indicating that HSI48 clock is stable and can |
bogdanm | 84:0b3ab51c8877 | 791 | * be used to clock the USB. |
bogdanm | 84:0b3ab51c8877 | 792 | * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes. |
bogdanm | 84:0b3ab51c8877 | 793 | */ |
bogdanm | 84:0b3ab51c8877 | 794 | #define __HAL_RCC_HSI48_ENABLE() do { SET_BIT(RCC->CRRCR, RCC_CRRCR_HSI48ON); \ |
bogdanm | 84:0b3ab51c8877 | 795 | RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; \ |
bogdanm | 84:0b3ab51c8877 | 796 | SYSCFG->CFGR3 |= (SYSCFG_CFGR3_ENREF_HSI48 | SYSCFG_CFGR3_EN_VREFINT); \ |
bogdanm | 84:0b3ab51c8877 | 797 | } while (0) |
bogdanm | 84:0b3ab51c8877 | 798 | #define __HAL_RCC_HSI48_DISABLE() do { CLEAR_BIT(RCC->CRRCR, RCC_CRRCR_HSI48ON); \ |
bogdanm | 84:0b3ab51c8877 | 799 | SYSCFG->CFGR3 &= (uint32_t)~((uint32_t)(SYSCFG_CFGR3_ENREF_HSI48 | SYSCFG_CFGR3_EN_VREFINT)); \ |
bogdanm | 84:0b3ab51c8877 | 800 | } while (0) |
bogdanm | 84:0b3ab51c8877 | 801 | |
bogdanm | 84:0b3ab51c8877 | 802 | /** @brief Macro to adjust the Internal High Speed oscillator (HSI) calibration value. |
bogdanm | 84:0b3ab51c8877 | 803 | * @note The calibration is used to compensate for the variations in voltage |
bogdanm | 84:0b3ab51c8877 | 804 | * and temperature that influence the frequency of the internal HSI RC. |
bogdanm | 84:0b3ab51c8877 | 805 | * @param __HSICalibrationValue__: specifies the calibration trimming value. |
bogdanm | 84:0b3ab51c8877 | 806 | * This parameter must be a number between 0 and 0x1F. |
bogdanm | 84:0b3ab51c8877 | 807 | */ |
bogdanm | 84:0b3ab51c8877 | 808 | #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICalibrationValue__) (MODIFY_REG(RCC->ICSCR,\ |
bogdanm | 84:0b3ab51c8877 | 809 | RCC_ICSCR_HSITRIM, (uint32_t)(__HSICalibrationValue__) << 8)) |
bogdanm | 84:0b3ab51c8877 | 810 | |
bogdanm | 84:0b3ab51c8877 | 811 | /** @brief Macro Adjusts the Internal Multi Speed oscillator (MSI) calibration value. |
bogdanm | 84:0b3ab51c8877 | 812 | * @note The calibration is used to compensate for the variations in voltage |
bogdanm | 84:0b3ab51c8877 | 813 | * and temperature that influence the frequency of the internal MSI RC. |
bogdanm | 84:0b3ab51c8877 | 814 | * Refer to the Application Note AN3300 for more details on how to |
bogdanm | 84:0b3ab51c8877 | 815 | * calibrate the MSI. |
bogdanm | 84:0b3ab51c8877 | 816 | * @param __MSICalibrationValue__: specifies the calibration trimming value. |
bogdanm | 84:0b3ab51c8877 | 817 | * This parameter must be a number between 0 and 0xFF. |
bogdanm | 84:0b3ab51c8877 | 818 | */ |
bogdanm | 84:0b3ab51c8877 | 819 | #define __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(__MSICalibrationValue__) (MODIFY_REG(RCC->ICSCR,\ |
bogdanm | 84:0b3ab51c8877 | 820 | RCC_ICSCR_MSITRIM, (uint32_t)(__MSICalibrationValue__) << 24)) |
bogdanm | 84:0b3ab51c8877 | 821 | |
bogdanm | 84:0b3ab51c8877 | 822 | /** |
bogdanm | 84:0b3ab51c8877 | 823 | * @brief Macro to configures the Internal Multi Speed oscillator (MSI) clock range. |
bogdanm | 84:0b3ab51c8877 | 824 | * @note After restart from Reset or wakeup from STANDBY, the MSI clock is |
bogdanm | 84:0b3ab51c8877 | 825 | * around 2.097 MHz. The MSI clock does not change after wake-up from |
bogdanm | 84:0b3ab51c8877 | 826 | * STOP mode. |
bogdanm | 84:0b3ab51c8877 | 827 | * @note The MSI clock range can be modified on the fly. |
bogdanm | 84:0b3ab51c8877 | 828 | * @param RCC_MSIRange: specifies the MSI Clock range. |
bogdanm | 84:0b3ab51c8877 | 829 | * This parameter must be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 830 | * @arg RCC_MSIRANGE_0: MSI clock is around 65.536 KHz |
bogdanm | 84:0b3ab51c8877 | 831 | * @arg RCC_MSIRANGE_1: MSI clock is around 131.072 KHz |
bogdanm | 84:0b3ab51c8877 | 832 | * @arg RCC_MSIRANGE_2: MSI clock is around 262.144 KHz |
bogdanm | 84:0b3ab51c8877 | 833 | * @arg RCC_MSIRANGE_3: MSI clock is around 524.288 KHz |
bogdanm | 84:0b3ab51c8877 | 834 | * @arg RCC_MSIRANGE_4: MSI clock is around 1.048 MHz |
bogdanm | 84:0b3ab51c8877 | 835 | * @arg RCC_MSIRANGE_5: MSI clock is around 2.097 MHz (default after Reset or wake-up from STANDBY) |
bogdanm | 84:0b3ab51c8877 | 836 | * @arg RCC_MSIRANGE_6: MSI clock is around 4.194 MHz |
bogdanm | 84:0b3ab51c8877 | 837 | */ |
bogdanm | 84:0b3ab51c8877 | 838 | #define __HAL_RCC_MSI_RANGE_CONFIG(__RCC_MSIRange__) (MODIFY_REG(RCC->ICSCR,\ |
bogdanm | 84:0b3ab51c8877 | 839 | RCC_ICSCR_MSIRANGE, (uint32_t)(__RCC_MSIRange__) )) |
bogdanm | 84:0b3ab51c8877 | 840 | |
bogdanm | 84:0b3ab51c8877 | 841 | /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI). |
bogdanm | 84:0b3ab51c8877 | 842 | * @note After enabling the LSI, the application software should wait on |
bogdanm | 84:0b3ab51c8877 | 843 | * LSIRDY flag to be set indicating that LSI clock is stable and can |
bogdanm | 84:0b3ab51c8877 | 844 | * be used to clock the IWDG and/or the RTC. |
bogdanm | 84:0b3ab51c8877 | 845 | * @note LSI can not be disabled if the IWDG is running. |
bogdanm | 84:0b3ab51c8877 | 846 | * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator |
bogdanm | 84:0b3ab51c8877 | 847 | * clock cycles. |
bogdanm | 84:0b3ab51c8877 | 848 | */ |
bogdanm | 84:0b3ab51c8877 | 849 | #define __HAL_RCC_LSI_ENABLE() SET_BIT(RCC->CSR, RCC_CSR_LSION) |
bogdanm | 84:0b3ab51c8877 | 850 | #define __HAL_RCC_LSI_DISABLE() CLEAR_BIT(RCC->CSR, RCC_CSR_LSION) |
bogdanm | 84:0b3ab51c8877 | 851 | |
bogdanm | 84:0b3ab51c8877 | 852 | /** |
bogdanm | 84:0b3ab51c8877 | 853 | * @brief Macro to configure the External High Speed oscillator (HSE). |
bogdanm | 84:0b3ab51c8877 | 854 | * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application |
bogdanm | 84:0b3ab51c8877 | 855 | * software should wait on HSERDY flag to be set indicating that HSE clock |
bogdanm | 84:0b3ab51c8877 | 856 | * is stable and can be used to clock the PLL and/or system clock. |
bogdanm | 84:0b3ab51c8877 | 857 | * @note HSE state can not be changed if it is used directly or through the |
bogdanm | 84:0b3ab51c8877 | 858 | * PLL as system clock. In this case, you have to select another source |
bogdanm | 84:0b3ab51c8877 | 859 | * of the system clock then change the HSE state (ex. disable it). |
bogdanm | 84:0b3ab51c8877 | 860 | * @note The HSE is stopped by hardware when entering STOP and STANDBY modes. |
bogdanm | 84:0b3ab51c8877 | 861 | * @note This function reset the CSSON bit, so if the clock security system(CSS) |
bogdanm | 84:0b3ab51c8877 | 862 | * was previously enabled you have to enable it again after calling this |
bogdanm | 84:0b3ab51c8877 | 863 | * function. |
bogdanm | 84:0b3ab51c8877 | 864 | * @param __STATE__: specifies the new state of the HSE. |
bogdanm | 84:0b3ab51c8877 | 865 | * This parameter can be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 866 | * @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after |
bogdanm | 84:0b3ab51c8877 | 867 | * 6 HSE oscillator clock cycles. |
bogdanm | 84:0b3ab51c8877 | 868 | * @arg RCC_HSE_ON: turn ON the HSE oscillator. |
bogdanm | 84:0b3ab51c8877 | 869 | * @arg RCC_HSE_BYPASS: HSE oscillator bypassed with external clock. |
bogdanm | 84:0b3ab51c8877 | 870 | */ |
bogdanm | 84:0b3ab51c8877 | 871 | #define __HAL_RCC_HSE_CONFIG(__STATE__) \ |
bogdanm | 84:0b3ab51c8877 | 872 | MODIFY_REG(RCC->CR, RCC_CR_HSEON|RCC_CR_HSEBYP, (uint32_t)(__STATE__)) |
bogdanm | 84:0b3ab51c8877 | 873 | |
bogdanm | 84:0b3ab51c8877 | 874 | /** |
bogdanm | 84:0b3ab51c8877 | 875 | * @brief Macro to configure the External Low Speed oscillator (LSE). |
bogdanm | 84:0b3ab51c8877 | 876 | * @note As the LSE is in the Backup domain and write access is denied to |
bogdanm | 84:0b3ab51c8877 | 877 | * this domain after reset, you have to enable write access using |
bogdanm | 84:0b3ab51c8877 | 878 | * HAL_PWR_EnableBkUpAccess() function before to configure the LSE |
bogdanm | 84:0b3ab51c8877 | 879 | * (to be done once after reset). |
bogdanm | 84:0b3ab51c8877 | 880 | * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application |
bogdanm | 84:0b3ab51c8877 | 881 | * software should wait on LSERDY flag to be set indicating that LSE clock |
bogdanm | 84:0b3ab51c8877 | 882 | * is stable and can be used to clock the RTC. |
bogdanm | 84:0b3ab51c8877 | 883 | * @param __STATE__: specifies the new state of the LSE. |
bogdanm | 84:0b3ab51c8877 | 884 | * This parameter can be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 885 | * @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after |
bogdanm | 84:0b3ab51c8877 | 886 | * 6 LSE oscillator clock cycles. |
bogdanm | 84:0b3ab51c8877 | 887 | * @arg RCC_LSE_ON: turn ON the LSE oscillator. |
bogdanm | 84:0b3ab51c8877 | 888 | * @arg RCC_LSE_BYPASS: LSE oscillator bypassed with external clock. |
bogdanm | 84:0b3ab51c8877 | 889 | */ |
bogdanm | 84:0b3ab51c8877 | 890 | #define __HAL_RCC_LSE_CONFIG(__STATE__) \ |
bogdanm | 84:0b3ab51c8877 | 891 | MODIFY_REG(RCC->CSR, RCC_CSR_LSEON|RCC_CSR_LSEBYP, (uint32_t)(__STATE__)) |
bogdanm | 84:0b3ab51c8877 | 892 | |
bogdanm | 84:0b3ab51c8877 | 893 | /** @brief Macros to enable or disable the the RTC clock. |
bogdanm | 84:0b3ab51c8877 | 894 | * @note These macros must be used only after the RTC clock source was selected. |
bogdanm | 84:0b3ab51c8877 | 895 | */ |
bogdanm | 84:0b3ab51c8877 | 896 | #define __HAL_RCC_RTC_ENABLE() SET_BIT(RCC->CSR, RCC_CSR_RTCEN) |
bogdanm | 84:0b3ab51c8877 | 897 | #define __HAL_RCC_RTC_DISABLE() CLEAR_BIT(RCC->CSR, RCC_CSR_RTCEN) |
bogdanm | 84:0b3ab51c8877 | 898 | |
bogdanm | 84:0b3ab51c8877 | 899 | /** |
bogdanm | 84:0b3ab51c8877 | 900 | * @brief Configures or Get the RTC and LCD clock (RTCCLK / LCDCLK). |
bogdanm | 84:0b3ab51c8877 | 901 | * @note As the RTC clock configuration bits are in the RTC domain and write |
bogdanm | 84:0b3ab51c8877 | 902 | * access is denied to this domain after reset, you have to enable write |
bogdanm | 84:0b3ab51c8877 | 903 | * access using PWR_RTCAccessCmd(ENABLE) function before to configure |
bogdanm | 84:0b3ab51c8877 | 904 | * the RTC clock source (to be done once after reset). |
bogdanm | 84:0b3ab51c8877 | 905 | * @note Once the RTC clock is configured it can't be changed unless the RTC |
bogdanm | 84:0b3ab51c8877 | 906 | * is reset using RCC_RTCResetCmd function, or by a Power On Reset (POR) |
bogdanm | 84:0b3ab51c8877 | 907 | * @note The RTC clock (RTCCLK) is used also to clock the LCD (LCDCLK). |
bogdanm | 84:0b3ab51c8877 | 908 | * |
bogdanm | 84:0b3ab51c8877 | 909 | * @param RCC_RTCCLKSource: specifies the RTC clock source. |
bogdanm | 84:0b3ab51c8877 | 910 | * This parameter can be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 911 | * @arg RCC_RTCCLKSOURCE_LSE: LSE selected as RTC clock |
bogdanm | 84:0b3ab51c8877 | 912 | * @arg RCC_RTCCLKSOURCE_LSI: LSI selected as RTC clock |
bogdanm | 84:0b3ab51c8877 | 913 | * @arg RCC_RTCCLKSOURCE_HSE_DIV2: HSE divided by 2 selected as RTC clock |
bogdanm | 84:0b3ab51c8877 | 914 | * @arg RCC_RTCCLKSOURCE_HSE_DIV4: HSE divided by 4 selected as RTC clock |
bogdanm | 84:0b3ab51c8877 | 915 | * @arg RCC_RTCCLKSOURCE_HSE_DIV8: HSE divided by 8 selected as RTC clock |
bogdanm | 84:0b3ab51c8877 | 916 | * @arg RCC_RTCCLKSOURCE_HSE_DIV16: HSE divided by 16 selected as RTC clock |
bogdanm | 84:0b3ab51c8877 | 917 | * |
bogdanm | 84:0b3ab51c8877 | 918 | * @note If the LSE or LSI is used as RTC clock source, the RTC continues to |
bogdanm | 84:0b3ab51c8877 | 919 | * work in STOP and STANDBY modes, and can be used as wakeup source. |
bogdanm | 84:0b3ab51c8877 | 920 | * However, when the HSE clock is used as RTC clock source, the RTC |
bogdanm | 84:0b3ab51c8877 | 921 | * cannot be used in STOP and STANDBY modes. |
bogdanm | 84:0b3ab51c8877 | 922 | * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as |
bogdanm | 84:0b3ab51c8877 | 923 | * RTC clock source). |
bogdanm | 84:0b3ab51c8877 | 924 | */ |
bogdanm | 84:0b3ab51c8877 | 925 | #define __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__) (((__RTCCLKSource__) & RCC_CSR_RTCSEL) == RCC_CSR_RTCSEL) ? \ |
bogdanm | 84:0b3ab51c8877 | 926 | MODIFY_REG(RCC->CR, RCC_CR_RTCPRE, ((__RTCCLKSource__) & 0xFFFCFFFF)) : CLEAR_BIT(RCC->CR, RCC_CR_RTCPRE) |
bogdanm | 84:0b3ab51c8877 | 927 | |
bogdanm | 84:0b3ab51c8877 | 928 | #define __HAL_RCC_RTC_CONFIG(__RTCCLKSource__) do { __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__); \ |
bogdanm | 84:0b3ab51c8877 | 929 | MODIFY_REG( RCC->CSR, RCC_CSR_RTCSEL, (uint32_t)(__RTCCLKSource__)); \ |
bogdanm | 84:0b3ab51c8877 | 930 | } while (0) |
bogdanm | 84:0b3ab51c8877 | 931 | |
bogdanm | 84:0b3ab51c8877 | 932 | #define __HAL_RCC_GET_RTC_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CSR_RTCSEL))) |
bogdanm | 84:0b3ab51c8877 | 933 | |
bogdanm | 84:0b3ab51c8877 | 934 | /** @brief Macros to force or release the Backup domain reset. |
bogdanm | 84:0b3ab51c8877 | 935 | * @note This function resets the RTC peripheral (including the backup registers) |
bogdanm | 84:0b3ab51c8877 | 936 | * and the RTC clock source selection in RCC_CSR register. |
bogdanm | 84:0b3ab51c8877 | 937 | * @note The BKPSRAM is not affected by this reset. |
bogdanm | 84:0b3ab51c8877 | 938 | */ |
bogdanm | 84:0b3ab51c8877 | 939 | #define __HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->CSR, RCC_CSR_RTCRST) |
bogdanm | 84:0b3ab51c8877 | 940 | #define __HAL_RCC_BACKUPRESET_RELEASE() CLEAR_BIT(RCC->CSR, RCC_CSR_RTCRST) |
bogdanm | 84:0b3ab51c8877 | 941 | |
bogdanm | 84:0b3ab51c8877 | 942 | /** @brief Macros to enable or disable the main PLL. |
bogdanm | 84:0b3ab51c8877 | 943 | * @note After enabling the main PLL, the application software should wait on |
bogdanm | 84:0b3ab51c8877 | 944 | * PLLRDY flag to be set indicating that PLL clock is stable and can |
bogdanm | 84:0b3ab51c8877 | 945 | * be used as system clock source. |
bogdanm | 84:0b3ab51c8877 | 946 | * @note The main PLL can not be disabled if it is used as system clock source |
bogdanm | 84:0b3ab51c8877 | 947 | * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes. |
bogdanm | 84:0b3ab51c8877 | 948 | */ |
bogdanm | 84:0b3ab51c8877 | 949 | #define __HAL_RCC_PLL_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLON) |
bogdanm | 84:0b3ab51c8877 | 950 | #define __HAL_RCC_PLL_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLON) |
bogdanm | 84:0b3ab51c8877 | 951 | |
bogdanm | 84:0b3ab51c8877 | 952 | /** @brief Macro to configure the main PLL clock source, multiplication and division factors. |
bogdanm | 84:0b3ab51c8877 | 953 | * @note This function must be used only when the main PLL is disabled. |
bogdanm | 84:0b3ab51c8877 | 954 | * @param __RCC_PLLSource__: specifies the PLL entry clock source. |
bogdanm | 84:0b3ab51c8877 | 955 | * This parameter can be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 956 | * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry |
bogdanm | 84:0b3ab51c8877 | 957 | * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry |
bogdanm | 84:0b3ab51c8877 | 958 | * @param __PLLMUL__: specifies the multiplication factor to generate the PLL VCO clock |
bogdanm | 84:0b3ab51c8877 | 959 | * This parameter must be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 960 | * @arg RCC_CFGR_PLLMUL3: PLLVCO = PLL clock entry x 3 |
bogdanm | 84:0b3ab51c8877 | 961 | * @arg RCC_CFGR_PLLMUL4: PLLVCO = PLL clock entry x 4 |
bogdanm | 84:0b3ab51c8877 | 962 | * @arg RCC_CFGR_PLLMUL6: PLLVCO = PLL clock entry x 6 |
bogdanm | 84:0b3ab51c8877 | 963 | * @arg RCC_CFGR_PLLMUL8: PLLVCO = PLL clock entry x 8 |
bogdanm | 84:0b3ab51c8877 | 964 | * @arg RCC_CFGR_PLLMUL12: PLLVCO = PLL clock entry x 12 |
bogdanm | 84:0b3ab51c8877 | 965 | * @arg RCC_CFGR_PLLMUL16: PLLVCO = PLL clock entry x 16 |
bogdanm | 84:0b3ab51c8877 | 966 | * @arg RCC_CFGR_PLLMUL24: PLLVCO = PLL clock entry x 24 |
bogdanm | 84:0b3ab51c8877 | 967 | * @arg RCC_CFGR_PLLMUL32: PLLVCO = PLL clock entry x 32 |
bogdanm | 84:0b3ab51c8877 | 968 | * @arg RCC_CFGR_PLLMUL48: PLLVCO = PLL clock entry x 48 |
bogdanm | 84:0b3ab51c8877 | 969 | * @note The PLL VCO clock frequency must not exceed 96 MHz when the product is in |
bogdanm | 84:0b3ab51c8877 | 970 | * Range 1, 48 MHz when the product is in Range 2 and 24 MHz when the product is |
bogdanm | 84:0b3ab51c8877 | 971 | * in Range 3. |
bogdanm | 84:0b3ab51c8877 | 972 | * @param __PLLDIV__: specifies the PLL output clock division from PLL VCO clock |
bogdanm | 84:0b3ab51c8877 | 973 | * This parameter must be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 974 | * @arg RCC_PLLDIV_2: PLL clock output = PLLVCO / 2 |
bogdanm | 84:0b3ab51c8877 | 975 | * @arg RCC_PLLDIV_3: PLL clock output = PLLVCO / 3 |
bogdanm | 84:0b3ab51c8877 | 976 | * @arg RCC_PLLDIV_4: PLL clock output = PLLVCO / 4 |
bogdanm | 84:0b3ab51c8877 | 977 | */ |
bogdanm | 84:0b3ab51c8877 | 978 | |
bogdanm | 84:0b3ab51c8877 | 979 | #define __HAL_RCC_PLL_CONFIG(__RCC_PLLSource__ , __PLLMUL__ ,__PLLDIV__ ) \ |
bogdanm | 84:0b3ab51c8877 | 980 | MODIFY_REG(RCC->CFGR, RCC_CFGR_PLLMUL | RCC_CFGR_PLLDIV | RCC_CFGR_PLLSRC, (uint32_t)((__PLLMUL__)| (__PLLDIV__)| (__RCC_PLLSource__))) |
bogdanm | 84:0b3ab51c8877 | 981 | |
bogdanm | 84:0b3ab51c8877 | 982 | /** @brief Macro to get the clock source used as system clock. |
bogdanm | 84:0b3ab51c8877 | 983 | * @retval The clock source used as system clock. The returned value can be one |
bogdanm | 84:0b3ab51c8877 | 984 | * of the following: |
bogdanm | 84:0b3ab51c8877 | 985 | * - RCC_CFGR_SWS_HSI: HSI used as system clock. |
bogdanm | 84:0b3ab51c8877 | 986 | * - RCC_CFGR_SWS_HSE: HSE used as system clock. |
bogdanm | 84:0b3ab51c8877 | 987 | * - RCC_CFGR_SWS_PLL: PLL used as system clock. |
bogdanm | 84:0b3ab51c8877 | 988 | */ |
bogdanm | 84:0b3ab51c8877 | 989 | #define __HAL_RCC_GET_SYSCLK_SOURCE() ((uint32_t)(RCC->CFGR & RCC_CFGR_SWS)) |
bogdanm | 84:0b3ab51c8877 | 990 | |
bogdanm | 84:0b3ab51c8877 | 991 | /** @brief Macro to get the oscillator used as PLL clock source. |
bogdanm | 84:0b3ab51c8877 | 992 | * @retval The oscillator used as PLL clock source. The returned value can be one |
bogdanm | 84:0b3ab51c8877 | 993 | * of the following: |
bogdanm | 84:0b3ab51c8877 | 994 | * - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source. |
bogdanm | 84:0b3ab51c8877 | 995 | * - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source. |
bogdanm | 84:0b3ab51c8877 | 996 | */ |
bogdanm | 84:0b3ab51c8877 | 997 | #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->CFGR & RCC_CFGR_PLLSRC)) |
bogdanm | 84:0b3ab51c8877 | 998 | |
bogdanm | 84:0b3ab51c8877 | 999 | /** @defgroup RCC_Flags_Interrupts_Management |
bogdanm | 84:0b3ab51c8877 | 1000 | * @brief macros to manage the specified RCC Flags and interrupts. |
bogdanm | 84:0b3ab51c8877 | 1001 | * @{ |
bogdanm | 84:0b3ab51c8877 | 1002 | */ |
bogdanm | 84:0b3ab51c8877 | 1003 | |
bogdanm | 84:0b3ab51c8877 | 1004 | /** @brief Enable RCC interrupt (Perform Byte access to RCC_CIER[0:7] bits to enable |
bogdanm | 84:0b3ab51c8877 | 1005 | * the selected interrupts). |
bogdanm | 84:0b3ab51c8877 | 1006 | * @note The CSS interrupt doesn't have an enable bit; once the CSS is enabled |
bogdanm | 84:0b3ab51c8877 | 1007 | * and if the HSE clock fails, the CSS interrupt occurs and an NMI is |
bogdanm | 84:0b3ab51c8877 | 1008 | * automatically generated. The NMI will be executed indefinitely, and |
bogdanm | 84:0b3ab51c8877 | 1009 | * since NMI has higher priority than any other IRQ (and main program) |
bogdanm | 84:0b3ab51c8877 | 1010 | * the application will be stacked in the NMI ISR unless the CSS interrupt |
bogdanm | 84:0b3ab51c8877 | 1011 | * pending bit is cleared. |
bogdanm | 84:0b3ab51c8877 | 1012 | * @param __INTERRUPT__: specifies the RCC interrupt sources to be enabled. |
bogdanm | 84:0b3ab51c8877 | 1013 | * This parameter can be any combination of the following values: |
bogdanm | 84:0b3ab51c8877 | 1014 | * @arg RCC_IT_LSIRDY: LSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1015 | * @arg RCC_IT_LSERDY: LSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1016 | * @arg RCC_IT_HSIRDY: HSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1017 | * @arg RCC_IT_HSERDY: HSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1018 | * @arg RCC_IT_PLLRDY: PLL ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1019 | * @arg RCC_IT_MSIRDY: MSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1020 | * @arg RCC_IT_LSECSS: LSE CSS interrupt |
bogdanm | 84:0b3ab51c8877 | 1021 | */ |
bogdanm | 84:0b3ab51c8877 | 1022 | #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) CIER_BYTE0_ADDRESS |= (__INTERRUPT__)) |
bogdanm | 84:0b3ab51c8877 | 1023 | |
bogdanm | 84:0b3ab51c8877 | 1024 | /** @brief Disable RCC interrupt (Perform Byte access to RCC_CIER[0:7] bits to disable |
bogdanm | 84:0b3ab51c8877 | 1025 | * the selected interrupts). |
bogdanm | 84:0b3ab51c8877 | 1026 | * @note The CSS interrupt doesn't have an enable bit; once the CSS is enabled |
bogdanm | 84:0b3ab51c8877 | 1027 | * and if the HSE clock fails, the CSS interrupt occurs and an NMI is |
bogdanm | 84:0b3ab51c8877 | 1028 | * automatically generated. The NMI will be executed indefinitely, and |
bogdanm | 84:0b3ab51c8877 | 1029 | * since NMI has higher priority than any other IRQ (and main program) |
bogdanm | 84:0b3ab51c8877 | 1030 | * the application will be stacked in the NMI ISR unless the CSS interrupt |
bogdanm | 84:0b3ab51c8877 | 1031 | * pending bit is cleared. |
bogdanm | 84:0b3ab51c8877 | 1032 | * @param __INTERRUPT__: specifies the RCC interrupt sources to be disabled. |
bogdanm | 84:0b3ab51c8877 | 1033 | * This parameter can be any combination of the following values: |
bogdanm | 84:0b3ab51c8877 | 1034 | * @arg RCC_IT_LSIRDY: LSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1035 | * @arg RCC_IT_LSERDY: LSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1036 | * @arg RCC_IT_HSIRDY: HSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1037 | * @arg RCC_IT_HSERDY: HSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1038 | * @arg RCC_IT_PLLRDY: PLL ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1039 | * @arg RCC_IT_MSIRDY: MSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1040 | * @arg RCC_IT_LSECSS: LSE CSS interrupt |
bogdanm | 84:0b3ab51c8877 | 1041 | */ |
bogdanm | 84:0b3ab51c8877 | 1042 | #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) CIER_BYTE0_ADDRESS &= ~(__INTERRUPT__)) |
bogdanm | 84:0b3ab51c8877 | 1043 | |
bogdanm | 84:0b3ab51c8877 | 1044 | /** @brief Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CIR[23:16] |
bogdanm | 84:0b3ab51c8877 | 1045 | * bits to clear the selected interrupt pending bits. |
bogdanm | 84:0b3ab51c8877 | 1046 | * @param __INTERRUPT__: specifies the interrupt pending bit to clear. |
bogdanm | 84:0b3ab51c8877 | 1047 | * This parameter can be any combination of the following values: |
bogdanm | 84:0b3ab51c8877 | 1048 | * @arg RCC_IT_LSIRDY: LSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1049 | * @arg RCC_IT_LSERDY: LSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1050 | * @arg RCC_IT_HSIRDY: HSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1051 | * @arg RCC_IT_HSERDY: HSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1052 | * @arg RCC_IT_PLLRDY: PLL ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1053 | * @arg RCC_IT_MSIRDY: MSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1054 | * @arg RCC_IT_LSECSS: LSE CSS interrupt |
bogdanm | 84:0b3ab51c8877 | 1055 | * @arg RCC_IT_CSS: Clock Security System interrupt |
bogdanm | 84:0b3ab51c8877 | 1056 | */ |
bogdanm | 84:0b3ab51c8877 | 1057 | #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) SET_BIT(RCC->CICR, (__INTERRUPT__)) |
bogdanm | 84:0b3ab51c8877 | 1058 | |
bogdanm | 84:0b3ab51c8877 | 1059 | /** @brief Check the RCC's interrupt has occurred or not. |
bogdanm | 84:0b3ab51c8877 | 1060 | * @param __INTERRUPT__: specifies the RCC interrupt source to check. |
bogdanm | 84:0b3ab51c8877 | 1061 | * This parameter can be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 1062 | * @arg RCC_IT_LSIRDY: LSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1063 | * @arg RCC_IT_LSERDY: LSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1064 | * @arg RCC_IT_HSIRDY: HSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1065 | * @arg RCC_IT_HSERDY: HSE ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1066 | * @arg RCC_IT_PLLRDY: PLL ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1067 | * @arg RCC_IT_MSIRDY: MSI ready interrupt |
bogdanm | 84:0b3ab51c8877 | 1068 | * @arg RCC_IT_LSECSS: LSE CSS interrupt |
bogdanm | 84:0b3ab51c8877 | 1069 | * @arg RCC_IT_CSS: Clock Security System interrupt |
bogdanm | 84:0b3ab51c8877 | 1070 | * @retval The new state of __INTERRUPT__ (TRUE or FALSE). |
bogdanm | 84:0b3ab51c8877 | 1071 | */ |
bogdanm | 84:0b3ab51c8877 | 1072 | #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIFR & (__INTERRUPT__)) == (__INTERRUPT__)) |
bogdanm | 84:0b3ab51c8877 | 1073 | |
bogdanm | 84:0b3ab51c8877 | 1074 | /** @brief Set RMVF bit to clear the reset flags. |
bogdanm | 84:0b3ab51c8877 | 1075 | * The reset flags are: RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_PORRST, |
bogdanm | 84:0b3ab51c8877 | 1076 | * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST. |
bogdanm | 84:0b3ab51c8877 | 1077 | */ |
bogdanm | 84:0b3ab51c8877 | 1078 | #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF) |
bogdanm | 84:0b3ab51c8877 | 1079 | |
bogdanm | 84:0b3ab51c8877 | 1080 | /** @brief Check RCC flag is set or not. |
bogdanm | 84:0b3ab51c8877 | 1081 | * @param __FLAG__: specifies the flag to check. |
bogdanm | 84:0b3ab51c8877 | 1082 | * This parameter can be one of the following values: |
bogdanm | 84:0b3ab51c8877 | 1083 | * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready |
bogdanm | 84:0b3ab51c8877 | 1084 | * @arg RCC_FLAG_MSIRDY: MSI oscillator clock ready |
bogdanm | 84:0b3ab51c8877 | 1085 | * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready |
bogdanm | 84:0b3ab51c8877 | 1086 | * @arg RCC_FLAG_PLLRDY: PLL clock ready |
bogdanm | 84:0b3ab51c8877 | 1087 | * @arg RCC_FLAG_LSECSS: LSE oscillator clock CSS detected |
bogdanm | 84:0b3ab51c8877 | 1088 | * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready |
bogdanm | 84:0b3ab51c8877 | 1089 | * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready |
bogdanm | 84:0b3ab51c8877 | 1090 | * @arg RCC_FLAG_OBLRST: Option Byte Loader (OBL) reset |
bogdanm | 84:0b3ab51c8877 | 1091 | * @arg RCC_FLAG_PINRST: Pin reset |
bogdanm | 84:0b3ab51c8877 | 1092 | * @arg RCC_FLAG_PORRST: POR/PDR reset |
bogdanm | 84:0b3ab51c8877 | 1093 | * @arg RCC_FLAG_SFTRST: Software reset |
bogdanm | 84:0b3ab51c8877 | 1094 | * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset |
bogdanm | 84:0b3ab51c8877 | 1095 | * @arg RCC_FLAG_WWDGRST: Window Watchdog reset |
bogdanm | 84:0b3ab51c8877 | 1096 | * @arg RCC_FLAG_LPWRRST: Low Power reset |
bogdanm | 84:0b3ab51c8877 | 1097 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
bogdanm | 84:0b3ab51c8877 | 1098 | */ |
bogdanm | 84:0b3ab51c8877 | 1099 | #define RCC_FLAG_MASK ((uint8_t)0x1F) |
bogdanm | 84:0b3ab51c8877 | 1100 | #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5) == 1)? RCC->CR :((((__FLAG__) >> 5) == 2) ? RCC->CSR :((((__FLAG__) >> 5) == 3)? \ |
bogdanm | 84:0b3ab51c8877 | 1101 | RCC->CRRCR :RCC->CIFR))) & ((uint32_t)1 << ((__FLAG__) & RCC_FLAG_MASK))) != 0 ) ? 1 : 0 ) |
bogdanm | 84:0b3ab51c8877 | 1102 | |
bogdanm | 84:0b3ab51c8877 | 1103 | /** |
bogdanm | 84:0b3ab51c8877 | 1104 | * @} |
bogdanm | 84:0b3ab51c8877 | 1105 | */ |
bogdanm | 84:0b3ab51c8877 | 1106 | |
bogdanm | 84:0b3ab51c8877 | 1107 | #define __RCC_PLLSRC() ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> POSITION_VAL(RCC_PLLCFGR_PLLSRC)) |
bogdanm | 84:0b3ab51c8877 | 1108 | /** |
bogdanm | 84:0b3ab51c8877 | 1109 | * @} |
bogdanm | 84:0b3ab51c8877 | 1110 | */ |
bogdanm | 84:0b3ab51c8877 | 1111 | |
bogdanm | 84:0b3ab51c8877 | 1112 | /* Include RCC HAL Extension module */ |
bogdanm | 84:0b3ab51c8877 | 1113 | #include "stm32L0xx_hal_rcc_ex.h" |
bogdanm | 84:0b3ab51c8877 | 1114 | |
bogdanm | 84:0b3ab51c8877 | 1115 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 84:0b3ab51c8877 | 1116 | /* Initialization and de-initialization methods ******************************/ |
bogdanm | 84:0b3ab51c8877 | 1117 | void HAL_RCC_DeInit(void); |
bogdanm | 84:0b3ab51c8877 | 1118 | HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct); |
bogdanm | 84:0b3ab51c8877 | 1119 | HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency); |
bogdanm | 84:0b3ab51c8877 | 1120 | |
bogdanm | 84:0b3ab51c8877 | 1121 | /* Peripheral Control methods ************************************************/ |
bogdanm | 84:0b3ab51c8877 | 1122 | void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv); |
bogdanm | 84:0b3ab51c8877 | 1123 | void HAL_RCC_EnableCSS(void); |
bogdanm | 84:0b3ab51c8877 | 1124 | uint32_t HAL_RCC_GetSysClockFreq(void); |
bogdanm | 84:0b3ab51c8877 | 1125 | uint32_t HAL_RCC_GetHCLKFreq(void); |
bogdanm | 84:0b3ab51c8877 | 1126 | uint32_t HAL_RCC_GetPCLK1Freq(void); |
bogdanm | 84:0b3ab51c8877 | 1127 | uint32_t HAL_RCC_GetPCLK2Freq(void); |
bogdanm | 84:0b3ab51c8877 | 1128 | void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct); |
bogdanm | 84:0b3ab51c8877 | 1129 | void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency); |
bogdanm | 84:0b3ab51c8877 | 1130 | |
bogdanm | 84:0b3ab51c8877 | 1131 | /* CSS NMI IRQ handler */ |
bogdanm | 84:0b3ab51c8877 | 1132 | void HAL_RCC_NMI_IRQHandler(void); |
bogdanm | 84:0b3ab51c8877 | 1133 | |
bogdanm | 84:0b3ab51c8877 | 1134 | /* User Callbacks in non blocking mode (IT mode) */ |
bogdanm | 84:0b3ab51c8877 | 1135 | void HAL_RCC_CCSCallback(void); |
bogdanm | 84:0b3ab51c8877 | 1136 | |
bogdanm | 84:0b3ab51c8877 | 1137 | /** |
bogdanm | 84:0b3ab51c8877 | 1138 | * @} |
bogdanm | 84:0b3ab51c8877 | 1139 | */ |
bogdanm | 84:0b3ab51c8877 | 1140 | |
bogdanm | 84:0b3ab51c8877 | 1141 | /** |
bogdanm | 84:0b3ab51c8877 | 1142 | * @} |
bogdanm | 84:0b3ab51c8877 | 1143 | */ |
bogdanm | 84:0b3ab51c8877 | 1144 | |
bogdanm | 84:0b3ab51c8877 | 1145 | #ifdef __cplusplus |
bogdanm | 84:0b3ab51c8877 | 1146 | } |
bogdanm | 84:0b3ab51c8877 | 1147 | #endif |
bogdanm | 84:0b3ab51c8877 | 1148 | |
bogdanm | 84:0b3ab51c8877 | 1149 | #endif /* __STM32L0xx_HAL_RCC_H */ |
bogdanm | 84:0b3ab51c8877 | 1150 | |
bogdanm | 84:0b3ab51c8877 | 1151 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |