I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhon309 0:ac8863619623 1 /**
jhon309 0:ac8863619623 2 ******************************************************************************
jhon309 0:ac8863619623 3 * @file stm32f0xx_hal_rcc_ex.h
jhon309 0:ac8863619623 4 * @author MCD Application Team
jhon309 0:ac8863619623 5 * @version V1.2.0
jhon309 0:ac8863619623 6 * @date 11-December-2014
jhon309 0:ac8863619623 7 * @brief Header file of RCC HAL Extension module.
jhon309 0:ac8863619623 8 ******************************************************************************
jhon309 0:ac8863619623 9 * @attention
jhon309 0:ac8863619623 10 *
jhon309 0:ac8863619623 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
jhon309 0:ac8863619623 12 *
jhon309 0:ac8863619623 13 * Redistribution and use in source and binary forms, with or without modification,
jhon309 0:ac8863619623 14 * are permitted provided that the following conditions are met:
jhon309 0:ac8863619623 15 * 1. Redistributions of source code must retain the above copyright notice,
jhon309 0:ac8863619623 16 * this list of conditions and the following disclaimer.
jhon309 0:ac8863619623 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
jhon309 0:ac8863619623 18 * this list of conditions and the following disclaimer in the documentation
jhon309 0:ac8863619623 19 * and/or other materials provided with the distribution.
jhon309 0:ac8863619623 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
jhon309 0:ac8863619623 21 * may be used to endorse or promote products derived from this software
jhon309 0:ac8863619623 22 * without specific prior written permission.
jhon309 0:ac8863619623 23 *
jhon309 0:ac8863619623 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
jhon309 0:ac8863619623 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
jhon309 0:ac8863619623 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jhon309 0:ac8863619623 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
jhon309 0:ac8863619623 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
jhon309 0:ac8863619623 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
jhon309 0:ac8863619623 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
jhon309 0:ac8863619623 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jhon309 0:ac8863619623 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
jhon309 0:ac8863619623 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jhon309 0:ac8863619623 34 *
jhon309 0:ac8863619623 35 ******************************************************************************
jhon309 0:ac8863619623 36 */
jhon309 0:ac8863619623 37
jhon309 0:ac8863619623 38 /* Define to prevent recursive inclusion -------------------------------------*/
jhon309 0:ac8863619623 39 #ifndef __STM32F0xx_HAL_RCC_EX_H
jhon309 0:ac8863619623 40 #define __STM32F0xx_HAL_RCC_EX_H
jhon309 0:ac8863619623 41
jhon309 0:ac8863619623 42 #ifdef __cplusplus
jhon309 0:ac8863619623 43 extern "C" {
jhon309 0:ac8863619623 44 #endif
jhon309 0:ac8863619623 45
jhon309 0:ac8863619623 46 /* Includes ------------------------------------------------------------------*/
jhon309 0:ac8863619623 47 #include "stm32f0xx_hal_def.h"
jhon309 0:ac8863619623 48
jhon309 0:ac8863619623 49 /** @addtogroup STM32F0xx_HAL_Driver
jhon309 0:ac8863619623 50 * @{
jhon309 0:ac8863619623 51 */
jhon309 0:ac8863619623 52
jhon309 0:ac8863619623 53 /** @addtogroup RCCEx
jhon309 0:ac8863619623 54 * @{
jhon309 0:ac8863619623 55 */
jhon309 0:ac8863619623 56
jhon309 0:ac8863619623 57 /* Exported types ------------------------------------------------------------*/
jhon309 0:ac8863619623 58
jhon309 0:ac8863619623 59 /** @defgroup RCCEx_Exported_Types RCCEx Exported Types
jhon309 0:ac8863619623 60 * @{
jhon309 0:ac8863619623 61 */
jhon309 0:ac8863619623 62
jhon309 0:ac8863619623 63 /**
jhon309 0:ac8863619623 64 * @brief RCC extended clocks structure definition
jhon309 0:ac8863619623 65 */
jhon309 0:ac8863619623 66 #if defined(STM32F030x6) || defined(STM32F030x8) || defined(STM32F031x6) || defined(STM32F038xx) || \
jhon309 0:ac8863619623 67 defined(STM32F030xC)
jhon309 0:ac8863619623 68 typedef struct
jhon309 0:ac8863619623 69 {
jhon309 0:ac8863619623 70 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
jhon309 0:ac8863619623 71 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
jhon309 0:ac8863619623 72
jhon309 0:ac8863619623 73 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
jhon309 0:ac8863619623 74 This parameter can be a value of @ref RCC_RTC_Clock_Source */
jhon309 0:ac8863619623 75
jhon309 0:ac8863619623 76 uint32_t Usart1ClockSelection; /*!< USART1 clock source
jhon309 0:ac8863619623 77 This parameter can be a value of @ref RCC_USART1_Clock_Source */
jhon309 0:ac8863619623 78
jhon309 0:ac8863619623 79 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
jhon309 0:ac8863619623 80 This parameter can be a value of @ref RCC_I2C1_Clock_Source */
jhon309 0:ac8863619623 81
jhon309 0:ac8863619623 82 }RCC_PeriphCLKInitTypeDef;
jhon309 0:ac8863619623 83 #endif /* STM32F030x6 || STM32F030x8 || STM32F031x6 || STM32F038xx ||
jhon309 0:ac8863619623 84 STM32F030xC */
jhon309 0:ac8863619623 85
jhon309 0:ac8863619623 86 #if defined(STM32F070x6) || defined(STM32F070xB)
jhon309 0:ac8863619623 87 typedef struct
jhon309 0:ac8863619623 88 {
jhon309 0:ac8863619623 89 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
jhon309 0:ac8863619623 90 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
jhon309 0:ac8863619623 91
jhon309 0:ac8863619623 92 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
jhon309 0:ac8863619623 93 This parameter can be a value of @ref RCC_RTC_Clock_Source */
jhon309 0:ac8863619623 94
jhon309 0:ac8863619623 95 uint32_t Usart1ClockSelection; /*!< USART1 clock source
jhon309 0:ac8863619623 96 This parameter can be a value of @ref RCC_USART1_Clock_Source */
jhon309 0:ac8863619623 97
jhon309 0:ac8863619623 98 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
jhon309 0:ac8863619623 99 This parameter can be a value of @ref RCC_I2C1_Clock_Source */
jhon309 0:ac8863619623 100
jhon309 0:ac8863619623 101 uint32_t UsbClockSelection; /*!< USB clock source
jhon309 0:ac8863619623 102 This parameter can be a value of @ref RCCEx_USB_Clock_Source */
jhon309 0:ac8863619623 103
jhon309 0:ac8863619623 104 }RCC_PeriphCLKInitTypeDef;
jhon309 0:ac8863619623 105 #endif /* STM32F070x6 || STM32F070xB */
jhon309 0:ac8863619623 106
jhon309 0:ac8863619623 107 #if defined(STM32F042x6) || defined(STM32F048xx)
jhon309 0:ac8863619623 108 typedef struct
jhon309 0:ac8863619623 109 {
jhon309 0:ac8863619623 110 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
jhon309 0:ac8863619623 111 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
jhon309 0:ac8863619623 112
jhon309 0:ac8863619623 113 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
jhon309 0:ac8863619623 114 This parameter can be a value of @ref RCC_RTC_Clock_Source */
jhon309 0:ac8863619623 115
jhon309 0:ac8863619623 116 uint32_t Usart1ClockSelection; /*!< USART1 clock source
jhon309 0:ac8863619623 117 This parameter can be a value of @ref RCC_USART1_Clock_Source */
jhon309 0:ac8863619623 118
jhon309 0:ac8863619623 119 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
jhon309 0:ac8863619623 120 This parameter can be a value of @ref RCC_I2C1_Clock_Source */
jhon309 0:ac8863619623 121
jhon309 0:ac8863619623 122 uint32_t CecClockSelection; /*!< HDMI CEC clock source
jhon309 0:ac8863619623 123 This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
jhon309 0:ac8863619623 124
jhon309 0:ac8863619623 125 uint32_t UsbClockSelection; /*!< USB clock source
jhon309 0:ac8863619623 126 This parameter can be a value of @ref RCCEx_USB_Clock_Source */
jhon309 0:ac8863619623 127
jhon309 0:ac8863619623 128 }RCC_PeriphCLKInitTypeDef;
jhon309 0:ac8863619623 129 #endif /* STM32F042x6 || STM32F048xx */
jhon309 0:ac8863619623 130
jhon309 0:ac8863619623 131 #if defined(STM32F051x8) || defined(STM32F058xx)
jhon309 0:ac8863619623 132 typedef struct
jhon309 0:ac8863619623 133 {
jhon309 0:ac8863619623 134 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
jhon309 0:ac8863619623 135 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
jhon309 0:ac8863619623 136
jhon309 0:ac8863619623 137 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
jhon309 0:ac8863619623 138 This parameter can be a value of @ref RCC_RTC_Clock_Source */
jhon309 0:ac8863619623 139
jhon309 0:ac8863619623 140 uint32_t Usart1ClockSelection; /*!< USART1 clock source
jhon309 0:ac8863619623 141 This parameter can be a value of @ref RCC_USART1_Clock_Source */
jhon309 0:ac8863619623 142
jhon309 0:ac8863619623 143 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
jhon309 0:ac8863619623 144 This parameter can be a value of @ref RCC_I2C1_Clock_Source */
jhon309 0:ac8863619623 145
jhon309 0:ac8863619623 146 uint32_t CecClockSelection; /*!< HDMI CEC clock source
jhon309 0:ac8863619623 147 This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
jhon309 0:ac8863619623 148
jhon309 0:ac8863619623 149 }RCC_PeriphCLKInitTypeDef;
jhon309 0:ac8863619623 150 #endif /* STM32F051x8 || STM32F058xx */
jhon309 0:ac8863619623 151
jhon309 0:ac8863619623 152 #if defined(STM32F071xB)
jhon309 0:ac8863619623 153 typedef struct
jhon309 0:ac8863619623 154 {
jhon309 0:ac8863619623 155 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
jhon309 0:ac8863619623 156 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
jhon309 0:ac8863619623 157
jhon309 0:ac8863619623 158 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
jhon309 0:ac8863619623 159 This parameter can be a value of @ref RCC_RTC_Clock_Source */
jhon309 0:ac8863619623 160
jhon309 0:ac8863619623 161 uint32_t Usart1ClockSelection; /*!< USART1 clock source
jhon309 0:ac8863619623 162 This parameter can be a value of @ref RCC_USART1_Clock_Source */
jhon309 0:ac8863619623 163
jhon309 0:ac8863619623 164 uint32_t Usart2ClockSelection; /*!< USART2 clock source
jhon309 0:ac8863619623 165 This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
jhon309 0:ac8863619623 166
jhon309 0:ac8863619623 167 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
jhon309 0:ac8863619623 168 This parameter can be a value of @ref RCC_I2C1_Clock_Source */
jhon309 0:ac8863619623 169
jhon309 0:ac8863619623 170 uint32_t CecClockSelection; /*!< HDMI CEC clock source
jhon309 0:ac8863619623 171 This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
jhon309 0:ac8863619623 172
jhon309 0:ac8863619623 173 }RCC_PeriphCLKInitTypeDef;
jhon309 0:ac8863619623 174 #endif /* STM32F071xB */
jhon309 0:ac8863619623 175
jhon309 0:ac8863619623 176 #if defined(STM32F072xB) || defined(STM32F078xx)
jhon309 0:ac8863619623 177 typedef struct
jhon309 0:ac8863619623 178 {
jhon309 0:ac8863619623 179 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
jhon309 0:ac8863619623 180 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
jhon309 0:ac8863619623 181
jhon309 0:ac8863619623 182 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
jhon309 0:ac8863619623 183 This parameter can be a value of @ref RCC_RTC_Clock_Source */
jhon309 0:ac8863619623 184
jhon309 0:ac8863619623 185 uint32_t Usart1ClockSelection; /*!< USART1 clock source
jhon309 0:ac8863619623 186 This parameter can be a value of @ref RCC_USART1_Clock_Source */
jhon309 0:ac8863619623 187
jhon309 0:ac8863619623 188 uint32_t Usart2ClockSelection; /*!< USART2 clock source
jhon309 0:ac8863619623 189 This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
jhon309 0:ac8863619623 190
jhon309 0:ac8863619623 191 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
jhon309 0:ac8863619623 192 This parameter can be a value of @ref RCC_I2C1_Clock_Source */
jhon309 0:ac8863619623 193
jhon309 0:ac8863619623 194 uint32_t CecClockSelection; /*!< HDMI CEC clock source
jhon309 0:ac8863619623 195 This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
jhon309 0:ac8863619623 196
jhon309 0:ac8863619623 197 uint32_t UsbClockSelection; /*!< USB clock source
jhon309 0:ac8863619623 198 This parameter can be a value of @ref RCCEx_USB_Clock_Source */
jhon309 0:ac8863619623 199
jhon309 0:ac8863619623 200 }RCC_PeriphCLKInitTypeDef;
jhon309 0:ac8863619623 201 #endif /* STM32F072xB || STM32F078xx */
jhon309 0:ac8863619623 202
jhon309 0:ac8863619623 203
jhon309 0:ac8863619623 204 #if defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 205 typedef struct
jhon309 0:ac8863619623 206 {
jhon309 0:ac8863619623 207 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
jhon309 0:ac8863619623 208 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
jhon309 0:ac8863619623 209
jhon309 0:ac8863619623 210 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
jhon309 0:ac8863619623 211 This parameter can be a value of @ref RCC_RTC_Clock_Source */
jhon309 0:ac8863619623 212
jhon309 0:ac8863619623 213 uint32_t Usart1ClockSelection; /*!< USART1 clock source
jhon309 0:ac8863619623 214 This parameter can be a value of @ref RCC_USART1_Clock_Source */
jhon309 0:ac8863619623 215
jhon309 0:ac8863619623 216 uint32_t Usart2ClockSelection; /*!< USART2 clock source
jhon309 0:ac8863619623 217 This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
jhon309 0:ac8863619623 218
jhon309 0:ac8863619623 219 uint32_t Usart3ClockSelection; /*!< USART3 clock source
jhon309 0:ac8863619623 220 This parameter can be a value of @ref RCCEx_USART3_Clock_Source */
jhon309 0:ac8863619623 221
jhon309 0:ac8863619623 222 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
jhon309 0:ac8863619623 223 This parameter can be a value of @ref RCC_I2C1_Clock_Source */
jhon309 0:ac8863619623 224
jhon309 0:ac8863619623 225 uint32_t CecClockSelection; /*!< HDMI CEC clock source
jhon309 0:ac8863619623 226 This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
jhon309 0:ac8863619623 227
jhon309 0:ac8863619623 228 }RCC_PeriphCLKInitTypeDef;
jhon309 0:ac8863619623 229 #endif /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 230
jhon309 0:ac8863619623 231 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 232 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 233 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 234
jhon309 0:ac8863619623 235 /**
jhon309 0:ac8863619623 236 * @brief RCC_CRS Init structure definition
jhon309 0:ac8863619623 237 */
jhon309 0:ac8863619623 238 typedef struct
jhon309 0:ac8863619623 239 {
jhon309 0:ac8863619623 240 uint32_t Prescaler; /*!< Specifies the division factor of the SYNC signal.
jhon309 0:ac8863619623 241 This parameter can be a value of @ref RCCEx_CRS_SynchroDivider */
jhon309 0:ac8863619623 242
jhon309 0:ac8863619623 243 uint32_t Source; /*!< Specifies the SYNC signal source.
jhon309 0:ac8863619623 244 This parameter can be a value of @ref RCCEx_CRS_SynchroSource */
jhon309 0:ac8863619623 245
jhon309 0:ac8863619623 246 uint32_t Polarity; /*!< Specifies the input polarity for the SYNC signal source.
jhon309 0:ac8863619623 247 This parameter can be a value of @ref RCCEx_CRS_SynchroPolarity */
jhon309 0:ac8863619623 248
jhon309 0:ac8863619623 249 uint32_t ReloadValue; /*!< Specifies the value to be loaded in the frequency error counter with each SYNC event.
jhon309 0:ac8863619623 250 It can be calculated in using macro __HAL_RCC_CRS_CALCULATE_RELOADVALUE(_FTARGET_, _FSYNC_)
jhon309 0:ac8863619623 251 This parameter must be a number between 0 and 0xFFFF or a value of @ref RCCEx_CRS_ReloadValueDefault .*/
jhon309 0:ac8863619623 252
jhon309 0:ac8863619623 253 uint32_t ErrorLimitValue; /*!< Specifies the value to be used to evaluate the captured frequency error value.
jhon309 0:ac8863619623 254 This parameter must be a number between 0 and 0xFF or a value of @ref RCCEx_CRS_ErrorLimitDefault */
jhon309 0:ac8863619623 255
jhon309 0:ac8863619623 256 uint32_t HSI48CalibrationValue; /*!< Specifies a user-programmable trimming value to the HSI48 oscillator.
jhon309 0:ac8863619623 257 This parameter must be a number between 0 and 0x3F or a value of @ref RCCEx_CRS_HSI48CalibrationDefault */
jhon309 0:ac8863619623 258
jhon309 0:ac8863619623 259 }RCC_CRSInitTypeDef;
jhon309 0:ac8863619623 260
jhon309 0:ac8863619623 261 /**
jhon309 0:ac8863619623 262 * @brief RCC_CRS Synchronization structure definition
jhon309 0:ac8863619623 263 */
jhon309 0:ac8863619623 264 typedef struct
jhon309 0:ac8863619623 265 {
jhon309 0:ac8863619623 266 uint32_t ReloadValue; /*!< Specifies the value loaded in the Counter reload value.
jhon309 0:ac8863619623 267 This parameter must be a number between 0 and 0xFFFF*/
jhon309 0:ac8863619623 268
jhon309 0:ac8863619623 269 uint32_t HSI48CalibrationValue; /*!< Specifies value loaded in HSI48 oscillator smooth trimming.
jhon309 0:ac8863619623 270 This parameter must be a number between 0 and 0x3F */
jhon309 0:ac8863619623 271
jhon309 0:ac8863619623 272 uint32_t FreqErrorCapture; /*!< Specifies the value loaded in the .FECAP, the frequency error counter
jhon309 0:ac8863619623 273 value latched in the time of the last SYNC event.
jhon309 0:ac8863619623 274 This parameter must be a number between 0 and 0xFFFF */
jhon309 0:ac8863619623 275
jhon309 0:ac8863619623 276 uint32_t FreqErrorDirection; /*!< Specifies the value loaded in the .FEDIR, the counting direction of the
jhon309 0:ac8863619623 277 frequency error counter latched in the time of the last SYNC event.
jhon309 0:ac8863619623 278 It shows whether the actual frequency is below or above the target.
jhon309 0:ac8863619623 279 This parameter must be a value of @ref RCCEx_CRS_FreqErrorDirection*/
jhon309 0:ac8863619623 280
jhon309 0:ac8863619623 281 }RCC_CRSSynchroInfoTypeDef;
jhon309 0:ac8863619623 282
jhon309 0:ac8863619623 283 #endif /* STM32F042x6 || STM32F048xx */
jhon309 0:ac8863619623 284 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 285 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 286
jhon309 0:ac8863619623 287 /**
jhon309 0:ac8863619623 288 * @}
jhon309 0:ac8863619623 289 */
jhon309 0:ac8863619623 290
jhon309 0:ac8863619623 291 /* Exported constants --------------------------------------------------------*/
jhon309 0:ac8863619623 292
jhon309 0:ac8863619623 293 /** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
jhon309 0:ac8863619623 294 * @{
jhon309 0:ac8863619623 295 */
jhon309 0:ac8863619623 296
jhon309 0:ac8863619623 297 /** @defgroup RCCEx_CRS_Status RCCEx CRS Status
jhon309 0:ac8863619623 298 * @{
jhon309 0:ac8863619623 299 */
jhon309 0:ac8863619623 300 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 301 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 302 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 303
jhon309 0:ac8863619623 304 #define RCC_CRS_NONE ((uint32_t)0x00000000)
jhon309 0:ac8863619623 305 #define RCC_CRS_TIMEOUT ((uint32_t)0x00000001)
jhon309 0:ac8863619623 306 #define RCC_CRS_SYNCOK ((uint32_t)0x00000002)
jhon309 0:ac8863619623 307 #define RCC_CRS_SYNCWARM ((uint32_t)0x00000004)
jhon309 0:ac8863619623 308 #define RCC_CRS_SYNCERR ((uint32_t)0x00000008)
jhon309 0:ac8863619623 309 #define RCC_CRS_SYNCMISS ((uint32_t)0x00000010)
jhon309 0:ac8863619623 310 #define RCC_CRS_TRIMOV ((uint32_t)0x00000020)
jhon309 0:ac8863619623 311
jhon309 0:ac8863619623 312 #endif /* STM32F042x6 || STM32F048xx */
jhon309 0:ac8863619623 313 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 314 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 315 /**
jhon309 0:ac8863619623 316 * @}
jhon309 0:ac8863619623 317 */
jhon309 0:ac8863619623 318
jhon309 0:ac8863619623 319 /** @defgroup RCCEx_Periph_Clock_Selection RCCEx Periph Clock Selection
jhon309 0:ac8863619623 320 * @{
jhon309 0:ac8863619623 321 */
jhon309 0:ac8863619623 322 #if defined(STM32F030x6) || defined(STM32F030x8) || defined(STM32F031x6) || defined(STM32F038xx) || \
jhon309 0:ac8863619623 323 defined(STM32F030xC)
jhon309 0:ac8863619623 324 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
jhon309 0:ac8863619623 325 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000020)
jhon309 0:ac8863619623 326 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00010000)
jhon309 0:ac8863619623 327
jhon309 0:ac8863619623 328 #define IS_RCC_PERIPHCLK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
jhon309 0:ac8863619623 329 RCC_PERIPHCLK_RTC))
jhon309 0:ac8863619623 330 #endif /* STM32F030x6 || STM32F030x8 || STM32F031x6 || STM32F038xx ||
jhon309 0:ac8863619623 331 STM32F030xC */
jhon309 0:ac8863619623 332
jhon309 0:ac8863619623 333 #if defined(STM32F070x6) || defined(STM32F070xB)
jhon309 0:ac8863619623 334 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
jhon309 0:ac8863619623 335 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000020)
jhon309 0:ac8863619623 336 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00010000)
jhon309 0:ac8863619623 337 #define RCC_PERIPHCLK_USB ((uint32_t)0x00020000)
jhon309 0:ac8863619623 338
jhon309 0:ac8863619623 339 #define IS_RCC_PERIPHCLK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
jhon309 0:ac8863619623 340 RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USB))
jhon309 0:ac8863619623 341 #endif /* STM32F070x6 || STM32F070xB */
jhon309 0:ac8863619623 342
jhon309 0:ac8863619623 343 #if defined(STM32F042x6) || defined(STM32F048xx)
jhon309 0:ac8863619623 344 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
jhon309 0:ac8863619623 345 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000020)
jhon309 0:ac8863619623 346 #define RCC_PERIPHCLK_CEC ((uint32_t)0x00000400)
jhon309 0:ac8863619623 347 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00010000)
jhon309 0:ac8863619623 348 #define RCC_PERIPHCLK_USB ((uint32_t)0x00020000)
jhon309 0:ac8863619623 349
jhon309 0:ac8863619623 350 #define IS_RCC_PERIPHCLK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
jhon309 0:ac8863619623 351 RCC_PERIPHCLK_CEC | RCC_PERIPHCLK_RTC | \
jhon309 0:ac8863619623 352 RCC_PERIPHCLK_USB))
jhon309 0:ac8863619623 353 #endif /* STM32F042x6 || STM32F048xx */
jhon309 0:ac8863619623 354
jhon309 0:ac8863619623 355 #if defined(STM32F051x8) || defined(STM32F058xx)
jhon309 0:ac8863619623 356 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
jhon309 0:ac8863619623 357 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000020)
jhon309 0:ac8863619623 358 #define RCC_PERIPHCLK_CEC ((uint32_t)0x00000400)
jhon309 0:ac8863619623 359 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00010000)
jhon309 0:ac8863619623 360
jhon309 0:ac8863619623 361 #define IS_RCC_PERIPHCLK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
jhon309 0:ac8863619623 362 RCC_PERIPHCLK_CEC | RCC_PERIPHCLK_RTC))
jhon309 0:ac8863619623 363 #endif /* STM32F051x8 || STM32F058xx */
jhon309 0:ac8863619623 364
jhon309 0:ac8863619623 365 #if defined(STM32F071xB)
jhon309 0:ac8863619623 366 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
jhon309 0:ac8863619623 367 #define RCC_PERIPHCLK_USART2 ((uint32_t)0x00000002)
jhon309 0:ac8863619623 368 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000020)
jhon309 0:ac8863619623 369 #define RCC_PERIPHCLK_CEC ((uint32_t)0x00000400)
jhon309 0:ac8863619623 370 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00010000)
jhon309 0:ac8863619623 371
jhon309 0:ac8863619623 372 #define IS_RCC_PERIPHCLK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | \
jhon309 0:ac8863619623 373 RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_CEC | \
jhon309 0:ac8863619623 374 RCC_PERIPHCLK_RTC))
jhon309 0:ac8863619623 375 #endif /* STM32F071xB */
jhon309 0:ac8863619623 376
jhon309 0:ac8863619623 377 #if defined(STM32F072xB) || defined(STM32F078xx)
jhon309 0:ac8863619623 378 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
jhon309 0:ac8863619623 379 #define RCC_PERIPHCLK_USART2 ((uint32_t)0x00000002)
jhon309 0:ac8863619623 380 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000020)
jhon309 0:ac8863619623 381 #define RCC_PERIPHCLK_CEC ((uint32_t)0x00000400)
jhon309 0:ac8863619623 382 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00010000)
jhon309 0:ac8863619623 383 #define RCC_PERIPHCLK_USB ((uint32_t)0x00020000)
jhon309 0:ac8863619623 384
jhon309 0:ac8863619623 385 #define IS_RCC_PERIPHCLK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | \
jhon309 0:ac8863619623 386 RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_CEC | \
jhon309 0:ac8863619623 387 RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USB))
jhon309 0:ac8863619623 388 #endif /* STM32F072xB || STM32F078xx */
jhon309 0:ac8863619623 389
jhon309 0:ac8863619623 390 #if defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 391 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
jhon309 0:ac8863619623 392 #define RCC_PERIPHCLK_USART2 ((uint32_t)0x00000002)
jhon309 0:ac8863619623 393 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000020)
jhon309 0:ac8863619623 394 #define RCC_PERIPHCLK_CEC ((uint32_t)0x00000400)
jhon309 0:ac8863619623 395 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00010000)
jhon309 0:ac8863619623 396 #define RCC_PERIPHCLK_USART3 ((uint32_t)0x00040000)
jhon309 0:ac8863619623 397
jhon309 0:ac8863619623 398 #define IS_RCC_PERIPHCLK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | \
jhon309 0:ac8863619623 399 RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_CEC | \
jhon309 0:ac8863619623 400 RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART3 ))
jhon309 0:ac8863619623 401 #endif /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 402
jhon309 0:ac8863619623 403 /**
jhon309 0:ac8863619623 404 * @}
jhon309 0:ac8863619623 405 */
jhon309 0:ac8863619623 406
jhon309 0:ac8863619623 407 /** @defgroup RCCEx_MCO_Clock_Source RCCEx MCO Clock Source
jhon309 0:ac8863619623 408 * @{
jhon309 0:ac8863619623 409 */
jhon309 0:ac8863619623 410
jhon309 0:ac8863619623 411 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) || defined(STM32F070x6) || defined(STM32F070xB) || defined(STM32F030xC)
jhon309 0:ac8863619623 412
jhon309 0:ac8863619623 413 #define RCC_MCOSOURCE_PLLCLK_NODIV (RCC_CFGR_MCO_PLL | RCC_CFGR_PLLNODIV)
jhon309 0:ac8863619623 414
jhon309 0:ac8863619623 415 #define IS_RCC_MCOSOURCE(SOURCE) (((SOURCE) == RCC_MCOSOURCE_NONE) || \
jhon309 0:ac8863619623 416 ((SOURCE) == RCC_MCOSOURCE_LSI) || \
jhon309 0:ac8863619623 417 ((SOURCE) == RCC_MCOSOURCE_LSE) || \
jhon309 0:ac8863619623 418 ((SOURCE) == RCC_MCOSOURCE_SYSCLK) || \
jhon309 0:ac8863619623 419 ((SOURCE) == RCC_MCOSOURCE_HSI) || \
jhon309 0:ac8863619623 420 ((SOURCE) == RCC_MCOSOURCE_HSE) || \
jhon309 0:ac8863619623 421 ((SOURCE) == RCC_MCOSOURCE_PLLCLK_NODIV) || \
jhon309 0:ac8863619623 422 ((SOURCE) == RCC_MCOSOURCE_PLLCLK_DIV2) || \
jhon309 0:ac8863619623 423 ((SOURCE) == RCC_MCOSOURCE_HSI14))
jhon309 0:ac8863619623 424
jhon309 0:ac8863619623 425 #endif /* STM32F030x6 || STM32F031x6 || STM32F038xx || STM32F070x6 || STM32F070xB || STM32F030xC */
jhon309 0:ac8863619623 426
jhon309 0:ac8863619623 427 #if defined(STM32F030x8) || defined(STM32F051x8) || defined(STM32F058xx)
jhon309 0:ac8863619623 428
jhon309 0:ac8863619623 429 #define IS_RCC_MCOSOURCE(SOURCE) (((SOURCE) == RCC_MCOSOURCE_NONE) || \
jhon309 0:ac8863619623 430 ((SOURCE) == RCC_MCOSOURCE_LSI) || \
jhon309 0:ac8863619623 431 ((SOURCE) == RCC_MCOSOURCE_LSE) || \
jhon309 0:ac8863619623 432 ((SOURCE) == RCC_MCOSOURCE_SYSCLK) || \
jhon309 0:ac8863619623 433 ((SOURCE) == RCC_MCOSOURCE_HSI) || \
jhon309 0:ac8863619623 434 ((SOURCE) == RCC_MCOSOURCE_HSE) || \
jhon309 0:ac8863619623 435 ((SOURCE) == RCC_MCOSOURCE_PLLCLK_DIV2) || \
jhon309 0:ac8863619623 436 ((SOURCE) == RCC_MCOSOURCE_HSI14))
jhon309 0:ac8863619623 437
jhon309 0:ac8863619623 438 #endif /* STM32F030x8 || STM32F051x8 || STM32F058xx */
jhon309 0:ac8863619623 439
jhon309 0:ac8863619623 440 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 441 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 442 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 443
jhon309 0:ac8863619623 444 #define RCC_MCOSOURCE_HSI48 RCC_CFGR_MCO_HSI48
jhon309 0:ac8863619623 445 #define RCC_MCOSOURCE_PLLCLK_NODIV (RCC_CFGR_MCO_PLL | RCC_CFGR_PLLNODIV)
jhon309 0:ac8863619623 446
jhon309 0:ac8863619623 447 #define IS_RCC_MCOSOURCE(SOURCE) (((SOURCE) == RCC_MCOSOURCE_NONE) || \
jhon309 0:ac8863619623 448 ((SOURCE) == RCC_MCOSOURCE_LSI) || \
jhon309 0:ac8863619623 449 ((SOURCE) == RCC_MCOSOURCE_LSE) || \
jhon309 0:ac8863619623 450 ((SOURCE) == RCC_MCOSOURCE_SYSCLK) || \
jhon309 0:ac8863619623 451 ((SOURCE) == RCC_MCOSOURCE_HSI) || \
jhon309 0:ac8863619623 452 ((SOURCE) == RCC_MCOSOURCE_HSE) || \
jhon309 0:ac8863619623 453 ((SOURCE) == RCC_MCOSOURCE_PLLCLK_NODIV) || \
jhon309 0:ac8863619623 454 ((SOURCE) == RCC_MCOSOURCE_PLLCLK_DIV2) || \
jhon309 0:ac8863619623 455 ((SOURCE) == RCC_MCOSOURCE_HSI14) || \
jhon309 0:ac8863619623 456 ((SOURCE) == RCC_MCOSOURCE_HSI48))
jhon309 0:ac8863619623 457
jhon309 0:ac8863619623 458 #define RCC_IT_HSI48 ((uint8_t)0x40)
jhon309 0:ac8863619623 459
jhon309 0:ac8863619623 460 /* Flags in the CR2 register */
jhon309 0:ac8863619623 461 #define RCC_CR2_HSI48RDY_BitNumber 16
jhon309 0:ac8863619623 462
jhon309 0:ac8863619623 463 #define RCC_FLAG_HSI48RDY ((uint8_t)((CR2_REG_INDEX << 5) | RCC_CR2_HSI48RDY_BitNumber))
jhon309 0:ac8863619623 464
jhon309 0:ac8863619623 465 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 466 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 467 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 468 /**
jhon309 0:ac8863619623 469 * @}
jhon309 0:ac8863619623 470 */
jhon309 0:ac8863619623 471
jhon309 0:ac8863619623 472 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx)
jhon309 0:ac8863619623 473
jhon309 0:ac8863619623 474 /** @defgroup RCCEx_USB_Clock_Source RCCEx USB Clock Source
jhon309 0:ac8863619623 475 * @{
jhon309 0:ac8863619623 476 */
jhon309 0:ac8863619623 477 #define RCC_USBCLKSOURCE_HSI48 RCC_CFGR3_USBSW_HSI48
jhon309 0:ac8863619623 478 #define RCC_USBCLKSOURCE_PLLCLK RCC_CFGR3_USBSW_PLLCLK
jhon309 0:ac8863619623 479
jhon309 0:ac8863619623 480 #define IS_RCC_USBCLKSOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSOURCE_HSI48) || \
jhon309 0:ac8863619623 481 ((SOURCE) == RCC_USBCLKSOURCE_PLLCLK))
jhon309 0:ac8863619623 482 /**
jhon309 0:ac8863619623 483 * @}
jhon309 0:ac8863619623 484 */
jhon309 0:ac8863619623 485
jhon309 0:ac8863619623 486 #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || STM32F078xx */
jhon309 0:ac8863619623 487
jhon309 0:ac8863619623 488 #if defined(STM32F070x6) || defined(STM32F070xB)
jhon309 0:ac8863619623 489
jhon309 0:ac8863619623 490 /** @defgroup RCCEx_USB_Clock_Source RCCEx USB Clock Source
jhon309 0:ac8863619623 491 * @{
jhon309 0:ac8863619623 492 */
jhon309 0:ac8863619623 493 #define RCC_USBCLKSOURCE_PLLCLK RCC_CFGR3_USBSW_PLLCLK
jhon309 0:ac8863619623 494
jhon309 0:ac8863619623 495 #define IS_RCC_USBCLKSOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSOURCE_PLLCLK))
jhon309 0:ac8863619623 496 /**
jhon309 0:ac8863619623 497 * @}
jhon309 0:ac8863619623 498 */
jhon309 0:ac8863619623 499
jhon309 0:ac8863619623 500 #endif /* STM32F070x6 || STM32F070xB */
jhon309 0:ac8863619623 501
jhon309 0:ac8863619623 502 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 503 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 504
jhon309 0:ac8863619623 505 /** @defgroup RCCEx_USART2_Clock_Source RCCEx USART2 Clock Source
jhon309 0:ac8863619623 506 * @{
jhon309 0:ac8863619623 507 */
jhon309 0:ac8863619623 508 #define RCC_USART2CLKSOURCE_PCLK1 RCC_CFGR3_USART2SW_PCLK
jhon309 0:ac8863619623 509 #define RCC_USART2CLKSOURCE_SYSCLK RCC_CFGR3_USART2SW_SYSCLK
jhon309 0:ac8863619623 510 #define RCC_USART2CLKSOURCE_LSE RCC_CFGR3_USART2SW_LSE
jhon309 0:ac8863619623 511 #define RCC_USART2CLKSOURCE_HSI RCC_CFGR3_USART2SW_HSI
jhon309 0:ac8863619623 512
jhon309 0:ac8863619623 513 #define IS_RCC_USART2CLKSOURCE(SOURCE) (((SOURCE) == RCC_USART2CLKSOURCE_PCLK1) || \
jhon309 0:ac8863619623 514 ((SOURCE) == RCC_USART2CLKSOURCE_SYSCLK) || \
jhon309 0:ac8863619623 515 ((SOURCE) == RCC_USART2CLKSOURCE_LSE) || \
jhon309 0:ac8863619623 516 ((SOURCE) == RCC_USART2CLKSOURCE_HSI))
jhon309 0:ac8863619623 517 /**
jhon309 0:ac8863619623 518 * @}
jhon309 0:ac8863619623 519 */
jhon309 0:ac8863619623 520
jhon309 0:ac8863619623 521 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 522 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 523
jhon309 0:ac8863619623 524 #if defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 525
jhon309 0:ac8863619623 526 /** @defgroup RCCEx_USART3_Clock_Source RCCEx USART3 Clock Source
jhon309 0:ac8863619623 527 * @{
jhon309 0:ac8863619623 528 */
jhon309 0:ac8863619623 529 #define RCC_USART3CLKSOURCE_PCLK1 RCC_CFGR3_USART3SW_PCLK
jhon309 0:ac8863619623 530 #define RCC_USART3CLKSOURCE_SYSCLK RCC_CFGR3_USART3SW_SYSCLK
jhon309 0:ac8863619623 531 #define RCC_USART3CLKSOURCE_LSE RCC_CFGR3_USART3SW_LSE
jhon309 0:ac8863619623 532 #define RCC_USART3CLKSOURCE_HSI RCC_CFGR3_USART3SW_HSI
jhon309 0:ac8863619623 533
jhon309 0:ac8863619623 534 #define IS_RCC_USART3CLKSOURCE(SOURCE) (((SOURCE) == RCC_USART3CLKSOURCE_PCLK1) || \
jhon309 0:ac8863619623 535 ((SOURCE) == RCC_USART3CLKSOURCE_SYSCLK) || \
jhon309 0:ac8863619623 536 ((SOURCE) == RCC_USART3CLKSOURCE_LSE) || \
jhon309 0:ac8863619623 537 ((SOURCE) == RCC_USART3CLKSOURCE_HSI))
jhon309 0:ac8863619623 538 /**
jhon309 0:ac8863619623 539 * @}
jhon309 0:ac8863619623 540 */
jhon309 0:ac8863619623 541
jhon309 0:ac8863619623 542 #endif /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 543
jhon309 0:ac8863619623 544
jhon309 0:ac8863619623 545 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 546 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 547 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 548 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 549
jhon309 0:ac8863619623 550 /** @defgroup RCCEx_CEC_Clock_Source RCCEx CEC Clock Source
jhon309 0:ac8863619623 551 * @{
jhon309 0:ac8863619623 552 */
jhon309 0:ac8863619623 553 #define RCC_CECCLKSOURCE_HSI RCC_CFGR3_CECSW_HSI_DIV244
jhon309 0:ac8863619623 554 #define RCC_CECCLKSOURCE_LSE RCC_CFGR3_CECSW_LSE
jhon309 0:ac8863619623 555
jhon309 0:ac8863619623 556 #define IS_RCC_CECCLKSOURCE(SOURCE) (((SOURCE) == RCC_CECCLKSOURCE_HSI) || \
jhon309 0:ac8863619623 557 ((SOURCE) == RCC_CECCLKSOURCE_LSE))
jhon309 0:ac8863619623 558 /**
jhon309 0:ac8863619623 559 * @}
jhon309 0:ac8863619623 560 */
jhon309 0:ac8863619623 561
jhon309 0:ac8863619623 562 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 563 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 564 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 565 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 566
jhon309 0:ac8863619623 567 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 568 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 569 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 570
jhon309 0:ac8863619623 571 /** @defgroup RCCEx_PLL_Clock_Source RCCEx PLL Clock Source
jhon309 0:ac8863619623 572 * @{
jhon309 0:ac8863619623 573 */
jhon309 0:ac8863619623 574 #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI_PREDIV
jhon309 0:ac8863619623 575 #define RCC_PLLSOURCE_HSI48 RCC_CFGR_PLLSRC_HSI48_PREDIV
jhon309 0:ac8863619623 576
jhon309 0:ac8863619623 577 #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
jhon309 0:ac8863619623 578 ((SOURCE) == RCC_PLLSOURCE_HSI48) || \
jhon309 0:ac8863619623 579 ((SOURCE) == RCC_PLLSOURCE_HSE))
jhon309 0:ac8863619623 580 /**
jhon309 0:ac8863619623 581 * @}
jhon309 0:ac8863619623 582 */
jhon309 0:ac8863619623 583
jhon309 0:ac8863619623 584 /** @defgroup RCCEx_System_Clock_Source RCCEx System Clock Source
jhon309 0:ac8863619623 585 * @{
jhon309 0:ac8863619623 586 */
jhon309 0:ac8863619623 587 #define RCC_SYSCLKSOURCE_HSI48 RCC_CFGR_SW_HSI48
jhon309 0:ac8863619623 588
jhon309 0:ac8863619623 589 #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
jhon309 0:ac8863619623 590 ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
jhon309 0:ac8863619623 591 ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK) || \
jhon309 0:ac8863619623 592 ((SOURCE) == RCC_SYSCLKSOURCE_HSI48))
jhon309 0:ac8863619623 593
jhon309 0:ac8863619623 594 #define RCC_SYSCLKSOURCE_STATUS_HSI48 RCC_CFGR_SWS_HSI48
jhon309 0:ac8863619623 595
jhon309 0:ac8863619623 596 #define IS_RCC_SYSCLKSOURCE_STATUS(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSI) || \
jhon309 0:ac8863619623 597 ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSE) || \
jhon309 0:ac8863619623 598 ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_PLLCLK) || \
jhon309 0:ac8863619623 599 ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSI48))
jhon309 0:ac8863619623 600 /**
jhon309 0:ac8863619623 601 * @}
jhon309 0:ac8863619623 602 */
jhon309 0:ac8863619623 603
jhon309 0:ac8863619623 604 /** @defgroup RCCEx_HSI48_Config RCCEx HSI48 Config
jhon309 0:ac8863619623 605 * @{
jhon309 0:ac8863619623 606 */
jhon309 0:ac8863619623 607 #define RCC_HSI48_OFF ((uint8_t)0x00)
jhon309 0:ac8863619623 608 #define RCC_HSI48_ON ((uint8_t)0x01)
jhon309 0:ac8863619623 609
jhon309 0:ac8863619623 610 #define IS_RCC_HSI48(HSI48) (((HSI48) == RCC_HSI48_OFF) || ((HSI48) == RCC_HSI48_ON))
jhon309 0:ac8863619623 611 /**
jhon309 0:ac8863619623 612 * @}
jhon309 0:ac8863619623 613 */
jhon309 0:ac8863619623 614 #else
jhon309 0:ac8863619623 615 /** @defgroup RCCEx_PLL_Clock_Source RCCEx PLL Clock Source
jhon309 0:ac8863619623 616 * @{
jhon309 0:ac8863619623 617 */
jhon309 0:ac8863619623 618
jhon309 0:ac8863619623 619 #if defined(STM32F070xB) || defined(STM32F070x6) || defined(STM32F030xC)
jhon309 0:ac8863619623 620 #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI_PREDIV
jhon309 0:ac8863619623 621 #else
jhon309 0:ac8863619623 622 #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI_DIV2
jhon309 0:ac8863619623 623 #endif
jhon309 0:ac8863619623 624
jhon309 0:ac8863619623 625 #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
jhon309 0:ac8863619623 626 ((SOURCE) == RCC_PLLSOURCE_HSE))
jhon309 0:ac8863619623 627 /**
jhon309 0:ac8863619623 628 * @}
jhon309 0:ac8863619623 629 */
jhon309 0:ac8863619623 630
jhon309 0:ac8863619623 631 /** @defgroup RCCEx_System_Clock_Source RCCEx System Clock Source
jhon309 0:ac8863619623 632 * @{
jhon309 0:ac8863619623 633 */
jhon309 0:ac8863619623 634 #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
jhon309 0:ac8863619623 635 ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
jhon309 0:ac8863619623 636 ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK))
jhon309 0:ac8863619623 637
jhon309 0:ac8863619623 638 #define IS_RCC_SYSCLKSOURCE_STATUS(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSI) || \
jhon309 0:ac8863619623 639 ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSE) || \
jhon309 0:ac8863619623 640 ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_PLLCLK))
jhon309 0:ac8863619623 641 /**
jhon309 0:ac8863619623 642 * @}
jhon309 0:ac8863619623 643 */
jhon309 0:ac8863619623 644
jhon309 0:ac8863619623 645 /** @defgroup RCCEx_HSI48_Config RCCEx HSI48 Config
jhon309 0:ac8863619623 646 * @{
jhon309 0:ac8863619623 647 */
jhon309 0:ac8863619623 648 #define RCC_HSI48_OFF ((uint8_t)0x00)
jhon309 0:ac8863619623 649
jhon309 0:ac8863619623 650 #define IS_RCC_HSI48(HSI48) (((HSI48) == RCC_HSI48_OFF))
jhon309 0:ac8863619623 651 /**
jhon309 0:ac8863619623 652 * @}
jhon309 0:ac8863619623 653 */
jhon309 0:ac8863619623 654
jhon309 0:ac8863619623 655 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 656 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 657 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 658
jhon309 0:ac8863619623 659
jhon309 0:ac8863619623 660 /** @defgroup RCCEx_MCOx_Clock_Prescaler RCCEx MCOx Clock Prescaler
jhon309 0:ac8863619623 661 * @{
jhon309 0:ac8863619623 662 */
jhon309 0:ac8863619623 663
jhon309 0:ac8863619623 664 #if defined(STM32F030x8) || defined(STM32F051x8) || defined(STM32F058xx)
jhon309 0:ac8863619623 665
jhon309 0:ac8863619623 666 #define RCC_MCO_NODIV ((uint32_t)0x00000000)
jhon309 0:ac8863619623 667
jhon309 0:ac8863619623 668 #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCO_NODIV))
jhon309 0:ac8863619623 669
jhon309 0:ac8863619623 670 #endif /* STM32F030x8 || STM32F051x8 || STM32F058xx */
jhon309 0:ac8863619623 671
jhon309 0:ac8863619623 672 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) || defined(STM32F070x6) || \
jhon309 0:ac8863619623 673 defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F071xB) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 674 defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 675 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 676
jhon309 0:ac8863619623 677 #define RCC_MCO_DIV1 ((uint32_t)0x00000000)
jhon309 0:ac8863619623 678 #define RCC_MCO_DIV2 ((uint32_t)0x10000000)
jhon309 0:ac8863619623 679 #define RCC_MCO_DIV4 ((uint32_t)0x20000000)
jhon309 0:ac8863619623 680 #define RCC_MCO_DIV8 ((uint32_t)0x30000000)
jhon309 0:ac8863619623 681 #define RCC_MCO_DIV16 ((uint32_t)0x40000000)
jhon309 0:ac8863619623 682 #define RCC_MCO_DIV32 ((uint32_t)0x50000000)
jhon309 0:ac8863619623 683 #define RCC_MCO_DIV64 ((uint32_t)0x60000000)
jhon309 0:ac8863619623 684 #define RCC_MCO_DIV128 ((uint32_t)0x70000000)
jhon309 0:ac8863619623 685
jhon309 0:ac8863619623 686 #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCO_DIV1) || ((DIV) == RCC_MCO_DIV2) || \
jhon309 0:ac8863619623 687 ((DIV) == RCC_MCO_DIV4) || ((DIV) == RCC_MCO_DIV8) || \
jhon309 0:ac8863619623 688 ((DIV) == RCC_MCO_DIV16) || ((DIV) == RCC_MCO_DIV32) || \
jhon309 0:ac8863619623 689 ((DIV) == RCC_MCO_DIV64) || ((DIV) == RCC_MCO_DIV128))
jhon309 0:ac8863619623 690
jhon309 0:ac8863619623 691 #endif /* STM32F030x6 || STM32F031x6 || STM32F038xx || STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 692 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070x6 || STM32F070xB */
jhon309 0:ac8863619623 693 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 694
jhon309 0:ac8863619623 695 /**
jhon309 0:ac8863619623 696 * @}
jhon309 0:ac8863619623 697 */
jhon309 0:ac8863619623 698
jhon309 0:ac8863619623 699 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 700 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 701 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 702
jhon309 0:ac8863619623 703 /** @defgroup RCCEx_CRS_SynchroSource RCCEx CRS SynchroSource
jhon309 0:ac8863619623 704 * @{
jhon309 0:ac8863619623 705 */
jhon309 0:ac8863619623 706 #define RCC_CRS_SYNC_SOURCE_GPIO ((uint32_t)0x00) /*!< Synchro Signal soucre GPIO */
jhon309 0:ac8863619623 707 #define RCC_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */
jhon309 0:ac8863619623 708 #define RCC_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/
jhon309 0:ac8863619623 709
jhon309 0:ac8863619623 710 #define IS_RCC_CRS_SYNC_SOURCE(_SOURCE_) (((_SOURCE_) == RCC_CRS_SYNC_SOURCE_GPIO) || \
jhon309 0:ac8863619623 711 ((_SOURCE_) == RCC_CRS_SYNC_SOURCE_LSE) || \
jhon309 0:ac8863619623 712 ((_SOURCE_) == RCC_CRS_SYNC_SOURCE_USB))
jhon309 0:ac8863619623 713 /**
jhon309 0:ac8863619623 714 * @}
jhon309 0:ac8863619623 715 */
jhon309 0:ac8863619623 716
jhon309 0:ac8863619623 717 /** @defgroup RCCEx_CRS_SynchroDivider RCCEx CRS SynchroDivider
jhon309 0:ac8863619623 718 * @{
jhon309 0:ac8863619623 719 */
jhon309 0:ac8863619623 720 #define RCC_CRS_SYNC_DIV1 ((uint32_t)0x00) /*!< Synchro Signal not divided (default) */
jhon309 0:ac8863619623 721 #define RCC_CRS_SYNC_DIV2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */
jhon309 0:ac8863619623 722 #define RCC_CRS_SYNC_DIV4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */
jhon309 0:ac8863619623 723 #define RCC_CRS_SYNC_DIV8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
jhon309 0:ac8863619623 724 #define RCC_CRS_SYNC_DIV16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */
jhon309 0:ac8863619623 725 #define RCC_CRS_SYNC_DIV32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
jhon309 0:ac8863619623 726 #define RCC_CRS_SYNC_DIV64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
jhon309 0:ac8863619623 727 #define RCC_CRS_SYNC_DIV128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */
jhon309 0:ac8863619623 728
jhon309 0:ac8863619623 729 #define IS_RCC_CRS_SYNC_DIV(_DIV_) (((_DIV_) == RCC_CRS_SYNC_DIV1) || ((_DIV_) == RCC_CRS_SYNC_DIV2) || \
jhon309 0:ac8863619623 730 ((_DIV_) == RCC_CRS_SYNC_DIV4) || ((_DIV_) == RCC_CRS_SYNC_DIV8) || \
jhon309 0:ac8863619623 731 ((_DIV_) == RCC_CRS_SYNC_DIV16) || ((_DIV_) == RCC_CRS_SYNC_DIV32) || \
jhon309 0:ac8863619623 732 ((_DIV_) == RCC_CRS_SYNC_DIV64) || ((_DIV_) == RCC_CRS_SYNC_DIV128))
jhon309 0:ac8863619623 733 /**
jhon309 0:ac8863619623 734 * @}
jhon309 0:ac8863619623 735 */
jhon309 0:ac8863619623 736
jhon309 0:ac8863619623 737 /** @defgroup RCCEx_CRS_SynchroPolarity RCCEx CRS SynchroPolarity
jhon309 0:ac8863619623 738 * @{
jhon309 0:ac8863619623 739 */
jhon309 0:ac8863619623 740 #define RCC_CRS_SYNC_POLARITY_RISING ((uint32_t)0x00) /*!< Synchro Active on rising edge (default) */
jhon309 0:ac8863619623 741 #define RCC_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */
jhon309 0:ac8863619623 742
jhon309 0:ac8863619623 743 #define IS_RCC_CRS_SYNC_POLARITY(_POLARITY_) (((_POLARITY_) == RCC_CRS_SYNC_POLARITY_RISING) || \
jhon309 0:ac8863619623 744 ((_POLARITY_) == RCC_CRS_SYNC_POLARITY_FALLING))
jhon309 0:ac8863619623 745 /**
jhon309 0:ac8863619623 746 * @}
jhon309 0:ac8863619623 747 */
jhon309 0:ac8863619623 748
jhon309 0:ac8863619623 749 /** @defgroup RCCEx_CRS_ReloadValueDefault RCCEx CRS ReloadValueDefault
jhon309 0:ac8863619623 750 * @{
jhon309 0:ac8863619623 751 */
jhon309 0:ac8863619623 752 #define RCC_CRS_RELOADVALUE_DEFAULT ((uint32_t)0xBB7F) /*!< The reset value of the RELOAD field corresponds
jhon309 0:ac8863619623 753 to a target frequency of 48 MHz and a synchronization signal frequency of 1 kHz (SOF signal from USB). */
jhon309 0:ac8863619623 754
jhon309 0:ac8863619623 755 #define IS_RCC_CRS_RELOADVALUE(_VALUE_) (((_VALUE_) <= 0xFFFF))
jhon309 0:ac8863619623 756 /**
jhon309 0:ac8863619623 757 * @}
jhon309 0:ac8863619623 758 */
jhon309 0:ac8863619623 759
jhon309 0:ac8863619623 760 /** @defgroup RCCEx_CRS_ErrorLimitDefault RCCEx CRS ErrorLimitDefault
jhon309 0:ac8863619623 761 * @{
jhon309 0:ac8863619623 762 */
jhon309 0:ac8863619623 763 #define RCC_CRS_ERRORLIMIT_DEFAULT ((uint32_t)0x22) /*!< Default Frequency error limit */
jhon309 0:ac8863619623 764
jhon309 0:ac8863619623 765 #define IS_RCC_CRS_ERRORLIMIT(_VALUE_) (((_VALUE_) <= 0xFF))
jhon309 0:ac8863619623 766 /**
jhon309 0:ac8863619623 767 * @}
jhon309 0:ac8863619623 768 */
jhon309 0:ac8863619623 769
jhon309 0:ac8863619623 770 /** @defgroup RCCEx_CRS_HSI48CalibrationDefault RCCEx CRS HSI48CalibrationDefault
jhon309 0:ac8863619623 771 * @{
jhon309 0:ac8863619623 772 */
jhon309 0:ac8863619623 773 #define RCC_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)0x20) /*!< The default value is 32, which corresponds to the middle of the trimming interval.
jhon309 0:ac8863619623 774 The trimming step is around 67 kHz between two consecutive TRIM steps. A higher TRIM value
jhon309 0:ac8863619623 775 corresponds to a higher output frequency */
jhon309 0:ac8863619623 776
jhon309 0:ac8863619623 777 #define IS_RCC_CRS_HSI48CALIBRATION(_VALUE_) (((_VALUE_) <= 0x3F))
jhon309 0:ac8863619623 778 /**
jhon309 0:ac8863619623 779 * @}
jhon309 0:ac8863619623 780 */
jhon309 0:ac8863619623 781
jhon309 0:ac8863619623 782 /** @defgroup RCCEx_CRS_FreqErrorDirection RCCEx CRS FreqErrorDirection
jhon309 0:ac8863619623 783 * @{
jhon309 0:ac8863619623 784 */
jhon309 0:ac8863619623 785 #define RCC_CRS_FREQERRORDIR_UP ((uint32_t)0x00) /*!< Upcounting direction, the actual frequency is above the target */
jhon309 0:ac8863619623 786 #define RCC_CRS_FREQERRORDIR_DOWN ((uint32_t)CRS_ISR_FEDIR) /*!< Downcounting direction, the actual frequency is below the target */
jhon309 0:ac8863619623 787
jhon309 0:ac8863619623 788 #define IS_RCC_CRS_FREQERRORDIR(_DIR_) (((_DIR_) == RCC_CRS_FREQERRORDIR_UP) || \
jhon309 0:ac8863619623 789 ((_DIR_) == RCC_CRS_FREQERRORDIR_DOWN))
jhon309 0:ac8863619623 790 /**
jhon309 0:ac8863619623 791 * @}
jhon309 0:ac8863619623 792 */
jhon309 0:ac8863619623 793
jhon309 0:ac8863619623 794 /** @defgroup RCCEx_CRS_Interrupt_Sources RCCEx CRS Interrupt Sources
jhon309 0:ac8863619623 795 * @{
jhon309 0:ac8863619623 796 */
jhon309 0:ac8863619623 797 #define RCC_CRS_IT_SYNCOK CRS_ISR_SYNCOKF /*!< SYNC event OK */
jhon309 0:ac8863619623 798 #define RCC_CRS_IT_SYNCWARN CRS_ISR_SYNCWARNF /*!< SYNC warning */
jhon309 0:ac8863619623 799 #define RCC_CRS_IT_ERR CRS_ISR_ERRF /*!< error */
jhon309 0:ac8863619623 800 #define RCC_CRS_IT_ESYNC CRS_ISR_ESYNCF /*!< Expected SYNC */
jhon309 0:ac8863619623 801 #define RCC_CRS_IT_TRIMOVF CRS_ISR_TRIMOVF /*!< Trimming overflow or underflow */
jhon309 0:ac8863619623 802 #define RCC_CRS_IT_SYNCERR CRS_ISR_SYNCERR /*!< SYNC error */
jhon309 0:ac8863619623 803 #define RCC_CRS_IT_SYNCMISS CRS_ISR_SYNCMISS /*!< SYNC missed*/
jhon309 0:ac8863619623 804
jhon309 0:ac8863619623 805 /**
jhon309 0:ac8863619623 806 * @}
jhon309 0:ac8863619623 807 */
jhon309 0:ac8863619623 808
jhon309 0:ac8863619623 809 /** @defgroup RCCEx_CRS_Flags RCCEx CRS Flags
jhon309 0:ac8863619623 810 * @{
jhon309 0:ac8863619623 811 */
jhon309 0:ac8863619623 812 #define RCC_CRS_FLAG_SYNCOK CRS_ISR_SYNCOKF /* SYNC event OK flag */
jhon309 0:ac8863619623 813 #define RCC_CRS_FLAG_SYNCWARN CRS_ISR_SYNCWARNF /* SYNC warning flag */
jhon309 0:ac8863619623 814 #define RCC_CRS_FLAG_ERR CRS_ISR_ERRF /* Error flag */
jhon309 0:ac8863619623 815 #define RCC_CRS_FLAG_ESYNC CRS_ISR_ESYNCF /* Expected SYNC flag */
jhon309 0:ac8863619623 816 #define RCC_CRS_FLAG_TRIMOVF CRS_ISR_TRIMOVF /*!< Trimming overflow or underflow */
jhon309 0:ac8863619623 817 #define RCC_CRS_FLAG_SYNCERR CRS_ISR_SYNCERR /*!< SYNC error */
jhon309 0:ac8863619623 818 #define RCC_CRS_FLAG_SYNCMISS CRS_ISR_SYNCMISS /*!< SYNC missed*/
jhon309 0:ac8863619623 819
jhon309 0:ac8863619623 820 /**
jhon309 0:ac8863619623 821 * @}
jhon309 0:ac8863619623 822 */
jhon309 0:ac8863619623 823
jhon309 0:ac8863619623 824 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 825 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 826 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 827
jhon309 0:ac8863619623 828 /**
jhon309 0:ac8863619623 829 * @}
jhon309 0:ac8863619623 830 */
jhon309 0:ac8863619623 831
jhon309 0:ac8863619623 832 /* Exported macros ------------------------------------------------------------*/
jhon309 0:ac8863619623 833 /** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
jhon309 0:ac8863619623 834 * @{
jhon309 0:ac8863619623 835 */
jhon309 0:ac8863619623 836
jhon309 0:ac8863619623 837 /** @defgroup RCCEx_Peripheral_Clock_Enable_Disable RCCEx_Peripheral_Clock_Enable_Disable
jhon309 0:ac8863619623 838 * @brief Enables or disables the AHB1 peripheral clock.
jhon309 0:ac8863619623 839 * @note After reset, the peripheral clock (used for registers read/write access)
jhon309 0:ac8863619623 840 * is disabled and the application software has to enable this clock before
jhon309 0:ac8863619623 841 * using it.
jhon309 0:ac8863619623 842 * @{
jhon309 0:ac8863619623 843 */
jhon309 0:ac8863619623 844 #if defined(STM32F030x6) || defined(STM32F030x8) || \
jhon309 0:ac8863619623 845 defined(STM32F051x8) || defined(STM32F058xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 846 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 847 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 848
jhon309 0:ac8863619623 849 #define __GPIOD_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_GPIODEN))
jhon309 0:ac8863619623 850
jhon309 0:ac8863619623 851 #define __GPIOD_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIODEN))
jhon309 0:ac8863619623 852
jhon309 0:ac8863619623 853 #endif /* STM32F030x6 || STM32F030x8 || */
jhon309 0:ac8863619623 854 /* STM32F051x8 || STM32F058xx || STM32F070xB || */
jhon309 0:ac8863619623 855 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 856 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 857
jhon309 0:ac8863619623 858 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 859 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 860
jhon309 0:ac8863619623 861 #define __GPIOE_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_GPIOEEN))
jhon309 0:ac8863619623 862
jhon309 0:ac8863619623 863 #define __GPIOE_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIOEEN))
jhon309 0:ac8863619623 864
jhon309 0:ac8863619623 865 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 866 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 867
jhon309 0:ac8863619623 868 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 869 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 870 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 871 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 872
jhon309 0:ac8863619623 873 #define __TSC_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_TSCEN))
jhon309 0:ac8863619623 874
jhon309 0:ac8863619623 875 #define __TSC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_TSCEN))
jhon309 0:ac8863619623 876
jhon309 0:ac8863619623 877 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 878 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 879 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 880 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 881
jhon309 0:ac8863619623 882 #if defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 883
jhon309 0:ac8863619623 884 #define __DMA2_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_DMA2EN))
jhon309 0:ac8863619623 885
jhon309 0:ac8863619623 886 #define __DMA2_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_DMA2EN))
jhon309 0:ac8863619623 887
jhon309 0:ac8863619623 888 #endif /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 889
jhon309 0:ac8863619623 890 /** @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
jhon309 0:ac8863619623 891 * @note After reset, the peripheral clock (used for registers read/write access)
jhon309 0:ac8863619623 892 * is disabled and the application software has to enable this clock before
jhon309 0:ac8863619623 893 * using it.
jhon309 0:ac8863619623 894 */
jhon309 0:ac8863619623 895 #if defined(STM32F030x8) || \
jhon309 0:ac8863619623 896 defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 897 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 898 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 899 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 900
jhon309 0:ac8863619623 901 #define __USART2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_USART2EN))
jhon309 0:ac8863619623 902 #define __SPI2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_SPI2EN))
jhon309 0:ac8863619623 903
jhon309 0:ac8863619623 904 #define __USART2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART2EN))
jhon309 0:ac8863619623 905 #define __SPI2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI2EN))
jhon309 0:ac8863619623 906
jhon309 0:ac8863619623 907 #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 908 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 909 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 910 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 911
jhon309 0:ac8863619623 912 #if defined(STM32F031x6) || defined(STM32F038xx) || \
jhon309 0:ac8863619623 913 defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 914 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 915 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 916 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 917
jhon309 0:ac8863619623 918 #define __TIM2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_TIM2EN))
jhon309 0:ac8863619623 919
jhon309 0:ac8863619623 920 #define __TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
jhon309 0:ac8863619623 921
jhon309 0:ac8863619623 922 #endif /* STM32F031x6 || STM32F038xx || */
jhon309 0:ac8863619623 923 /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 924 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 925 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 926 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 927
jhon309 0:ac8863619623 928 #if defined(STM32F030x8) || \
jhon309 0:ac8863619623 929 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 930 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 931 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 932
jhon309 0:ac8863619623 933 #define __TIM6_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_TIM6EN))
jhon309 0:ac8863619623 934 #define __I2C2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_I2C2EN))
jhon309 0:ac8863619623 935
jhon309 0:ac8863619623 936 #define __TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
jhon309 0:ac8863619623 937 #define __I2C2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN))
jhon309 0:ac8863619623 938
jhon309 0:ac8863619623 939 #endif /* STM32F030x8 || */
jhon309 0:ac8863619623 940 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 941 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 942 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 943
jhon309 0:ac8863619623 944 #if defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 945 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 946 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 947
jhon309 0:ac8863619623 948 #define __DAC1_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_DACEN))
jhon309 0:ac8863619623 949
jhon309 0:ac8863619623 950 #define __DAC1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
jhon309 0:ac8863619623 951
jhon309 0:ac8863619623 952 #endif /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 953 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 954 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 955
jhon309 0:ac8863619623 956 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 957 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 958 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 959 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 960
jhon309 0:ac8863619623 961 #define __CEC_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_CECEN))
jhon309 0:ac8863619623 962
jhon309 0:ac8863619623 963 #define __CEC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CECEN))
jhon309 0:ac8863619623 964
jhon309 0:ac8863619623 965 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 966 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 967 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 968 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 969
jhon309 0:ac8863619623 970 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 971 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 972
jhon309 0:ac8863619623 973 #define __TIM7_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_TIM7EN))
jhon309 0:ac8863619623 974 #define __USART3_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_USART3EN))
jhon309 0:ac8863619623 975 #define __USART4_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_USART4EN))
jhon309 0:ac8863619623 976
jhon309 0:ac8863619623 977 #define __TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
jhon309 0:ac8863619623 978 #define __USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
jhon309 0:ac8863619623 979 #define __USART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART4EN))
jhon309 0:ac8863619623 980
jhon309 0:ac8863619623 981 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 982 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 983
jhon309 0:ac8863619623 984 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) || \
jhon309 0:ac8863619623 985 defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
jhon309 0:ac8863619623 986
jhon309 0:ac8863619623 987 #define __USB_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_USBEN))
jhon309 0:ac8863619623 988
jhon309 0:ac8863619623 989 #define __USB_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USBEN))
jhon309 0:ac8863619623 990
jhon309 0:ac8863619623 991 #endif /* STM32F042x6 || STM32F048xx || STM32F070x6 || */
jhon309 0:ac8863619623 992 /* STM32F072xB || STM32F078xx || STM32F070xB */
jhon309 0:ac8863619623 993
jhon309 0:ac8863619623 994 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || \
jhon309 0:ac8863619623 995 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 996
jhon309 0:ac8863619623 997 #define __CAN_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_CANEN))
jhon309 0:ac8863619623 998 #define __CAN_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CANEN))
jhon309 0:ac8863619623 999
jhon309 0:ac8863619623 1000 #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || */
jhon309 0:ac8863619623 1001 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1002
jhon309 0:ac8863619623 1003 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1004 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1005 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1006
jhon309 0:ac8863619623 1007 #define __CRS_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_CRSEN))
jhon309 0:ac8863619623 1008
jhon309 0:ac8863619623 1009 #define __CRS_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CRSEN))
jhon309 0:ac8863619623 1010
jhon309 0:ac8863619623 1011 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1012 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1013 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1014
jhon309 0:ac8863619623 1015 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1016
jhon309 0:ac8863619623 1017 #define __USART5_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_USART5EN))
jhon309 0:ac8863619623 1018
jhon309 0:ac8863619623 1019 #define __USART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART5EN))
jhon309 0:ac8863619623 1020
jhon309 0:ac8863619623 1021 #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1022
jhon309 0:ac8863619623 1023 /** @brief Enable or disable the High Speed APB (APB2) peripheral clock.
jhon309 0:ac8863619623 1024 * @note After reset, the peripheral clock (used for registers read/write access)
jhon309 0:ac8863619623 1025 * is disabled and the application software has to enable this clock before
jhon309 0:ac8863619623 1026 * using it.
jhon309 0:ac8863619623 1027 */
jhon309 0:ac8863619623 1028 #if defined(STM32F030x8) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) || \
jhon309 0:ac8863619623 1029 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1030 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 1031 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1032
jhon309 0:ac8863619623 1033 #define __TIM15_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_TIM15EN))
jhon309 0:ac8863619623 1034
jhon309 0:ac8863619623 1035 #define __TIM15_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM15EN))
jhon309 0:ac8863619623 1036
jhon309 0:ac8863619623 1037 #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || STM32F070x6 || */
jhon309 0:ac8863619623 1038 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1039 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1040 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1041
jhon309 0:ac8863619623 1042 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1043
jhon309 0:ac8863619623 1044 #define __USART6_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_USART6EN))
jhon309 0:ac8863619623 1045
jhon309 0:ac8863619623 1046 #define __USART6_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART6EN))
jhon309 0:ac8863619623 1047
jhon309 0:ac8863619623 1048 #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1049
jhon309 0:ac8863619623 1050 #if defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1051
jhon309 0:ac8863619623 1052 #define __USART7_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_USART7EN))
jhon309 0:ac8863619623 1053 #define __USART8_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_USART8EN))
jhon309 0:ac8863619623 1054
jhon309 0:ac8863619623 1055 #define __USART7_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART7EN))
jhon309 0:ac8863619623 1056 #define __USART8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART8EN))
jhon309 0:ac8863619623 1057
jhon309 0:ac8863619623 1058 #endif /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1059
jhon309 0:ac8863619623 1060 /**
jhon309 0:ac8863619623 1061 * @}
jhon309 0:ac8863619623 1062 */
jhon309 0:ac8863619623 1063
jhon309 0:ac8863619623 1064
jhon309 0:ac8863619623 1065 /** @defgroup RCCEx_Force_Release_Peripheral_Reset RCCEx Force Release Peripheral Reset
jhon309 0:ac8863619623 1066 * @brief Forces or releases peripheral reset.
jhon309 0:ac8863619623 1067 * @{
jhon309 0:ac8863619623 1068 */
jhon309 0:ac8863619623 1069
jhon309 0:ac8863619623 1070 /** @brief Force or release AHB peripheral reset.
jhon309 0:ac8863619623 1071 */
jhon309 0:ac8863619623 1072 #if defined(STM32F030x6) || defined(STM32F030x8) || \
jhon309 0:ac8863619623 1073 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1074 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 1075 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1076
jhon309 0:ac8863619623 1077 #define __GPIOD_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIODRST))
jhon309 0:ac8863619623 1078
jhon309 0:ac8863619623 1079 #define __GPIOD_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIODRST))
jhon309 0:ac8863619623 1080
jhon309 0:ac8863619623 1081 #endif /* STM32F030x6 || STM32F030x8 || */
jhon309 0:ac8863619623 1082 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1083 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1084 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1085
jhon309 0:ac8863619623 1086 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 1087 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1088
jhon309 0:ac8863619623 1089 #define __GPIOE_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIOERST))
jhon309 0:ac8863619623 1090
jhon309 0:ac8863619623 1091 #define __GPIOE_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIOERST))
jhon309 0:ac8863619623 1092
jhon309 0:ac8863619623 1093 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1094 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1095
jhon309 0:ac8863619623 1096 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1097 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1098 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1099 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1100
jhon309 0:ac8863619623 1101 #define __TSC_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_TSCRST))
jhon309 0:ac8863619623 1102
jhon309 0:ac8863619623 1103 #define __TSC_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_TSCRST))
jhon309 0:ac8863619623 1104
jhon309 0:ac8863619623 1105 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1106 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1107 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1108 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1109
jhon309 0:ac8863619623 1110 /** @brief Force or release APB1 peripheral reset.
jhon309 0:ac8863619623 1111 */
jhon309 0:ac8863619623 1112 #if defined(STM32F030x8) || \
jhon309 0:ac8863619623 1113 defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) || \
jhon309 0:ac8863619623 1114 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1115 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 1116 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1117
jhon309 0:ac8863619623 1118 #define __USART2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
jhon309 0:ac8863619623 1119 #define __SPI2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
jhon309 0:ac8863619623 1120
jhon309 0:ac8863619623 1121 #define __USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
jhon309 0:ac8863619623 1122 #define __SPI2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI2RST))
jhon309 0:ac8863619623 1123
jhon309 0:ac8863619623 1124 #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || STM32F070x6 || */
jhon309 0:ac8863619623 1125 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1126 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1127 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1128
jhon309 0:ac8863619623 1129 #if defined(STM32F031x6) || defined(STM32F038xx) || \
jhon309 0:ac8863619623 1130 defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1131 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1132 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1133 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1134
jhon309 0:ac8863619623 1135 #define __TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
jhon309 0:ac8863619623 1136
jhon309 0:ac8863619623 1137 #define __TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
jhon309 0:ac8863619623 1138
jhon309 0:ac8863619623 1139 #endif /* STM32F031x6 || STM32F038xx || */
jhon309 0:ac8863619623 1140 /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1141 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1142 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1143 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1144
jhon309 0:ac8863619623 1145 #if defined(STM32F030x8) || \
jhon309 0:ac8863619623 1146 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1147 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) ||\
jhon309 0:ac8863619623 1148 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1149
jhon309 0:ac8863619623 1150 #define __TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
jhon309 0:ac8863619623 1151 #define __I2C2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
jhon309 0:ac8863619623 1152
jhon309 0:ac8863619623 1153 #define __TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
jhon309 0:ac8863619623 1154 #define __I2C2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C2RST))
jhon309 0:ac8863619623 1155
jhon309 0:ac8863619623 1156 #endif /* STM32F030x8 || */
jhon309 0:ac8863619623 1157 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1158 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1159 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1160
jhon309 0:ac8863619623 1161 #if defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1162 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1163 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1164
jhon309 0:ac8863619623 1165 #define __DAC1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
jhon309 0:ac8863619623 1166
jhon309 0:ac8863619623 1167 #define __DAC1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
jhon309 0:ac8863619623 1168
jhon309 0:ac8863619623 1169 #endif /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1170 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1171 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1172
jhon309 0:ac8863619623 1173 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1174 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1175 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1176 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1177
jhon309 0:ac8863619623 1178 #define __CEC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CECRST))
jhon309 0:ac8863619623 1179
jhon309 0:ac8863619623 1180 #define __CEC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CECRST))
jhon309 0:ac8863619623 1181
jhon309 0:ac8863619623 1182 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1183 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1184 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1185 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1186
jhon309 0:ac8863619623 1187 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 1188 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1189
jhon309 0:ac8863619623 1190 #define __TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
jhon309 0:ac8863619623 1191 #define __USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
jhon309 0:ac8863619623 1192 #define __USART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART4RST))
jhon309 0:ac8863619623 1193
jhon309 0:ac8863619623 1194 #define __TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
jhon309 0:ac8863619623 1195 #define __USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
jhon309 0:ac8863619623 1196 #define __USART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART4RST))
jhon309 0:ac8863619623 1197
jhon309 0:ac8863619623 1198 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1199 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1200
jhon309 0:ac8863619623 1201 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) || \
jhon309 0:ac8863619623 1202 defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
jhon309 0:ac8863619623 1203
jhon309 0:ac8863619623 1204 #define __USB_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USBRST))
jhon309 0:ac8863619623 1205
jhon309 0:ac8863619623 1206 #define __USB_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USBRST))
jhon309 0:ac8863619623 1207
jhon309 0:ac8863619623 1208 #endif /* STM32F042x6 || STM32F048xx || STM32F070x6 || */
jhon309 0:ac8863619623 1209 /* STM32F072xB || STM32F078xx || STM32F070xB */
jhon309 0:ac8863619623 1210
jhon309 0:ac8863619623 1211 #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || \
jhon309 0:ac8863619623 1212 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1213
jhon309 0:ac8863619623 1214 #define __CAN_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CANRST))
jhon309 0:ac8863619623 1215
jhon309 0:ac8863619623 1216 #define __CAN_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CANRST))
jhon309 0:ac8863619623 1217
jhon309 0:ac8863619623 1218 #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || */
jhon309 0:ac8863619623 1219 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1220
jhon309 0:ac8863619623 1221 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1222 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1223 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1224
jhon309 0:ac8863619623 1225 #define __CRS_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CRSRST))
jhon309 0:ac8863619623 1226
jhon309 0:ac8863619623 1227 #define __CRS_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CRSRST))
jhon309 0:ac8863619623 1228
jhon309 0:ac8863619623 1229 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1230 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1231 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1232
jhon309 0:ac8863619623 1233 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1234
jhon309 0:ac8863619623 1235 #define __USART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART5RST))
jhon309 0:ac8863619623 1236
jhon309 0:ac8863619623 1237 #define __USART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART5RST))
jhon309 0:ac8863619623 1238
jhon309 0:ac8863619623 1239 #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1240
jhon309 0:ac8863619623 1241
jhon309 0:ac8863619623 1242 /** @brief Force or release APB2 peripheral reset.
jhon309 0:ac8863619623 1243 */
jhon309 0:ac8863619623 1244 #if defined(STM32F030x8) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) || \
jhon309 0:ac8863619623 1245 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1246 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 1247 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1248
jhon309 0:ac8863619623 1249 #define __TIM15_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM15RST))
jhon309 0:ac8863619623 1250
jhon309 0:ac8863619623 1251 #define __TIM15_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM15RST))
jhon309 0:ac8863619623 1252
jhon309 0:ac8863619623 1253 #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || STM32F070x6 || */
jhon309 0:ac8863619623 1254 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1255 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1256 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1257
jhon309 0:ac8863619623 1258 #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1259
jhon309 0:ac8863619623 1260 #define __USART6_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART6RST))
jhon309 0:ac8863619623 1261
jhon309 0:ac8863619623 1262 #define __USART6_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART6RST))
jhon309 0:ac8863619623 1263
jhon309 0:ac8863619623 1264 #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1265
jhon309 0:ac8863619623 1266 #if defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1267
jhon309 0:ac8863619623 1268 #define __USART7_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART7RST))
jhon309 0:ac8863619623 1269 #define __USART8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART8RST))
jhon309 0:ac8863619623 1270
jhon309 0:ac8863619623 1271 #define __USART7_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART7RST))
jhon309 0:ac8863619623 1272 #define __USART8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART8RST))
jhon309 0:ac8863619623 1273
jhon309 0:ac8863619623 1274 #endif /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1275
jhon309 0:ac8863619623 1276 /**
jhon309 0:ac8863619623 1277 * @}
jhon309 0:ac8863619623 1278 */
jhon309 0:ac8863619623 1279
jhon309 0:ac8863619623 1280 /** @defgroup RCCEx_HSI48_Enable_Disable RCCEx HSI48 Enable Disable
jhon309 0:ac8863619623 1281 * @brief Macros to enable or disable the Internal 48Mhz High Speed oscillator (HSI48).
jhon309 0:ac8863619623 1282 * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes.
jhon309 0:ac8863619623 1283 * @note HSI48 can not be stopped if it is used as system clock source. In this case,
jhon309 0:ac8863619623 1284 * you have to select another source of the system clock then stop the HSI14.
jhon309 0:ac8863619623 1285 * @note After enabling the HSI48 with __HAL_RCC_HSI48_ENABLE(), the application software
jhon309 0:ac8863619623 1286 * should wait on HSI48RDY flag to be set indicating that HSI48 clock is stable and can be
jhon309 0:ac8863619623 1287 * used as system clock source. This is not necessary if HAL_RCC_OscConfig() is used.
jhon309 0:ac8863619623 1288 * @note When the HSI48 is stopped, HSI48RDY flag goes low after 6 HSI48 oscillator
jhon309 0:ac8863619623 1289 * clock cycles.
jhon309 0:ac8863619623 1290 * @{
jhon309 0:ac8863619623 1291 */
jhon309 0:ac8863619623 1292 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1293 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1294 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1295
jhon309 0:ac8863619623 1296 #define __HAL_RCC_HSI48_ENABLE() SET_BIT(RCC->CR2, RCC_CR2_HSI48ON)
jhon309 0:ac8863619623 1297 #define __HAL_RCC_HSI48_DISABLE() CLEAR_BIT(RCC->CR2, RCC_CR2_HSI48ON)
jhon309 0:ac8863619623 1298
jhon309 0:ac8863619623 1299 /** @brief Macro to get the Internal 48Mhz High Speed oscillator (HSI48) state.
jhon309 0:ac8863619623 1300 * @retval The clock source can be one of the following values:
jhon309 0:ac8863619623 1301 * @arg RCC_HSI48_ON: HSI48 enabled
jhon309 0:ac8863619623 1302 * @arg RCC_HSI48_OFF: HSI48 disabled
jhon309 0:ac8863619623 1303 */
jhon309 0:ac8863619623 1304 #define __HAL_RCC_GET_HSI48_STATE() \
jhon309 0:ac8863619623 1305 (((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CR2_HSI48ON)) != RESET) ? RCC_HSI48_ON : RCC_HSI48_OFF)
jhon309 0:ac8863619623 1306
jhon309 0:ac8863619623 1307 #else
jhon309 0:ac8863619623 1308
jhon309 0:ac8863619623 1309 /** @brief Macro to get the Internal 48Mhz High Speed oscillator (HSI48) state.
jhon309 0:ac8863619623 1310 * @retval The clock source can be one of the following values:
jhon309 0:ac8863619623 1311 * @arg RCC_HSI_OFF: HSI48 disabled
jhon309 0:ac8863619623 1312 */
jhon309 0:ac8863619623 1313 #define __HAL_RCC_GET_HSI48_STATE() RCC_HSI_OFF
jhon309 0:ac8863619623 1314
jhon309 0:ac8863619623 1315 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1316 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1317 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1318
jhon309 0:ac8863619623 1319 /**
jhon309 0:ac8863619623 1320 * @}
jhon309 0:ac8863619623 1321 */
jhon309 0:ac8863619623 1322
jhon309 0:ac8863619623 1323 /** @defgroup RCCEx_Peripheral_Clock_Source_Config RCCEx Peripheral Clock Source Config
jhon309 0:ac8863619623 1324 * @{
jhon309 0:ac8863619623 1325 */
jhon309 0:ac8863619623 1326 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1327 defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1328 defined(STM32F070x6) || defined(STM32F070xB)
jhon309 0:ac8863619623 1329
jhon309 0:ac8863619623 1330 /** @brief Macro to configure the USB clock (USBCLK).
jhon309 0:ac8863619623 1331 * @param __USBCLKSource__: specifies the USB clock source.
jhon309 0:ac8863619623 1332 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1333 * @arg RCC_USBCLKSOURCE_HSI48: HSI48 selected as USB clock (not available for STM32F070x6 & STM32F070xB)
jhon309 0:ac8863619623 1334 * @arg RCC_USBCLKSOURCE_PLLCLK: PLL Clock selected as USB clock
jhon309 0:ac8863619623 1335 */
jhon309 0:ac8863619623 1336 #define __HAL_RCC_USB_CONFIG(__USBCLKSource__) \
jhon309 0:ac8863619623 1337 MODIFY_REG(RCC->CFGR3, RCC_CFGR3_USBSW, (uint32_t)(__USBCLKSource__))
jhon309 0:ac8863619623 1338
jhon309 0:ac8863619623 1339 /** @brief Macro to get the USB clock source.
jhon309 0:ac8863619623 1340 * @retval The clock source can be one of the following values:
jhon309 0:ac8863619623 1341 * @arg RCC_USBCLKSOURCE_HSI48: HSI48 selected as USB clock (not available for STM32F070x6 & STM32F070xB)
jhon309 0:ac8863619623 1342 * @arg RCC_USBCLKSOURCE_PLLCLK: PLL Clock selected as USB clock
jhon309 0:ac8863619623 1343 */
jhon309 0:ac8863619623 1344 #define __HAL_RCC_GET_USB_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_USBSW)))
jhon309 0:ac8863619623 1345
jhon309 0:ac8863619623 1346 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1347 /* STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1348 /* STM32F070x6 || STM32F070xB */
jhon309 0:ac8863619623 1349
jhon309 0:ac8863619623 1350 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1351 defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 1352 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1353 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1354
jhon309 0:ac8863619623 1355 /** @brief Macro to configure the CEC clock.
jhon309 0:ac8863619623 1356 * @param __CECCLKSource__: specifies the CEC clock source.
jhon309 0:ac8863619623 1357 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1358 * @arg RCC_CECCLKSOURCE_HSI: HSI selected as CEC clock
jhon309 0:ac8863619623 1359 * @arg RCC_CECCLKSOURCE_LSE: LSE selected as CEC clock
jhon309 0:ac8863619623 1360 */
jhon309 0:ac8863619623 1361 #define __HAL_RCC_CEC_CONFIG(__CECCLKSource__) \
jhon309 0:ac8863619623 1362 MODIFY_REG(RCC->CFGR3, RCC_CFGR3_CECSW, (uint32_t)(__CECCLKSource__))
jhon309 0:ac8863619623 1363
jhon309 0:ac8863619623 1364 /** @brief Macro to get the HDMI CEC clock source.
jhon309 0:ac8863619623 1365 * @retval The clock source can be one of the following values:
jhon309 0:ac8863619623 1366 * @arg RCC_CECCLKSOURCE_HSI: HSI selected as CEC clock
jhon309 0:ac8863619623 1367 * @arg RCC_CECCLKSOURCE_LSE: LSE selected as CEC clock
jhon309 0:ac8863619623 1368 */
jhon309 0:ac8863619623 1369 #define __HAL_RCC_GET_CEC_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_CECSW)))
jhon309 0:ac8863619623 1370
jhon309 0:ac8863619623 1371 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1372 /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 1373 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1374 /* STM32F091xC || defined(STM32F098xx) */
jhon309 0:ac8863619623 1375
jhon309 0:ac8863619623 1376 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) || \
jhon309 0:ac8863619623 1377 defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6) || \
jhon309 0:ac8863619623 1378 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB) || \
jhon309 0:ac8863619623 1379 defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
jhon309 0:ac8863619623 1380
jhon309 0:ac8863619623 1381 /** @brief Macro to configure the MCO clock.
jhon309 0:ac8863619623 1382 * @param __MCOCLKSource__: specifies the MCO clock source.
jhon309 0:ac8863619623 1383 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1384 * @arg RCC_MCOSOURCE_HSI: HSI selected as MCO clock
jhon309 0:ac8863619623 1385 * @arg RCC_MCOSOURCE_HSE: HSE selected as MCO clock
jhon309 0:ac8863619623 1386 * @arg RCC_MCOSOURCE_LSI: LSI selected as MCO clock
jhon309 0:ac8863619623 1387 * @arg RCC_MCOSOURCE_LSE: LSE selected as MCO clock
jhon309 0:ac8863619623 1388 * @arg RCC_MCOSOURCE_PLLCLK_NODIV: PLLCLK selected as MCO clock
jhon309 0:ac8863619623 1389 * @arg RCC_MCOSOURCE_PLLCLK_DIV2: PLLCLK Divided by 2 selected as MCO clock
jhon309 0:ac8863619623 1390 * @arg RCC_MCOSOURCE_SYSCLK: System Clock selected as MCO clock
jhon309 0:ac8863619623 1391 * @arg RCC_MCOSOURCE_HSI14: HSI14 selected as MCO clock
jhon309 0:ac8863619623 1392 * @arg RCC_MCOSOURCE_HSI48: HSI48 selected as MCO clock
jhon309 0:ac8863619623 1393 * @param __MCODiv__: specifies the MCO clock prescaler.
jhon309 0:ac8863619623 1394 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1395 * @arg RCC_MCO_DIV1: MCO clock source is divided by 1
jhon309 0:ac8863619623 1396 * @arg RCC_MCO_DIV2: MCO clock source is divided by 2
jhon309 0:ac8863619623 1397 * @arg RCC_MCO_DIV4: MCO clock source is divided by 4
jhon309 0:ac8863619623 1398 * @arg RCC_MCO_DIV8: MCO clock source is divided by 8
jhon309 0:ac8863619623 1399 * @arg RCC_MCO_DIV16: MCO clock source is divided by 16
jhon309 0:ac8863619623 1400 * @arg RCC_MCO_DIV32: MCO clock source is divided by 32
jhon309 0:ac8863619623 1401 * @arg RCC_MCO_DIV64: MCO clock source is divided by 64
jhon309 0:ac8863619623 1402 * @arg RCC_MCO_DIV128: MCO clock source is divided by 128
jhon309 0:ac8863619623 1403 */
jhon309 0:ac8863619623 1404 #define __HAL_RCC_MCO_CONFIG(__MCOCLKSource__, __MCODiv__) \
jhon309 0:ac8863619623 1405 MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO | RCC_CFGR_MCOPRE), ((__MCOCLKSource__) | (__MCODiv__)))
jhon309 0:ac8863619623 1406 #else
jhon309 0:ac8863619623 1407
jhon309 0:ac8863619623 1408 /** @brief Macro to configure the MCO clock.
jhon309 0:ac8863619623 1409 * @param __MCOCLKSource__: specifies the MCO clock source.
jhon309 0:ac8863619623 1410 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1411 * @arg RCC_MCOSOURCE_HSI: HSI selected as MCO clock
jhon309 0:ac8863619623 1412 * @arg RCC_MCOSOURCE_HSE: HSE selected as MCO clock
jhon309 0:ac8863619623 1413 * @arg RCC_MCOSOURCE_LSI: LSI selected as MCO clock
jhon309 0:ac8863619623 1414 * @arg RCC_MCOSOURCE_LSE: LSE selected as MCO clock
jhon309 0:ac8863619623 1415 * @arg RCC_MCOSOURCE_PLLCLK_DIV2: PLLCLK Divided by 2 selected as MCO clock
jhon309 0:ac8863619623 1416 * @arg RCC_MCOSOURCE_SYSCLK: System Clock selected as MCO clock
jhon309 0:ac8863619623 1417 * @arg RCC_MCOSOURCE_HSI14: HSI14 selected as MCO clock
jhon309 0:ac8863619623 1418 * @arg RCC_MCOSOURCE_HSI48: HSI48 selected as MCO clock
jhon309 0:ac8863619623 1419 * @param __MCODiv__: specifies the MCO clock prescaler.
jhon309 0:ac8863619623 1420 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1421 * @arg RCC_MCO_NODIV: No division applied on MCO clock source
jhon309 0:ac8863619623 1422 */
jhon309 0:ac8863619623 1423 #define __HAL_RCC_MCO_CONFIG(__MCOCLKSource__, __MCODiv__) \
jhon309 0:ac8863619623 1424 MODIFY_REG(RCC->CFGR, RCC_CFGR_MCO, __MCOCLKSource__)
jhon309 0:ac8863619623 1425
jhon309 0:ac8863619623 1426 #endif /* STM32F030x6 || STM32F031x6 || STM32F038xx || STM32F070x6 || */
jhon309 0:ac8863619623 1427 /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1428 /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
jhon309 0:ac8863619623 1429 /* STM32F091xC || STM32F098xx || STM32F030xC */
jhon309 0:ac8863619623 1430
jhon309 0:ac8863619623 1431 #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1432 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1433 /** @brief Macro to configure the USART2 clock (USART2CLK).
jhon309 0:ac8863619623 1434 * @param __USART2CLKSource__: specifies the USART2 clock source.
jhon309 0:ac8863619623 1435 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1436 * @arg RCC_USART2CLKSOURCE_PCLK1: PCLK1 selected as USART2 clock
jhon309 0:ac8863619623 1437 * @arg RCC_USART2CLKSOURCE_HSI: HSI selected as USART2 clock
jhon309 0:ac8863619623 1438 * @arg RCC_USART2CLKSOURCE_SYSCLK: System Clock selected as USART2 clock
jhon309 0:ac8863619623 1439 * @arg RCC_USART2CLKSOURCE_LSE: LSE selected as USART2 clock
jhon309 0:ac8863619623 1440 */
jhon309 0:ac8863619623 1441 #define __HAL_RCC_USART2_CONFIG(__USART2CLKSource__) \
jhon309 0:ac8863619623 1442 MODIFY_REG(RCC->CFGR3, RCC_CFGR3_USART2SW, (uint32_t)(__USART2CLKSource__))
jhon309 0:ac8863619623 1443
jhon309 0:ac8863619623 1444 /** @brief Macro to get the USART2 clock source.
jhon309 0:ac8863619623 1445 * @retval The clock source can be one of the following values:
jhon309 0:ac8863619623 1446 * @arg RCC_USART2CLKSOURCE_PCLK1: PCLK1 selected as USART2 clock
jhon309 0:ac8863619623 1447 * @arg RCC_USART2CLKSOURCE_HSI: HSI selected as USART2 clock
jhon309 0:ac8863619623 1448 * @arg RCC_USART2CLKSOURCE_SYSCLK: System Clock selected as USART2 clock
jhon309 0:ac8863619623 1449 * @arg RCC_USART2CLKSOURCE_LSE: LSE selected as USART2 clock
jhon309 0:ac8863619623 1450 */
jhon309 0:ac8863619623 1451 #define __HAL_RCC_GET_USART2_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_USART2SW)))
jhon309 0:ac8863619623 1452 #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F091xC || STM32F098xx*/
jhon309 0:ac8863619623 1453
jhon309 0:ac8863619623 1454 #if defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1455 /** @brief Macro to configure the USART3 clock (USART3CLK).
jhon309 0:ac8863619623 1456 * @param __USART3CLKSource__: specifies the USART3 clock source.
jhon309 0:ac8863619623 1457 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1458 * @arg RCC_USART3CLKSOURCE_PCLK1: PCLK1 selected as USART3 clock
jhon309 0:ac8863619623 1459 * @arg RCC_USART3CLKSOURCE_HSI: HSI selected as USART3 clock
jhon309 0:ac8863619623 1460 * @arg RCC_USART3CLKSOURCE_SYSCLK: System Clock selected as USART3 clock
jhon309 0:ac8863619623 1461 * @arg RCC_USART3CLKSOURCE_LSE: LSE selected as USART3 clock
jhon309 0:ac8863619623 1462 */
jhon309 0:ac8863619623 1463 #define __HAL_RCC_USART3_CONFIG(__USART3CLKSource__) \
jhon309 0:ac8863619623 1464 MODIFY_REG(RCC->CFGR3, RCC_CFGR3_USART3SW, (uint32_t)(__USART3CLKSource__))
jhon309 0:ac8863619623 1465
jhon309 0:ac8863619623 1466 /** @brief Macro to get the USART3 clock source.
jhon309 0:ac8863619623 1467 * @retval The clock source can be one of the following values:
jhon309 0:ac8863619623 1468 * @arg RCC_USART3CLKSOURCE_PCLK1: PCLK1 selected as USART3 clock
jhon309 0:ac8863619623 1469 * @arg RCC_USART3CLKSOURCE_HSI: HSI selected as USART3 clock
jhon309 0:ac8863619623 1470 * @arg RCC_USART3CLKSOURCE_SYSCLK: System Clock selected as USART3 clock
jhon309 0:ac8863619623 1471 * @arg RCC_USART3CLKSOURCE_LSE: LSE selected as USART3 clock
jhon309 0:ac8863619623 1472 */
jhon309 0:ac8863619623 1473 #define __HAL_RCC_GET_USART3_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_USART3SW)))
jhon309 0:ac8863619623 1474
jhon309 0:ac8863619623 1475 #endif /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1476 /**
jhon309 0:ac8863619623 1477 * @}
jhon309 0:ac8863619623 1478 */
jhon309 0:ac8863619623 1479
jhon309 0:ac8863619623 1480 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1481 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1482 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1483
jhon309 0:ac8863619623 1484 /** @defgroup RCCEx_IT_And_Flag RCCEx IT and Flag
jhon309 0:ac8863619623 1485 * @{
jhon309 0:ac8863619623 1486 */
jhon309 0:ac8863619623 1487 /* Interrupt & Flag management */
jhon309 0:ac8863619623 1488
jhon309 0:ac8863619623 1489 /**
jhon309 0:ac8863619623 1490 * @brief Enables the specified CRS interrupts.
jhon309 0:ac8863619623 1491 * @param __INTERRUPT__: specifies the CRS interrupt sources to be enabled.
jhon309 0:ac8863619623 1492 * This parameter can be any combination of the following values:
jhon309 0:ac8863619623 1493 * @arg RCC_CRS_IT_SYNCOK
jhon309 0:ac8863619623 1494 * @arg RCC_CRS_IT_SYNCWARN
jhon309 0:ac8863619623 1495 * @arg RCC_CRS_IT_ERR
jhon309 0:ac8863619623 1496 * @arg RCC_CRS_IT_ESYNC
jhon309 0:ac8863619623 1497 * @retval None
jhon309 0:ac8863619623 1498 */
jhon309 0:ac8863619623 1499 #define __HAL_RCC_CRS_ENABLE_IT(__INTERRUPT__) (CRS->CR |= (__INTERRUPT__))
jhon309 0:ac8863619623 1500
jhon309 0:ac8863619623 1501 /**
jhon309 0:ac8863619623 1502 * @brief Disables the specified CRS interrupts.
jhon309 0:ac8863619623 1503 * @param __INTERRUPT__: specifies the CRS interrupt sources to be disabled.
jhon309 0:ac8863619623 1504 * This parameter can be any combination of the following values:
jhon309 0:ac8863619623 1505 * @arg RCC_CRS_IT_SYNCOK
jhon309 0:ac8863619623 1506 * @arg RCC_CRS_IT_SYNCWARN
jhon309 0:ac8863619623 1507 * @arg RCC_CRS_IT_ERR
jhon309 0:ac8863619623 1508 * @arg RCC_CRS_IT_ESYNC
jhon309 0:ac8863619623 1509 * @retval None
jhon309 0:ac8863619623 1510 */
jhon309 0:ac8863619623 1511 #define __HAL_RCC_CRS_DISABLE_IT(__INTERRUPT__) (CRS->CR &= ~(__INTERRUPT__))
jhon309 0:ac8863619623 1512
jhon309 0:ac8863619623 1513 /** @brief Check the CRS's interrupt has occurred or not.
jhon309 0:ac8863619623 1514 * @param __INTERRUPT__: specifies the CRS interrupt source to check.
jhon309 0:ac8863619623 1515 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1516 * @arg RCC_CRS_IT_SYNCOK
jhon309 0:ac8863619623 1517 * @arg RCC_CRS_IT_SYNCWARN
jhon309 0:ac8863619623 1518 * @arg RCC_CRS_IT_ERR
jhon309 0:ac8863619623 1519 * @arg RCC_CRS_IT_ESYNC
jhon309 0:ac8863619623 1520 * @retval The new state of __INTERRUPT__ (SET or RESET).
jhon309 0:ac8863619623 1521 */
jhon309 0:ac8863619623 1522 #define __HAL_RCC_CRS_GET_IT_SOURCE(__INTERRUPT__) ((CRS->CR & (__INTERRUPT__))? SET : RESET)
jhon309 0:ac8863619623 1523
jhon309 0:ac8863619623 1524 /** @brief Clear the CRS's interrupt pending bits
jhon309 0:ac8863619623 1525 * bits to clear the selected interrupt pending bits.
jhon309 0:ac8863619623 1526 * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
jhon309 0:ac8863619623 1527 * This parameter can be any combination of the following values:
jhon309 0:ac8863619623 1528 * @arg RCC_CRS_IT_SYNCOK
jhon309 0:ac8863619623 1529 * @arg RCC_CRS_IT_SYNCWARN
jhon309 0:ac8863619623 1530 * @arg RCC_CRS_IT_ERR
jhon309 0:ac8863619623 1531 * @arg RCC_CRS_IT_ESYNC
jhon309 0:ac8863619623 1532 * @arg RCC_CRS_IT_TRIMOVF
jhon309 0:ac8863619623 1533 * @arg RCC_CRS_IT_SYNCERR
jhon309 0:ac8863619623 1534 * @arg RCC_CRS_IT_SYNCMISS
jhon309 0:ac8863619623 1535 */
jhon309 0:ac8863619623 1536 /* CRS IT Error Mask */
jhon309 0:ac8863619623 1537 #define RCC_CRS_IT_ERROR_MASK ((uint32_t)(RCC_CRS_IT_TRIMOVF | RCC_CRS_IT_SYNCERR | RCC_CRS_IT_SYNCMISS))
jhon309 0:ac8863619623 1538
jhon309 0:ac8863619623 1539 #define __HAL_RCC_CRS_CLEAR_IT(__INTERRUPT__) ((((__INTERRUPT__) & RCC_CRS_IT_ERROR_MASK)!= 0) ? (CRS->ICR |= CRS_ICR_ERRC) : \
jhon309 0:ac8863619623 1540 (CRS->ICR |= (__INTERRUPT__)))
jhon309 0:ac8863619623 1541
jhon309 0:ac8863619623 1542 /**
jhon309 0:ac8863619623 1543 * @brief Checks whether the specified CRS flag is set or not.
jhon309 0:ac8863619623 1544 * @param _FLAG_: specifies the flag to check.
jhon309 0:ac8863619623 1545 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1546 * @arg RCC_CRS_FLAG_SYNCOK
jhon309 0:ac8863619623 1547 * @arg RCC_CRS_FLAG_SYNCWARN
jhon309 0:ac8863619623 1548 * @arg RCC_CRS_FLAG_ERR
jhon309 0:ac8863619623 1549 * @arg RCC_CRS_FLAG_ESYNC
jhon309 0:ac8863619623 1550 * @arg RCC_CRS_FLAG_TRIMOVF
jhon309 0:ac8863619623 1551 * @arg RCC_CRS_FLAG_SYNCERR
jhon309 0:ac8863619623 1552 * @arg RCC_CRS_FLAG_SYNCMISS
jhon309 0:ac8863619623 1553 * @retval The new state of _FLAG_ (TRUE or FALSE).
jhon309 0:ac8863619623 1554 */
jhon309 0:ac8863619623 1555 #define __HAL_RCC_CRS_GET_FLAG(_FLAG_) ((CRS->ISR & (_FLAG_)) == (_FLAG_))
jhon309 0:ac8863619623 1556
jhon309 0:ac8863619623 1557 /**
jhon309 0:ac8863619623 1558 * @brief Clears the CRS specified FLAG.
jhon309 0:ac8863619623 1559 * @param _FLAG_: specifies the flag to clear.
jhon309 0:ac8863619623 1560 * This parameter can be one of the following values:
jhon309 0:ac8863619623 1561 * @arg RCC_CRS_FLAG_SYNCOK
jhon309 0:ac8863619623 1562 * @arg RCC_CRS_FLAG_SYNCWARN
jhon309 0:ac8863619623 1563 * @arg RCC_CRS_FLAG_ERR
jhon309 0:ac8863619623 1564 * @arg RCC_CRS_FLAG_ESYNC
jhon309 0:ac8863619623 1565 * @arg RCC_CRS_FLAG_TRIMOVF
jhon309 0:ac8863619623 1566 * @arg RCC_CRS_FLAG_SYNCERR
jhon309 0:ac8863619623 1567 * @arg RCC_CRS_FLAG_SYNCMISS
jhon309 0:ac8863619623 1568 * @retval None
jhon309 0:ac8863619623 1569 */
jhon309 0:ac8863619623 1570
jhon309 0:ac8863619623 1571 /* CRS Flag Error Mask */
jhon309 0:ac8863619623 1572 #define RCC_CRS_FLAG_ERROR_MASK ((uint32_t)(RCC_CRS_FLAG_TRIMOVF | RCC_CRS_FLAG_SYNCERR | RCC_CRS_FLAG_SYNCMISS))
jhon309 0:ac8863619623 1573
jhon309 0:ac8863619623 1574 #define __HAL_RCC_CRS_CLEAR_FLAG(__FLAG__) ((((__FLAG__) & RCC_CRS_FLAG_ERROR_MASK)!= 0) ? (CRS->ICR |= CRS_ICR_ERRC) : \
jhon309 0:ac8863619623 1575 (CRS->ICR |= (__FLAG__)))
jhon309 0:ac8863619623 1576
jhon309 0:ac8863619623 1577 /**
jhon309 0:ac8863619623 1578 * @}
jhon309 0:ac8863619623 1579 */
jhon309 0:ac8863619623 1580
jhon309 0:ac8863619623 1581 /** @defgroup RCCEx_CRS_Extended_Features RCCEx CRS Extended Features
jhon309 0:ac8863619623 1582 * @{
jhon309 0:ac8863619623 1583 */
jhon309 0:ac8863619623 1584 /**
jhon309 0:ac8863619623 1585 * @brief Enables the oscillator clock for frequency error counter.
jhon309 0:ac8863619623 1586 * @note when the CEN bit is set the CRS_CFGR register becomes write-protected.
jhon309 0:ac8863619623 1587 * @retval None
jhon309 0:ac8863619623 1588 */
jhon309 0:ac8863619623 1589 #define __HAL_RCC_CRS_ENABLE_FREQ_ERROR_COUNTER() (CRS->CR |= CRS_CR_CEN)
jhon309 0:ac8863619623 1590
jhon309 0:ac8863619623 1591 /**
jhon309 0:ac8863619623 1592 * @brief Disables the oscillator clock for frequency error counter.
jhon309 0:ac8863619623 1593 * @retval None
jhon309 0:ac8863619623 1594 */
jhon309 0:ac8863619623 1595 #define __HAL_RCC_CRS_DISABLE_FREQ_ERROR_COUNTER() (CRS->CR &= ~CRS_CR_CEN)
jhon309 0:ac8863619623 1596
jhon309 0:ac8863619623 1597 /**
jhon309 0:ac8863619623 1598 * @brief Enables the automatic hardware adjustement of TRIM bits.
jhon309 0:ac8863619623 1599 * @note When the AUTOTRIMEN bit is set the CRS_CFGR register becomes write-protected.
jhon309 0:ac8863619623 1600 * @retval None
jhon309 0:ac8863619623 1601 */
jhon309 0:ac8863619623 1602 #define __HAL_RCC_CRS_ENABLE_AUTOMATIC_CALIB() (CRS->CR |= CRS_CR_AUTOTRIMEN)
jhon309 0:ac8863619623 1603
jhon309 0:ac8863619623 1604 /**
jhon309 0:ac8863619623 1605 * @brief Enables or disables the automatic hardware adjustement of TRIM bits.
jhon309 0:ac8863619623 1606 * @retval None
jhon309 0:ac8863619623 1607 */
jhon309 0:ac8863619623 1608 #define __HAL_RCC_CRS_DISABLE_AUTOMATIC_CALIB() (CRS->CR &= ~CRS_CR_AUTOTRIMEN)
jhon309 0:ac8863619623 1609
jhon309 0:ac8863619623 1610 /**
jhon309 0:ac8863619623 1611 * @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies
jhon309 0:ac8863619623 1612 * @note The RELOAD value should be selected according to the ratio between the target frequency and the frequency
jhon309 0:ac8863619623 1613 * of the synchronization source after prescaling. It is then decreased by one in order to
jhon309 0:ac8863619623 1614 * reach the expected synchronization on the zero value. The formula is the following:
jhon309 0:ac8863619623 1615 * RELOAD = (fTARGET / fSYNC) -1
jhon309 0:ac8863619623 1616 * @param _FTARGET_ Target frequency (value in Hz)
jhon309 0:ac8863619623 1617 * @param _FSYNC_ Synchronization signal frequency (value in Hz)
jhon309 0:ac8863619623 1618 * @retval None
jhon309 0:ac8863619623 1619 */
jhon309 0:ac8863619623 1620 #define __HAL_RCC_CRS_CALCULATE_RELOADVALUE(_FTARGET_, _FSYNC_) (((_FTARGET_) / (_FSYNC_)) - 1)
jhon309 0:ac8863619623 1621
jhon309 0:ac8863619623 1622 /**
jhon309 0:ac8863619623 1623 * @}
jhon309 0:ac8863619623 1624 */
jhon309 0:ac8863619623 1625
jhon309 0:ac8863619623 1626 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1627 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1628 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1629
jhon309 0:ac8863619623 1630 /**
jhon309 0:ac8863619623 1631 * @}
jhon309 0:ac8863619623 1632 */
jhon309 0:ac8863619623 1633
jhon309 0:ac8863619623 1634 /* Exported functions --------------------------------------------------------*/
jhon309 0:ac8863619623 1635 /** @addtogroup RCCEx_Exported_Functions
jhon309 0:ac8863619623 1636 * @{
jhon309 0:ac8863619623 1637 */
jhon309 0:ac8863619623 1638
jhon309 0:ac8863619623 1639 /** @addtogroup RCCEx_Exported_Functions_Group1
jhon309 0:ac8863619623 1640 * @{
jhon309 0:ac8863619623 1641 */
jhon309 0:ac8863619623 1642
jhon309 0:ac8863619623 1643 HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
jhon309 0:ac8863619623 1644 void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
jhon309 0:ac8863619623 1645
jhon309 0:ac8863619623 1646 #if defined(STM32F042x6) || defined(STM32F048xx) || \
jhon309 0:ac8863619623 1647 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 1648 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 1649 void HAL_RCCEx_CRSConfig(RCC_CRSInitTypeDef *pInit);
jhon309 0:ac8863619623 1650 void HAL_RCCEx_CRSSoftwareSynchronizationGenerate(void);
jhon309 0:ac8863619623 1651 void HAL_RCCEx_CRSGetSynchronizationInfo(RCC_CRSSynchroInfoTypeDef *pSynchroInfo);
jhon309 0:ac8863619623 1652 uint32_t HAL_RCCEx_CRSWaitSynchronization(uint32_t Timeout);
jhon309 0:ac8863619623 1653 #endif /* STM32F042x6 || STM32F048xx || */
jhon309 0:ac8863619623 1654 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 1655 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 1656
jhon309 0:ac8863619623 1657
jhon309 0:ac8863619623 1658 /**
jhon309 0:ac8863619623 1659 * @}
jhon309 0:ac8863619623 1660 */
jhon309 0:ac8863619623 1661
jhon309 0:ac8863619623 1662 /**
jhon309 0:ac8863619623 1663 * @}
jhon309 0:ac8863619623 1664 */
jhon309 0:ac8863619623 1665
jhon309 0:ac8863619623 1666 /**
jhon309 0:ac8863619623 1667 * @}
jhon309 0:ac8863619623 1668 */
jhon309 0:ac8863619623 1669
jhon309 0:ac8863619623 1670 /**
jhon309 0:ac8863619623 1671 * @}
jhon309 0:ac8863619623 1672 */
jhon309 0:ac8863619623 1673
jhon309 0:ac8863619623 1674 #ifdef __cplusplus
jhon309 0:ac8863619623 1675 }
jhon309 0:ac8863619623 1676 #endif
jhon309 0:ac8863619623 1677
jhon309 0:ac8863619623 1678 #endif /* __STM32F0xx_HAL_RCC_EX_H */
jhon309 0:ac8863619623 1679
jhon309 0:ac8863619623 1680 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/