mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
mbed_official
Date:
Tue Mar 15 15:45:10 2016 +0000
Revision:
92:49efcc0d6d73
Parent:
87:444eeba2d452
Child:
144:ef7eb2e8f9f7
Synchronized with git revision 287c3b71f4ca9dab98d9d768f8cac688491abb56

Full URL: https://github.com/mbedmicro/mbed/commit/287c3b71f4ca9dab98d9d768f8cac688491abb56/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:9b334a45a8ff 1 /**
bogdanm 0:9b334a45a8ff 2 ******************************************************************************
bogdanm 0:9b334a45a8ff 3 * @file stm32f4xx_hal_rcc.h
bogdanm 0:9b334a45a8ff 4 * @author MCD Application Team
mbed_official 19:112740acecfa 5 * @version V1.4.1
mbed_official 19:112740acecfa 6 * @date 09-October-2015
bogdanm 0:9b334a45a8ff 7 * @brief Header file of RCC HAL module.
bogdanm 0:9b334a45a8ff 8 ******************************************************************************
bogdanm 0:9b334a45a8ff 9 * @attention
bogdanm 0:9b334a45a8ff 10 *
bogdanm 0:9b334a45a8ff 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
bogdanm 0:9b334a45a8ff 12 *
bogdanm 0:9b334a45a8ff 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 0:9b334a45a8ff 14 * are permitted provided that the following conditions are met:
bogdanm 0:9b334a45a8ff 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 0:9b334a45a8ff 16 * this list of conditions and the following disclaimer.
bogdanm 0:9b334a45a8ff 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 0:9b334a45a8ff 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 0:9b334a45a8ff 19 * and/or other materials provided with the distribution.
bogdanm 0:9b334a45a8ff 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 0:9b334a45a8ff 21 * may be used to endorse or promote products derived from this software
bogdanm 0:9b334a45a8ff 22 * without specific prior written permission.
bogdanm 0:9b334a45a8ff 23 *
bogdanm 0:9b334a45a8ff 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 0:9b334a45a8ff 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 0:9b334a45a8ff 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 0:9b334a45a8ff 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 0:9b334a45a8ff 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 0:9b334a45a8ff 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 0:9b334a45a8ff 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 0:9b334a45a8ff 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 0:9b334a45a8ff 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 0:9b334a45a8ff 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 0:9b334a45a8ff 34 *
bogdanm 0:9b334a45a8ff 35 ******************************************************************************
bogdanm 0:9b334a45a8ff 36 */
bogdanm 0:9b334a45a8ff 37
bogdanm 0:9b334a45a8ff 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 0:9b334a45a8ff 39 #ifndef __STM32F4xx_HAL_RCC_H
bogdanm 0:9b334a45a8ff 40 #define __STM32F4xx_HAL_RCC_H
bogdanm 0:9b334a45a8ff 41
bogdanm 0:9b334a45a8ff 42 #ifdef __cplusplus
bogdanm 0:9b334a45a8ff 43 extern "C" {
bogdanm 0:9b334a45a8ff 44 #endif
bogdanm 0:9b334a45a8ff 45
bogdanm 0:9b334a45a8ff 46 /* Includes ------------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 47 #include "stm32f4xx_hal_def.h"
bogdanm 0:9b334a45a8ff 48
bogdanm 0:9b334a45a8ff 49 /* Include RCC HAL Extended module */
bogdanm 0:9b334a45a8ff 50 /* (include on top of file since RCC structures are defined in extended file) */
bogdanm 0:9b334a45a8ff 51 #include "stm32f4xx_hal_rcc_ex.h"
bogdanm 0:9b334a45a8ff 52
bogdanm 0:9b334a45a8ff 53 /** @addtogroup STM32F4xx_HAL_Driver
bogdanm 0:9b334a45a8ff 54 * @{
bogdanm 0:9b334a45a8ff 55 */
bogdanm 0:9b334a45a8ff 56
bogdanm 0:9b334a45a8ff 57 /** @addtogroup RCC
bogdanm 0:9b334a45a8ff 58 * @{
bogdanm 0:9b334a45a8ff 59 */
bogdanm 0:9b334a45a8ff 60
bogdanm 0:9b334a45a8ff 61 /* Exported types ------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 62 /** @defgroup RCC_Exported_Types RCC Exported Types
bogdanm 0:9b334a45a8ff 63 * @{
bogdanm 0:9b334a45a8ff 64 */
bogdanm 0:9b334a45a8ff 65
bogdanm 0:9b334a45a8ff 66 /**
bogdanm 0:9b334a45a8ff 67 * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
bogdanm 0:9b334a45a8ff 68 */
bogdanm 0:9b334a45a8ff 69 typedef struct
bogdanm 0:9b334a45a8ff 70 {
bogdanm 0:9b334a45a8ff 71 uint32_t OscillatorType; /*!< The oscillators to be configured.
bogdanm 0:9b334a45a8ff 72 This parameter can be a value of @ref RCC_Oscillator_Type */
bogdanm 0:9b334a45a8ff 73
bogdanm 0:9b334a45a8ff 74 uint32_t HSEState; /*!< The new state of the HSE.
bogdanm 0:9b334a45a8ff 75 This parameter can be a value of @ref RCC_HSE_Config */
bogdanm 0:9b334a45a8ff 76
bogdanm 0:9b334a45a8ff 77 uint32_t LSEState; /*!< The new state of the LSE.
bogdanm 0:9b334a45a8ff 78 This parameter can be a value of @ref RCC_LSE_Config */
bogdanm 0:9b334a45a8ff 79
bogdanm 0:9b334a45a8ff 80 uint32_t HSIState; /*!< The new state of the HSI.
bogdanm 0:9b334a45a8ff 81 This parameter can be a value of @ref RCC_HSI_Config */
bogdanm 0:9b334a45a8ff 82
bogdanm 0:9b334a45a8ff 83 uint32_t HSICalibrationValue; /*!< The calibration trimming value.
bogdanm 0:9b334a45a8ff 84 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
bogdanm 0:9b334a45a8ff 85
bogdanm 0:9b334a45a8ff 86 uint32_t LSIState; /*!< The new state of the LSI.
bogdanm 0:9b334a45a8ff 87 This parameter can be a value of @ref RCC_LSI_Config */
bogdanm 0:9b334a45a8ff 88
bogdanm 0:9b334a45a8ff 89 RCC_PLLInitTypeDef PLL; /*!< PLL structure parameters */
bogdanm 0:9b334a45a8ff 90
bogdanm 0:9b334a45a8ff 91 }RCC_OscInitTypeDef;
bogdanm 0:9b334a45a8ff 92
bogdanm 0:9b334a45a8ff 93 /**
bogdanm 0:9b334a45a8ff 94 * @brief RCC System, AHB and APB busses clock configuration structure definition
bogdanm 0:9b334a45a8ff 95 */
bogdanm 0:9b334a45a8ff 96 typedef struct
bogdanm 0:9b334a45a8ff 97 {
bogdanm 0:9b334a45a8ff 98 uint32_t ClockType; /*!< The clock to be configured.
bogdanm 0:9b334a45a8ff 99 This parameter can be a value of @ref RCC_System_Clock_Type */
bogdanm 0:9b334a45a8ff 100
bogdanm 0:9b334a45a8ff 101 uint32_t SYSCLKSource; /*!< The clock source (SYSCLKS) used as system clock.
bogdanm 0:9b334a45a8ff 102 This parameter can be a value of @ref RCC_System_Clock_Source */
bogdanm 0:9b334a45a8ff 103
bogdanm 0:9b334a45a8ff 104 uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
bogdanm 0:9b334a45a8ff 105 This parameter can be a value of @ref RCC_AHB_Clock_Source */
bogdanm 0:9b334a45a8ff 106
bogdanm 0:9b334a45a8ff 107 uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
bogdanm 0:9b334a45a8ff 108 This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
bogdanm 0:9b334a45a8ff 109
bogdanm 0:9b334a45a8ff 110 uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
bogdanm 0:9b334a45a8ff 111 This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
bogdanm 0:9b334a45a8ff 112
bogdanm 0:9b334a45a8ff 113 }RCC_ClkInitTypeDef;
bogdanm 0:9b334a45a8ff 114
bogdanm 0:9b334a45a8ff 115 /**
bogdanm 0:9b334a45a8ff 116 * @}
bogdanm 0:9b334a45a8ff 117 */
bogdanm 0:9b334a45a8ff 118
bogdanm 0:9b334a45a8ff 119 /* Exported constants --------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 120 /** @defgroup RCC_Exported_Constants RCC Exported Constants
bogdanm 0:9b334a45a8ff 121 * @{
bogdanm 0:9b334a45a8ff 122 */
bogdanm 0:9b334a45a8ff 123
bogdanm 0:9b334a45a8ff 124 /** @defgroup RCC_Oscillator_Type Oscillator Type
bogdanm 0:9b334a45a8ff 125 * @{
bogdanm 0:9b334a45a8ff 126 */
bogdanm 0:9b334a45a8ff 127 #define RCC_OSCILLATORTYPE_NONE ((uint32_t)0x00000000)
bogdanm 0:9b334a45a8ff 128 #define RCC_OSCILLATORTYPE_HSE ((uint32_t)0x00000001)
bogdanm 0:9b334a45a8ff 129 #define RCC_OSCILLATORTYPE_HSI ((uint32_t)0x00000002)
bogdanm 0:9b334a45a8ff 130 #define RCC_OSCILLATORTYPE_LSE ((uint32_t)0x00000004)
bogdanm 0:9b334a45a8ff 131 #define RCC_OSCILLATORTYPE_LSI ((uint32_t)0x00000008)
bogdanm 0:9b334a45a8ff 132 /**
bogdanm 0:9b334a45a8ff 133 * @}
bogdanm 0:9b334a45a8ff 134 */
bogdanm 0:9b334a45a8ff 135
bogdanm 0:9b334a45a8ff 136 /** @defgroup RCC_HSE_Config HSE Config
bogdanm 0:9b334a45a8ff 137 * @{
bogdanm 0:9b334a45a8ff 138 */
bogdanm 0:9b334a45a8ff 139 #define RCC_HSE_OFF ((uint8_t)0x00)
bogdanm 0:9b334a45a8ff 140 #define RCC_HSE_ON ((uint8_t)0x01)
bogdanm 0:9b334a45a8ff 141 #define RCC_HSE_BYPASS ((uint8_t)0x05)
bogdanm 0:9b334a45a8ff 142 /**
bogdanm 0:9b334a45a8ff 143 * @}
bogdanm 0:9b334a45a8ff 144 */
bogdanm 0:9b334a45a8ff 145
bogdanm 0:9b334a45a8ff 146 /** @defgroup RCC_LSE_Config LSE Config
bogdanm 0:9b334a45a8ff 147 * @{
bogdanm 0:9b334a45a8ff 148 */
bogdanm 0:9b334a45a8ff 149 #define RCC_LSE_OFF ((uint8_t)0x00)
bogdanm 0:9b334a45a8ff 150 #define RCC_LSE_ON ((uint8_t)0x01)
bogdanm 0:9b334a45a8ff 151 #define RCC_LSE_BYPASS ((uint8_t)0x05)
bogdanm 0:9b334a45a8ff 152 /**
bogdanm 0:9b334a45a8ff 153 * @}
bogdanm 0:9b334a45a8ff 154 */
bogdanm 0:9b334a45a8ff 155
bogdanm 0:9b334a45a8ff 156 /** @defgroup RCC_HSI_Config HSI Config
bogdanm 0:9b334a45a8ff 157 * @{
bogdanm 0:9b334a45a8ff 158 */
bogdanm 0:9b334a45a8ff 159 #define RCC_HSI_OFF ((uint8_t)0x00)
bogdanm 0:9b334a45a8ff 160 #define RCC_HSI_ON ((uint8_t)0x01)
bogdanm 0:9b334a45a8ff 161 /**
bogdanm 0:9b334a45a8ff 162 * @}
bogdanm 0:9b334a45a8ff 163 */
bogdanm 0:9b334a45a8ff 164
bogdanm 0:9b334a45a8ff 165 /** @defgroup RCC_LSI_Config LSI Config
bogdanm 0:9b334a45a8ff 166 * @{
bogdanm 0:9b334a45a8ff 167 */
bogdanm 0:9b334a45a8ff 168 #define RCC_LSI_OFF ((uint8_t)0x00)
bogdanm 0:9b334a45a8ff 169 #define RCC_LSI_ON ((uint8_t)0x01)
bogdanm 0:9b334a45a8ff 170 /**
bogdanm 0:9b334a45a8ff 171 * @}
bogdanm 0:9b334a45a8ff 172 */
bogdanm 0:9b334a45a8ff 173
bogdanm 0:9b334a45a8ff 174 /** @defgroup RCC_PLL_Config PLL Config
bogdanm 0:9b334a45a8ff 175 * @{
bogdanm 0:9b334a45a8ff 176 */
bogdanm 0:9b334a45a8ff 177 #define RCC_PLL_NONE ((uint8_t)0x00)
bogdanm 0:9b334a45a8ff 178 #define RCC_PLL_OFF ((uint8_t)0x01)
bogdanm 0:9b334a45a8ff 179 #define RCC_PLL_ON ((uint8_t)0x02)
bogdanm 0:9b334a45a8ff 180 /**
bogdanm 0:9b334a45a8ff 181 * @}
bogdanm 0:9b334a45a8ff 182 */
bogdanm 0:9b334a45a8ff 183
bogdanm 0:9b334a45a8ff 184 /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
bogdanm 0:9b334a45a8ff 185 * @{
bogdanm 0:9b334a45a8ff 186 */
bogdanm 0:9b334a45a8ff 187 #define RCC_PLLP_DIV2 ((uint32_t)0x00000002)
bogdanm 0:9b334a45a8ff 188 #define RCC_PLLP_DIV4 ((uint32_t)0x00000004)
bogdanm 0:9b334a45a8ff 189 #define RCC_PLLP_DIV6 ((uint32_t)0x00000006)
bogdanm 0:9b334a45a8ff 190 #define RCC_PLLP_DIV8 ((uint32_t)0x00000008)
bogdanm 0:9b334a45a8ff 191 /**
bogdanm 0:9b334a45a8ff 192 * @}
bogdanm 0:9b334a45a8ff 193 */
bogdanm 0:9b334a45a8ff 194
bogdanm 0:9b334a45a8ff 195 /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
bogdanm 0:9b334a45a8ff 196 * @{
bogdanm 0:9b334a45a8ff 197 */
bogdanm 0:9b334a45a8ff 198 #define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI
bogdanm 0:9b334a45a8ff 199 #define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE
bogdanm 0:9b334a45a8ff 200 /**
bogdanm 0:9b334a45a8ff 201 * @}
bogdanm 0:9b334a45a8ff 202 */
bogdanm 0:9b334a45a8ff 203
bogdanm 0:9b334a45a8ff 204 /** @defgroup RCC_System_Clock_Type System Clock Type
bogdanm 0:9b334a45a8ff 205 * @{
bogdanm 0:9b334a45a8ff 206 */
bogdanm 0:9b334a45a8ff 207 #define RCC_CLOCKTYPE_SYSCLK ((uint32_t)0x00000001)
bogdanm 0:9b334a45a8ff 208 #define RCC_CLOCKTYPE_HCLK ((uint32_t)0x00000002)
bogdanm 0:9b334a45a8ff 209 #define RCC_CLOCKTYPE_PCLK1 ((uint32_t)0x00000004)
bogdanm 0:9b334a45a8ff 210 #define RCC_CLOCKTYPE_PCLK2 ((uint32_t)0x00000008)
bogdanm 0:9b334a45a8ff 211 /**
bogdanm 0:9b334a45a8ff 212 * @}
bogdanm 0:9b334a45a8ff 213 */
bogdanm 0:9b334a45a8ff 214
bogdanm 0:9b334a45a8ff 215 /** @defgroup RCC_System_Clock_Source System Clock Source
bogdanm 0:9b334a45a8ff 216 * @{
bogdanm 0:9b334a45a8ff 217 */
bogdanm 0:9b334a45a8ff 218 #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI
bogdanm 0:9b334a45a8ff 219 #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE
bogdanm 0:9b334a45a8ff 220 #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL
bogdanm 0:9b334a45a8ff 221 #define RCC_SYSCLKSOURCE_PLLRCLK ((uint32_t)(RCC_CFGR_SW_0 | RCC_CFGR_SW_1))
bogdanm 0:9b334a45a8ff 222 /**
bogdanm 0:9b334a45a8ff 223 * @}
bogdanm 0:9b334a45a8ff 224 */
bogdanm 0:9b334a45a8ff 225
bogdanm 0:9b334a45a8ff 226 /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
bogdanm 0:9b334a45a8ff 227 * @{
bogdanm 0:9b334a45a8ff 228 */
bogdanm 0:9b334a45a8ff 229 #define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
bogdanm 0:9b334a45a8ff 230 #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
bogdanm 0:9b334a45a8ff 231 #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
bogdanm 0:9b334a45a8ff 232 #define RCC_SYSCLKSOURCE_STATUS_PLLRCLK ((uint32_t)(RCC_CFGR_SW_0 | RCC_CFGR_SW_1)) /*!< PLLR used as system clock */
bogdanm 0:9b334a45a8ff 233 /**
bogdanm 0:9b334a45a8ff 234 * @}
bogdanm 0:9b334a45a8ff 235 */
bogdanm 0:9b334a45a8ff 236
bogdanm 0:9b334a45a8ff 237 /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
bogdanm 0:9b334a45a8ff 238 * @{
bogdanm 0:9b334a45a8ff 239 */
bogdanm 0:9b334a45a8ff 240 #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1
bogdanm 0:9b334a45a8ff 241 #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2
bogdanm 0:9b334a45a8ff 242 #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4
bogdanm 0:9b334a45a8ff 243 #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8
bogdanm 0:9b334a45a8ff 244 #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16
bogdanm 0:9b334a45a8ff 245 #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64
bogdanm 0:9b334a45a8ff 246 #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128
bogdanm 0:9b334a45a8ff 247 #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256
bogdanm 0:9b334a45a8ff 248 #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512
bogdanm 0:9b334a45a8ff 249 /**
bogdanm 0:9b334a45a8ff 250 * @}
bogdanm 0:9b334a45a8ff 251 */
bogdanm 0:9b334a45a8ff 252
bogdanm 0:9b334a45a8ff 253 /** @defgroup RCC_APB1_APB2_Clock_Source APB1/APB2 Clock Source
bogdanm 0:9b334a45a8ff 254 * @{
bogdanm 0:9b334a45a8ff 255 */
bogdanm 0:9b334a45a8ff 256 #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1
bogdanm 0:9b334a45a8ff 257 #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2
bogdanm 0:9b334a45a8ff 258 #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4
bogdanm 0:9b334a45a8ff 259 #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8
bogdanm 0:9b334a45a8ff 260 #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16
bogdanm 0:9b334a45a8ff 261 /**
bogdanm 0:9b334a45a8ff 262 * @}
bogdanm 0:9b334a45a8ff 263 */
bogdanm 0:9b334a45a8ff 264
bogdanm 0:9b334a45a8ff 265 /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
bogdanm 0:9b334a45a8ff 266 * @{
bogdanm 0:9b334a45a8ff 267 */
bogdanm 0:9b334a45a8ff 268 #define RCC_RTCCLKSOURCE_LSE ((uint32_t)0x00000100)
bogdanm 0:9b334a45a8ff 269 #define RCC_RTCCLKSOURCE_LSI ((uint32_t)0x00000200)
bogdanm 0:9b334a45a8ff 270 #define RCC_RTCCLKSOURCE_HSE_DIV2 ((uint32_t)0x00020300)
bogdanm 0:9b334a45a8ff 271 #define RCC_RTCCLKSOURCE_HSE_DIV3 ((uint32_t)0x00030300)
bogdanm 0:9b334a45a8ff 272 #define RCC_RTCCLKSOURCE_HSE_DIV4 ((uint32_t)0x00040300)
bogdanm 0:9b334a45a8ff 273 #define RCC_RTCCLKSOURCE_HSE_DIV5 ((uint32_t)0x00050300)
bogdanm 0:9b334a45a8ff 274 #define RCC_RTCCLKSOURCE_HSE_DIV6 ((uint32_t)0x00060300)
bogdanm 0:9b334a45a8ff 275 #define RCC_RTCCLKSOURCE_HSE_DIV7 ((uint32_t)0x00070300)
bogdanm 0:9b334a45a8ff 276 #define RCC_RTCCLKSOURCE_HSE_DIV8 ((uint32_t)0x00080300)
bogdanm 0:9b334a45a8ff 277 #define RCC_RTCCLKSOURCE_HSE_DIV9 ((uint32_t)0x00090300)
bogdanm 0:9b334a45a8ff 278 #define RCC_RTCCLKSOURCE_HSE_DIV10 ((uint32_t)0x000A0300)
bogdanm 0:9b334a45a8ff 279 #define RCC_RTCCLKSOURCE_HSE_DIV11 ((uint32_t)0x000B0300)
bogdanm 0:9b334a45a8ff 280 #define RCC_RTCCLKSOURCE_HSE_DIV12 ((uint32_t)0x000C0300)
bogdanm 0:9b334a45a8ff 281 #define RCC_RTCCLKSOURCE_HSE_DIV13 ((uint32_t)0x000D0300)
bogdanm 0:9b334a45a8ff 282 #define RCC_RTCCLKSOURCE_HSE_DIV14 ((uint32_t)0x000E0300)
bogdanm 0:9b334a45a8ff 283 #define RCC_RTCCLKSOURCE_HSE_DIV15 ((uint32_t)0x000F0300)
bogdanm 0:9b334a45a8ff 284 #define RCC_RTCCLKSOURCE_HSE_DIV16 ((uint32_t)0x00100300)
bogdanm 0:9b334a45a8ff 285 #define RCC_RTCCLKSOURCE_HSE_DIV17 ((uint32_t)0x00110300)
bogdanm 0:9b334a45a8ff 286 #define RCC_RTCCLKSOURCE_HSE_DIV18 ((uint32_t)0x00120300)
bogdanm 0:9b334a45a8ff 287 #define RCC_RTCCLKSOURCE_HSE_DIV19 ((uint32_t)0x00130300)
bogdanm 0:9b334a45a8ff 288 #define RCC_RTCCLKSOURCE_HSE_DIV20 ((uint32_t)0x00140300)
bogdanm 0:9b334a45a8ff 289 #define RCC_RTCCLKSOURCE_HSE_DIV21 ((uint32_t)0x00150300)
bogdanm 0:9b334a45a8ff 290 #define RCC_RTCCLKSOURCE_HSE_DIV22 ((uint32_t)0x00160300)
bogdanm 0:9b334a45a8ff 291 #define RCC_RTCCLKSOURCE_HSE_DIV23 ((uint32_t)0x00170300)
bogdanm 0:9b334a45a8ff 292 #define RCC_RTCCLKSOURCE_HSE_DIV24 ((uint32_t)0x00180300)
bogdanm 0:9b334a45a8ff 293 #define RCC_RTCCLKSOURCE_HSE_DIV25 ((uint32_t)0x00190300)
bogdanm 0:9b334a45a8ff 294 #define RCC_RTCCLKSOURCE_HSE_DIV26 ((uint32_t)0x001A0300)
bogdanm 0:9b334a45a8ff 295 #define RCC_RTCCLKSOURCE_HSE_DIV27 ((uint32_t)0x001B0300)
bogdanm 0:9b334a45a8ff 296 #define RCC_RTCCLKSOURCE_HSE_DIV28 ((uint32_t)0x001C0300)
bogdanm 0:9b334a45a8ff 297 #define RCC_RTCCLKSOURCE_HSE_DIV29 ((uint32_t)0x001D0300)
bogdanm 0:9b334a45a8ff 298 #define RCC_RTCCLKSOURCE_HSE_DIV30 ((uint32_t)0x001E0300)
bogdanm 0:9b334a45a8ff 299 #define RCC_RTCCLKSOURCE_HSE_DIV31 ((uint32_t)0x001F0300)
bogdanm 0:9b334a45a8ff 300 /**
bogdanm 0:9b334a45a8ff 301 * @}
bogdanm 0:9b334a45a8ff 302 */
bogdanm 0:9b334a45a8ff 303
bogdanm 0:9b334a45a8ff 304 /** @defgroup RCC_MCO_Index MCO Index
bogdanm 0:9b334a45a8ff 305 * @{
bogdanm 0:9b334a45a8ff 306 */
bogdanm 0:9b334a45a8ff 307 #define RCC_MCO1 ((uint32_t)0x00000000)
bogdanm 0:9b334a45a8ff 308 #define RCC_MCO2 ((uint32_t)0x00000001)
bogdanm 0:9b334a45a8ff 309 /**
bogdanm 0:9b334a45a8ff 310 * @}
bogdanm 0:9b334a45a8ff 311 */
bogdanm 0:9b334a45a8ff 312
bogdanm 0:9b334a45a8ff 313 /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
bogdanm 0:9b334a45a8ff 314 * @{
bogdanm 0:9b334a45a8ff 315 */
bogdanm 0:9b334a45a8ff 316 #define RCC_MCO1SOURCE_HSI ((uint32_t)0x00000000)
bogdanm 0:9b334a45a8ff 317 #define RCC_MCO1SOURCE_LSE RCC_CFGR_MCO1_0
bogdanm 0:9b334a45a8ff 318 #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCO1_1
bogdanm 0:9b334a45a8ff 319 #define RCC_MCO1SOURCE_PLLCLK RCC_CFGR_MCO1
bogdanm 0:9b334a45a8ff 320 /**
bogdanm 0:9b334a45a8ff 321 * @}
bogdanm 0:9b334a45a8ff 322 */
bogdanm 0:9b334a45a8ff 323
bogdanm 0:9b334a45a8ff 324 /** @defgroup RCC_MCOx_Clock_Prescaler MCOx Clock Prescaler
bogdanm 0:9b334a45a8ff 325 * @{
bogdanm 0:9b334a45a8ff 326 */
bogdanm 0:9b334a45a8ff 327 #define RCC_MCODIV_1 ((uint32_t)0x00000000)
bogdanm 0:9b334a45a8ff 328 #define RCC_MCODIV_2 RCC_CFGR_MCO1PRE_2
bogdanm 0:9b334a45a8ff 329 #define RCC_MCODIV_3 ((uint32_t)RCC_CFGR_MCO1PRE_0 | RCC_CFGR_MCO1PRE_2)
bogdanm 0:9b334a45a8ff 330 #define RCC_MCODIV_4 ((uint32_t)RCC_CFGR_MCO1PRE_1 | RCC_CFGR_MCO1PRE_2)
bogdanm 0:9b334a45a8ff 331 #define RCC_MCODIV_5 RCC_CFGR_MCO1PRE
bogdanm 0:9b334a45a8ff 332 /**
bogdanm 0:9b334a45a8ff 333 * @}
bogdanm 0:9b334a45a8ff 334 */
bogdanm 0:9b334a45a8ff 335
bogdanm 0:9b334a45a8ff 336 /** @defgroup RCC_Interrupt Interrupts
bogdanm 0:9b334a45a8ff 337 * @{
bogdanm 0:9b334a45a8ff 338 */
bogdanm 0:9b334a45a8ff 339 #define RCC_IT_LSIRDY ((uint8_t)0x01)
bogdanm 0:9b334a45a8ff 340 #define RCC_IT_LSERDY ((uint8_t)0x02)
bogdanm 0:9b334a45a8ff 341 #define RCC_IT_HSIRDY ((uint8_t)0x04)
bogdanm 0:9b334a45a8ff 342 #define RCC_IT_HSERDY ((uint8_t)0x08)
bogdanm 0:9b334a45a8ff 343 #define RCC_IT_PLLRDY ((uint8_t)0x10)
bogdanm 0:9b334a45a8ff 344 #define RCC_IT_PLLI2SRDY ((uint8_t)0x20)
bogdanm 0:9b334a45a8ff 345 #define RCC_IT_CSS ((uint8_t)0x80)
bogdanm 0:9b334a45a8ff 346 /**
bogdanm 0:9b334a45a8ff 347 * @}
bogdanm 0:9b334a45a8ff 348 */
bogdanm 0:9b334a45a8ff 349
bogdanm 0:9b334a45a8ff 350 /** @defgroup RCC_Flag Flags
bogdanm 0:9b334a45a8ff 351 * Elements values convention: 0XXYYYYYb
bogdanm 0:9b334a45a8ff 352 * - YYYYY : Flag position in the register
bogdanm 0:9b334a45a8ff 353 * - 0XX : Register index
bogdanm 0:9b334a45a8ff 354 * - 01: CR register
bogdanm 0:9b334a45a8ff 355 * - 10: BDCR register
bogdanm 0:9b334a45a8ff 356 * - 11: CSR register
bogdanm 0:9b334a45a8ff 357 * @{
bogdanm 0:9b334a45a8ff 358 */
bogdanm 0:9b334a45a8ff 359 /* Flags in the CR register */
bogdanm 0:9b334a45a8ff 360 #define RCC_FLAG_HSIRDY ((uint8_t)0x21)
bogdanm 0:9b334a45a8ff 361 #define RCC_FLAG_HSERDY ((uint8_t)0x31)
bogdanm 0:9b334a45a8ff 362 #define RCC_FLAG_PLLRDY ((uint8_t)0x39)
bogdanm 0:9b334a45a8ff 363 #define RCC_FLAG_PLLI2SRDY ((uint8_t)0x3B)
bogdanm 0:9b334a45a8ff 364
bogdanm 0:9b334a45a8ff 365 /* Flags in the BDCR register */
bogdanm 0:9b334a45a8ff 366 #define RCC_FLAG_LSERDY ((uint8_t)0x41)
bogdanm 0:9b334a45a8ff 367
bogdanm 0:9b334a45a8ff 368 /* Flags in the CSR register */
bogdanm 0:9b334a45a8ff 369 #define RCC_FLAG_LSIRDY ((uint8_t)0x61)
bogdanm 0:9b334a45a8ff 370 #define RCC_FLAG_BORRST ((uint8_t)0x79)
bogdanm 0:9b334a45a8ff 371 #define RCC_FLAG_PINRST ((uint8_t)0x7A)
bogdanm 0:9b334a45a8ff 372 #define RCC_FLAG_PORRST ((uint8_t)0x7B)
bogdanm 0:9b334a45a8ff 373 #define RCC_FLAG_SFTRST ((uint8_t)0x7C)
bogdanm 0:9b334a45a8ff 374 #define RCC_FLAG_IWDGRST ((uint8_t)0x7D)
bogdanm 0:9b334a45a8ff 375 #define RCC_FLAG_WWDGRST ((uint8_t)0x7E)
bogdanm 0:9b334a45a8ff 376 #define RCC_FLAG_LPWRRST ((uint8_t)0x7F)
bogdanm 0:9b334a45a8ff 377 /**
bogdanm 0:9b334a45a8ff 378 * @}
bogdanm 0:9b334a45a8ff 379 */
bogdanm 0:9b334a45a8ff 380
bogdanm 0:9b334a45a8ff 381 /**
bogdanm 0:9b334a45a8ff 382 * @}
bogdanm 0:9b334a45a8ff 383 */
bogdanm 0:9b334a45a8ff 384
bogdanm 0:9b334a45a8ff 385 /* Exported macro ------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 386 /** @defgroup RCC_Exported_Macros RCC Exported Macros
bogdanm 0:9b334a45a8ff 387 * @{
bogdanm 0:9b334a45a8ff 388 */
bogdanm 0:9b334a45a8ff 389
bogdanm 0:9b334a45a8ff 390 /** @defgroup RCC_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
bogdanm 0:9b334a45a8ff 391 * @brief Enable or disable the AHB1 peripheral clock.
bogdanm 0:9b334a45a8ff 392 * @note After reset, the peripheral clock (used for registers read/write access)
bogdanm 0:9b334a45a8ff 393 * is disabled and the application software has to enable this clock before
bogdanm 0:9b334a45a8ff 394 * using it.
bogdanm 0:9b334a45a8ff 395 * @{
bogdanm 0:9b334a45a8ff 396 */
bogdanm 0:9b334a45a8ff 397 #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 398 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 399 SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOAEN);\
bogdanm 0:9b334a45a8ff 400 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 401 tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOAEN);\
bogdanm 0:9b334a45a8ff 402 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 403 } while(0)
bogdanm 0:9b334a45a8ff 404 #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 405 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 406 SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOBEN);\
bogdanm 0:9b334a45a8ff 407 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 408 tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOBEN);\
bogdanm 0:9b334a45a8ff 409 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 410 } while(0)
bogdanm 0:9b334a45a8ff 411 #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 412 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 413 SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);\
bogdanm 0:9b334a45a8ff 414 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 415 tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);\
bogdanm 0:9b334a45a8ff 416 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 417 } while(0)
bogdanm 0:9b334a45a8ff 418 #define __HAL_RCC_GPIOH_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 419 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 420 SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOHEN);\
bogdanm 0:9b334a45a8ff 421 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 422 tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOHEN);\
bogdanm 0:9b334a45a8ff 423 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 424 } while(0)
bogdanm 0:9b334a45a8ff 425 #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 426 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 427 SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
bogdanm 0:9b334a45a8ff 428 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 429 tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
bogdanm 0:9b334a45a8ff 430 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 431 } while(0)
bogdanm 0:9b334a45a8ff 432 #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 433 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 434 SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN);\
bogdanm 0:9b334a45a8ff 435 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 436 tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN);\
bogdanm 0:9b334a45a8ff 437 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 438 } while(0)
bogdanm 0:9b334a45a8ff 439
bogdanm 0:9b334a45a8ff 440 #define __HAL_RCC_GPIOA_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOAEN))
bogdanm 0:9b334a45a8ff 441 #define __HAL_RCC_GPIOB_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOBEN))
bogdanm 0:9b334a45a8ff 442 #define __HAL_RCC_GPIOC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOCEN))
bogdanm 0:9b334a45a8ff 443 #define __HAL_RCC_GPIOH_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOHEN))
bogdanm 0:9b334a45a8ff 444 #define __HAL_RCC_DMA1_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA1EN))
bogdanm 0:9b334a45a8ff 445 #define __HAL_RCC_DMA2_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA2EN))
bogdanm 0:9b334a45a8ff 446
bogdanm 0:9b334a45a8ff 447 /**
bogdanm 0:9b334a45a8ff 448 * @}
bogdanm 0:9b334a45a8ff 449 */
bogdanm 0:9b334a45a8ff 450
bogdanm 0:9b334a45a8ff 451 /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
bogdanm 0:9b334a45a8ff 452 * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
bogdanm 0:9b334a45a8ff 453 * @note After reset, the peripheral clock (used for registers read/write access)
bogdanm 0:9b334a45a8ff 454 * is disabled and the application software has to enable this clock before
bogdanm 0:9b334a45a8ff 455 * using it.
bogdanm 0:9b334a45a8ff 456 * @{
bogdanm 0:9b334a45a8ff 457 */
bogdanm 0:9b334a45a8ff 458 #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 459 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 460 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
bogdanm 0:9b334a45a8ff 461 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 462 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
bogdanm 0:9b334a45a8ff 463 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 464 } while(0)
bogdanm 0:9b334a45a8ff 465 #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 466 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 467 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
bogdanm 0:9b334a45a8ff 468 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 469 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
bogdanm 0:9b334a45a8ff 470 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 471 } while(0)
bogdanm 0:9b334a45a8ff 472 #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 473 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 474 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
bogdanm 0:9b334a45a8ff 475 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 476 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
bogdanm 0:9b334a45a8ff 477 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 478 } while(0)
bogdanm 0:9b334a45a8ff 479 #define __HAL_RCC_USART2_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 480 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 481 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
bogdanm 0:9b334a45a8ff 482 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 483 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
bogdanm 0:9b334a45a8ff 484 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 485 } while(0)
bogdanm 0:9b334a45a8ff 486 #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 487 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 488 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
bogdanm 0:9b334a45a8ff 489 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 490 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
bogdanm 0:9b334a45a8ff 491 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 492 } while(0)
bogdanm 0:9b334a45a8ff 493 #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 494 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 495 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
bogdanm 0:9b334a45a8ff 496 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 497 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
bogdanm 0:9b334a45a8ff 498 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 499 } while(0)
bogdanm 0:9b334a45a8ff 500 #define __HAL_RCC_PWR_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 501 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 502 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
bogdanm 0:9b334a45a8ff 503 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 504 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
bogdanm 0:9b334a45a8ff 505 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 506 } while(0)
mbed_official 19:112740acecfa 507
bogdanm 0:9b334a45a8ff 508 #define __HAL_RCC_TIM5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM5EN))
bogdanm 0:9b334a45a8ff 509 #define __HAL_RCC_WWDG_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_WWDGEN))
bogdanm 0:9b334a45a8ff 510 #define __HAL_RCC_SPI2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI2EN))
bogdanm 0:9b334a45a8ff 511 #define __HAL_RCC_USART2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART2EN))
bogdanm 0:9b334a45a8ff 512 #define __HAL_RCC_I2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C1EN))
bogdanm 0:9b334a45a8ff 513 #define __HAL_RCC_I2C2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN))
bogdanm 0:9b334a45a8ff 514 #define __HAL_RCC_PWR_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN))
bogdanm 0:9b334a45a8ff 515 /**
bogdanm 0:9b334a45a8ff 516 * @}
bogdanm 0:9b334a45a8ff 517 */
bogdanm 0:9b334a45a8ff 518
bogdanm 0:9b334a45a8ff 519 /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
bogdanm 0:9b334a45a8ff 520 * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
bogdanm 0:9b334a45a8ff 521 * @note After reset, the peripheral clock (used for registers read/write access)
bogdanm 0:9b334a45a8ff 522 * is disabled and the application software has to enable this clock before
bogdanm 0:9b334a45a8ff 523 * using it.
bogdanm 0:9b334a45a8ff 524 * @{
bogdanm 0:9b334a45a8ff 525 */
bogdanm 0:9b334a45a8ff 526 #define __HAL_RCC_TIM1_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 527 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 528 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
bogdanm 0:9b334a45a8ff 529 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 530 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
bogdanm 0:9b334a45a8ff 531 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 532 } while(0)
bogdanm 0:9b334a45a8ff 533 #define __HAL_RCC_USART1_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 534 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 535 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
bogdanm 0:9b334a45a8ff 536 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 537 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
bogdanm 0:9b334a45a8ff 538 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 539 } while(0)
bogdanm 0:9b334a45a8ff 540 #define __HAL_RCC_USART6_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 541 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 542 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
bogdanm 0:9b334a45a8ff 543 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 544 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
bogdanm 0:9b334a45a8ff 545 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 546 } while(0)
bogdanm 0:9b334a45a8ff 547 #define __HAL_RCC_ADC1_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 548 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 549 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
bogdanm 0:9b334a45a8ff 550 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 551 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
bogdanm 0:9b334a45a8ff 552 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 553 } while(0)
bogdanm 0:9b334a45a8ff 554 #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 555 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 556 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
bogdanm 0:9b334a45a8ff 557 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 558 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
bogdanm 0:9b334a45a8ff 559 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 560 } while(0)
bogdanm 0:9b334a45a8ff 561 #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 562 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 563 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
bogdanm 0:9b334a45a8ff 564 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 565 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
bogdanm 0:9b334a45a8ff 566 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 567 } while(0)
bogdanm 0:9b334a45a8ff 568 #define __HAL_RCC_TIM9_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 569 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 570 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
bogdanm 0:9b334a45a8ff 571 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 572 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
bogdanm 0:9b334a45a8ff 573 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 574 } while(0)
bogdanm 0:9b334a45a8ff 575 #define __HAL_RCC_TIM11_CLK_ENABLE() do { \
bogdanm 0:9b334a45a8ff 576 __IO uint32_t tmpreg; \
bogdanm 0:9b334a45a8ff 577 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
bogdanm 0:9b334a45a8ff 578 /* Delay after an RCC peripheral clock enabling */ \
bogdanm 0:9b334a45a8ff 579 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
bogdanm 0:9b334a45a8ff 580 UNUSED(tmpreg); \
bogdanm 0:9b334a45a8ff 581 } while(0)
bogdanm 0:9b334a45a8ff 582
bogdanm 0:9b334a45a8ff 583 #define __HAL_RCC_TIM1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM1EN))
bogdanm 0:9b334a45a8ff 584 #define __HAL_RCC_USART1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
bogdanm 0:9b334a45a8ff 585 #define __HAL_RCC_USART6_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART6EN))
bogdanm 0:9b334a45a8ff 586 #define __HAL_RCC_ADC1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC1EN))
bogdanm 0:9b334a45a8ff 587 #define __HAL_RCC_SPI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI1EN))
bogdanm 0:9b334a45a8ff 588 #define __HAL_RCC_SYSCFG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SYSCFGEN))
bogdanm 0:9b334a45a8ff 589 #define __HAL_RCC_TIM9_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM9EN))
bogdanm 0:9b334a45a8ff 590 #define __HAL_RCC_TIM11_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM11EN))
bogdanm 0:9b334a45a8ff 591 /**
bogdanm 0:9b334a45a8ff 592 * @}
bogdanm 0:9b334a45a8ff 593 */
bogdanm 0:9b334a45a8ff 594
bogdanm 0:9b334a45a8ff 595 /** @defgroup RCC_AHB1_Force_Release_Reset AHB1 Force Release Reset
bogdanm 0:9b334a45a8ff 596 * @brief Force or release AHB1 peripheral reset.
bogdanm 0:9b334a45a8ff 597 * @{
bogdanm 0:9b334a45a8ff 598 */
bogdanm 0:9b334a45a8ff 599 #define __HAL_RCC_AHB1_FORCE_RESET() (RCC->AHB1RSTR = 0xFFFFFFFF)
bogdanm 0:9b334a45a8ff 600 #define __HAL_RCC_GPIOA_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOARST))
bogdanm 0:9b334a45a8ff 601 #define __HAL_RCC_GPIOB_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOBRST))
bogdanm 0:9b334a45a8ff 602 #define __HAL_RCC_GPIOC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOCRST))
bogdanm 0:9b334a45a8ff 603 #define __HAL_RCC_GPIOH_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOHRST))
bogdanm 0:9b334a45a8ff 604 #define __HAL_RCC_DMA1_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA1RST))
bogdanm 0:9b334a45a8ff 605 #define __HAL_RCC_DMA2_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA2RST))
bogdanm 0:9b334a45a8ff 606
bogdanm 0:9b334a45a8ff 607 #define __HAL_RCC_AHB1_RELEASE_RESET() (RCC->AHB1RSTR = 0x00)
bogdanm 0:9b334a45a8ff 608 #define __HAL_RCC_GPIOA_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOARST))
bogdanm 0:9b334a45a8ff 609 #define __HAL_RCC_GPIOB_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOBRST))
bogdanm 0:9b334a45a8ff 610 #define __HAL_RCC_GPIOC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOCRST))
bogdanm 0:9b334a45a8ff 611 #define __HAL_RCC_GPIOH_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOHRST))
bogdanm 0:9b334a45a8ff 612 #define __HAL_RCC_DMA1_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA1RST))
bogdanm 0:9b334a45a8ff 613 #define __HAL_RCC_DMA2_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA2RST))
bogdanm 0:9b334a45a8ff 614 /**
bogdanm 0:9b334a45a8ff 615 * @}
bogdanm 0:9b334a45a8ff 616 */
bogdanm 0:9b334a45a8ff 617
bogdanm 0:9b334a45a8ff 618 /** @defgroup RCC_APB1_Force_Release_Reset APB1 Force Release Reset
bogdanm 0:9b334a45a8ff 619 * @brief Force or release APB1 peripheral reset.
bogdanm 0:9b334a45a8ff 620 * @{
bogdanm 0:9b334a45a8ff 621 */
bogdanm 0:9b334a45a8ff 622 #define __HAL_RCC_APB1_FORCE_RESET() (RCC->APB1RSTR = 0xFFFFFFFF)
bogdanm 0:9b334a45a8ff 623 #define __HAL_RCC_TIM5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM5RST))
bogdanm 0:9b334a45a8ff 624 #define __HAL_RCC_WWDG_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
bogdanm 0:9b334a45a8ff 625 #define __HAL_RCC_SPI2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
bogdanm 0:9b334a45a8ff 626 #define __HAL_RCC_USART2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
bogdanm 0:9b334a45a8ff 627 #define __HAL_RCC_I2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
bogdanm 0:9b334a45a8ff 628 #define __HAL_RCC_I2C2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
bogdanm 0:9b334a45a8ff 629 #define __HAL_RCC_PWR_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
bogdanm 0:9b334a45a8ff 630
bogdanm 0:9b334a45a8ff 631 #define __HAL_RCC_APB1_RELEASE_RESET() (RCC->APB1RSTR = 0x00)
bogdanm 0:9b334a45a8ff 632 #define __HAL_RCC_TIM5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM5RST))
bogdanm 0:9b334a45a8ff 633 #define __HAL_RCC_WWDG_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
bogdanm 0:9b334a45a8ff 634 #define __HAL_RCC_SPI2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI2RST))
bogdanm 0:9b334a45a8ff 635 #define __HAL_RCC_USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
bogdanm 0:9b334a45a8ff 636 #define __HAL_RCC_I2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C1RST))
bogdanm 0:9b334a45a8ff 637 #define __HAL_RCC_I2C2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C2RST))
bogdanm 0:9b334a45a8ff 638 #define __HAL_RCC_PWR_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_PWRRST))
bogdanm 0:9b334a45a8ff 639 /**
bogdanm 0:9b334a45a8ff 640 * @}
bogdanm 0:9b334a45a8ff 641 */
bogdanm 0:9b334a45a8ff 642
bogdanm 0:9b334a45a8ff 643 /** @defgroup RCC_APB2_Force_Release_Reset APB2 Force Release Reset
bogdanm 0:9b334a45a8ff 644 * @brief Force or release APB2 peripheral reset.
bogdanm 0:9b334a45a8ff 645 * @{
bogdanm 0:9b334a45a8ff 646 */
bogdanm 0:9b334a45a8ff 647 #define __HAL_RCC_APB2_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFF)
bogdanm 0:9b334a45a8ff 648 #define __HAL_RCC_TIM1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM1RST))
bogdanm 0:9b334a45a8ff 649 #define __HAL_RCC_USART1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
bogdanm 0:9b334a45a8ff 650 #define __HAL_RCC_USART6_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART6RST))
bogdanm 0:9b334a45a8ff 651 #define __HAL_RCC_ADC_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_ADCRST))
bogdanm 0:9b334a45a8ff 652 #define __HAL_RCC_SPI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
bogdanm 0:9b334a45a8ff 653 #define __HAL_RCC_SYSCFG_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SYSCFGRST))
bogdanm 0:9b334a45a8ff 654 #define __HAL_RCC_TIM9_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM9RST))
bogdanm 0:9b334a45a8ff 655 #define __HAL_RCC_TIM11_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM11RST))
bogdanm 0:9b334a45a8ff 656
bogdanm 0:9b334a45a8ff 657 #define __HAL_RCC_APB2_RELEASE_RESET() (RCC->APB2RSTR = 0x00)
bogdanm 0:9b334a45a8ff 658 #define __HAL_RCC_TIM1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM1RST))
bogdanm 0:9b334a45a8ff 659 #define __HAL_RCC_USART1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART1RST))
bogdanm 0:9b334a45a8ff 660 #define __HAL_RCC_USART6_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART6RST))
bogdanm 0:9b334a45a8ff 661 #define __HAL_RCC_ADC_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_ADCRST))
bogdanm 0:9b334a45a8ff 662 #define __HAL_RCC_SPI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI1RST))
bogdanm 0:9b334a45a8ff 663 #define __HAL_RCC_SYSCFG_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SYSCFGRST))
bogdanm 0:9b334a45a8ff 664 #define __HAL_RCC_TIM9_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM9RST))
bogdanm 0:9b334a45a8ff 665 #define __HAL_RCC_TIM11_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM11RST))
bogdanm 0:9b334a45a8ff 666 /**
bogdanm 0:9b334a45a8ff 667 * @}
bogdanm 0:9b334a45a8ff 668 */
bogdanm 0:9b334a45a8ff 669
bogdanm 0:9b334a45a8ff 670 /** @defgroup RCC_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
bogdanm 0:9b334a45a8ff 671 * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
bogdanm 0:9b334a45a8ff 672 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
bogdanm 0:9b334a45a8ff 673 * power consumption.
bogdanm 0:9b334a45a8ff 674 * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
bogdanm 0:9b334a45a8ff 675 * @note By default, all peripheral clocks are enabled during SLEEP mode.
bogdanm 0:9b334a45a8ff 676 * @{
bogdanm 0:9b334a45a8ff 677 */
bogdanm 0:9b334a45a8ff 678 #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOALPEN))
bogdanm 0:9b334a45a8ff 679 #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOBLPEN))
bogdanm 0:9b334a45a8ff 680 #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOCLPEN))
bogdanm 0:9b334a45a8ff 681 #define __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOHLPEN))
bogdanm 0:9b334a45a8ff 682 #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA1LPEN))
bogdanm 0:9b334a45a8ff 683 #define __HAL_RCC_DMA2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA2LPEN))
bogdanm 0:9b334a45a8ff 684
bogdanm 0:9b334a45a8ff 685 #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOALPEN))
bogdanm 0:9b334a45a8ff 686 #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOBLPEN))
bogdanm 0:9b334a45a8ff 687 #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOCLPEN))
bogdanm 0:9b334a45a8ff 688 #define __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOHLPEN))
bogdanm 0:9b334a45a8ff 689 #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA1LPEN))
bogdanm 0:9b334a45a8ff 690 #define __HAL_RCC_DMA2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA2LPEN))
bogdanm 0:9b334a45a8ff 691 /**
bogdanm 0:9b334a45a8ff 692 * @}
bogdanm 0:9b334a45a8ff 693 */
bogdanm 0:9b334a45a8ff 694
bogdanm 0:9b334a45a8ff 695 /** @defgroup RCC_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
bogdanm 0:9b334a45a8ff 696 * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
bogdanm 0:9b334a45a8ff 697 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
bogdanm 0:9b334a45a8ff 698 * power consumption.
bogdanm 0:9b334a45a8ff 699 * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
bogdanm 0:9b334a45a8ff 700 * @note By default, all peripheral clocks are enabled during SLEEP mode.
bogdanm 0:9b334a45a8ff 701 * @{
bogdanm 0:9b334a45a8ff 702 */
bogdanm 0:9b334a45a8ff 703 #define __HAL_RCC_TIM5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM5LPEN))
bogdanm 0:9b334a45a8ff 704 #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_WWDGLPEN))
bogdanm 0:9b334a45a8ff 705 #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI2LPEN))
bogdanm 0:9b334a45a8ff 706 #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART2LPEN))
bogdanm 0:9b334a45a8ff 707 #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C1LPEN))
bogdanm 0:9b334a45a8ff 708 #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C2LPEN))
bogdanm 0:9b334a45a8ff 709 #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_PWRLPEN))
bogdanm 0:9b334a45a8ff 710
bogdanm 0:9b334a45a8ff 711 #define __HAL_RCC_TIM5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM5LPEN))
bogdanm 0:9b334a45a8ff 712 #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_WWDGLPEN))
bogdanm 0:9b334a45a8ff 713 #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI2LPEN))
bogdanm 0:9b334a45a8ff 714 #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART2LPEN))
bogdanm 0:9b334a45a8ff 715 #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C1LPEN))
bogdanm 0:9b334a45a8ff 716 #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C2LPEN))
bogdanm 0:9b334a45a8ff 717 #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_PWRLPEN))
bogdanm 0:9b334a45a8ff 718 /**
bogdanm 0:9b334a45a8ff 719 * @}
bogdanm 0:9b334a45a8ff 720 */
bogdanm 0:9b334a45a8ff 721
bogdanm 0:9b334a45a8ff 722 /** @defgroup RCC_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
bogdanm 0:9b334a45a8ff 723 * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
bogdanm 0:9b334a45a8ff 724 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
bogdanm 0:9b334a45a8ff 725 * power consumption.
bogdanm 0:9b334a45a8ff 726 * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
bogdanm 0:9b334a45a8ff 727 * @note By default, all peripheral clocks are enabled during SLEEP mode.
bogdanm 0:9b334a45a8ff 728 * @{
bogdanm 0:9b334a45a8ff 729 */
bogdanm 0:9b334a45a8ff 730 #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM1LPEN))
bogdanm 0:9b334a45a8ff 731 #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_USART1LPEN))
bogdanm 0:9b334a45a8ff 732 #define __HAL_RCC_USART6_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_USART6LPEN))
bogdanm 0:9b334a45a8ff 733 #define __HAL_RCC_ADC1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC1LPEN))
bogdanm 0:9b334a45a8ff 734 #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI1LPEN))
bogdanm 0:9b334a45a8ff 735 #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SYSCFGLPEN))
bogdanm 0:9b334a45a8ff 736 #define __HAL_RCC_TIM9_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM9LPEN))
bogdanm 0:9b334a45a8ff 737 #define __HAL_RCC_TIM11_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM11LPEN))
bogdanm 0:9b334a45a8ff 738
bogdanm 0:9b334a45a8ff 739 #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM1LPEN))
bogdanm 0:9b334a45a8ff 740 #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_USART1LPEN))
bogdanm 0:9b334a45a8ff 741 #define __HAL_RCC_USART6_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_USART6LPEN))
bogdanm 0:9b334a45a8ff 742 #define __HAL_RCC_ADC1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC1LPEN))
bogdanm 0:9b334a45a8ff 743 #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI1LPEN))
bogdanm 0:9b334a45a8ff 744 #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SYSCFGLPEN))
bogdanm 0:9b334a45a8ff 745 #define __HAL_RCC_TIM9_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM9LPEN))
bogdanm 0:9b334a45a8ff 746 #define __HAL_RCC_TIM11_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM11LPEN))
bogdanm 0:9b334a45a8ff 747 /**
bogdanm 0:9b334a45a8ff 748 * @}
bogdanm 0:9b334a45a8ff 749 */
bogdanm 0:9b334a45a8ff 750
bogdanm 0:9b334a45a8ff 751 /** @defgroup RCC_HSI_Configuration HSI Configuration
bogdanm 0:9b334a45a8ff 752 * @{
bogdanm 0:9b334a45a8ff 753 */
bogdanm 0:9b334a45a8ff 754
bogdanm 0:9b334a45a8ff 755 /** @brief Macros to enable or disable the Internal High Speed oscillator (HSI).
bogdanm 0:9b334a45a8ff 756 * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
bogdanm 0:9b334a45a8ff 757 * It is used (enabled by hardware) as system clock source after startup
bogdanm 0:9b334a45a8ff 758 * from Reset, wake-up from STOP and STANDBY mode, or in case of failure
bogdanm 0:9b334a45a8ff 759 * of the HSE used directly or indirectly as system clock (if the Clock
bogdanm 0:9b334a45a8ff 760 * Security System CSS is enabled).
bogdanm 0:9b334a45a8ff 761 * @note HSI can not be stopped if it is used as system clock source. In this case,
bogdanm 0:9b334a45a8ff 762 * you have to select another source of the system clock then stop the HSI.
bogdanm 0:9b334a45a8ff 763 * @note After enabling the HSI, the application software should wait on HSIRDY
bogdanm 0:9b334a45a8ff 764 * flag to be set indicating that HSI clock is stable and can be used as
bogdanm 0:9b334a45a8ff 765 * system clock source.
bogdanm 0:9b334a45a8ff 766 * This parameter can be: ENABLE or DISABLE.
bogdanm 0:9b334a45a8ff 767 * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
bogdanm 0:9b334a45a8ff 768 * clock cycles.
bogdanm 0:9b334a45a8ff 769 */
bogdanm 0:9b334a45a8ff 770 #define __HAL_RCC_HSI_ENABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = ENABLE)
bogdanm 0:9b334a45a8ff 771 #define __HAL_RCC_HSI_DISABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = DISABLE)
bogdanm 0:9b334a45a8ff 772
bogdanm 0:9b334a45a8ff 773 /** @brief Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
bogdanm 0:9b334a45a8ff 774 * @note The calibration is used to compensate for the variations in voltage
bogdanm 0:9b334a45a8ff 775 * and temperature that influence the frequency of the internal HSI RC.
bogdanm 0:9b334a45a8ff 776 * @param __HSICalibrationValue__: specifies the calibration trimming value.
bogdanm 0:9b334a45a8ff 777 * This parameter must be a number between 0 and 0x1F.
bogdanm 0:9b334a45a8ff 778 */
bogdanm 0:9b334a45a8ff 779 #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICalibrationValue__) (MODIFY_REG(RCC->CR,\
bogdanm 0:9b334a45a8ff 780 RCC_CR_HSITRIM, (uint32_t)(__HSICalibrationValue__) << POSITION_VAL(RCC_CR_HSITRIM)))
bogdanm 0:9b334a45a8ff 781 /**
bogdanm 0:9b334a45a8ff 782 * @}
bogdanm 0:9b334a45a8ff 783 */
bogdanm 0:9b334a45a8ff 784
bogdanm 0:9b334a45a8ff 785 /** @defgroup RCC_LSI_Configuration LSI Configuration
bogdanm 0:9b334a45a8ff 786 * @{
bogdanm 0:9b334a45a8ff 787 */
bogdanm 0:9b334a45a8ff 788
bogdanm 0:9b334a45a8ff 789 /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
bogdanm 0:9b334a45a8ff 790 * @note After enabling the LSI, the application software should wait on
bogdanm 0:9b334a45a8ff 791 * LSIRDY flag to be set indicating that LSI clock is stable and can
bogdanm 0:9b334a45a8ff 792 * be used to clock the IWDG and/or the RTC.
bogdanm 0:9b334a45a8ff 793 * @note LSI can not be disabled if the IWDG is running.
bogdanm 0:9b334a45a8ff 794 * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
bogdanm 0:9b334a45a8ff 795 * clock cycles.
bogdanm 0:9b334a45a8ff 796 */
bogdanm 0:9b334a45a8ff 797 #define __HAL_RCC_LSI_ENABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = ENABLE)
bogdanm 0:9b334a45a8ff 798 #define __HAL_RCC_LSI_DISABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = DISABLE)
bogdanm 0:9b334a45a8ff 799 /**
bogdanm 0:9b334a45a8ff 800 * @}
bogdanm 0:9b334a45a8ff 801 */
bogdanm 0:9b334a45a8ff 802
bogdanm 0:9b334a45a8ff 803 /** @defgroup RCC_HSE_Configuration HSE Configuration
bogdanm 0:9b334a45a8ff 804 * @{
bogdanm 0:9b334a45a8ff 805 */
bogdanm 0:9b334a45a8ff 806
bogdanm 0:9b334a45a8ff 807 /**
bogdanm 0:9b334a45a8ff 808 * @brief Macro to configure the External High Speed oscillator (HSE).
bogdanm 0:9b334a45a8ff 809 * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not supported by this macro.
bogdanm 0:9b334a45a8ff 810 * User should request a transition to HSE Off first and then HSE On or HSE Bypass.
bogdanm 0:9b334a45a8ff 811 * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
bogdanm 0:9b334a45a8ff 812 * software should wait on HSERDY flag to be set indicating that HSE clock
bogdanm 0:9b334a45a8ff 813 * is stable and can be used to clock the PLL and/or system clock.
bogdanm 0:9b334a45a8ff 814 * @note HSE state can not be changed if it is used directly or through the
bogdanm 0:9b334a45a8ff 815 * PLL as system clock. In this case, you have to select another source
bogdanm 0:9b334a45a8ff 816 * of the system clock then change the HSE state (ex. disable it).
bogdanm 0:9b334a45a8ff 817 * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
bogdanm 0:9b334a45a8ff 818 * @note This function reset the CSSON bit, so if the clock security system(CSS)
bogdanm 0:9b334a45a8ff 819 * was previously enabled you have to enable it again after calling this
bogdanm 0:9b334a45a8ff 820 * function.
bogdanm 0:9b334a45a8ff 821 * @param __STATE__: specifies the new state of the HSE.
bogdanm 0:9b334a45a8ff 822 * This parameter can be one of the following values:
bogdanm 0:9b334a45a8ff 823 * @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after
bogdanm 0:9b334a45a8ff 824 * 6 HSE oscillator clock cycles.
bogdanm 0:9b334a45a8ff 825 * @arg RCC_HSE_ON: turn ON the HSE oscillator.
bogdanm 0:9b334a45a8ff 826 * @arg RCC_HSE_BYPASS: HSE oscillator bypassed with external clock.
bogdanm 0:9b334a45a8ff 827 */
bogdanm 0:9b334a45a8ff 828 #define __HAL_RCC_HSE_CONFIG(__STATE__) (*(__IO uint8_t *) RCC_CR_BYTE2_ADDRESS = (__STATE__))
bogdanm 0:9b334a45a8ff 829 /**
bogdanm 0:9b334a45a8ff 830 * @}
bogdanm 0:9b334a45a8ff 831 */
bogdanm 0:9b334a45a8ff 832
bogdanm 0:9b334a45a8ff 833 /** @defgroup RCC_LSE_Configuration LSE Configuration
bogdanm 0:9b334a45a8ff 834 * @{
bogdanm 0:9b334a45a8ff 835 */
bogdanm 0:9b334a45a8ff 836
bogdanm 0:9b334a45a8ff 837 /**
bogdanm 0:9b334a45a8ff 838 * @brief Macro to configure the External Low Speed oscillator (LSE).
bogdanm 0:9b334a45a8ff 839 * @note Transition LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro.
bogdanm 0:9b334a45a8ff 840 * User should request a transition to LSE Off first and then LSE On or LSE Bypass.
bogdanm 0:9b334a45a8ff 841 * @note As the LSE is in the Backup domain and write access is denied to
bogdanm 0:9b334a45a8ff 842 * this domain after reset, you have to enable write access using
bogdanm 0:9b334a45a8ff 843 * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
bogdanm 0:9b334a45a8ff 844 * (to be done once after reset).
bogdanm 0:9b334a45a8ff 845 * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
bogdanm 0:9b334a45a8ff 846 * software should wait on LSERDY flag to be set indicating that LSE clock
bogdanm 0:9b334a45a8ff 847 * is stable and can be used to clock the RTC.
bogdanm 0:9b334a45a8ff 848 * @param __STATE__: specifies the new state of the LSE.
bogdanm 0:9b334a45a8ff 849 * This parameter can be one of the following values:
bogdanm 0:9b334a45a8ff 850 * @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after
bogdanm 0:9b334a45a8ff 851 * 6 LSE oscillator clock cycles.
bogdanm 0:9b334a45a8ff 852 * @arg RCC_LSE_ON: turn ON the LSE oscillator.
bogdanm 0:9b334a45a8ff 853 * @arg RCC_LSE_BYPASS: LSE oscillator bypassed with external clock.
bogdanm 0:9b334a45a8ff 854 */
bogdanm 0:9b334a45a8ff 855 #define __HAL_RCC_LSE_CONFIG(__STATE__) (*(__IO uint8_t *) RCC_BDCR_BYTE0_ADDRESS = (__STATE__))
bogdanm 0:9b334a45a8ff 856
bogdanm 0:9b334a45a8ff 857 /**
bogdanm 0:9b334a45a8ff 858 * @}
bogdanm 0:9b334a45a8ff 859 */
bogdanm 0:9b334a45a8ff 860
bogdanm 0:9b334a45a8ff 861 /** @defgroup RCC_Internal_RTC_Clock_Configuration RTC Clock Configuration
bogdanm 0:9b334a45a8ff 862 * @{
bogdanm 0:9b334a45a8ff 863 */
bogdanm 0:9b334a45a8ff 864
bogdanm 0:9b334a45a8ff 865 /** @brief Macros to enable or disable the RTC clock.
bogdanm 0:9b334a45a8ff 866 * @note These macros must be used only after the RTC clock source was selected.
bogdanm 0:9b334a45a8ff 867 */
bogdanm 0:9b334a45a8ff 868 #define __HAL_RCC_RTC_ENABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = ENABLE)
bogdanm 0:9b334a45a8ff 869 #define __HAL_RCC_RTC_DISABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = DISABLE)
bogdanm 0:9b334a45a8ff 870
bogdanm 0:9b334a45a8ff 871 /** @brief Macros to configure the RTC clock (RTCCLK).
bogdanm 0:9b334a45a8ff 872 * @note As the RTC clock configuration bits are in the Backup domain and write
bogdanm 0:9b334a45a8ff 873 * access is denied to this domain after reset, you have to enable write
bogdanm 0:9b334a45a8ff 874 * access using the Power Backup Access macro before to configure
bogdanm 0:9b334a45a8ff 875 * the RTC clock source (to be done once after reset).
bogdanm 0:9b334a45a8ff 876 * @note Once the RTC clock is configured it can't be changed unless the
bogdanm 0:9b334a45a8ff 877 * Backup domain is reset using __HAL_RCC_BackupReset_RELEASE() macro, or by
bogdanm 0:9b334a45a8ff 878 * a Power On Reset (POR).
bogdanm 0:9b334a45a8ff 879 * @param __RTCCLKSource__: specifies the RTC clock source.
bogdanm 0:9b334a45a8ff 880 * This parameter can be one of the following values:
bogdanm 0:9b334a45a8ff 881 * @arg RCC_RTCCLKSOURCE_LSE: LSE selected as RTC clock.
bogdanm 0:9b334a45a8ff 882 * @arg RCC_RTCCLKSOURCE_LSI: LSI selected as RTC clock.
bogdanm 0:9b334a45a8ff 883 * @arg RCC_RTCCLKSOURCE_HSE_DIVx: HSE clock divided by x selected
bogdanm 0:9b334a45a8ff 884 * as RTC clock, where x:[2,31]
bogdanm 0:9b334a45a8ff 885 * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
bogdanm 0:9b334a45a8ff 886 * work in STOP and STANDBY modes, and can be used as wake-up source.
bogdanm 0:9b334a45a8ff 887 * However, when the HSE clock is used as RTC clock source, the RTC
bogdanm 0:9b334a45a8ff 888 * cannot be used in STOP and STANDBY modes.
bogdanm 0:9b334a45a8ff 889 * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
bogdanm 0:9b334a45a8ff 890 * RTC clock source).
bogdanm 0:9b334a45a8ff 891 */
bogdanm 0:9b334a45a8ff 892 #define __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__) (((__RTCCLKSource__) & RCC_BDCR_RTCSEL) == RCC_BDCR_RTCSEL) ? \
bogdanm 0:9b334a45a8ff 893 MODIFY_REG(RCC->CFGR, RCC_CFGR_RTCPRE, ((__RTCCLKSource__) & 0xFFFFCFF)) : CLEAR_BIT(RCC->CFGR, RCC_CFGR_RTCPRE)
bogdanm 0:9b334a45a8ff 894
bogdanm 0:9b334a45a8ff 895 #define __HAL_RCC_RTC_CONFIG(__RTCCLKSource__) do { __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__); \
bogdanm 0:9b334a45a8ff 896 RCC->BDCR |= ((__RTCCLKSource__) & 0x00000FFF); \
bogdanm 0:9b334a45a8ff 897 } while (0)
bogdanm 0:9b334a45a8ff 898
bogdanm 0:9b334a45a8ff 899 /** @brief Macros to force or release the Backup domain reset.
bogdanm 0:9b334a45a8ff 900 * @note This function resets the RTC peripheral (including the backup registers)
bogdanm 0:9b334a45a8ff 901 * and the RTC clock source selection in RCC_CSR register.
bogdanm 0:9b334a45a8ff 902 * @note The BKPSRAM is not affected by this reset.
bogdanm 0:9b334a45a8ff 903 */
bogdanm 0:9b334a45a8ff 904 #define __HAL_RCC_BACKUPRESET_FORCE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = ENABLE)
bogdanm 0:9b334a45a8ff 905 #define __HAL_RCC_BACKUPRESET_RELEASE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = DISABLE)
bogdanm 0:9b334a45a8ff 906 /**
bogdanm 0:9b334a45a8ff 907 * @}
bogdanm 0:9b334a45a8ff 908 */
bogdanm 0:9b334a45a8ff 909
bogdanm 0:9b334a45a8ff 910 /** @defgroup RCC_PLL_Configuration PLL Configuration
bogdanm 0:9b334a45a8ff 911 * @{
bogdanm 0:9b334a45a8ff 912 */
bogdanm 0:9b334a45a8ff 913
bogdanm 0:9b334a45a8ff 914 /** @brief Macros to enable or disable the main PLL.
bogdanm 0:9b334a45a8ff 915 * @note After enabling the main PLL, the application software should wait on
bogdanm 0:9b334a45a8ff 916 * PLLRDY flag to be set indicating that PLL clock is stable and can
bogdanm 0:9b334a45a8ff 917 * be used as system clock source.
bogdanm 0:9b334a45a8ff 918 * @note The main PLL can not be disabled if it is used as system clock source
bogdanm 0:9b334a45a8ff 919 * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
bogdanm 0:9b334a45a8ff 920 */
bogdanm 0:9b334a45a8ff 921 #define __HAL_RCC_PLL_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
bogdanm 0:9b334a45a8ff 922 #define __HAL_RCC_PLL_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = DISABLE)
bogdanm 0:9b334a45a8ff 923
bogdanm 0:9b334a45a8ff 924 /** @brief Macro to configure the PLL clock source.
bogdanm 0:9b334a45a8ff 925 * @note This function must be used only when the main PLL is disabled.
bogdanm 0:9b334a45a8ff 926 * @param __PLLSOURCE__: specifies the PLL entry clock source.
bogdanm 0:9b334a45a8ff 927 * This parameter can be one of the following values:
bogdanm 0:9b334a45a8ff 928 * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
bogdanm 0:9b334a45a8ff 929 * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
bogdanm 0:9b334a45a8ff 930 *
bogdanm 0:9b334a45a8ff 931 */
bogdanm 0:9b334a45a8ff 932 #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
bogdanm 0:9b334a45a8ff 933
bogdanm 0:9b334a45a8ff 934 /** @brief Macro to configure the PLL multiplication factor.
bogdanm 0:9b334a45a8ff 935 * @note This function must be used only when the main PLL is disabled.
bogdanm 0:9b334a45a8ff 936 * @param __PLLM__: specifies the division factor for PLL VCO input clock
bogdanm 0:9b334a45a8ff 937 * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
bogdanm 0:9b334a45a8ff 938 * @note You have to set the PLLM parameter correctly to ensure that the VCO input
bogdanm 0:9b334a45a8ff 939 * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
bogdanm 0:9b334a45a8ff 940 * of 2 MHz to limit PLL jitter.
bogdanm 0:9b334a45a8ff 941 *
bogdanm 0:9b334a45a8ff 942 */
bogdanm 0:9b334a45a8ff 943 #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, (__PLLM__))
bogdanm 0:9b334a45a8ff 944 /**
bogdanm 0:9b334a45a8ff 945 * @}
mbed_official 19:112740acecfa 946 */
mbed_official 19:112740acecfa 947
bogdanm 0:9b334a45a8ff 948 /** @defgroup RCC_Get_Clock_source Get Clock source
bogdanm 0:9b334a45a8ff 949 * @{
bogdanm 0:9b334a45a8ff 950 */
bogdanm 0:9b334a45a8ff 951 /**
bogdanm 0:9b334a45a8ff 952 * @brief Macro to configure the system clock source.
bogdanm 0:9b334a45a8ff 953 * @param __RCC_SYSCLKSOURCE__: specifies the system clock source.
bogdanm 0:9b334a45a8ff 954 * This parameter can be one of the following values:
bogdanm 0:9b334a45a8ff 955 * - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
bogdanm 0:9b334a45a8ff 956 * - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
bogdanm 0:9b334a45a8ff 957 * - RCC_SYSCLKSOURCE_PLLCLK: PLL output is used as system clock source.
bogdanm 0:9b334a45a8ff 958 * - RCC_SYSCLKSOURCE_PLLRCLK: PLLR output is used as system clock source.
bogdanm 0:9b334a45a8ff 959 */
bogdanm 0:9b334a45a8ff 960 #define __HAL_RCC_SYSCLK_CONFIG(__RCC_SYSCLKSOURCE__) MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__RCC_SYSCLKSOURCE__))
bogdanm 0:9b334a45a8ff 961
bogdanm 0:9b334a45a8ff 962 /** @brief Macro to get the clock source used as system clock.
bogdanm 0:9b334a45a8ff 963 * @retval The clock source used as system clock. The returned value can be one
bogdanm 0:9b334a45a8ff 964 * of the following:
bogdanm 0:9b334a45a8ff 965 * - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
bogdanm 0:9b334a45a8ff 966 * - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
bogdanm 0:9b334a45a8ff 967 * - RCC_SYSCLKSOURCE_STATUS_PLLCLK: PLL used as system clock.
bogdanm 0:9b334a45a8ff 968 * - RCC_SYSCLKSOURCE_STATUS_PLLRCLK: PLLR used as system clock.
bogdanm 0:9b334a45a8ff 969 */
bogdanm 0:9b334a45a8ff 970 #define __HAL_RCC_GET_SYSCLK_SOURCE() ((uint32_t)(RCC->CFGR & RCC_CFGR_SWS))
bogdanm 0:9b334a45a8ff 971
bogdanm 0:9b334a45a8ff 972 /** @brief Macro to get the oscillator used as PLL clock source.
bogdanm 0:9b334a45a8ff 973 * @retval The oscillator used as PLL clock source. The returned value can be one
bogdanm 0:9b334a45a8ff 974 * of the following:
bogdanm 0:9b334a45a8ff 975 * - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source.
bogdanm 0:9b334a45a8ff 976 * - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source.
bogdanm 0:9b334a45a8ff 977 */
bogdanm 0:9b334a45a8ff 978 #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC))
bogdanm 0:9b334a45a8ff 979 /**
bogdanm 0:9b334a45a8ff 980 * @}
bogdanm 0:9b334a45a8ff 981 */
bogdanm 0:9b334a45a8ff 982
mbed_official 19:112740acecfa 983 /** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
mbed_official 19:112740acecfa 984 * @{
mbed_official 19:112740acecfa 985 */
mbed_official 19:112740acecfa 986
mbed_official 19:112740acecfa 987 /** @brief Macro to configure the MCO1 clock.
mbed_official 19:112740acecfa 988 * @param __MCOCLKSOURCE__ specifies the MCO clock source.
mbed_official 19:112740acecfa 989 * This parameter can be one of the following values:
mbed_official 19:112740acecfa 990 * @arg RCC_MCO1SOURCE_HSI: HSI clock selected as MCO1 source
mbed_official 19:112740acecfa 991 * @arg RCC_MCO1SOURCE_LSE: LSE clock selected as MCO1 source
mbed_official 19:112740acecfa 992 * @arg RCC_MCO1SOURCE_HSE: HSE clock selected as MCO1 source
mbed_official 19:112740acecfa 993 * @arg RCC_MCO1SOURCE_PLLCLK: main PLL clock selected as MCO1 source
mbed_official 19:112740acecfa 994 * @param __MCODIV__ specifies the MCO clock prescaler.
mbed_official 19:112740acecfa 995 * This parameter can be one of the following values:
mbed_official 19:112740acecfa 996 * @arg RCC_MCODIV_1: no division applied to MCOx clock
mbed_official 19:112740acecfa 997 * @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
mbed_official 19:112740acecfa 998 * @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
mbed_official 19:112740acecfa 999 * @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
mbed_official 19:112740acecfa 1000 * @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
mbed_official 19:112740acecfa 1001 */
mbed_official 19:112740acecfa 1002
mbed_official 19:112740acecfa 1003 #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
mbed_official 19:112740acecfa 1004 MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO1 | RCC_CFGR_MCO1PRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
mbed_official 19:112740acecfa 1005
mbed_official 19:112740acecfa 1006 /** @brief Macro to configure the MCO2 clock.
mbed_official 19:112740acecfa 1007 * @param __MCOCLKSOURCE__ specifies the MCO clock source.
mbed_official 19:112740acecfa 1008 * This parameter can be one of the following values:
mbed_official 19:112740acecfa 1009 * @arg RCC_MCO2SOURCE_SYSCLK: System clock (SYSCLK) selected as MCO2 source
mbed_official 19:112740acecfa 1010 * @arg RCC_MCO2SOURCE_PLLI2SCLK: PLLI2S clock selected as MCO2 source, available for all STM32F4 devices except STM32F410xx
mbed_official 19:112740acecfa 1011 * @arg RCC_MCO2SOURCE_I2SCLK: I2SCLK clock selected as MCO2 source, available only for STM32F410Rx devices
mbed_official 19:112740acecfa 1012 * @arg RCC_MCO2SOURCE_HSE: HSE clock selected as MCO2 source
mbed_official 19:112740acecfa 1013 * @arg RCC_MCO2SOURCE_PLLCLK: main PLL clock selected as MCO2 source
mbed_official 19:112740acecfa 1014 * @param __MCODIV__ specifies the MCO clock prescaler.
mbed_official 19:112740acecfa 1015 * This parameter can be one of the following values:
mbed_official 19:112740acecfa 1016 * @arg RCC_MCODIV_1: no division applied to MCOx clock
mbed_official 19:112740acecfa 1017 * @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
mbed_official 19:112740acecfa 1018 * @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
mbed_official 19:112740acecfa 1019 * @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
mbed_official 19:112740acecfa 1020 * @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
mbed_official 19:112740acecfa 1021 * @note For STM32F410Rx devices to output I2SCLK clock on MCO2 you should have
mbed_official 19:112740acecfa 1022 * at last one of the SPI clocks enabled (SPI1, SPI2 or SPI5).
mbed_official 19:112740acecfa 1023 */
mbed_official 19:112740acecfa 1024
mbed_official 19:112740acecfa 1025 #define __HAL_RCC_MCO2_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
mbed_official 19:112740acecfa 1026 MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO2 | RCC_CFGR_MCO2PRE), (__MCOCLKSOURCE__ | (__MCODIV__ << 3)));
mbed_official 19:112740acecfa 1027 /**
mbed_official 19:112740acecfa 1028 * @}
mbed_official 19:112740acecfa 1029 */
mbed_official 19:112740acecfa 1030
bogdanm 0:9b334a45a8ff 1031 /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
bogdanm 0:9b334a45a8ff 1032 * @brief macros to manage the specified RCC Flags and interrupts.
bogdanm 0:9b334a45a8ff 1033 * @{
bogdanm 0:9b334a45a8ff 1034 */
bogdanm 0:9b334a45a8ff 1035
bogdanm 0:9b334a45a8ff 1036 /** @brief Enable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to enable
bogdanm 0:9b334a45a8ff 1037 * the selected interrupts).
bogdanm 0:9b334a45a8ff 1038 * @param __INTERRUPT__: specifies the RCC interrupt sources to be enabled.
bogdanm 0:9b334a45a8ff 1039 * This parameter can be any combination of the following values:
bogdanm 0:9b334a45a8ff 1040 * @arg RCC_IT_LSIRDY: LSI ready interrupt.
bogdanm 0:9b334a45a8ff 1041 * @arg RCC_IT_LSERDY: LSE ready interrupt.
bogdanm 0:9b334a45a8ff 1042 * @arg RCC_IT_HSIRDY: HSI ready interrupt.
bogdanm 0:9b334a45a8ff 1043 * @arg RCC_IT_HSERDY: HSE ready interrupt.
bogdanm 0:9b334a45a8ff 1044 * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
bogdanm 0:9b334a45a8ff 1045 * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
bogdanm 0:9b334a45a8ff 1046 */
bogdanm 0:9b334a45a8ff 1047 #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS |= (__INTERRUPT__))
bogdanm 0:9b334a45a8ff 1048
bogdanm 0:9b334a45a8ff 1049 /** @brief Disable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to disable
bogdanm 0:9b334a45a8ff 1050 * the selected interrupts).
bogdanm 0:9b334a45a8ff 1051 * @param __INTERRUPT__: specifies the RCC interrupt sources to be disabled.
bogdanm 0:9b334a45a8ff 1052 * This parameter can be any combination of the following values:
bogdanm 0:9b334a45a8ff 1053 * @arg RCC_IT_LSIRDY: LSI ready interrupt.
bogdanm 0:9b334a45a8ff 1054 * @arg RCC_IT_LSERDY: LSE ready interrupt.
bogdanm 0:9b334a45a8ff 1055 * @arg RCC_IT_HSIRDY: HSI ready interrupt.
bogdanm 0:9b334a45a8ff 1056 * @arg RCC_IT_HSERDY: HSE ready interrupt.
bogdanm 0:9b334a45a8ff 1057 * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
bogdanm 0:9b334a45a8ff 1058 * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
bogdanm 0:9b334a45a8ff 1059 */
bogdanm 0:9b334a45a8ff 1060 #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS &= ~(__INTERRUPT__))
bogdanm 0:9b334a45a8ff 1061
bogdanm 0:9b334a45a8ff 1062 /** @brief Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CIR[23:16]
bogdanm 0:9b334a45a8ff 1063 * bits to clear the selected interrupt pending bits.
bogdanm 0:9b334a45a8ff 1064 * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
bogdanm 0:9b334a45a8ff 1065 * This parameter can be any combination of the following values:
bogdanm 0:9b334a45a8ff 1066 * @arg RCC_IT_LSIRDY: LSI ready interrupt.
bogdanm 0:9b334a45a8ff 1067 * @arg RCC_IT_LSERDY: LSE ready interrupt.
bogdanm 0:9b334a45a8ff 1068 * @arg RCC_IT_HSIRDY: HSI ready interrupt.
bogdanm 0:9b334a45a8ff 1069 * @arg RCC_IT_HSERDY: HSE ready interrupt.
bogdanm 0:9b334a45a8ff 1070 * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
bogdanm 0:9b334a45a8ff 1071 * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
bogdanm 0:9b334a45a8ff 1072 * @arg RCC_IT_CSS: Clock Security System interrupt
bogdanm 0:9b334a45a8ff 1073 */
bogdanm 0:9b334a45a8ff 1074 #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE2_ADDRESS = (__INTERRUPT__))
bogdanm 0:9b334a45a8ff 1075
bogdanm 0:9b334a45a8ff 1076 /** @brief Check the RCC's interrupt has occurred or not.
bogdanm 0:9b334a45a8ff 1077 * @param __INTERRUPT__: specifies the RCC interrupt source to check.
bogdanm 0:9b334a45a8ff 1078 * This parameter can be one of the following values:
bogdanm 0:9b334a45a8ff 1079 * @arg RCC_IT_LSIRDY: LSI ready interrupt.
bogdanm 0:9b334a45a8ff 1080 * @arg RCC_IT_LSERDY: LSE ready interrupt.
bogdanm 0:9b334a45a8ff 1081 * @arg RCC_IT_HSIRDY: HSI ready interrupt.
bogdanm 0:9b334a45a8ff 1082 * @arg RCC_IT_HSERDY: HSE ready interrupt.
bogdanm 0:9b334a45a8ff 1083 * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
bogdanm 0:9b334a45a8ff 1084 * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
bogdanm 0:9b334a45a8ff 1085 * @arg RCC_IT_CSS: Clock Security System interrupt
bogdanm 0:9b334a45a8ff 1086 * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
bogdanm 0:9b334a45a8ff 1087 */
bogdanm 0:9b334a45a8ff 1088 #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIR & (__INTERRUPT__)) == (__INTERRUPT__))
bogdanm 0:9b334a45a8ff 1089
bogdanm 0:9b334a45a8ff 1090 /** @brief Set RMVF bit to clear the reset flags: RCC_FLAG_PINRST, RCC_FLAG_PORRST,
bogdanm 0:9b334a45a8ff 1091 * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
bogdanm 0:9b334a45a8ff 1092 */
bogdanm 0:9b334a45a8ff 1093 #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
bogdanm 0:9b334a45a8ff 1094
bogdanm 0:9b334a45a8ff 1095 /** @brief Check RCC flag is set or not.
bogdanm 0:9b334a45a8ff 1096 * @param __FLAG__: specifies the flag to check.
bogdanm 0:9b334a45a8ff 1097 * This parameter can be one of the following values:
bogdanm 0:9b334a45a8ff 1098 * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready.
bogdanm 0:9b334a45a8ff 1099 * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready.
bogdanm 0:9b334a45a8ff 1100 * @arg RCC_FLAG_PLLRDY: Main PLL clock ready.
bogdanm 0:9b334a45a8ff 1101 * @arg RCC_FLAG_PLLI2SRDY: PLLI2S clock ready.
bogdanm 0:9b334a45a8ff 1102 * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready.
bogdanm 0:9b334a45a8ff 1103 * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready.
bogdanm 0:9b334a45a8ff 1104 * @arg RCC_FLAG_BORRST: POR/PDR or BOR reset.
bogdanm 0:9b334a45a8ff 1105 * @arg RCC_FLAG_PINRST: Pin reset.
bogdanm 0:9b334a45a8ff 1106 * @arg RCC_FLAG_PORRST: POR/PDR reset.
bogdanm 0:9b334a45a8ff 1107 * @arg RCC_FLAG_SFTRST: Software reset.
bogdanm 0:9b334a45a8ff 1108 * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset.
bogdanm 0:9b334a45a8ff 1109 * @arg RCC_FLAG_WWDGRST: Window Watchdog reset.
bogdanm 0:9b334a45a8ff 1110 * @arg RCC_FLAG_LPWRRST: Low Power reset.
bogdanm 0:9b334a45a8ff 1111 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 0:9b334a45a8ff 1112 */
bogdanm 0:9b334a45a8ff 1113 #define RCC_FLAG_MASK ((uint8_t)0x1F)
bogdanm 0:9b334a45a8ff 1114 #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5) == 1)? RCC->CR :((((__FLAG__) >> 5) == 2) ? RCC->BDCR :((((__FLAG__) >> 5) == 3)? RCC->CSR :RCC->CIR))) & ((uint32_t)1 << ((__FLAG__) & RCC_FLAG_MASK)))!= 0)? 1 : 0)
bogdanm 0:9b334a45a8ff 1115
bogdanm 0:9b334a45a8ff 1116 /**
bogdanm 0:9b334a45a8ff 1117 * @}
bogdanm 0:9b334a45a8ff 1118 */
bogdanm 0:9b334a45a8ff 1119
bogdanm 0:9b334a45a8ff 1120 /**
bogdanm 0:9b334a45a8ff 1121 * @}
bogdanm 0:9b334a45a8ff 1122 */
bogdanm 0:9b334a45a8ff 1123
bogdanm 0:9b334a45a8ff 1124 /* Exported functions --------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 1125 /** @addtogroup RCC_Exported_Functions
bogdanm 0:9b334a45a8ff 1126 * @{
bogdanm 0:9b334a45a8ff 1127 */
bogdanm 0:9b334a45a8ff 1128
bogdanm 0:9b334a45a8ff 1129 /** @addtogroup RCC_Exported_Functions_Group1
bogdanm 0:9b334a45a8ff 1130 * @{
bogdanm 0:9b334a45a8ff 1131 */
bogdanm 0:9b334a45a8ff 1132 /* Initialization and de-initialization functions ******************************/
bogdanm 0:9b334a45a8ff 1133 void HAL_RCC_DeInit(void);
bogdanm 0:9b334a45a8ff 1134 HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
bogdanm 0:9b334a45a8ff 1135 HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
bogdanm 0:9b334a45a8ff 1136 /**
bogdanm 0:9b334a45a8ff 1137 * @}
bogdanm 0:9b334a45a8ff 1138 */
bogdanm 0:9b334a45a8ff 1139
bogdanm 0:9b334a45a8ff 1140 /** @addtogroup RCC_Exported_Functions_Group2
bogdanm 0:9b334a45a8ff 1141 * @{
bogdanm 0:9b334a45a8ff 1142 */
bogdanm 0:9b334a45a8ff 1143 /* Peripheral Control functions ************************************************/
bogdanm 0:9b334a45a8ff 1144 void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
bogdanm 0:9b334a45a8ff 1145 void HAL_RCC_EnableCSS(void);
bogdanm 0:9b334a45a8ff 1146 void HAL_RCC_DisableCSS(void);
bogdanm 0:9b334a45a8ff 1147 uint32_t HAL_RCC_GetSysClockFreq(void);
bogdanm 0:9b334a45a8ff 1148 uint32_t HAL_RCC_GetHCLKFreq(void);
bogdanm 0:9b334a45a8ff 1149 uint32_t HAL_RCC_GetPCLK1Freq(void);
bogdanm 0:9b334a45a8ff 1150 uint32_t HAL_RCC_GetPCLK2Freq(void);
bogdanm 0:9b334a45a8ff 1151 void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
bogdanm 0:9b334a45a8ff 1152 void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
bogdanm 0:9b334a45a8ff 1153
bogdanm 0:9b334a45a8ff 1154 /* CSS NMI IRQ handler */
bogdanm 0:9b334a45a8ff 1155 void HAL_RCC_NMI_IRQHandler(void);
bogdanm 0:9b334a45a8ff 1156
bogdanm 0:9b334a45a8ff 1157 /* User Callbacks in non blocking mode (IT mode) */
bogdanm 0:9b334a45a8ff 1158 void HAL_RCC_CSSCallback(void);
bogdanm 0:9b334a45a8ff 1159
bogdanm 0:9b334a45a8ff 1160 /**
bogdanm 0:9b334a45a8ff 1161 * @}
bogdanm 0:9b334a45a8ff 1162 */
bogdanm 0:9b334a45a8ff 1163
bogdanm 0:9b334a45a8ff 1164 /**
bogdanm 0:9b334a45a8ff 1165 * @}
bogdanm 0:9b334a45a8ff 1166 */
bogdanm 0:9b334a45a8ff 1167
bogdanm 0:9b334a45a8ff 1168 /* Private types -------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 1169 /* Private variables ---------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 1170 /* Private constants ---------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 1171 /** @defgroup RCC_Private_Constants RCC Private Constants
bogdanm 0:9b334a45a8ff 1172 * @{
bogdanm 0:9b334a45a8ff 1173 */
bogdanm 0:9b334a45a8ff 1174
bogdanm 0:9b334a45a8ff 1175 /** @defgroup RCC_BitAddress_AliasRegion RCC BitAddress AliasRegion
bogdanm 0:9b334a45a8ff 1176 * @brief RCC registers bit address in the alias region
bogdanm 0:9b334a45a8ff 1177 * @{
bogdanm 0:9b334a45a8ff 1178 */
bogdanm 0:9b334a45a8ff 1179 #define RCC_OFFSET (RCC_BASE - PERIPH_BASE)
bogdanm 0:9b334a45a8ff 1180 /* --- CR Register ---*/
bogdanm 0:9b334a45a8ff 1181 /* Alias word address of HSION bit */
bogdanm 0:9b334a45a8ff 1182 #define RCC_CR_OFFSET (RCC_OFFSET + 0x00)
bogdanm 0:9b334a45a8ff 1183 #define RCC_HSION_BIT_NUMBER 0x00
bogdanm 0:9b334a45a8ff 1184 #define RCC_CR_HSION_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32) + (RCC_HSION_BIT_NUMBER * 4))
bogdanm 0:9b334a45a8ff 1185 /* Alias word address of CSSON bit */
bogdanm 0:9b334a45a8ff 1186 #define RCC_CSSON_BIT_NUMBER 0x13
bogdanm 0:9b334a45a8ff 1187 #define RCC_CR_CSSON_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32) + (RCC_CSSON_BIT_NUMBER * 4))
bogdanm 0:9b334a45a8ff 1188 /* Alias word address of PLLON bit */
bogdanm 0:9b334a45a8ff 1189 #define RCC_PLLON_BIT_NUMBER 0x18
bogdanm 0:9b334a45a8ff 1190 #define RCC_CR_PLLON_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32) + (RCC_PLLON_BIT_NUMBER * 4))
bogdanm 0:9b334a45a8ff 1191
bogdanm 0:9b334a45a8ff 1192 /* --- BDCR Register ---*/
bogdanm 0:9b334a45a8ff 1193 /* Alias word address of RTCEN bit */
bogdanm 0:9b334a45a8ff 1194 #define RCC_BDCR_OFFSET (RCC_OFFSET + 0x70)
bogdanm 0:9b334a45a8ff 1195 #define RCC_RTCEN_BIT_NUMBER 0x0F
bogdanm 0:9b334a45a8ff 1196 #define RCC_BDCR_RTCEN_BB (PERIPH_BB_BASE + (RCC_BDCR_OFFSET * 32) + (RCC_RTCEN_BIT_NUMBER * 4))
bogdanm 0:9b334a45a8ff 1197 /* Alias word address of BDRST bit */
bogdanm 0:9b334a45a8ff 1198 #define RCC_BDRST_BIT_NUMBER 0x10
bogdanm 0:9b334a45a8ff 1199 #define RCC_BDCR_BDRST_BB (PERIPH_BB_BASE + (RCC_BDCR_OFFSET * 32) + (RCC_BDRST_BIT_NUMBER * 4))
bogdanm 0:9b334a45a8ff 1200
bogdanm 0:9b334a45a8ff 1201 /* --- CSR Register ---*/
bogdanm 0:9b334a45a8ff 1202 /* Alias word address of LSION bit */
bogdanm 0:9b334a45a8ff 1203 #define RCC_CSR_OFFSET (RCC_OFFSET + 0x74)
bogdanm 0:9b334a45a8ff 1204 #define RCC_LSION_BIT_NUMBER 0x00
bogdanm 0:9b334a45a8ff 1205 #define RCC_CSR_LSION_BB (PERIPH_BB_BASE + (RCC_CSR_OFFSET * 32) + (RCC_LSION_BIT_NUMBER * 4))
bogdanm 0:9b334a45a8ff 1206
bogdanm 0:9b334a45a8ff 1207 /* CR register byte 3 (Bits[23:16]) base address */
bogdanm 0:9b334a45a8ff 1208 #define RCC_CR_BYTE2_ADDRESS ((uint32_t)0x40023802)
bogdanm 0:9b334a45a8ff 1209
bogdanm 0:9b334a45a8ff 1210 /* CIR register byte 2 (Bits[15:8]) base address */
bogdanm 0:9b334a45a8ff 1211 #define RCC_CIR_BYTE1_ADDRESS ((uint32_t)(RCC_BASE + 0x0C + 0x01))
bogdanm 0:9b334a45a8ff 1212
bogdanm 0:9b334a45a8ff 1213 /* CIR register byte 3 (Bits[23:16]) base address */
bogdanm 0:9b334a45a8ff 1214 #define RCC_CIR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + 0x0C + 0x02))
bogdanm 0:9b334a45a8ff 1215
bogdanm 0:9b334a45a8ff 1216 /* BDCR register base address */
bogdanm 0:9b334a45a8ff 1217 #define RCC_BDCR_BYTE0_ADDRESS (PERIPH_BASE + RCC_BDCR_OFFSET)
bogdanm 0:9b334a45a8ff 1218
bogdanm 0:9b334a45a8ff 1219 #define RCC_DBP_TIMEOUT_VALUE ((uint32_t)100)
mbed_official 87:444eeba2d452 1220 #define RCC_LSE_TIMEOUT_VALUE ((uint32_t)5000) /* 5000 ms */
bogdanm 0:9b334a45a8ff 1221
bogdanm 0:9b334a45a8ff 1222 #define HSE_TIMEOUT_VALUE HSE_STARTUP_TIMEOUT
bogdanm 0:9b334a45a8ff 1223 #define HSI_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */
bogdanm 0:9b334a45a8ff 1224 #define LSI_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */
bogdanm 0:9b334a45a8ff 1225
bogdanm 0:9b334a45a8ff 1226 /**
bogdanm 0:9b334a45a8ff 1227 * @}
bogdanm 0:9b334a45a8ff 1228 */
bogdanm 0:9b334a45a8ff 1229
bogdanm 0:9b334a45a8ff 1230 /**
bogdanm 0:9b334a45a8ff 1231 * @}
bogdanm 0:9b334a45a8ff 1232 */
bogdanm 0:9b334a45a8ff 1233
bogdanm 0:9b334a45a8ff 1234 /* Private macros ------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 1235 /** @addtogroup RCC_Private_Macros RCC Private Macros
bogdanm 0:9b334a45a8ff 1236 * @{
bogdanm 0:9b334a45a8ff 1237 */
bogdanm 0:9b334a45a8ff 1238
bogdanm 0:9b334a45a8ff 1239 /** @defgroup RCC_IS_RCC_Definitions RCC Private macros to check input parameters
bogdanm 0:9b334a45a8ff 1240 * @{
bogdanm 0:9b334a45a8ff 1241 */
bogdanm 0:9b334a45a8ff 1242 #define IS_RCC_OSCILLATORTYPE(OSCILLATOR) ((OSCILLATOR) <= 15)
bogdanm 0:9b334a45a8ff 1243
bogdanm 0:9b334a45a8ff 1244 #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \
bogdanm 0:9b334a45a8ff 1245 ((HSE) == RCC_HSE_BYPASS))
bogdanm 0:9b334a45a8ff 1246
bogdanm 0:9b334a45a8ff 1247 #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
bogdanm 0:9b334a45a8ff 1248 ((LSE) == RCC_LSE_BYPASS))
bogdanm 0:9b334a45a8ff 1249
bogdanm 0:9b334a45a8ff 1250 #define IS_RCC_HSI(HSI) (((HSI) == RCC_HSI_OFF) || ((HSI) == RCC_HSI_ON))
bogdanm 0:9b334a45a8ff 1251
bogdanm 0:9b334a45a8ff 1252 #define IS_RCC_LSI(LSI) (((LSI) == RCC_LSI_OFF) || ((LSI) == RCC_LSI_ON))
bogdanm 0:9b334a45a8ff 1253
bogdanm 0:9b334a45a8ff 1254 #define IS_RCC_PLL(PLL) (((PLL) == RCC_PLL_NONE) ||((PLL) == RCC_PLL_OFF) || ((PLL) == RCC_PLL_ON))
bogdanm 0:9b334a45a8ff 1255
bogdanm 0:9b334a45a8ff 1256 #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
bogdanm 0:9b334a45a8ff 1257 ((SOURCE) == RCC_PLLSOURCE_HSE))
bogdanm 0:9b334a45a8ff 1258
bogdanm 0:9b334a45a8ff 1259 #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
bogdanm 0:9b334a45a8ff 1260 ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
bogdanm 0:9b334a45a8ff 1261 ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK) || \
bogdanm 0:9b334a45a8ff 1262 ((SOURCE) == RCC_SYSCLKSOURCE_PLLRCLK))
bogdanm 0:9b334a45a8ff 1263
bogdanm 0:9b334a45a8ff 1264 #define IS_RCC_PLLM_VALUE(VALUE) ((VALUE) <= 63)
bogdanm 0:9b334a45a8ff 1265
bogdanm 0:9b334a45a8ff 1266 #define IS_RCC_PLLN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
bogdanm 0:9b334a45a8ff 1267
bogdanm 0:9b334a45a8ff 1268 #define IS_RCC_PLLP_VALUE(VALUE) (((VALUE) == 2) || ((VALUE) == 4) || ((VALUE) == 6) || ((VALUE) == 8))
bogdanm 0:9b334a45a8ff 1269
bogdanm 0:9b334a45a8ff 1270 #define IS_RCC_PLLQ_VALUE(VALUE) ((4 <= (VALUE)) && ((VALUE) <= 15))
bogdanm 0:9b334a45a8ff 1271
bogdanm 0:9b334a45a8ff 1272 #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_DIV1) || ((HCLK) == RCC_SYSCLK_DIV2) || \
bogdanm 0:9b334a45a8ff 1273 ((HCLK) == RCC_SYSCLK_DIV4) || ((HCLK) == RCC_SYSCLK_DIV8) || \
bogdanm 0:9b334a45a8ff 1274 ((HCLK) == RCC_SYSCLK_DIV16) || ((HCLK) == RCC_SYSCLK_DIV64) || \
bogdanm 0:9b334a45a8ff 1275 ((HCLK) == RCC_SYSCLK_DIV128) || ((HCLK) == RCC_SYSCLK_DIV256) || \
bogdanm 0:9b334a45a8ff 1276 ((HCLK) == RCC_SYSCLK_DIV512))
bogdanm 0:9b334a45a8ff 1277
bogdanm 0:9b334a45a8ff 1278 #define IS_RCC_CLOCKTYPE(CLK) ((1 <= (CLK)) && ((CLK) <= 15))
bogdanm 0:9b334a45a8ff 1279
bogdanm 0:9b334a45a8ff 1280 #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_DIV1) || ((PCLK) == RCC_HCLK_DIV2) || \
bogdanm 0:9b334a45a8ff 1281 ((PCLK) == RCC_HCLK_DIV4) || ((PCLK) == RCC_HCLK_DIV8) || \
bogdanm 0:9b334a45a8ff 1282 ((PCLK) == RCC_HCLK_DIV16))
bogdanm 0:9b334a45a8ff 1283
bogdanm 0:9b334a45a8ff 1284 #define IS_RCC_MCO(MCOx) (((MCOx) == RCC_MCO1) || ((MCOx) == RCC_MCO2))
bogdanm 0:9b334a45a8ff 1285
bogdanm 0:9b334a45a8ff 1286 #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_HSI) || ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
bogdanm 0:9b334a45a8ff 1287 ((SOURCE) == RCC_MCO1SOURCE_HSE) || ((SOURCE) == RCC_MCO1SOURCE_PLLCLK))
bogdanm 0:9b334a45a8ff 1288
bogdanm 0:9b334a45a8ff 1289 #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1) || ((DIV) == RCC_MCODIV_2) || \
bogdanm 0:9b334a45a8ff 1290 ((DIV) == RCC_MCODIV_3) || ((DIV) == RCC_MCODIV_4) || \
bogdanm 0:9b334a45a8ff 1291 ((DIV) == RCC_MCODIV_5))
bogdanm 0:9b334a45a8ff 1292 #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F)
bogdanm 0:9b334a45a8ff 1293
bogdanm 0:9b334a45a8ff 1294 /**
bogdanm 0:9b334a45a8ff 1295 * @}
bogdanm 0:9b334a45a8ff 1296 */
bogdanm 0:9b334a45a8ff 1297
bogdanm 0:9b334a45a8ff 1298 /**
bogdanm 0:9b334a45a8ff 1299 * @}
bogdanm 0:9b334a45a8ff 1300 */
bogdanm 0:9b334a45a8ff 1301
bogdanm 0:9b334a45a8ff 1302 /**
bogdanm 0:9b334a45a8ff 1303 * @}
bogdanm 0:9b334a45a8ff 1304 */
bogdanm 0:9b334a45a8ff 1305
bogdanm 0:9b334a45a8ff 1306 /**
bogdanm 0:9b334a45a8ff 1307 * @}
bogdanm 0:9b334a45a8ff 1308 */
bogdanm 0:9b334a45a8ff 1309
bogdanm 0:9b334a45a8ff 1310 #ifdef __cplusplus
bogdanm 0:9b334a45a8ff 1311 }
bogdanm 0:9b334a45a8ff 1312 #endif
bogdanm 0:9b334a45a8ff 1313
bogdanm 0:9b334a45a8ff 1314 #endif /* __STM32F4xx_HAL_RCC_H */
bogdanm 0:9b334a45a8ff 1315
bogdanm 0:9b334a45a8ff 1316 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/