mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
106:ced8cbb51063
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 76:aeb1df146756 1 /**
mbed_official 76:aeb1df146756 2 ******************************************************************************
mbed_official 76:aeb1df146756 3 * @file stm32f0xx_rcc.c
mbed_official 76:aeb1df146756 4 * @author MCD Application Team
mbed_official 76:aeb1df146756 5 * @version V1.3.0
mbed_official 76:aeb1df146756 6 * @date 16-January-2014
mbed_official 76:aeb1df146756 7 * @brief This file provides firmware functions to manage the following
mbed_official 76:aeb1df146756 8 * functionalities of the Reset and clock control (RCC) peripheral:
mbed_official 76:aeb1df146756 9 * + Internal/external clocks, PLL, CSS and MCO configuration
mbed_official 76:aeb1df146756 10 * + System, AHB and APB busses clocks configuration
mbed_official 76:aeb1df146756 11 * + Peripheral clocks configuration
mbed_official 76:aeb1df146756 12 * + Interrupts and flags management
mbed_official 76:aeb1df146756 13 *
mbed_official 76:aeb1df146756 14 @verbatim
mbed_official 76:aeb1df146756 15
mbed_official 76:aeb1df146756 16 ===============================================================================
mbed_official 76:aeb1df146756 17 ##### RCC specific features #####
mbed_official 76:aeb1df146756 18 ===============================================================================
mbed_official 76:aeb1df146756 19 [..] After reset the device is running from HSI (8 MHz) with Flash 0 WS,
mbed_official 76:aeb1df146756 20 all peripherals are off except internal SRAM, Flash and SWD.
mbed_official 76:aeb1df146756 21 (#) There is no prescaler on High speed (AHB) and Low speed (APB) busses;
mbed_official 76:aeb1df146756 22 all peripherals mapped on these busses are running at HSI speed.
mbed_official 76:aeb1df146756 23 (#) The clock for all peripherals is switched off, except the SRAM and FLASH.
mbed_official 76:aeb1df146756 24 (#) All GPIOs are in input floating state, except the SWD pins which
mbed_official 76:aeb1df146756 25 are assigned to be used for debug purpose.
mbed_official 76:aeb1df146756 26 [..] Once the device started from reset, the user application has to:
mbed_official 76:aeb1df146756 27 (#) Configure the clock source to be used to drive the System clock
mbed_official 76:aeb1df146756 28 (if the application needs higher frequency/performance)
mbed_official 76:aeb1df146756 29 (#) Configure the System clock frequency and Flash settings
mbed_official 76:aeb1df146756 30 (#) Configure the AHB and APB busses prescalers
mbed_official 76:aeb1df146756 31 (#) Enable the clock for the peripheral(s) to be used
mbed_official 76:aeb1df146756 32 (#) Configure the clock source(s) for peripherals which clocks are not
mbed_official 76:aeb1df146756 33 derived from the System clock (ADC, CEC, I2C, USART, RTC and IWDG)
mbed_official 76:aeb1df146756 34
mbed_official 76:aeb1df146756 35 @endverbatim
mbed_official 76:aeb1df146756 36
mbed_official 76:aeb1df146756 37 ******************************************************************************
mbed_official 76:aeb1df146756 38 * @attention
mbed_official 76:aeb1df146756 39 *
mbed_official 106:ced8cbb51063 40 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 76:aeb1df146756 41 *
mbed_official 106:ced8cbb51063 42 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 106:ced8cbb51063 43 * are permitted provided that the following conditions are met:
mbed_official 106:ced8cbb51063 44 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 106:ced8cbb51063 45 * this list of conditions and the following disclaimer.
mbed_official 106:ced8cbb51063 46 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 106:ced8cbb51063 47 * this list of conditions and the following disclaimer in the documentation
mbed_official 106:ced8cbb51063 48 * and/or other materials provided with the distribution.
mbed_official 106:ced8cbb51063 49 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 106:ced8cbb51063 50 * may be used to endorse or promote products derived from this software
mbed_official 106:ced8cbb51063 51 * without specific prior written permission.
mbed_official 76:aeb1df146756 52 *
mbed_official 106:ced8cbb51063 53 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 106:ced8cbb51063 54 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 106:ced8cbb51063 55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 106:ced8cbb51063 56 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 106:ced8cbb51063 57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 106:ced8cbb51063 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 106:ced8cbb51063 59 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 106:ced8cbb51063 60 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 106:ced8cbb51063 61 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 106:ced8cbb51063 62 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 76:aeb1df146756 63 *
mbed_official 76:aeb1df146756 64 ******************************************************************************
mbed_official 76:aeb1df146756 65 */
mbed_official 76:aeb1df146756 66
mbed_official 76:aeb1df146756 67 /* Includes ------------------------------------------------------------------*/
mbed_official 76:aeb1df146756 68 #include "stm32f0xx_rcc.h"
mbed_official 76:aeb1df146756 69
mbed_official 76:aeb1df146756 70 /** @addtogroup STM32F0xx_StdPeriph_Driver
mbed_official 76:aeb1df146756 71 * @{
mbed_official 76:aeb1df146756 72 */
mbed_official 76:aeb1df146756 73
mbed_official 76:aeb1df146756 74 /** @defgroup RCC
mbed_official 76:aeb1df146756 75 * @brief RCC driver modules
mbed_official 76:aeb1df146756 76 * @{
mbed_official 76:aeb1df146756 77 */
mbed_official 76:aeb1df146756 78
mbed_official 76:aeb1df146756 79 /* Private typedef -----------------------------------------------------------*/
mbed_official 76:aeb1df146756 80 /* Private define ------------------------------------------------------------*/
mbed_official 76:aeb1df146756 81
mbed_official 76:aeb1df146756 82 /* ---------------------- RCC registers mask -------------------------------- */
mbed_official 76:aeb1df146756 83 /* RCC Flag Mask */
mbed_official 76:aeb1df146756 84 #define FLAG_MASK ((uint8_t)0x1F)
mbed_official 76:aeb1df146756 85
mbed_official 76:aeb1df146756 86 /* CR register byte 2 (Bits[23:16]) base address */
mbed_official 76:aeb1df146756 87 #define CR_BYTE2_ADDRESS ((uint32_t)0x40021002)
mbed_official 76:aeb1df146756 88
mbed_official 76:aeb1df146756 89 /* CFGR register byte 3 (Bits[31:23]) base address */
mbed_official 76:aeb1df146756 90 #define CFGR_BYTE3_ADDRESS ((uint32_t)0x40021007)
mbed_official 76:aeb1df146756 91
mbed_official 76:aeb1df146756 92 /* CIR register byte 1 (Bits[15:8]) base address */
mbed_official 76:aeb1df146756 93 #define CIR_BYTE1_ADDRESS ((uint32_t)0x40021009)
mbed_official 76:aeb1df146756 94
mbed_official 76:aeb1df146756 95 /* CIR register byte 2 (Bits[23:16]) base address */
mbed_official 76:aeb1df146756 96 #define CIR_BYTE2_ADDRESS ((uint32_t)0x4002100A)
mbed_official 76:aeb1df146756 97
mbed_official 76:aeb1df146756 98 /* Private macro -------------------------------------------------------------*/
mbed_official 76:aeb1df146756 99 /* Private variables ---------------------------------------------------------*/
mbed_official 76:aeb1df146756 100 static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
mbed_official 76:aeb1df146756 101
mbed_official 76:aeb1df146756 102 /* Private function prototypes -----------------------------------------------*/
mbed_official 76:aeb1df146756 103 /* Private functions ---------------------------------------------------------*/
mbed_official 76:aeb1df146756 104
mbed_official 76:aeb1df146756 105 /** @defgroup RCC_Private_Functions
mbed_official 76:aeb1df146756 106 * @{
mbed_official 76:aeb1df146756 107 */
mbed_official 76:aeb1df146756 108
mbed_official 76:aeb1df146756 109 /** @defgroup RCC_Group1 Internal and external clocks, PLL, CSS and MCO configuration functions
mbed_official 76:aeb1df146756 110 * @brief Internal and external clocks, PLL, CSS and MCO configuration functions
mbed_official 76:aeb1df146756 111 *
mbed_official 76:aeb1df146756 112 @verbatim
mbed_official 76:aeb1df146756 113 ===============================================================================
mbed_official 76:aeb1df146756 114 ##### Internal-external clocks, PLL, CSS and MCO configuration functions #####
mbed_official 76:aeb1df146756 115 ===============================================================================
mbed_official 76:aeb1df146756 116 [..] This section provides functions allowing to configure the internal/external clocks,
mbed_official 76:aeb1df146756 117 PLL, CSS and MCO.
mbed_official 76:aeb1df146756 118 (#) HSI (high-speed internal), 8 MHz factory-trimmed RC used directly
mbed_official 76:aeb1df146756 119 or through the PLL as System clock source.
mbed_official 76:aeb1df146756 120 The HSI clock can be used also to clock the USART, I2C and CEC peripherals.
mbed_official 76:aeb1df146756 121 (#) HSI14 (high-speed internal for ADC), 14 MHz factory-trimmed RC used to clock
mbed_official 76:aeb1df146756 122 the ADC peripheral.
mbed_official 76:aeb1df146756 123 (#) LSI (low-speed internal), 40 KHz low consumption RC used as IWDG and/or RTC
mbed_official 76:aeb1df146756 124 clock source.
mbed_official 76:aeb1df146756 125 (#) HSE (high-speed external), 4 to 32 MHz crystal oscillator used directly or
mbed_official 76:aeb1df146756 126 through the PLL as System clock source. Can be used also as RTC clock source.
mbed_official 76:aeb1df146756 127 (#) LSE (low-speed external), 32 KHz oscillator used as RTC clock source.
mbed_official 76:aeb1df146756 128 LSE can be used also to clock the USART and CEC peripherals.
mbed_official 76:aeb1df146756 129 (#) PLL (clocked by HSI or HSE), for System clock.
mbed_official 76:aeb1df146756 130 (#) CSS (Clock security system), once enabled and if a HSE clock failure occurs
mbed_official 76:aeb1df146756 131 (HSE used directly or through PLL as System clock source), the System clock
mbed_official 76:aeb1df146756 132 is automatically switched to HSI and an interrupt is generated if enabled.
mbed_official 76:aeb1df146756 133 The interrupt is linked to the Cortex-M0 NMI (Non-Maskable Interrupt)
mbed_official 76:aeb1df146756 134 exception vector.
mbed_official 76:aeb1df146756 135 (#) MCO (microcontroller clock output), used to output SYSCLK, HSI, HSI14, LSI,
mbed_official 76:aeb1df146756 136 HSE, LSE or PLL (divided by 2) clock on PA8 pin.
mbed_official 76:aeb1df146756 137
mbed_official 76:aeb1df146756 138 @endverbatim
mbed_official 76:aeb1df146756 139 * @{
mbed_official 76:aeb1df146756 140 */
mbed_official 76:aeb1df146756 141
mbed_official 76:aeb1df146756 142 /**
mbed_official 76:aeb1df146756 143 * @brief Resets the RCC clock configuration to the default reset state.
mbed_official 76:aeb1df146756 144 * @note The default reset state of the clock configuration is given below:
mbed_official 76:aeb1df146756 145 * @note HSI ON and used as system clock source
mbed_official 76:aeb1df146756 146 * @note HSI14, HSE and PLL OFF
mbed_official 76:aeb1df146756 147 * @note AHB, APB prescaler set to 1.
mbed_official 76:aeb1df146756 148 * @note CSS and MCO OFF
mbed_official 76:aeb1df146756 149 * @note All interrupts disabled
mbed_official 76:aeb1df146756 150 * @note However, this function doesn't modify the configuration of the
mbed_official 76:aeb1df146756 151 * @note Peripheral clocks
mbed_official 76:aeb1df146756 152 * @note LSI, LSE and RTC clocks
mbed_official 76:aeb1df146756 153 * @param None
mbed_official 76:aeb1df146756 154 * @retval None
mbed_official 76:aeb1df146756 155 */
mbed_official 76:aeb1df146756 156 void RCC_DeInit(void)
mbed_official 76:aeb1df146756 157 {
mbed_official 76:aeb1df146756 158 /* Set HSION bit */
mbed_official 76:aeb1df146756 159 RCC->CR |= (uint32_t)0x00000001;
mbed_official 76:aeb1df146756 160
mbed_official 76:aeb1df146756 161 #if defined (STM32F051)
mbed_official 76:aeb1df146756 162 /* Reset SW[1:0], HPRE[3:0], PPRE[2:0] and MCOSEL[2:0] bits */
mbed_official 76:aeb1df146756 163 RCC->CFGR &= (uint32_t)0xF8FFB80C;
mbed_official 76:aeb1df146756 164 #else
mbed_official 76:aeb1df146756 165 /* Reset SW[1:0], HPRE[3:0], PPRE[2:0], ADCPRE, MCOSEL[2:0], MCOPRE[2:0] and PLLNODIV bits */
mbed_official 76:aeb1df146756 166 RCC->CFGR &= (uint32_t)0x08FFB80C;
mbed_official 76:aeb1df146756 167 #endif /* STM32F051 */
mbed_official 76:aeb1df146756 168
mbed_official 76:aeb1df146756 169 /* Reset HSEON, CSSON and PLLON bits */
mbed_official 76:aeb1df146756 170 RCC->CR &= (uint32_t)0xFEF6FFFF;
mbed_official 76:aeb1df146756 171
mbed_official 76:aeb1df146756 172 /* Reset HSEBYP bit */
mbed_official 76:aeb1df146756 173 RCC->CR &= (uint32_t)0xFFFBFFFF;
mbed_official 76:aeb1df146756 174
mbed_official 76:aeb1df146756 175 /* Reset PLLSRC, PLLXTPRE and PLLMUL[3:0] bits */
mbed_official 76:aeb1df146756 176 RCC->CFGR &= (uint32_t)0xFFC0FFFF;
mbed_official 76:aeb1df146756 177
mbed_official 76:aeb1df146756 178 /* Reset PREDIV1[3:0] bits */
mbed_official 76:aeb1df146756 179 RCC->CFGR2 &= (uint32_t)0xFFFFFFF0;
mbed_official 76:aeb1df146756 180
mbed_official 76:aeb1df146756 181 /* Reset USARTSW[1:0], I2CSW, CECSW and ADCSW bits */
mbed_official 76:aeb1df146756 182 RCC->CFGR3 &= (uint32_t)0xFFFFFEAC;
mbed_official 76:aeb1df146756 183
mbed_official 76:aeb1df146756 184 /* Reset HSI14 bit */
mbed_official 76:aeb1df146756 185 RCC->CR2 &= (uint32_t)0xFFFFFFFE;
mbed_official 76:aeb1df146756 186
mbed_official 76:aeb1df146756 187 /* Disable all interrupts */
mbed_official 76:aeb1df146756 188 RCC->CIR = 0x00000000;
mbed_official 76:aeb1df146756 189 }
mbed_official 76:aeb1df146756 190
mbed_official 76:aeb1df146756 191 /**
mbed_official 76:aeb1df146756 192 * @brief Configures the External High Speed oscillator (HSE).
mbed_official 76:aeb1df146756 193 * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
mbed_official 76:aeb1df146756 194 * software should wait on HSERDY flag to be set indicating that HSE clock
mbed_official 76:aeb1df146756 195 * is stable and can be used to clock the PLL and/or system clock.
mbed_official 76:aeb1df146756 196 * @note HSE state can not be changed if it is used directly or through the
mbed_official 76:aeb1df146756 197 * PLL as system clock. In this case, you have to select another source
mbed_official 76:aeb1df146756 198 * of the system clock then change the HSE state (ex. disable it).
mbed_official 76:aeb1df146756 199 * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
mbed_official 76:aeb1df146756 200 * @note This function resets the CSSON bit, so if the Clock security system(CSS)
mbed_official 76:aeb1df146756 201 * was previously enabled you have to enable it again after calling this
mbed_official 76:aeb1df146756 202 * function.
mbed_official 76:aeb1df146756 203 * @param RCC_HSE: specifies the new state of the HSE.
mbed_official 76:aeb1df146756 204 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 205 * @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after
mbed_official 76:aeb1df146756 206 * 6 HSE oscillator clock cycles.
mbed_official 76:aeb1df146756 207 * @arg RCC_HSE_ON: turn ON the HSE oscillator
mbed_official 76:aeb1df146756 208 * @arg RCC_HSE_Bypass: HSE oscillator bypassed with external clock
mbed_official 76:aeb1df146756 209 * @retval None
mbed_official 76:aeb1df146756 210 */
mbed_official 76:aeb1df146756 211 void RCC_HSEConfig(uint8_t RCC_HSE)
mbed_official 76:aeb1df146756 212 {
mbed_official 76:aeb1df146756 213 /* Check the parameters */
mbed_official 76:aeb1df146756 214 assert_param(IS_RCC_HSE(RCC_HSE));
mbed_official 76:aeb1df146756 215
mbed_official 76:aeb1df146756 216 /* Reset HSEON and HSEBYP bits before configuring the HSE ------------------*/
mbed_official 76:aeb1df146756 217 *(__IO uint8_t *) CR_BYTE2_ADDRESS = RCC_HSE_OFF;
mbed_official 76:aeb1df146756 218
mbed_official 76:aeb1df146756 219 /* Set the new HSE configuration -------------------------------------------*/
mbed_official 76:aeb1df146756 220 *(__IO uint8_t *) CR_BYTE2_ADDRESS = RCC_HSE;
mbed_official 76:aeb1df146756 221
mbed_official 76:aeb1df146756 222 }
mbed_official 76:aeb1df146756 223
mbed_official 76:aeb1df146756 224 /**
mbed_official 76:aeb1df146756 225 * @brief Waits for HSE start-up.
mbed_official 76:aeb1df146756 226 * @note This function waits on HSERDY flag to be set and return SUCCESS if
mbed_official 76:aeb1df146756 227 * this flag is set, otherwise returns ERROR if the timeout is reached
mbed_official 76:aeb1df146756 228 * and this flag is not set. The timeout value is defined by the constant
mbed_official 76:aeb1df146756 229 * HSE_STARTUP_TIMEOUT in stm32f0xx.h file. You can tailor it depending
mbed_official 76:aeb1df146756 230 * on the HSE crystal used in your application.
mbed_official 76:aeb1df146756 231 * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
mbed_official 76:aeb1df146756 232 * @param None
mbed_official 76:aeb1df146756 233 * @retval An ErrorStatus enumeration value:
mbed_official 76:aeb1df146756 234 * - SUCCESS: HSE oscillator is stable and ready to use
mbed_official 76:aeb1df146756 235 * - ERROR: HSE oscillator not yet ready
mbed_official 76:aeb1df146756 236 */
mbed_official 76:aeb1df146756 237 ErrorStatus RCC_WaitForHSEStartUp(void)
mbed_official 76:aeb1df146756 238 {
mbed_official 76:aeb1df146756 239 __IO uint32_t StartUpCounter = 0;
mbed_official 76:aeb1df146756 240 ErrorStatus status = ERROR;
mbed_official 76:aeb1df146756 241 FlagStatus HSEStatus = RESET;
mbed_official 76:aeb1df146756 242
mbed_official 76:aeb1df146756 243 /* Wait till HSE is ready and if timeout is reached exit */
mbed_official 76:aeb1df146756 244 do
mbed_official 76:aeb1df146756 245 {
mbed_official 76:aeb1df146756 246 HSEStatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY);
mbed_official 76:aeb1df146756 247 StartUpCounter++;
mbed_official 76:aeb1df146756 248 } while((StartUpCounter != HSE_STARTUP_TIMEOUT) && (HSEStatus == RESET));
mbed_official 76:aeb1df146756 249
mbed_official 76:aeb1df146756 250 if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET)
mbed_official 76:aeb1df146756 251 {
mbed_official 76:aeb1df146756 252 status = SUCCESS;
mbed_official 76:aeb1df146756 253 }
mbed_official 76:aeb1df146756 254 else
mbed_official 76:aeb1df146756 255 {
mbed_official 76:aeb1df146756 256 status = ERROR;
mbed_official 76:aeb1df146756 257 }
mbed_official 76:aeb1df146756 258 return (status);
mbed_official 76:aeb1df146756 259 }
mbed_official 76:aeb1df146756 260
mbed_official 76:aeb1df146756 261 /**
mbed_official 76:aeb1df146756 262 * @brief Adjusts the Internal High Speed oscillator (HSI) calibration value.
mbed_official 76:aeb1df146756 263 * @note The calibration is used to compensate for the variations in voltage
mbed_official 76:aeb1df146756 264 * and temperature that influence the frequency of the internal HSI RC.
mbed_official 76:aeb1df146756 265 * Refer to the Application Note AN4067 for more details on how to
mbed_official 76:aeb1df146756 266 * calibrate the HSI.
mbed_official 76:aeb1df146756 267 * @param HSICalibrationValue: specifies the HSI calibration trimming value.
mbed_official 76:aeb1df146756 268 * This parameter must be a number between 0 and 0x1F.
mbed_official 76:aeb1df146756 269 * @retval None
mbed_official 76:aeb1df146756 270 */
mbed_official 76:aeb1df146756 271 void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
mbed_official 76:aeb1df146756 272 {
mbed_official 76:aeb1df146756 273 uint32_t tmpreg = 0;
mbed_official 76:aeb1df146756 274
mbed_official 76:aeb1df146756 275 /* Check the parameters */
mbed_official 76:aeb1df146756 276 assert_param(IS_RCC_HSI_CALIBRATION_VALUE(HSICalibrationValue));
mbed_official 76:aeb1df146756 277
mbed_official 76:aeb1df146756 278 tmpreg = RCC->CR;
mbed_official 76:aeb1df146756 279
mbed_official 76:aeb1df146756 280 /* Clear HSITRIM[4:0] bits */
mbed_official 76:aeb1df146756 281 tmpreg &= ~RCC_CR_HSITRIM;
mbed_official 76:aeb1df146756 282
mbed_official 76:aeb1df146756 283 /* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */
mbed_official 76:aeb1df146756 284 tmpreg |= (uint32_t)HSICalibrationValue << 3;
mbed_official 76:aeb1df146756 285
mbed_official 76:aeb1df146756 286 /* Store the new value */
mbed_official 76:aeb1df146756 287 RCC->CR = tmpreg;
mbed_official 76:aeb1df146756 288 }
mbed_official 76:aeb1df146756 289
mbed_official 76:aeb1df146756 290 /**
mbed_official 76:aeb1df146756 291 * @brief Enables or disables the Internal High Speed oscillator (HSI).
mbed_official 76:aeb1df146756 292 * @note After enabling the HSI, the application software should wait on
mbed_official 76:aeb1df146756 293 * HSIRDY flag to be set indicating that HSI clock is stable and can
mbed_official 76:aeb1df146756 294 * be used to clock the PLL and/or system clock.
mbed_official 76:aeb1df146756 295 * @note HSI can not be stopped if it is used directly or through the PLL
mbed_official 76:aeb1df146756 296 * as system clock. In this case, you have to select another source
mbed_official 76:aeb1df146756 297 * of the system clock then stop the HSI.
mbed_official 76:aeb1df146756 298 * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
mbed_official 76:aeb1df146756 299 * @param NewState: new state of the HSI.
mbed_official 76:aeb1df146756 300 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 301 * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
mbed_official 76:aeb1df146756 302 * clock cycles.
mbed_official 76:aeb1df146756 303 * @retval None
mbed_official 76:aeb1df146756 304 */
mbed_official 76:aeb1df146756 305 void RCC_HSICmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 306 {
mbed_official 76:aeb1df146756 307 /* Check the parameters */
mbed_official 76:aeb1df146756 308 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 309
mbed_official 76:aeb1df146756 310 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 311 {
mbed_official 76:aeb1df146756 312 RCC->CR |= RCC_CR_HSION;
mbed_official 76:aeb1df146756 313 }
mbed_official 76:aeb1df146756 314 else
mbed_official 76:aeb1df146756 315 {
mbed_official 76:aeb1df146756 316 RCC->CR &= ~RCC_CR_HSION;
mbed_official 76:aeb1df146756 317 }
mbed_official 76:aeb1df146756 318 }
mbed_official 76:aeb1df146756 319
mbed_official 76:aeb1df146756 320 /**
mbed_official 76:aeb1df146756 321 * @brief Adjusts the Internal High Speed oscillator for ADC (HSI14)
mbed_official 76:aeb1df146756 322 * calibration value.
mbed_official 76:aeb1df146756 323 * @note The calibration is used to compensate for the variations in voltage
mbed_official 76:aeb1df146756 324 * and temperature that influence the frequency of the internal HSI RC.
mbed_official 76:aeb1df146756 325 * Refer to the Application Note AN4067 for more details on how to
mbed_official 76:aeb1df146756 326 * calibrate the HSI14.
mbed_official 76:aeb1df146756 327 * @param HSI14CalibrationValue: specifies the HSI14 calibration trimming value.
mbed_official 76:aeb1df146756 328 * This parameter must be a number between 0 and 0x1F.
mbed_official 76:aeb1df146756 329 * @retval None
mbed_official 76:aeb1df146756 330 */
mbed_official 76:aeb1df146756 331 void RCC_AdjustHSI14CalibrationValue(uint8_t HSI14CalibrationValue)
mbed_official 76:aeb1df146756 332 {
mbed_official 76:aeb1df146756 333 uint32_t tmpreg = 0;
mbed_official 76:aeb1df146756 334
mbed_official 76:aeb1df146756 335 /* Check the parameters */
mbed_official 76:aeb1df146756 336 assert_param(IS_RCC_HSI14_CALIBRATION_VALUE(HSI14CalibrationValue));
mbed_official 76:aeb1df146756 337
mbed_official 76:aeb1df146756 338 tmpreg = RCC->CR2;
mbed_official 76:aeb1df146756 339
mbed_official 76:aeb1df146756 340 /* Clear HSI14TRIM[4:0] bits */
mbed_official 76:aeb1df146756 341 tmpreg &= ~RCC_CR2_HSI14TRIM;
mbed_official 76:aeb1df146756 342
mbed_official 76:aeb1df146756 343 /* Set the HSITRIM14[4:0] bits according to HSI14CalibrationValue value */
mbed_official 76:aeb1df146756 344 tmpreg |= (uint32_t)HSI14CalibrationValue << 3;
mbed_official 76:aeb1df146756 345
mbed_official 76:aeb1df146756 346 /* Store the new value */
mbed_official 76:aeb1df146756 347 RCC->CR2 = tmpreg;
mbed_official 76:aeb1df146756 348 }
mbed_official 76:aeb1df146756 349
mbed_official 76:aeb1df146756 350 /**
mbed_official 76:aeb1df146756 351 * @brief Enables or disables the Internal High Speed oscillator for ADC (HSI14).
mbed_official 76:aeb1df146756 352 * @note After enabling the HSI14, the application software should wait on
mbed_official 76:aeb1df146756 353 * HSIRDY flag to be set indicating that HSI clock is stable and can
mbed_official 76:aeb1df146756 354 * be used to clock the ADC.
mbed_official 76:aeb1df146756 355 * @note The HSI14 is stopped by hardware when entering STOP and STANDBY modes.
mbed_official 76:aeb1df146756 356 * @param NewState: new state of the HSI14.
mbed_official 76:aeb1df146756 357 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 358 * @note When the HSI14 is stopped, HSI14RDY flag goes low after 6 HSI14 oscillator
mbed_official 76:aeb1df146756 359 * clock cycles.
mbed_official 76:aeb1df146756 360 * @retval None
mbed_official 76:aeb1df146756 361 */
mbed_official 76:aeb1df146756 362 void RCC_HSI14Cmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 363 {
mbed_official 76:aeb1df146756 364 /* Check the parameters */
mbed_official 76:aeb1df146756 365 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 366
mbed_official 76:aeb1df146756 367 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 368 {
mbed_official 76:aeb1df146756 369 RCC->CR2 |= RCC_CR2_HSI14ON;
mbed_official 76:aeb1df146756 370 }
mbed_official 76:aeb1df146756 371 else
mbed_official 76:aeb1df146756 372 {
mbed_official 76:aeb1df146756 373 RCC->CR2 &= ~RCC_CR2_HSI14ON;
mbed_official 76:aeb1df146756 374 }
mbed_official 76:aeb1df146756 375 }
mbed_official 76:aeb1df146756 376
mbed_official 76:aeb1df146756 377 /**
mbed_official 76:aeb1df146756 378 * @brief Enables or disables the Internal High Speed oscillator request from ADC.
mbed_official 76:aeb1df146756 379 * @param NewState: new state of the HSI14 ADC request.
mbed_official 76:aeb1df146756 380 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 381 * @retval None
mbed_official 76:aeb1df146756 382 */
mbed_official 76:aeb1df146756 383 void RCC_HSI14ADCRequestCmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 384 {
mbed_official 76:aeb1df146756 385 /* Check the parameters */
mbed_official 76:aeb1df146756 386 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 387
mbed_official 76:aeb1df146756 388 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 389 {
mbed_official 76:aeb1df146756 390 RCC->CR2 &= ~RCC_CR2_HSI14DIS;
mbed_official 76:aeb1df146756 391 }
mbed_official 76:aeb1df146756 392 else
mbed_official 76:aeb1df146756 393 {
mbed_official 76:aeb1df146756 394 RCC->CR2 |= RCC_CR2_HSI14DIS;
mbed_official 76:aeb1df146756 395 }
mbed_official 76:aeb1df146756 396 }
mbed_official 76:aeb1df146756 397
mbed_official 76:aeb1df146756 398 /**
mbed_official 76:aeb1df146756 399 * @brief Configures the External Low Speed oscillator (LSE).
mbed_official 76:aeb1df146756 400 * @note As the LSE is in the Backup domain and write access is denied to this
mbed_official 76:aeb1df146756 401 * domain after reset, you have to enable write access using
mbed_official 76:aeb1df146756 402 * PWR_BackupAccessCmd(ENABLE) function before to configure the LSE
mbed_official 76:aeb1df146756 403 * (to be done once after reset).
mbed_official 76:aeb1df146756 404 * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_Bypass), the application
mbed_official 76:aeb1df146756 405 * software should wait on LSERDY flag to be set indicating that LSE clock
mbed_official 76:aeb1df146756 406 * is stable and can be used to clock the RTC.
mbed_official 76:aeb1df146756 407 * @param RCC_LSE: specifies the new state of the LSE.
mbed_official 76:aeb1df146756 408 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 409 * @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after
mbed_official 76:aeb1df146756 410 * 6 LSE oscillator clock cycles.
mbed_official 76:aeb1df146756 411 * @arg RCC_LSE_ON: turn ON the LSE oscillator
mbed_official 76:aeb1df146756 412 * @arg RCC_LSE_Bypass: LSE oscillator bypassed with external clock
mbed_official 76:aeb1df146756 413 * @retval None
mbed_official 76:aeb1df146756 414 */
mbed_official 76:aeb1df146756 415 void RCC_LSEConfig(uint32_t RCC_LSE)
mbed_official 76:aeb1df146756 416 {
mbed_official 76:aeb1df146756 417 /* Check the parameters */
mbed_official 76:aeb1df146756 418 assert_param(IS_RCC_LSE(RCC_LSE));
mbed_official 76:aeb1df146756 419
mbed_official 76:aeb1df146756 420 /* Reset LSEON and LSEBYP bits before configuring the LSE ------------------*/
mbed_official 76:aeb1df146756 421 /* Reset LSEON bit */
mbed_official 76:aeb1df146756 422 RCC->BDCR &= ~(RCC_BDCR_LSEON);
mbed_official 76:aeb1df146756 423
mbed_official 76:aeb1df146756 424 /* Reset LSEBYP bit */
mbed_official 76:aeb1df146756 425 RCC->BDCR &= ~(RCC_BDCR_LSEBYP);
mbed_official 76:aeb1df146756 426
mbed_official 76:aeb1df146756 427 /* Configure LSE */
mbed_official 76:aeb1df146756 428 RCC->BDCR |= RCC_LSE;
mbed_official 76:aeb1df146756 429 }
mbed_official 76:aeb1df146756 430
mbed_official 76:aeb1df146756 431 /**
mbed_official 76:aeb1df146756 432 * @brief Configures the External Low Speed oscillator (LSE) drive capability.
mbed_official 76:aeb1df146756 433 * @param RCC_LSEDrive: specifies the new state of the LSE drive capability.
mbed_official 76:aeb1df146756 434 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 435 * @arg RCC_LSEDrive_Low: LSE oscillator low drive capability.
mbed_official 76:aeb1df146756 436 * @arg RCC_LSEDrive_MediumLow: LSE oscillator medium low drive capability.
mbed_official 76:aeb1df146756 437 * @arg RCC_LSEDrive_MediumHigh: LSE oscillator medium high drive capability.
mbed_official 76:aeb1df146756 438 * @arg RCC_LSEDrive_High: LSE oscillator high drive capability.
mbed_official 76:aeb1df146756 439 * @retval None
mbed_official 76:aeb1df146756 440 */
mbed_official 76:aeb1df146756 441 void RCC_LSEDriveConfig(uint32_t RCC_LSEDrive)
mbed_official 76:aeb1df146756 442 {
mbed_official 76:aeb1df146756 443 /* Check the parameters */
mbed_official 76:aeb1df146756 444 assert_param(IS_RCC_LSE_DRIVE(RCC_LSEDrive));
mbed_official 76:aeb1df146756 445
mbed_official 76:aeb1df146756 446 /* Clear LSEDRV[1:0] bits */
mbed_official 76:aeb1df146756 447 RCC->BDCR &= ~(RCC_BDCR_LSEDRV);
mbed_official 76:aeb1df146756 448
mbed_official 76:aeb1df146756 449 /* Set the LSE Drive */
mbed_official 76:aeb1df146756 450 RCC->BDCR |= RCC_LSEDrive;
mbed_official 76:aeb1df146756 451 }
mbed_official 76:aeb1df146756 452
mbed_official 76:aeb1df146756 453 /**
mbed_official 76:aeb1df146756 454 * @brief Enables or disables the Internal Low Speed oscillator (LSI).
mbed_official 76:aeb1df146756 455 * @note After enabling the LSI, the application software should wait on
mbed_official 76:aeb1df146756 456 * LSIRDY flag to be set indicating that LSI clock is stable and can
mbed_official 76:aeb1df146756 457 * be used to clock the IWDG and/or the RTC.
mbed_official 76:aeb1df146756 458 * @note LSI can not be disabled if the IWDG is running.
mbed_official 76:aeb1df146756 459 * @param NewState: new state of the LSI.
mbed_official 76:aeb1df146756 460 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 461 * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
mbed_official 76:aeb1df146756 462 * clock cycles.
mbed_official 76:aeb1df146756 463 * @retval None
mbed_official 76:aeb1df146756 464 */
mbed_official 76:aeb1df146756 465 void RCC_LSICmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 466 {
mbed_official 76:aeb1df146756 467 /* Check the parameters */
mbed_official 76:aeb1df146756 468 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 469
mbed_official 76:aeb1df146756 470 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 471 {
mbed_official 76:aeb1df146756 472 RCC->CSR |= RCC_CSR_LSION;
mbed_official 76:aeb1df146756 473 }
mbed_official 76:aeb1df146756 474 else
mbed_official 76:aeb1df146756 475 {
mbed_official 76:aeb1df146756 476 RCC->CSR &= ~RCC_CSR_LSION;
mbed_official 76:aeb1df146756 477 }
mbed_official 76:aeb1df146756 478 }
mbed_official 76:aeb1df146756 479
mbed_official 76:aeb1df146756 480 /**
mbed_official 76:aeb1df146756 481 * @brief Configures the PLL clock source and multiplication factor.
mbed_official 76:aeb1df146756 482 * @note This function must be used only when the PLL is disabled.
mbed_official 76:aeb1df146756 483 *
mbed_official 76:aeb1df146756 484 * @param RCC_PLLSource: specifies the PLL entry clock source.
mbed_official 76:aeb1df146756 485 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 486 * @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock selected as PLL clock source
mbed_official 76:aeb1df146756 487 * @arg RCC_PLLSource_PREDIV1: PREDIV1 clock selected as PLL clock entry
mbed_official 76:aeb1df146756 488 * @arg RCC_PLLSource_HSI48 HSI48 oscillator clock selected as PLL clock source, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 489 * @arg RCC_PLLSource_HSI: HSI clock selected as PLL clock entry, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 490 * @note The minimum input clock frequency for PLL is 2 MHz (when using HSE as
mbed_official 76:aeb1df146756 491 * PLL source).
mbed_official 76:aeb1df146756 492 *
mbed_official 76:aeb1df146756 493 * @param RCC_PLLMul: specifies the PLL multiplication factor, which drive the PLLVCO clock
mbed_official 76:aeb1df146756 494 * This parameter can be RCC_PLLMul_x where x:[2,16]
mbed_official 76:aeb1df146756 495 *
mbed_official 76:aeb1df146756 496 * @retval None
mbed_official 76:aeb1df146756 497 */
mbed_official 76:aeb1df146756 498 void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul)
mbed_official 76:aeb1df146756 499 {
mbed_official 76:aeb1df146756 500 /* Check the parameters */
mbed_official 76:aeb1df146756 501 assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));
mbed_official 76:aeb1df146756 502 assert_param(IS_RCC_PLL_MUL(RCC_PLLMul));
mbed_official 76:aeb1df146756 503
mbed_official 76:aeb1df146756 504 /* Clear PLL Source [16] and Multiplier [21:18] bits */
mbed_official 76:aeb1df146756 505 RCC->CFGR &= ~(RCC_CFGR_PLLMULL | RCC_CFGR_PLLSRC);
mbed_official 76:aeb1df146756 506
mbed_official 76:aeb1df146756 507 /* Set the PLL Source and Multiplier */
mbed_official 76:aeb1df146756 508 RCC->CFGR |= (uint32_t)(RCC_PLLSource | RCC_PLLMul);
mbed_official 76:aeb1df146756 509 }
mbed_official 76:aeb1df146756 510
mbed_official 76:aeb1df146756 511 /**
mbed_official 76:aeb1df146756 512 * @brief Enables or disables the PLL.
mbed_official 76:aeb1df146756 513 * @note After enabling the PLL, the application software should wait on
mbed_official 76:aeb1df146756 514 * PLLRDY flag to be set indicating that PLL clock is stable and can
mbed_official 76:aeb1df146756 515 * be used as system clock source.
mbed_official 76:aeb1df146756 516 * @note The PLL can not be disabled if it is used as system clock source
mbed_official 76:aeb1df146756 517 * @note The PLL is disabled by hardware when entering STOP and STANDBY modes.
mbed_official 76:aeb1df146756 518 * @param NewState: new state of the PLL.
mbed_official 76:aeb1df146756 519 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 520 * @retval None
mbed_official 76:aeb1df146756 521 */
mbed_official 76:aeb1df146756 522 void RCC_PLLCmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 523 {
mbed_official 76:aeb1df146756 524 /* Check the parameters */
mbed_official 76:aeb1df146756 525 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 526
mbed_official 76:aeb1df146756 527 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 528 {
mbed_official 76:aeb1df146756 529 RCC->CR |= RCC_CR_PLLON;
mbed_official 76:aeb1df146756 530 }
mbed_official 76:aeb1df146756 531 else
mbed_official 76:aeb1df146756 532 {
mbed_official 76:aeb1df146756 533 RCC->CR &= ~RCC_CR_PLLON;
mbed_official 76:aeb1df146756 534 }
mbed_official 76:aeb1df146756 535 }
mbed_official 76:aeb1df146756 536
mbed_official 76:aeb1df146756 537 /**
mbed_official 76:aeb1df146756 538 * @brief Enables or disables the Internal High Speed oscillator for USB (HSI48).
mbed_official 76:aeb1df146756 539 * This function is only applicable for STM32F072 devices.
mbed_official 76:aeb1df146756 540 * @note After enabling the HSI48, the application software should wait on
mbed_official 76:aeb1df146756 541 * HSI48RDY flag to be set indicating that HSI48 clock is stable and can
mbed_official 76:aeb1df146756 542 * be used to clock the USB.
mbed_official 76:aeb1df146756 543 * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes.
mbed_official 76:aeb1df146756 544 * @param NewState: new state of the HSI48.
mbed_official 76:aeb1df146756 545 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 546 * @retval None
mbed_official 76:aeb1df146756 547 */
mbed_official 76:aeb1df146756 548 void RCC_HSI48Cmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 549 {
mbed_official 76:aeb1df146756 550 /* Check the parameters */
mbed_official 76:aeb1df146756 551 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 552
mbed_official 76:aeb1df146756 553 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 554 {
mbed_official 76:aeb1df146756 555 RCC->CR2 |= RCC_CR2_HSI48ON;
mbed_official 76:aeb1df146756 556 }
mbed_official 76:aeb1df146756 557 else
mbed_official 76:aeb1df146756 558 {
mbed_official 76:aeb1df146756 559 RCC->CR2 &= ~RCC_CR2_HSI48ON;
mbed_official 76:aeb1df146756 560 }
mbed_official 76:aeb1df146756 561 }
mbed_official 76:aeb1df146756 562
mbed_official 76:aeb1df146756 563 /**
mbed_official 76:aeb1df146756 564 * @brief Configures the PREDIV1 division factor.
mbed_official 76:aeb1df146756 565 * @note This function must be used only when the PLL is disabled.
mbed_official 76:aeb1df146756 566 * @param RCC_PREDIV1_Div: specifies the PREDIV1 clock division factor.
mbed_official 76:aeb1df146756 567 * This parameter can be RCC_PREDIV1_Divx where x:[1,16]
mbed_official 76:aeb1df146756 568 * @retval None
mbed_official 76:aeb1df146756 569 */
mbed_official 76:aeb1df146756 570 void RCC_PREDIV1Config(uint32_t RCC_PREDIV1_Div)
mbed_official 76:aeb1df146756 571 {
mbed_official 76:aeb1df146756 572 uint32_t tmpreg = 0;
mbed_official 76:aeb1df146756 573
mbed_official 76:aeb1df146756 574 /* Check the parameters */
mbed_official 76:aeb1df146756 575 assert_param(IS_RCC_PREDIV1(RCC_PREDIV1_Div));
mbed_official 76:aeb1df146756 576
mbed_official 76:aeb1df146756 577 tmpreg = RCC->CFGR2;
mbed_official 76:aeb1df146756 578 /* Clear PREDIV1[3:0] bits */
mbed_official 76:aeb1df146756 579 tmpreg &= ~(RCC_CFGR2_PREDIV1);
mbed_official 76:aeb1df146756 580 /* Set the PREDIV1 division factor */
mbed_official 76:aeb1df146756 581 tmpreg |= RCC_PREDIV1_Div;
mbed_official 76:aeb1df146756 582 /* Store the new value */
mbed_official 76:aeb1df146756 583 RCC->CFGR2 = tmpreg;
mbed_official 76:aeb1df146756 584 }
mbed_official 76:aeb1df146756 585
mbed_official 76:aeb1df146756 586 /**
mbed_official 76:aeb1df146756 587 * @brief Enables or disables the Clock Security System.
mbed_official 76:aeb1df146756 588 * @note If a failure is detected on the HSE oscillator clock, this oscillator
mbed_official 76:aeb1df146756 589 * is automatically disabled and an interrupt is generated to inform the
mbed_official 76:aeb1df146756 590 * software about the failure (Clock Security System Interrupt, CSSI),
mbed_official 76:aeb1df146756 591 * allowing the MCU to perform rescue operations. The CSSI is linked to
mbed_official 76:aeb1df146756 592 * the Cortex-M0 NMI (Non-Maskable Interrupt) exception vector.
mbed_official 76:aeb1df146756 593 * @param NewState: new state of the Clock Security System.
mbed_official 76:aeb1df146756 594 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 595 * @retval None
mbed_official 76:aeb1df146756 596 */
mbed_official 76:aeb1df146756 597 void RCC_ClockSecuritySystemCmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 598 {
mbed_official 76:aeb1df146756 599 /* Check the parameters */
mbed_official 76:aeb1df146756 600 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 601
mbed_official 76:aeb1df146756 602 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 603 {
mbed_official 76:aeb1df146756 604 RCC->CR |= RCC_CR_CSSON;
mbed_official 76:aeb1df146756 605 }
mbed_official 76:aeb1df146756 606 else
mbed_official 76:aeb1df146756 607 {
mbed_official 76:aeb1df146756 608 RCC->CR &= ~RCC_CR_CSSON;
mbed_official 76:aeb1df146756 609 }
mbed_official 76:aeb1df146756 610 }
mbed_official 76:aeb1df146756 611
mbed_official 76:aeb1df146756 612 #ifdef STM32F051
mbed_official 76:aeb1df146756 613 /**
mbed_official 76:aeb1df146756 614 * @brief Selects the clock source to output on MCO pin (PA8).
mbed_official 76:aeb1df146756 615 * @note PA8 should be configured in alternate function mode.
mbed_official 76:aeb1df146756 616 * @param RCC_MCOSource: specifies the clock source to output.
mbed_official 76:aeb1df146756 617 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 618 * @arg RCC_MCOSource_NoClock: No clock selected.
mbed_official 76:aeb1df146756 619 * @arg RCC_MCOSource_HSI14: HSI14 oscillator clock selected.
mbed_official 76:aeb1df146756 620 * @arg RCC_MCOSource_LSI: LSI oscillator clock selected.
mbed_official 76:aeb1df146756 621 * @arg RCC_MCOSource_LSE: LSE oscillator clock selected.
mbed_official 76:aeb1df146756 622 * @arg RCC_MCOSource_SYSCLK: System clock selected.
mbed_official 76:aeb1df146756 623 * @arg RCC_MCOSource_HSI: HSI oscillator clock selected.
mbed_official 76:aeb1df146756 624 * @arg RCC_MCOSource_HSE: HSE oscillator clock selected.
mbed_official 76:aeb1df146756 625 * @arg RCC_MCOSource_PLLCLK_Div2: PLL clock divided by 2 selected.
mbed_official 76:aeb1df146756 626 * @retval None
mbed_official 76:aeb1df146756 627 */
mbed_official 76:aeb1df146756 628 void RCC_MCOConfig(uint8_t RCC_MCOSource)
mbed_official 76:aeb1df146756 629 {
mbed_official 76:aeb1df146756 630 /* Check the parameters */
mbed_official 76:aeb1df146756 631 assert_param(IS_RCC_MCO_SOURCE(RCC_MCOSource));
mbed_official 76:aeb1df146756 632
mbed_official 76:aeb1df146756 633 /* Select MCO clock source and prescaler */
mbed_official 76:aeb1df146756 634 *(__IO uint8_t *) CFGR_BYTE3_ADDRESS = RCC_MCOSource;
mbed_official 76:aeb1df146756 635 }
mbed_official 76:aeb1df146756 636 #else
mbed_official 76:aeb1df146756 637
mbed_official 76:aeb1df146756 638 /**
mbed_official 76:aeb1df146756 639 * @brief Selects the clock source to output on MCO pin (PA8) and the corresponding
mbed_official 76:aeb1df146756 640 * prescsaler.
mbed_official 76:aeb1df146756 641 * @note PA8 should be configured in alternate function mode.
mbed_official 76:aeb1df146756 642 * @param RCC_MCOSource: specifies the clock source to output.
mbed_official 76:aeb1df146756 643 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 644 * @arg RCC_MCOSource_NoClock: No clock selected.
mbed_official 76:aeb1df146756 645 * @arg RCC_MCOSource_HSI14: HSI14 oscillator clock selected.
mbed_official 76:aeb1df146756 646 * @arg RCC_MCOSource_LSI: LSI oscillator clock selected.
mbed_official 76:aeb1df146756 647 * @arg RCC_MCOSource_LSE: LSE oscillator clock selected.
mbed_official 76:aeb1df146756 648 * @arg RCC_MCOSource_SYSCLK: System clock selected.
mbed_official 76:aeb1df146756 649 * @arg RCC_MCOSource_HSI: HSI oscillator clock selected.
mbed_official 76:aeb1df146756 650 * @arg RCC_MCOSource_HSE: HSE oscillator clock selected.
mbed_official 76:aeb1df146756 651 * @arg RCC_MCOSource_PLLCLK_Div2: PLL clock divided by 2 selected.
mbed_official 76:aeb1df146756 652 * @arg RCC_MCOSource_PLLCLK: PLL clock selected.
mbed_official 76:aeb1df146756 653 * @arg RCC_MCOSource_HSI48: HSI48 clock selected.
mbed_official 76:aeb1df146756 654 * @param RCC_MCOPrescaler: specifies the prescaler on MCO pin.
mbed_official 76:aeb1df146756 655 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 656 * @arg RCC_MCOPrescaler_1: MCO clock is divided by 1.
mbed_official 76:aeb1df146756 657 * @arg RCC_MCOPrescaler_2: MCO clock is divided by 2.
mbed_official 76:aeb1df146756 658 * @arg RCC_MCOPrescaler_4: MCO clock is divided by 4.
mbed_official 76:aeb1df146756 659 * @arg RCC_MCOPrescaler_8: MCO clock is divided by 8.
mbed_official 76:aeb1df146756 660 * @arg RCC_MCOPrescaler_16: MCO clock is divided by 16.
mbed_official 76:aeb1df146756 661 * @arg RCC_MCOPrescaler_32: MCO clock is divided by 32.
mbed_official 76:aeb1df146756 662 * @arg RCC_MCOPrescaler_64: MCO clock is divided by 64.
mbed_official 76:aeb1df146756 663 * @arg RCC_MCOPrescaler_128: MCO clock is divided by 128.
mbed_official 76:aeb1df146756 664 * @retval None
mbed_official 76:aeb1df146756 665 */
mbed_official 76:aeb1df146756 666 void RCC_MCOConfig(uint8_t RCC_MCOSource, uint32_t RCC_MCOPrescaler)
mbed_official 76:aeb1df146756 667 {
mbed_official 76:aeb1df146756 668 uint32_t tmpreg = 0;
mbed_official 76:aeb1df146756 669
mbed_official 76:aeb1df146756 670 /* Check the parameters */
mbed_official 76:aeb1df146756 671 assert_param(IS_RCC_MCO_SOURCE(RCC_MCOSource));
mbed_official 76:aeb1df146756 672 assert_param(IS_RCC_MCO_PRESCALER(RCC_MCOPrescaler));
mbed_official 76:aeb1df146756 673
mbed_official 76:aeb1df146756 674 /* Get CFGR value */
mbed_official 76:aeb1df146756 675 tmpreg = RCC->CFGR;
mbed_official 76:aeb1df146756 676 /* Clear MCOPRE[2:0] bits */
mbed_official 76:aeb1df146756 677 tmpreg &= ~(RCC_CFGR_MCO_PRE | RCC_CFGR_MCO | RCC_CFGR_PLLNODIV);
mbed_official 76:aeb1df146756 678 /* Set the RCC_MCOSource and RCC_MCOPrescaler */
mbed_official 76:aeb1df146756 679 tmpreg |= (RCC_MCOPrescaler | ((uint32_t)RCC_MCOSource<<24));
mbed_official 76:aeb1df146756 680 /* Store the new value */
mbed_official 76:aeb1df146756 681 RCC->CFGR = tmpreg;
mbed_official 76:aeb1df146756 682 }
mbed_official 76:aeb1df146756 683 #endif /* STM32F072 */
mbed_official 76:aeb1df146756 684
mbed_official 76:aeb1df146756 685 /**
mbed_official 76:aeb1df146756 686 * @}
mbed_official 76:aeb1df146756 687 */
mbed_official 76:aeb1df146756 688
mbed_official 76:aeb1df146756 689 /** @defgroup RCC_Group2 System AHB and APB busses clocks configuration functions
mbed_official 76:aeb1df146756 690 * @brief System, AHB and APB busses clocks configuration functions
mbed_official 76:aeb1df146756 691 *
mbed_official 76:aeb1df146756 692 @verbatim
mbed_official 76:aeb1df146756 693 ===============================================================================
mbed_official 76:aeb1df146756 694 ##### System, AHB and APB busses clocks configuration functions #####
mbed_official 76:aeb1df146756 695 ===============================================================================
mbed_official 76:aeb1df146756 696
mbed_official 76:aeb1df146756 697 [..] This section provide functions allowing to configure the System, AHB and
mbed_official 76:aeb1df146756 698 APB busses clocks.
mbed_official 76:aeb1df146756 699 (#) Several clock sources can be used to drive the System clock (SYSCLK): HSI,
mbed_official 76:aeb1df146756 700 HSE and PLL.
mbed_official 76:aeb1df146756 701 The AHB clock (HCLK) is derived from System clock through configurable prescaler
mbed_official 76:aeb1df146756 702 and used to clock the CPU, memory and peripherals mapped on AHB bus (DMA and GPIO).
mbed_official 76:aeb1df146756 703 and APB (PCLK) clocks are derived from AHB clock through
mbed_official 76:aeb1df146756 704 configurable prescalers and used to clock the peripherals mapped on these busses.
mbed_official 76:aeb1df146756 705 You can use "RCC_GetClocksFreq()" function to retrieve the frequencies of these clocks.
mbed_official 76:aeb1df146756 706
mbed_official 76:aeb1df146756 707 -@- All the peripheral clocks are derived from the System clock (SYSCLK) except:
mbed_official 76:aeb1df146756 708 (+@) The ADC clock which is derived from HSI14 or APB (APB divided by a
mbed_official 76:aeb1df146756 709 programmable prescaler: 2 or 4).
mbed_official 76:aeb1df146756 710 (+@) The CEC clock which is derived from LSE or HSI divided by 244.
mbed_official 76:aeb1df146756 711 (+@) The I2C clock which is derived from HSI or system clock (SYSCLK).
mbed_official 76:aeb1df146756 712 (+@) The USART clock which is derived from HSI, system clock (SYSCLK), APB or LSE.
mbed_official 76:aeb1df146756 713 (+@) The RTC/LCD clock which is derived from the LSE, LSI or 2 MHz HSE_RTC (HSE
mbed_official 76:aeb1df146756 714 divided by a programmable prescaler).
mbed_official 76:aeb1df146756 715 The System clock (SYSCLK) frequency must be higher or equal to the RTC/LCD
mbed_official 76:aeb1df146756 716 clock frequency.
mbed_official 76:aeb1df146756 717 (+@) IWDG clock which is always the LSI clock.
mbed_official 76:aeb1df146756 718
mbed_official 76:aeb1df146756 719 (#) The maximum frequency of the SYSCLK, HCLK and PCLK is 48 MHz.
mbed_official 76:aeb1df146756 720 Depending on the maximum frequency, the FLASH wait states (WS) should be
mbed_official 76:aeb1df146756 721 adapted accordingly:
mbed_official 76:aeb1df146756 722 +--------------------------------------------- +
mbed_official 76:aeb1df146756 723 | Wait states | HCLK clock frequency (MHz) |
mbed_official 76:aeb1df146756 724 |---------------|------------------------------|
mbed_official 76:aeb1df146756 725 |0WS(1CPU cycle)| 0 < HCLK <= 24 |
mbed_official 76:aeb1df146756 726 |---------------|------------------------------|
mbed_official 76:aeb1df146756 727 |1WS(2CPU cycle)| 24 < HCLK <= 48 |
mbed_official 76:aeb1df146756 728 +----------------------------------------------+
mbed_official 76:aeb1df146756 729
mbed_official 76:aeb1df146756 730 (#) After reset, the System clock source is the HSI (8 MHz) with 0 WS and
mbed_official 76:aeb1df146756 731 prefetch is disabled.
mbed_official 76:aeb1df146756 732
mbed_official 76:aeb1df146756 733 [..] It is recommended to use the following software sequences to tune the number
mbed_official 76:aeb1df146756 734 of wait states needed to access the Flash memory with the CPU frequency (HCLK).
mbed_official 76:aeb1df146756 735 (+) Increasing the CPU frequency
mbed_official 76:aeb1df146756 736 (++) Program the Flash Prefetch buffer, using "FLASH_PrefetchBufferCmd(ENABLE)"
mbed_official 76:aeb1df146756 737 function
mbed_official 76:aeb1df146756 738 (++) Check that Flash Prefetch buffer activation is taken into account by
mbed_official 76:aeb1df146756 739 reading FLASH_ACR using the FLASH_GetPrefetchBufferStatus() function
mbed_official 76:aeb1df146756 740 (++) Program Flash WS to 1, using "FLASH_SetLatency(FLASH_Latency_1)" function
mbed_official 76:aeb1df146756 741 (++) Check that the new number of WS is taken into account by reading FLASH_ACR
mbed_official 76:aeb1df146756 742 (++) Modify the CPU clock source, using "RCC_SYSCLKConfig()" function
mbed_official 76:aeb1df146756 743 (++) If needed, modify the CPU clock prescaler by using "RCC_HCLKConfig()" function
mbed_official 76:aeb1df146756 744 (++) Check that the new CPU clock source is taken into account by reading
mbed_official 76:aeb1df146756 745 the clock source status, using "RCC_GetSYSCLKSource()" function
mbed_official 76:aeb1df146756 746 (+) Decreasing the CPU frequency
mbed_official 76:aeb1df146756 747 (++) Modify the CPU clock source, using "RCC_SYSCLKConfig()" function
mbed_official 76:aeb1df146756 748 (++) If needed, modify the CPU clock prescaler by using "RCC_HCLKConfig()" function
mbed_official 76:aeb1df146756 749 (++) Check that the new CPU clock source is taken into account by reading
mbed_official 76:aeb1df146756 750 the clock source status, using "RCC_GetSYSCLKSource()" function
mbed_official 76:aeb1df146756 751 (++) Program the new number of WS, using "FLASH_SetLatency()" function
mbed_official 76:aeb1df146756 752 (++) Check that the new number of WS is taken into account by reading FLASH_ACR
mbed_official 76:aeb1df146756 753 (++) Disable the Flash Prefetch buffer using "FLASH_PrefetchBufferCmd(DISABLE)"
mbed_official 76:aeb1df146756 754 function
mbed_official 76:aeb1df146756 755 (++) Check that Flash Prefetch buffer deactivation is taken into account by reading FLASH_ACR
mbed_official 76:aeb1df146756 756 using the FLASH_GetPrefetchBufferStatus() function.
mbed_official 76:aeb1df146756 757
mbed_official 76:aeb1df146756 758 @endverbatim
mbed_official 76:aeb1df146756 759 * @{
mbed_official 76:aeb1df146756 760 */
mbed_official 76:aeb1df146756 761
mbed_official 76:aeb1df146756 762 /**
mbed_official 76:aeb1df146756 763 * @brief Configures the system clock (SYSCLK).
mbed_official 76:aeb1df146756 764 * @note The HSI is used (enabled by hardware) as system clock source after
mbed_official 76:aeb1df146756 765 * startup from Reset, wake-up from STOP and STANDBY mode, or in case
mbed_official 76:aeb1df146756 766 * of failure of the HSE used directly or indirectly as system clock
mbed_official 76:aeb1df146756 767 * (if the Clock Security System CSS is enabled).
mbed_official 76:aeb1df146756 768 * @note A switch from one clock source to another occurs only if the target
mbed_official 76:aeb1df146756 769 * clock source is ready (clock stable after startup delay or PLL locked).
mbed_official 76:aeb1df146756 770 * If a clock source which is not yet ready is selected, the switch will
mbed_official 76:aeb1df146756 771 * occur when the clock source will be ready.
mbed_official 76:aeb1df146756 772 * You can use RCC_GetSYSCLKSource() function to know which clock is
mbed_official 76:aeb1df146756 773 * currently used as system clock source.
mbed_official 76:aeb1df146756 774 * @param RCC_SYSCLKSource: specifies the clock source used as system clock source
mbed_official 76:aeb1df146756 775 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 776 * @arg RCC_SYSCLKSource_HSI: HSI selected as system clock source
mbed_official 76:aeb1df146756 777 * @arg RCC_SYSCLKSource_HSE: HSE selected as system clock source
mbed_official 76:aeb1df146756 778 * @arg RCC_SYSCLKSource_PLLCLK: PLL selected as system clock source
mbed_official 76:aeb1df146756 779 * @arg RCC_SYSCLKSource_HSI48: HSI48 selected as system clock source, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 780 * @retval None
mbed_official 76:aeb1df146756 781 */
mbed_official 76:aeb1df146756 782 void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource)
mbed_official 76:aeb1df146756 783 {
mbed_official 76:aeb1df146756 784 uint32_t tmpreg = 0;
mbed_official 76:aeb1df146756 785
mbed_official 76:aeb1df146756 786 /* Check the parameters */
mbed_official 76:aeb1df146756 787 assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource));
mbed_official 76:aeb1df146756 788
mbed_official 76:aeb1df146756 789 tmpreg = RCC->CFGR;
mbed_official 76:aeb1df146756 790
mbed_official 76:aeb1df146756 791 /* Clear SW[1:0] bits */
mbed_official 76:aeb1df146756 792 tmpreg &= ~RCC_CFGR_SW;
mbed_official 76:aeb1df146756 793
mbed_official 76:aeb1df146756 794 /* Set SW[1:0] bits according to RCC_SYSCLKSource value */
mbed_official 76:aeb1df146756 795 tmpreg |= RCC_SYSCLKSource;
mbed_official 76:aeb1df146756 796
mbed_official 76:aeb1df146756 797 /* Store the new value */
mbed_official 76:aeb1df146756 798 RCC->CFGR = tmpreg;
mbed_official 76:aeb1df146756 799 }
mbed_official 76:aeb1df146756 800
mbed_official 76:aeb1df146756 801 /**
mbed_official 76:aeb1df146756 802 * @brief Returns the clock source used as system clock.
mbed_official 76:aeb1df146756 803 * @param None
mbed_official 76:aeb1df146756 804 * @retval The clock source used as system clock. The returned value can be one
mbed_official 76:aeb1df146756 805 * of the following values:
mbed_official 76:aeb1df146756 806 * - 0x00: HSI used as system clock
mbed_official 76:aeb1df146756 807 * - 0x04: HSE used as system clock
mbed_official 76:aeb1df146756 808 * - 0x08: PLL used as system clock
mbed_official 76:aeb1df146756 809 * - 0x0C: HSI48 used as system clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 810 */
mbed_official 76:aeb1df146756 811 uint8_t RCC_GetSYSCLKSource(void)
mbed_official 76:aeb1df146756 812 {
mbed_official 76:aeb1df146756 813 return ((uint8_t)(RCC->CFGR & RCC_CFGR_SWS));
mbed_official 76:aeb1df146756 814 }
mbed_official 76:aeb1df146756 815
mbed_official 76:aeb1df146756 816 /**
mbed_official 76:aeb1df146756 817 * @brief Configures the AHB clock (HCLK).
mbed_official 76:aeb1df146756 818 * @param RCC_SYSCLK: defines the AHB clock divider. This clock is derived from
mbed_official 76:aeb1df146756 819 * the system clock (SYSCLK).
mbed_official 76:aeb1df146756 820 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 821 * @arg RCC_SYSCLK_Div1: AHB clock = SYSCLK
mbed_official 76:aeb1df146756 822 * @arg RCC_SYSCLK_Div2: AHB clock = SYSCLK/2
mbed_official 76:aeb1df146756 823 * @arg RCC_SYSCLK_Div4: AHB clock = SYSCLK/4
mbed_official 76:aeb1df146756 824 * @arg RCC_SYSCLK_Div8: AHB clock = SYSCLK/8
mbed_official 76:aeb1df146756 825 * @arg RCC_SYSCLK_Div16: AHB clock = SYSCLK/16
mbed_official 76:aeb1df146756 826 * @arg RCC_SYSCLK_Div64: AHB clock = SYSCLK/64
mbed_official 76:aeb1df146756 827 * @arg RCC_SYSCLK_Div128: AHB clock = SYSCLK/128
mbed_official 76:aeb1df146756 828 * @arg RCC_SYSCLK_Div256: AHB clock = SYSCLK/256
mbed_official 76:aeb1df146756 829 * @arg RCC_SYSCLK_Div512: AHB clock = SYSCLK/512
mbed_official 76:aeb1df146756 830 * @retval None
mbed_official 76:aeb1df146756 831 */
mbed_official 76:aeb1df146756 832 void RCC_HCLKConfig(uint32_t RCC_SYSCLK)
mbed_official 76:aeb1df146756 833 {
mbed_official 76:aeb1df146756 834 uint32_t tmpreg = 0;
mbed_official 76:aeb1df146756 835
mbed_official 76:aeb1df146756 836 /* Check the parameters */
mbed_official 76:aeb1df146756 837 assert_param(IS_RCC_HCLK(RCC_SYSCLK));
mbed_official 76:aeb1df146756 838
mbed_official 76:aeb1df146756 839 tmpreg = RCC->CFGR;
mbed_official 76:aeb1df146756 840
mbed_official 76:aeb1df146756 841 /* Clear HPRE[3:0] bits */
mbed_official 76:aeb1df146756 842 tmpreg &= ~RCC_CFGR_HPRE;
mbed_official 76:aeb1df146756 843
mbed_official 76:aeb1df146756 844 /* Set HPRE[3:0] bits according to RCC_SYSCLK value */
mbed_official 76:aeb1df146756 845 tmpreg |= RCC_SYSCLK;
mbed_official 76:aeb1df146756 846
mbed_official 76:aeb1df146756 847 /* Store the new value */
mbed_official 76:aeb1df146756 848 RCC->CFGR = tmpreg;
mbed_official 76:aeb1df146756 849 }
mbed_official 76:aeb1df146756 850
mbed_official 76:aeb1df146756 851 /**
mbed_official 76:aeb1df146756 852 * @brief Configures the APB clock (PCLK).
mbed_official 76:aeb1df146756 853 * @param RCC_HCLK: defines the APB clock divider. This clock is derived from
mbed_official 76:aeb1df146756 854 * the AHB clock (HCLK).
mbed_official 76:aeb1df146756 855 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 856 * @arg RCC_HCLK_Div1: APB clock = HCLK
mbed_official 76:aeb1df146756 857 * @arg RCC_HCLK_Div2: APB clock = HCLK/2
mbed_official 76:aeb1df146756 858 * @arg RCC_HCLK_Div4: APB clock = HCLK/4
mbed_official 76:aeb1df146756 859 * @arg RCC_HCLK_Div8: APB clock = HCLK/8
mbed_official 76:aeb1df146756 860 * @arg RCC_HCLK_Div16: APB clock = HCLK/16
mbed_official 76:aeb1df146756 861 * @retval None
mbed_official 76:aeb1df146756 862 */
mbed_official 76:aeb1df146756 863 void RCC_PCLKConfig(uint32_t RCC_HCLK)
mbed_official 76:aeb1df146756 864 {
mbed_official 76:aeb1df146756 865 uint32_t tmpreg = 0;
mbed_official 76:aeb1df146756 866
mbed_official 76:aeb1df146756 867 /* Check the parameters */
mbed_official 76:aeb1df146756 868 assert_param(IS_RCC_PCLK(RCC_HCLK));
mbed_official 76:aeb1df146756 869
mbed_official 76:aeb1df146756 870 tmpreg = RCC->CFGR;
mbed_official 76:aeb1df146756 871
mbed_official 76:aeb1df146756 872 /* Clear PPRE[2:0] bits */
mbed_official 76:aeb1df146756 873 tmpreg &= ~RCC_CFGR_PPRE;
mbed_official 76:aeb1df146756 874
mbed_official 76:aeb1df146756 875 /* Set PPRE[2:0] bits according to RCC_HCLK value */
mbed_official 76:aeb1df146756 876 tmpreg |= RCC_HCLK;
mbed_official 76:aeb1df146756 877
mbed_official 76:aeb1df146756 878 /* Store the new value */
mbed_official 76:aeb1df146756 879 RCC->CFGR = tmpreg;
mbed_official 76:aeb1df146756 880 }
mbed_official 76:aeb1df146756 881
mbed_official 76:aeb1df146756 882 /**
mbed_official 76:aeb1df146756 883 * @brief Configures the ADC clock (ADCCLK).
mbed_official 76:aeb1df146756 884 * @note This function is obsolete.
mbed_official 76:aeb1df146756 885 * For proper ADC clock selection, refer to ADC_ClockModeConfig() in the ADC driver
mbed_official 76:aeb1df146756 886 * @param RCC_ADCCLK: defines the ADC clock source. This clock is derived
mbed_official 76:aeb1df146756 887 * from the HSI14 or APB clock (PCLK).
mbed_official 76:aeb1df146756 888 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 889 * @arg RCC_ADCCLK_HSI14: ADC clock = HSI14 (14MHz)
mbed_official 76:aeb1df146756 890 * @arg RCC_ADCCLK_PCLK_Div2: ADC clock = PCLK/2
mbed_official 76:aeb1df146756 891 * @arg RCC_ADCCLK_PCLK_Div4: ADC clock = PCLK/4
mbed_official 76:aeb1df146756 892 * @retval None
mbed_official 76:aeb1df146756 893 */
mbed_official 76:aeb1df146756 894 void RCC_ADCCLKConfig(uint32_t RCC_ADCCLK)
mbed_official 76:aeb1df146756 895 {
mbed_official 76:aeb1df146756 896 /* Check the parameters */
mbed_official 76:aeb1df146756 897 assert_param(IS_RCC_ADCCLK(RCC_ADCCLK));
mbed_official 76:aeb1df146756 898
mbed_official 76:aeb1df146756 899 /* Clear ADCPRE bit */
mbed_official 76:aeb1df146756 900 RCC->CFGR &= ~RCC_CFGR_ADCPRE;
mbed_official 76:aeb1df146756 901 /* Set ADCPRE bits according to RCC_PCLK value */
mbed_official 76:aeb1df146756 902 RCC->CFGR |= RCC_ADCCLK & 0xFFFF;
mbed_official 76:aeb1df146756 903
mbed_official 76:aeb1df146756 904 /* Clear ADCSW bit */
mbed_official 76:aeb1df146756 905 RCC->CFGR3 &= ~RCC_CFGR3_ADCSW;
mbed_official 76:aeb1df146756 906 /* Set ADCSW bits according to RCC_ADCCLK value */
mbed_official 76:aeb1df146756 907 RCC->CFGR3 |= RCC_ADCCLK >> 16;
mbed_official 76:aeb1df146756 908 }
mbed_official 76:aeb1df146756 909
mbed_official 76:aeb1df146756 910 /**
mbed_official 76:aeb1df146756 911 * @brief Configures the CEC clock (CECCLK).
mbed_official 76:aeb1df146756 912 * @param RCC_CECCLK: defines the CEC clock source. This clock is derived
mbed_official 76:aeb1df146756 913 * from the HSI or LSE clock.
mbed_official 76:aeb1df146756 914 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 915 * @arg RCC_CECCLK_HSI_Div244: CEC clock = HSI/244 (32768Hz)
mbed_official 76:aeb1df146756 916 * @arg RCC_CECCLK_LSE: CEC clock = LSE
mbed_official 76:aeb1df146756 917 * @retval None
mbed_official 76:aeb1df146756 918 */
mbed_official 76:aeb1df146756 919 void RCC_CECCLKConfig(uint32_t RCC_CECCLK)
mbed_official 76:aeb1df146756 920 {
mbed_official 76:aeb1df146756 921 /* Check the parameters */
mbed_official 76:aeb1df146756 922 assert_param(IS_RCC_CECCLK(RCC_CECCLK));
mbed_official 76:aeb1df146756 923
mbed_official 76:aeb1df146756 924 /* Clear CECSW bit */
mbed_official 76:aeb1df146756 925 RCC->CFGR3 &= ~RCC_CFGR3_CECSW;
mbed_official 76:aeb1df146756 926 /* Set CECSW bits according to RCC_CECCLK value */
mbed_official 76:aeb1df146756 927 RCC->CFGR3 |= RCC_CECCLK;
mbed_official 76:aeb1df146756 928 }
mbed_official 76:aeb1df146756 929
mbed_official 76:aeb1df146756 930 /**
mbed_official 76:aeb1df146756 931 * @brief Configures the I2C1 clock (I2C1CLK).
mbed_official 76:aeb1df146756 932 * @param RCC_I2CCLK: defines the I2C1 clock source. This clock is derived
mbed_official 76:aeb1df146756 933 * from the HSI or System clock.
mbed_official 76:aeb1df146756 934 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 935 * @arg RCC_I2C1CLK_HSI: I2C1 clock = HSI
mbed_official 76:aeb1df146756 936 * @arg RCC_I2C1CLK_SYSCLK: I2C1 clock = System Clock
mbed_official 76:aeb1df146756 937 * @retval None
mbed_official 76:aeb1df146756 938 */
mbed_official 76:aeb1df146756 939 void RCC_I2CCLKConfig(uint32_t RCC_I2CCLK)
mbed_official 76:aeb1df146756 940 {
mbed_official 76:aeb1df146756 941 /* Check the parameters */
mbed_official 76:aeb1df146756 942 assert_param(IS_RCC_I2CCLK(RCC_I2CCLK));
mbed_official 76:aeb1df146756 943
mbed_official 76:aeb1df146756 944 /* Clear I2CSW bit */
mbed_official 76:aeb1df146756 945 RCC->CFGR3 &= ~RCC_CFGR3_I2C1SW;
mbed_official 76:aeb1df146756 946 /* Set I2CSW bits according to RCC_I2CCLK value */
mbed_official 76:aeb1df146756 947 RCC->CFGR3 |= RCC_I2CCLK;
mbed_official 76:aeb1df146756 948 }
mbed_official 76:aeb1df146756 949
mbed_official 76:aeb1df146756 950 /**
mbed_official 76:aeb1df146756 951 * @brief Configures the USART1 clock (USART1CLK).
mbed_official 76:aeb1df146756 952 * @param RCC_USARTCLK: defines the USART clock source. This clock is derived
mbed_official 76:aeb1df146756 953 * from the HSI or System clock.
mbed_official 76:aeb1df146756 954 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 955 * @arg RCC_USART1CLK_PCLK: USART1 clock = APB Clock (PCLK)
mbed_official 76:aeb1df146756 956 * @arg RCC_USART1CLK_SYSCLK: USART1 clock = System Clock
mbed_official 76:aeb1df146756 957 * @arg RCC_USART1CLK_LSE: USART1 clock = LSE Clock
mbed_official 76:aeb1df146756 958 * @arg RCC_USART1CLK_HSI: USART1 clock = HSI Clock
mbed_official 76:aeb1df146756 959 * @arg RCC_USART2CLK_PCLK: USART2 clock = APB Clock (PCLK), applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 960 * @arg RCC_USART2CLK_SYSCLK: USART2 clock = System Clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 961 * @arg RCC_USART2CLK_LSE: USART2 clock = LSE Clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 962 * @arg RCC_USART2CLK_HSI: USART2 clock = HSI Clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 963 * @retval None
mbed_official 76:aeb1df146756 964 */
mbed_official 76:aeb1df146756 965 void RCC_USARTCLKConfig(uint32_t RCC_USARTCLK)
mbed_official 76:aeb1df146756 966 {
mbed_official 76:aeb1df146756 967 uint32_t tmp = 0;
mbed_official 76:aeb1df146756 968
mbed_official 76:aeb1df146756 969 /* Check the parameters */
mbed_official 76:aeb1df146756 970 assert_param(IS_RCC_USARTCLK(RCC_USARTCLK));
mbed_official 76:aeb1df146756 971
mbed_official 76:aeb1df146756 972 /* Get USART index */
mbed_official 76:aeb1df146756 973 tmp = (RCC_USARTCLK >> 28);
mbed_official 76:aeb1df146756 974
mbed_official 76:aeb1df146756 975 /* Clear USARTSW[1:0] bit */
mbed_official 76:aeb1df146756 976 if (tmp == (uint32_t)0x00000001)
mbed_official 76:aeb1df146756 977 {
mbed_official 76:aeb1df146756 978 /* Clear USART1SW[1:0] bit */
mbed_official 76:aeb1df146756 979 RCC->CFGR3 &= ~RCC_CFGR3_USART1SW;
mbed_official 76:aeb1df146756 980 }
mbed_official 76:aeb1df146756 981 else
mbed_official 76:aeb1df146756 982 {
mbed_official 76:aeb1df146756 983 /* Clear USART2SW[1:0] bit */
mbed_official 76:aeb1df146756 984 RCC->CFGR3 &= ~RCC_CFGR3_USART2SW;
mbed_official 76:aeb1df146756 985 }
mbed_official 76:aeb1df146756 986
mbed_official 76:aeb1df146756 987 /* Set USARTxSW bits according to RCC_USARTCLK value */
mbed_official 76:aeb1df146756 988 RCC->CFGR3 |= RCC_USARTCLK;
mbed_official 76:aeb1df146756 989 }
mbed_official 76:aeb1df146756 990
mbed_official 76:aeb1df146756 991 /**
mbed_official 76:aeb1df146756 992 * @brief Configures the USB clock (USBCLK).
mbed_official 76:aeb1df146756 993 * This function is only applicable for STM32F072 devices.
mbed_official 76:aeb1df146756 994 * @param RCC_USBCLK: defines the USB clock source. This clock is derived
mbed_official 76:aeb1df146756 995 * from the HSI48 or system clock.
mbed_official 76:aeb1df146756 996 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 997 * @arg RCC_USBCLK_HSI48: USB clock = HSI48
mbed_official 76:aeb1df146756 998 * @arg RCC_USBCLK_PLLCLK: USB clock = PLL clock
mbed_official 76:aeb1df146756 999 * @retval None
mbed_official 76:aeb1df146756 1000 */
mbed_official 76:aeb1df146756 1001 void RCC_USBCLKConfig(uint32_t RCC_USBCLK)
mbed_official 76:aeb1df146756 1002 {
mbed_official 76:aeb1df146756 1003 /* Check the parameters */
mbed_official 76:aeb1df146756 1004 assert_param(IS_RCC_USBCLK(RCC_USBCLK));
mbed_official 76:aeb1df146756 1005
mbed_official 76:aeb1df146756 1006 /* Clear USBSW bit */
mbed_official 76:aeb1df146756 1007 RCC->CFGR3 &= ~RCC_CFGR3_USBSW;
mbed_official 76:aeb1df146756 1008 /* Set USBSW bits according to RCC_USBCLK value */
mbed_official 76:aeb1df146756 1009 RCC->CFGR3 |= RCC_USBCLK;
mbed_official 76:aeb1df146756 1010 }
mbed_official 76:aeb1df146756 1011
mbed_official 76:aeb1df146756 1012 /**
mbed_official 76:aeb1df146756 1013 * @brief Returns the frequencies of the System, AHB and APB busses clocks.
mbed_official 76:aeb1df146756 1014 * @note The frequency returned by this function is not the real frequency
mbed_official 76:aeb1df146756 1015 * in the chip. It is calculated based on the predefined constant and
mbed_official 76:aeb1df146756 1016 * the source selected by RCC_SYSCLKConfig():
mbed_official 76:aeb1df146756 1017 *
mbed_official 76:aeb1df146756 1018 * @note If SYSCLK source is HSI, function returns constant HSI_VALUE(*)
mbed_official 76:aeb1df146756 1019 *
mbed_official 76:aeb1df146756 1020 * @note If SYSCLK source is HSE, function returns constant HSE_VALUE(**)
mbed_official 76:aeb1df146756 1021 *
mbed_official 76:aeb1df146756 1022 * @note If SYSCLK source is PLL, function returns constant HSE_VALUE(**)
mbed_official 76:aeb1df146756 1023 * or HSI_VALUE(*) multiplied by the PLL factors.
mbed_official 76:aeb1df146756 1024 *
mbed_official 76:aeb1df146756 1025 * @note If SYSCLK source is HSI48, function returns constant HSI48_VALUE(***)
mbed_official 76:aeb1df146756 1026 *
mbed_official 76:aeb1df146756 1027 * @note (*) HSI_VALUE is a constant defined in stm32f0xx.h file (default value
mbed_official 76:aeb1df146756 1028 * 8 MHz) but the real value may vary depending on the variations
mbed_official 76:aeb1df146756 1029 * in voltage and temperature, refer to RCC_AdjustHSICalibrationValue().
mbed_official 76:aeb1df146756 1030 *
mbed_official 76:aeb1df146756 1031 * @note (**) HSE_VALUE is a constant defined in stm32f0xx.h file (default value
mbed_official 76:aeb1df146756 1032 * 8 MHz), user has to ensure that HSE_VALUE is same as the real
mbed_official 76:aeb1df146756 1033 * frequency of the crystal used. Otherwise, this function may
mbed_official 76:aeb1df146756 1034 * return wrong result.
mbed_official 76:aeb1df146756 1035 *
mbed_official 76:aeb1df146756 1036 * @note (***) HSI48_VALUE is a constant defined in stm32f0xx.h file (default value
mbed_official 76:aeb1df146756 1037 * 48 MHz) but the real value may vary depending on the variations
mbed_official 76:aeb1df146756 1038 * in voltage and temperature.
mbed_official 76:aeb1df146756 1039 *
mbed_official 76:aeb1df146756 1040 * @note The result of this function could be not correct when using fractional
mbed_official 76:aeb1df146756 1041 * value for HSE crystal.
mbed_official 76:aeb1df146756 1042 *
mbed_official 76:aeb1df146756 1043 * @param RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold
mbed_official 76:aeb1df146756 1044 * the clocks frequencies.
mbed_official 76:aeb1df146756 1045 *
mbed_official 76:aeb1df146756 1046 * @note This function can be used by the user application to compute the
mbed_official 76:aeb1df146756 1047 * baudrate for the communication peripherals or configure other parameters.
mbed_official 76:aeb1df146756 1048 * @note Each time SYSCLK, HCLK and/or PCLK clock changes, this function
mbed_official 76:aeb1df146756 1049 * must be called to update the structure's field. Otherwise, any
mbed_official 76:aeb1df146756 1050 * configuration based on this function will be incorrect.
mbed_official 76:aeb1df146756 1051 *
mbed_official 76:aeb1df146756 1052 * @retval None
mbed_official 76:aeb1df146756 1053 */
mbed_official 76:aeb1df146756 1054 void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)
mbed_official 76:aeb1df146756 1055 {
mbed_official 76:aeb1df146756 1056 uint32_t tmp = 0, pllmull = 0, pllsource = 0, prediv1factor = 0, presc = 0, pllclk = 0;
mbed_official 76:aeb1df146756 1057
mbed_official 76:aeb1df146756 1058 /* Get SYSCLK source -------------------------------------------------------*/
mbed_official 76:aeb1df146756 1059 tmp = RCC->CFGR & RCC_CFGR_SWS;
mbed_official 76:aeb1df146756 1060
mbed_official 76:aeb1df146756 1061 switch (tmp)
mbed_official 76:aeb1df146756 1062 {
mbed_official 76:aeb1df146756 1063 case 0x00: /* HSI used as system clock */
mbed_official 76:aeb1df146756 1064 RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;
mbed_official 76:aeb1df146756 1065 break;
mbed_official 76:aeb1df146756 1066 case 0x04: /* HSE used as system clock */
mbed_official 76:aeb1df146756 1067 RCC_Clocks->SYSCLK_Frequency = HSE_VALUE;
mbed_official 76:aeb1df146756 1068 break;
mbed_official 76:aeb1df146756 1069 case 0x08: /* PLL used as system clock */
mbed_official 76:aeb1df146756 1070 /* Get PLL clock source and multiplication factor ----------------------*/
mbed_official 76:aeb1df146756 1071 pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
mbed_official 76:aeb1df146756 1072 pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
mbed_official 76:aeb1df146756 1073 pllmull = ( pllmull >> 18) + 2;
mbed_official 76:aeb1df146756 1074
mbed_official 76:aeb1df146756 1075 if (pllsource == 0x00)
mbed_official 76:aeb1df146756 1076 {
mbed_official 76:aeb1df146756 1077 /* HSI oscillator clock divided by 2 selected as PLL clock entry */
mbed_official 76:aeb1df146756 1078 pllclk = (HSI_VALUE >> 1) * pllmull;
mbed_official 76:aeb1df146756 1079 }
mbed_official 76:aeb1df146756 1080 else
mbed_official 76:aeb1df146756 1081 {
mbed_official 76:aeb1df146756 1082 prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1;
mbed_official 76:aeb1df146756 1083 /* HSE oscillator clock selected as PREDIV1 clock entry */
mbed_official 76:aeb1df146756 1084 pllclk = (HSE_VALUE / prediv1factor) * pllmull;
mbed_official 76:aeb1df146756 1085 }
mbed_official 76:aeb1df146756 1086 RCC_Clocks->SYSCLK_Frequency = pllclk;
mbed_official 76:aeb1df146756 1087 break;
mbed_official 76:aeb1df146756 1088 case 0x0C: /* HSI48 used as system clock */
mbed_official 76:aeb1df146756 1089 RCC_Clocks->SYSCLK_Frequency = HSI48_VALUE;
mbed_official 76:aeb1df146756 1090 break;
mbed_official 76:aeb1df146756 1091 default: /* HSI used as system clock */
mbed_official 76:aeb1df146756 1092 RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;
mbed_official 76:aeb1df146756 1093 break;
mbed_official 76:aeb1df146756 1094 }
mbed_official 76:aeb1df146756 1095 /* Compute HCLK, PCLK clocks frequencies -----------------------------------*/
mbed_official 76:aeb1df146756 1096 /* Get HCLK prescaler */
mbed_official 76:aeb1df146756 1097 tmp = RCC->CFGR & RCC_CFGR_HPRE;
mbed_official 76:aeb1df146756 1098 tmp = tmp >> 4;
mbed_official 76:aeb1df146756 1099 presc = APBAHBPrescTable[tmp];
mbed_official 76:aeb1df146756 1100 /* HCLK clock frequency */
mbed_official 76:aeb1df146756 1101 RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc;
mbed_official 76:aeb1df146756 1102
mbed_official 76:aeb1df146756 1103 /* Get PCLK prescaler */
mbed_official 76:aeb1df146756 1104 tmp = RCC->CFGR & RCC_CFGR_PPRE;
mbed_official 76:aeb1df146756 1105 tmp = tmp >> 8;
mbed_official 76:aeb1df146756 1106 presc = APBAHBPrescTable[tmp];
mbed_official 76:aeb1df146756 1107 /* PCLK clock frequency */
mbed_official 76:aeb1df146756 1108 RCC_Clocks->PCLK_Frequency = RCC_Clocks->HCLK_Frequency >> presc;
mbed_official 76:aeb1df146756 1109
mbed_official 76:aeb1df146756 1110 /* ADCCLK clock frequency */
mbed_official 76:aeb1df146756 1111 if((RCC->CFGR3 & RCC_CFGR3_ADCSW) != RCC_CFGR3_ADCSW)
mbed_official 76:aeb1df146756 1112 {
mbed_official 76:aeb1df146756 1113 /* ADC Clock is HSI14 Osc. */
mbed_official 76:aeb1df146756 1114 RCC_Clocks->ADCCLK_Frequency = HSI14_VALUE;
mbed_official 76:aeb1df146756 1115 }
mbed_official 76:aeb1df146756 1116 else
mbed_official 76:aeb1df146756 1117 {
mbed_official 76:aeb1df146756 1118 if((RCC->CFGR & RCC_CFGR_ADCPRE) != RCC_CFGR_ADCPRE)
mbed_official 76:aeb1df146756 1119 {
mbed_official 76:aeb1df146756 1120 /* ADC Clock is derived from PCLK/2 */
mbed_official 76:aeb1df146756 1121 RCC_Clocks->ADCCLK_Frequency = RCC_Clocks->PCLK_Frequency >> 1;
mbed_official 76:aeb1df146756 1122 }
mbed_official 76:aeb1df146756 1123 else
mbed_official 76:aeb1df146756 1124 {
mbed_official 76:aeb1df146756 1125 /* ADC Clock is derived from PCLK/4 */
mbed_official 76:aeb1df146756 1126 RCC_Clocks->ADCCLK_Frequency = RCC_Clocks->PCLK_Frequency >> 2;
mbed_official 76:aeb1df146756 1127 }
mbed_official 76:aeb1df146756 1128
mbed_official 76:aeb1df146756 1129 }
mbed_official 76:aeb1df146756 1130
mbed_official 76:aeb1df146756 1131 /* CECCLK clock frequency */
mbed_official 76:aeb1df146756 1132 if((RCC->CFGR3 & RCC_CFGR3_CECSW) != RCC_CFGR3_CECSW)
mbed_official 76:aeb1df146756 1133 {
mbed_official 76:aeb1df146756 1134 /* CEC Clock is HSI/244 */
mbed_official 76:aeb1df146756 1135 RCC_Clocks->CECCLK_Frequency = HSI_VALUE / 244;
mbed_official 76:aeb1df146756 1136 }
mbed_official 76:aeb1df146756 1137 else
mbed_official 76:aeb1df146756 1138 {
mbed_official 76:aeb1df146756 1139 /* CECC Clock is LSE Osc. */
mbed_official 76:aeb1df146756 1140 RCC_Clocks->CECCLK_Frequency = LSE_VALUE;
mbed_official 76:aeb1df146756 1141 }
mbed_official 76:aeb1df146756 1142
mbed_official 76:aeb1df146756 1143 /* I2C1CLK clock frequency */
mbed_official 76:aeb1df146756 1144 if((RCC->CFGR3 & RCC_CFGR3_I2C1SW) != RCC_CFGR3_I2C1SW)
mbed_official 76:aeb1df146756 1145 {
mbed_official 76:aeb1df146756 1146 /* I2C1 Clock is HSI Osc. */
mbed_official 76:aeb1df146756 1147 RCC_Clocks->I2C1CLK_Frequency = HSI_VALUE;
mbed_official 76:aeb1df146756 1148 }
mbed_official 76:aeb1df146756 1149 else
mbed_official 76:aeb1df146756 1150 {
mbed_official 76:aeb1df146756 1151 /* I2C1 Clock is System Clock */
mbed_official 76:aeb1df146756 1152 RCC_Clocks->I2C1CLK_Frequency = RCC_Clocks->SYSCLK_Frequency;
mbed_official 76:aeb1df146756 1153 }
mbed_official 76:aeb1df146756 1154
mbed_official 76:aeb1df146756 1155 /* USART1CLK clock frequency */
mbed_official 76:aeb1df146756 1156 if((RCC->CFGR3 & RCC_CFGR3_USART1SW) == 0x0)
mbed_official 76:aeb1df146756 1157 {
mbed_official 76:aeb1df146756 1158 /* USART1 Clock is PCLK */
mbed_official 76:aeb1df146756 1159 RCC_Clocks->USART1CLK_Frequency = RCC_Clocks->PCLK_Frequency;
mbed_official 76:aeb1df146756 1160 }
mbed_official 76:aeb1df146756 1161 else if((RCC->CFGR3 & RCC_CFGR3_USART1SW) == RCC_CFGR3_USART1SW_0)
mbed_official 76:aeb1df146756 1162 {
mbed_official 76:aeb1df146756 1163 /* USART1 Clock is System Clock */
mbed_official 76:aeb1df146756 1164 RCC_Clocks->USART1CLK_Frequency = RCC_Clocks->SYSCLK_Frequency;
mbed_official 76:aeb1df146756 1165 }
mbed_official 76:aeb1df146756 1166 else if((RCC->CFGR3 & RCC_CFGR3_USART1SW) == RCC_CFGR3_USART1SW_1)
mbed_official 76:aeb1df146756 1167 {
mbed_official 76:aeb1df146756 1168 /* USART1 Clock is LSE Osc. */
mbed_official 76:aeb1df146756 1169 RCC_Clocks->USART1CLK_Frequency = LSE_VALUE;
mbed_official 76:aeb1df146756 1170 }
mbed_official 76:aeb1df146756 1171 else if((RCC->CFGR3 & RCC_CFGR3_USART1SW) == RCC_CFGR3_USART1SW)
mbed_official 76:aeb1df146756 1172 {
mbed_official 76:aeb1df146756 1173 /* USART1 Clock is HSI Osc. */
mbed_official 76:aeb1df146756 1174 RCC_Clocks->USART1CLK_Frequency = HSI_VALUE;
mbed_official 76:aeb1df146756 1175 }
mbed_official 76:aeb1df146756 1176
mbed_official 76:aeb1df146756 1177 /* USART2CLK clock frequency */
mbed_official 76:aeb1df146756 1178 if((RCC->CFGR3 & RCC_CFGR3_USART2SW) == 0x0)
mbed_official 76:aeb1df146756 1179 {
mbed_official 76:aeb1df146756 1180 /* USART Clock is PCLK */
mbed_official 76:aeb1df146756 1181 RCC_Clocks->USART2CLK_Frequency = RCC_Clocks->PCLK_Frequency;
mbed_official 76:aeb1df146756 1182 }
mbed_official 76:aeb1df146756 1183 else if((RCC->CFGR3 & RCC_CFGR3_USART2SW) == RCC_CFGR3_USART2SW_0)
mbed_official 76:aeb1df146756 1184 {
mbed_official 76:aeb1df146756 1185 /* USART Clock is System Clock */
mbed_official 76:aeb1df146756 1186 RCC_Clocks->USART2CLK_Frequency = RCC_Clocks->SYSCLK_Frequency;
mbed_official 76:aeb1df146756 1187 }
mbed_official 76:aeb1df146756 1188 else if((RCC->CFGR3 & RCC_CFGR3_USART2SW) == RCC_CFGR3_USART2SW_1)
mbed_official 76:aeb1df146756 1189 {
mbed_official 76:aeb1df146756 1190 /* USART Clock is LSE Osc. */
mbed_official 76:aeb1df146756 1191 RCC_Clocks->USART2CLK_Frequency = LSE_VALUE;
mbed_official 76:aeb1df146756 1192 }
mbed_official 76:aeb1df146756 1193 else if((RCC->CFGR3 & RCC_CFGR3_USART2SW) == RCC_CFGR3_USART2SW)
mbed_official 76:aeb1df146756 1194 {
mbed_official 76:aeb1df146756 1195 /* USART Clock is HSI Osc. */
mbed_official 76:aeb1df146756 1196 RCC_Clocks->USART2CLK_Frequency = HSI_VALUE;
mbed_official 76:aeb1df146756 1197 }
mbed_official 76:aeb1df146756 1198
mbed_official 76:aeb1df146756 1199 /* USBCLK clock frequency */
mbed_official 76:aeb1df146756 1200 if((RCC->CFGR3 & RCC_CFGR3_USBSW) != RCC_CFGR3_USBSW)
mbed_official 76:aeb1df146756 1201 {
mbed_official 76:aeb1df146756 1202 /* USB Clock is HSI48 */
mbed_official 76:aeb1df146756 1203 RCC_Clocks->USBCLK_Frequency = HSI48_VALUE;
mbed_official 76:aeb1df146756 1204 }
mbed_official 76:aeb1df146756 1205 else
mbed_official 76:aeb1df146756 1206 {
mbed_official 76:aeb1df146756 1207 /* USB Clock is PLL clock */
mbed_official 76:aeb1df146756 1208 RCC_Clocks->USBCLK_Frequency = pllclk;
mbed_official 76:aeb1df146756 1209 }
mbed_official 76:aeb1df146756 1210 }
mbed_official 76:aeb1df146756 1211
mbed_official 76:aeb1df146756 1212 /**
mbed_official 76:aeb1df146756 1213 * @}
mbed_official 76:aeb1df146756 1214 */
mbed_official 76:aeb1df146756 1215
mbed_official 76:aeb1df146756 1216 /** @defgroup RCC_Group3 Peripheral clocks configuration functions
mbed_official 76:aeb1df146756 1217 * @brief Peripheral clocks configuration functions
mbed_official 76:aeb1df146756 1218 *
mbed_official 76:aeb1df146756 1219 @verbatim
mbed_official 76:aeb1df146756 1220 ===============================================================================
mbed_official 76:aeb1df146756 1221 #####Peripheral clocks configuration functions #####
mbed_official 76:aeb1df146756 1222 ===============================================================================
mbed_official 76:aeb1df146756 1223
mbed_official 76:aeb1df146756 1224 [..] This section provide functions allowing to configure the Peripheral clocks.
mbed_official 76:aeb1df146756 1225 (#) The RTC clock which is derived from the LSE, LSI or HSE_Div32 (HSE
mbed_official 76:aeb1df146756 1226 divided by 32).
mbed_official 76:aeb1df146756 1227 (#) After restart from Reset or wakeup from STANDBY, all peripherals are off
mbed_official 76:aeb1df146756 1228 except internal SRAM, Flash and SWD. Before to start using a peripheral you
mbed_official 76:aeb1df146756 1229 have to enable its interface clock. You can do this using RCC_AHBPeriphClockCmd(),
mbed_official 76:aeb1df146756 1230 RCC_APB2PeriphClockCmd() and RCC_APB1PeriphClockCmd() functions.
mbed_official 76:aeb1df146756 1231 (#) To reset the peripherals configuration (to the default state after device reset)
mbed_official 76:aeb1df146756 1232 you can use RCC_AHBPeriphResetCmd(), RCC_APB2PeriphResetCmd() and
mbed_official 76:aeb1df146756 1233 RCC_APB1PeriphResetCmd() functions.
mbed_official 76:aeb1df146756 1234
mbed_official 76:aeb1df146756 1235 @endverbatim
mbed_official 76:aeb1df146756 1236 * @{
mbed_official 76:aeb1df146756 1237 */
mbed_official 76:aeb1df146756 1238
mbed_official 76:aeb1df146756 1239 /**
mbed_official 76:aeb1df146756 1240 * @brief Configures the RTC clock (RTCCLK).
mbed_official 76:aeb1df146756 1241 * @note As the RTC clock configuration bits are in the Backup domain and write
mbed_official 76:aeb1df146756 1242 * access is denied to this domain after reset, you have to enable write
mbed_official 76:aeb1df146756 1243 * access using PWR_BackupAccessCmd(ENABLE) function before to configure
mbed_official 76:aeb1df146756 1244 * the RTC clock source (to be done once after reset).
mbed_official 76:aeb1df146756 1245 * @note Once the RTC clock is configured it can't be changed unless the RTC
mbed_official 76:aeb1df146756 1246 * is reset using RCC_BackupResetCmd function, or by a Power On Reset (POR)
mbed_official 76:aeb1df146756 1247 *
mbed_official 76:aeb1df146756 1248 * @param RCC_RTCCLKSource: specifies the RTC clock source.
mbed_official 76:aeb1df146756 1249 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 1250 * @arg RCC_RTCCLKSource_LSE: LSE selected as RTC clock
mbed_official 76:aeb1df146756 1251 * @arg RCC_RTCCLKSource_LSI: LSI selected as RTC clock
mbed_official 76:aeb1df146756 1252 * @arg RCC_RTCCLKSource_HSE_Div32: HSE divided by 32 selected as RTC clock
mbed_official 76:aeb1df146756 1253 *
mbed_official 76:aeb1df146756 1254 * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
mbed_official 76:aeb1df146756 1255 * work in STOP and STANDBY modes, and can be used as wakeup source.
mbed_official 76:aeb1df146756 1256 * However, when the HSE clock is used as RTC clock source, the RTC
mbed_official 76:aeb1df146756 1257 * cannot be used in STOP and STANDBY modes.
mbed_official 76:aeb1df146756 1258 *
mbed_official 76:aeb1df146756 1259 * @note The maximum input clock frequency for RTC is 2MHz (when using HSE as
mbed_official 76:aeb1df146756 1260 * RTC clock source).
mbed_official 76:aeb1df146756 1261 *
mbed_official 76:aeb1df146756 1262 * @retval None
mbed_official 76:aeb1df146756 1263 */
mbed_official 76:aeb1df146756 1264 void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)
mbed_official 76:aeb1df146756 1265 {
mbed_official 76:aeb1df146756 1266 /* Check the parameters */
mbed_official 76:aeb1df146756 1267 assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));
mbed_official 76:aeb1df146756 1268
mbed_official 76:aeb1df146756 1269 /* Select the RTC clock source */
mbed_official 76:aeb1df146756 1270 RCC->BDCR |= RCC_RTCCLKSource;
mbed_official 76:aeb1df146756 1271 }
mbed_official 76:aeb1df146756 1272
mbed_official 76:aeb1df146756 1273 /**
mbed_official 76:aeb1df146756 1274 * @brief Enables or disables the RTC clock.
mbed_official 76:aeb1df146756 1275 * @note This function must be used only after the RTC clock source was selected
mbed_official 76:aeb1df146756 1276 * using the RCC_RTCCLKConfig function.
mbed_official 76:aeb1df146756 1277 * @param NewState: new state of the RTC clock.
mbed_official 76:aeb1df146756 1278 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1279 * @retval None
mbed_official 76:aeb1df146756 1280 */
mbed_official 76:aeb1df146756 1281 void RCC_RTCCLKCmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 1282 {
mbed_official 76:aeb1df146756 1283 /* Check the parameters */
mbed_official 76:aeb1df146756 1284 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1285
mbed_official 76:aeb1df146756 1286 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1287 {
mbed_official 76:aeb1df146756 1288 RCC->BDCR |= RCC_BDCR_RTCEN;
mbed_official 76:aeb1df146756 1289 }
mbed_official 76:aeb1df146756 1290 else
mbed_official 76:aeb1df146756 1291 {
mbed_official 76:aeb1df146756 1292 RCC->BDCR &= ~RCC_BDCR_RTCEN;
mbed_official 76:aeb1df146756 1293 }
mbed_official 76:aeb1df146756 1294 }
mbed_official 76:aeb1df146756 1295
mbed_official 76:aeb1df146756 1296 /**
mbed_official 76:aeb1df146756 1297 * @brief Forces or releases the Backup domain reset.
mbed_official 76:aeb1df146756 1298 * @note This function resets the RTC peripheral (including the backup registers)
mbed_official 76:aeb1df146756 1299 * and the RTC clock source selection in RCC_BDCR register.
mbed_official 76:aeb1df146756 1300 * @param NewState: new state of the Backup domain reset.
mbed_official 76:aeb1df146756 1301 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1302 * @retval None
mbed_official 76:aeb1df146756 1303 */
mbed_official 76:aeb1df146756 1304 void RCC_BackupResetCmd(FunctionalState NewState)
mbed_official 76:aeb1df146756 1305 {
mbed_official 76:aeb1df146756 1306 /* Check the parameters */
mbed_official 76:aeb1df146756 1307 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1308
mbed_official 76:aeb1df146756 1309 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1310 {
mbed_official 76:aeb1df146756 1311 RCC->BDCR |= RCC_BDCR_BDRST;
mbed_official 76:aeb1df146756 1312 }
mbed_official 76:aeb1df146756 1313 else
mbed_official 76:aeb1df146756 1314 {
mbed_official 76:aeb1df146756 1315 RCC->BDCR &= ~RCC_BDCR_BDRST;
mbed_official 76:aeb1df146756 1316 }
mbed_official 76:aeb1df146756 1317 }
mbed_official 76:aeb1df146756 1318
mbed_official 76:aeb1df146756 1319 /**
mbed_official 76:aeb1df146756 1320 * @brief Enables or disables the AHB peripheral clock.
mbed_official 76:aeb1df146756 1321 * @note After reset, the peripheral clock (used for registers read/write access)
mbed_official 76:aeb1df146756 1322 * is disabled and the application software has to enable this clock before
mbed_official 76:aeb1df146756 1323 * using it.
mbed_official 76:aeb1df146756 1324 * @param RCC_AHBPeriph: specifies the AHB peripheral to gates its clock.
mbed_official 76:aeb1df146756 1325 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1326 * @arg RCC_AHBPeriph_GPIOA: GPIOA clock
mbed_official 76:aeb1df146756 1327 * @arg RCC_AHBPeriph_GPIOB: GPIOB clock
mbed_official 76:aeb1df146756 1328 * @arg RCC_AHBPeriph_GPIOC: GPIOC clock
mbed_official 76:aeb1df146756 1329 * @arg RCC_AHBPeriph_GPIOD: GPIOD clock
mbed_official 76:aeb1df146756 1330 * @arg RCC_AHBPeriph_GPIOE: GPIOE clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1331 * @arg RCC_AHBPeriph_GPIOF: GPIOF clock
mbed_official 76:aeb1df146756 1332 * @arg RCC_AHBPeriph_TS: TS clock
mbed_official 76:aeb1df146756 1333 * @arg RCC_AHBPeriph_CRC: CRC clock
mbed_official 76:aeb1df146756 1334 * @arg RCC_AHBPeriph_FLITF: (has effect only when the Flash memory is in power down mode)
mbed_official 76:aeb1df146756 1335 * @arg RCC_AHBPeriph_SRAM: SRAM clock
mbed_official 76:aeb1df146756 1336 * @arg RCC_AHBPeriph_DMA1: DMA1 clock
mbed_official 76:aeb1df146756 1337 * @param NewState: new state of the specified peripheral clock.
mbed_official 76:aeb1df146756 1338 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1339 * @retval None
mbed_official 76:aeb1df146756 1340 */
mbed_official 76:aeb1df146756 1341 void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)
mbed_official 76:aeb1df146756 1342 {
mbed_official 76:aeb1df146756 1343 /* Check the parameters */
mbed_official 76:aeb1df146756 1344 assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph));
mbed_official 76:aeb1df146756 1345 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1346
mbed_official 76:aeb1df146756 1347 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1348 {
mbed_official 76:aeb1df146756 1349 RCC->AHBENR |= RCC_AHBPeriph;
mbed_official 76:aeb1df146756 1350 }
mbed_official 76:aeb1df146756 1351 else
mbed_official 76:aeb1df146756 1352 {
mbed_official 76:aeb1df146756 1353 RCC->AHBENR &= ~RCC_AHBPeriph;
mbed_official 76:aeb1df146756 1354 }
mbed_official 76:aeb1df146756 1355 }
mbed_official 76:aeb1df146756 1356
mbed_official 76:aeb1df146756 1357 /**
mbed_official 76:aeb1df146756 1358 * @brief Enables or disables the High Speed APB (APB2) peripheral clock.
mbed_official 76:aeb1df146756 1359 * @note After reset, the peripheral clock (used for registers read/write access)
mbed_official 76:aeb1df146756 1360 * is disabled and the application software has to enable this clock before
mbed_official 76:aeb1df146756 1361 * using it.
mbed_official 76:aeb1df146756 1362 * @param RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.
mbed_official 76:aeb1df146756 1363 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1364 * @arg RCC_APB2Periph_SYSCFG: SYSCFG clock
mbed_official 76:aeb1df146756 1365 * @arg RCC_APB2Periph_ADC1: ADC1 clock
mbed_official 76:aeb1df146756 1366 * @arg RCC_APB2Periph_TIM1: TIM1 clock
mbed_official 76:aeb1df146756 1367 * @arg RCC_APB2Periph_SPI1: SPI1 clock
mbed_official 76:aeb1df146756 1368 * @arg RCC_APB2Periph_USART1: USART1 clock
mbed_official 76:aeb1df146756 1369 * @arg RCC_APB2Periph_TIM15: TIM15 clock
mbed_official 76:aeb1df146756 1370 * @arg RCC_APB2Periph_TIM16: TIM16 clock
mbed_official 76:aeb1df146756 1371 * @arg RCC_APB2Periph_TIM17: TIM17 clock
mbed_official 76:aeb1df146756 1372 * @arg RCC_APB2Periph_DBGMCU: DBGMCU clock
mbed_official 76:aeb1df146756 1373 * @param NewState: new state of the specified peripheral clock.
mbed_official 76:aeb1df146756 1374 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1375 * @retval None
mbed_official 76:aeb1df146756 1376 */
mbed_official 76:aeb1df146756 1377 void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
mbed_official 76:aeb1df146756 1378 {
mbed_official 76:aeb1df146756 1379 /* Check the parameters */
mbed_official 76:aeb1df146756 1380 assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
mbed_official 76:aeb1df146756 1381 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1382
mbed_official 76:aeb1df146756 1383 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1384 {
mbed_official 76:aeb1df146756 1385 RCC->APB2ENR |= RCC_APB2Periph;
mbed_official 76:aeb1df146756 1386 }
mbed_official 76:aeb1df146756 1387 else
mbed_official 76:aeb1df146756 1388 {
mbed_official 76:aeb1df146756 1389 RCC->APB2ENR &= ~RCC_APB2Periph;
mbed_official 76:aeb1df146756 1390 }
mbed_official 76:aeb1df146756 1391 }
mbed_official 76:aeb1df146756 1392
mbed_official 76:aeb1df146756 1393 /**
mbed_official 76:aeb1df146756 1394 * @brief Enables or disables the Low Speed APB (APB1) peripheral clock.
mbed_official 76:aeb1df146756 1395 * @note After reset, the peripheral clock (used for registers read/write access)
mbed_official 76:aeb1df146756 1396 * is disabled and the application software has to enable this clock before
mbed_official 76:aeb1df146756 1397 * using it.
mbed_official 76:aeb1df146756 1398 * @param RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.
mbed_official 76:aeb1df146756 1399 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1400 * @arg RCC_APB1Periph_TIM2: TIM2 clock, applicable only for STM32F051 and STM32F072 devices
mbed_official 76:aeb1df146756 1401 * @arg RCC_APB1Periph_TIM3: TIM3 clock
mbed_official 76:aeb1df146756 1402 * @arg RCC_APB1Periph_TIM6: TIM6 clock
mbed_official 76:aeb1df146756 1403 * @arg RCC_APB1Periph_TIM7: TIM7 clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1404 * @arg RCC_APB1Periph_TIM14: TIM14 clock
mbed_official 76:aeb1df146756 1405 * @arg RCC_APB1Periph_WWDG: WWDG clock
mbed_official 76:aeb1df146756 1406 * @arg RCC_APB1Periph_SPI2: SPI2 clock
mbed_official 76:aeb1df146756 1407 * @arg RCC_APB1Periph_USART2: USART2 clock
mbed_official 76:aeb1df146756 1408 * @arg RCC_APB1Periph_USART3: USART3 clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1409 * @arg RCC_APB1Periph_USART4: USART4 clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1410 * @arg RCC_APB1Periph_I2C1: I2C1 clock
mbed_official 76:aeb1df146756 1411 * @arg RCC_APB1Periph_I2C2: I2C2 clock
mbed_official 76:aeb1df146756 1412 * @arg RCC_APB1Periph_USB: USB clock, applicable only for STM32F042 and STM32F072 devices
mbed_official 76:aeb1df146756 1413 * @arg RCC_APB1Periph_CAN: CAN clock, applicable only for STM32F042 and STM32F072 devices
mbed_official 76:aeb1df146756 1414 * @arg RCC_APB1Periph_CRS: CRS clock , applicable only for STM32F042 and STM32F072 devices
mbed_official 76:aeb1df146756 1415 * @arg RCC_APB1Periph_PWR: PWR clock
mbed_official 76:aeb1df146756 1416 * @arg RCC_APB1Periph_DAC: DAC clock, applicable only for STM32F051 and STM32F072 devices
mbed_official 76:aeb1df146756 1417 * @arg RCC_APB1Periph_CEC: CEC clock, applicable only for STM32F051, STM32F042 and STM32F072 devices
mbed_official 76:aeb1df146756 1418 * @param NewState: new state of the specified peripheral clock.
mbed_official 76:aeb1df146756 1419 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1420 * @retval None
mbed_official 76:aeb1df146756 1421 */
mbed_official 76:aeb1df146756 1422 void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
mbed_official 76:aeb1df146756 1423 {
mbed_official 76:aeb1df146756 1424 /* Check the parameters */
mbed_official 76:aeb1df146756 1425 assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
mbed_official 76:aeb1df146756 1426 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1427
mbed_official 76:aeb1df146756 1428 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1429 {
mbed_official 76:aeb1df146756 1430 RCC->APB1ENR |= RCC_APB1Periph;
mbed_official 76:aeb1df146756 1431 }
mbed_official 76:aeb1df146756 1432 else
mbed_official 76:aeb1df146756 1433 {
mbed_official 76:aeb1df146756 1434 RCC->APB1ENR &= ~RCC_APB1Periph;
mbed_official 76:aeb1df146756 1435 }
mbed_official 76:aeb1df146756 1436 }
mbed_official 76:aeb1df146756 1437
mbed_official 76:aeb1df146756 1438 /**
mbed_official 76:aeb1df146756 1439 * @brief Forces or releases AHB peripheral reset.
mbed_official 76:aeb1df146756 1440 * @param RCC_AHBPeriph: specifies the AHB peripheral to reset.
mbed_official 76:aeb1df146756 1441 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1442 * @arg RCC_AHBPeriph_GPIOA: GPIOA clock
mbed_official 76:aeb1df146756 1443 * @arg RCC_AHBPeriph_GPIOB: GPIOB clock
mbed_official 76:aeb1df146756 1444 * @arg RCC_AHBPeriph_GPIOC: GPIOC clock
mbed_official 76:aeb1df146756 1445 * @arg RCC_AHBPeriph_GPIOD: GPIOD clock
mbed_official 76:aeb1df146756 1446 * @arg RCC_AHBPeriph_GPIOE: GPIOE clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1447 * @arg RCC_AHBPeriph_GPIOF: GPIOF clock
mbed_official 76:aeb1df146756 1448 * @arg RCC_AHBPeriph_TS: TS clock
mbed_official 76:aeb1df146756 1449 * @param NewState: new state of the specified peripheral reset.
mbed_official 76:aeb1df146756 1450 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1451 * @retval None
mbed_official 76:aeb1df146756 1452 */
mbed_official 76:aeb1df146756 1453 void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)
mbed_official 76:aeb1df146756 1454 {
mbed_official 76:aeb1df146756 1455 /* Check the parameters */
mbed_official 76:aeb1df146756 1456 assert_param(IS_RCC_AHB_RST_PERIPH(RCC_AHBPeriph));
mbed_official 76:aeb1df146756 1457 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1458
mbed_official 76:aeb1df146756 1459 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1460 {
mbed_official 76:aeb1df146756 1461 RCC->AHBRSTR |= RCC_AHBPeriph;
mbed_official 76:aeb1df146756 1462 }
mbed_official 76:aeb1df146756 1463 else
mbed_official 76:aeb1df146756 1464 {
mbed_official 76:aeb1df146756 1465 RCC->AHBRSTR &= ~RCC_AHBPeriph;
mbed_official 76:aeb1df146756 1466 }
mbed_official 76:aeb1df146756 1467 }
mbed_official 76:aeb1df146756 1468
mbed_official 76:aeb1df146756 1469 /**
mbed_official 76:aeb1df146756 1470 * @brief Forces or releases High Speed APB (APB2) peripheral reset.
mbed_official 76:aeb1df146756 1471 * @param RCC_APB2Periph: specifies the APB2 peripheral to reset.
mbed_official 76:aeb1df146756 1472 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1473 * @arg RCC_APB2Periph_SYSCFG: SYSCFG clock
mbed_official 76:aeb1df146756 1474 * @arg RCC_APB2Periph_ADC1: ADC1 clock
mbed_official 76:aeb1df146756 1475 * @arg RCC_APB2Periph_TIM1: TIM1 clock
mbed_official 76:aeb1df146756 1476 * @arg RCC_APB2Periph_SPI1: SPI1 clock
mbed_official 76:aeb1df146756 1477 * @arg RCC_APB2Periph_USART1: USART1 clock
mbed_official 76:aeb1df146756 1478 * @arg RCC_APB2Periph_TIM15: TIM15 clock
mbed_official 76:aeb1df146756 1479 * @arg RCC_APB2Periph_TIM16: TIM16 clock
mbed_official 76:aeb1df146756 1480 * @arg RCC_APB2Periph_TIM17: TIM17 clock
mbed_official 76:aeb1df146756 1481 * @arg RCC_APB2Periph_DBGMCU: DBGMCU clock
mbed_official 76:aeb1df146756 1482 * @param NewState: new state of the specified peripheral reset.
mbed_official 76:aeb1df146756 1483 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1484 * @retval None
mbed_official 76:aeb1df146756 1485 */
mbed_official 76:aeb1df146756 1486 void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
mbed_official 76:aeb1df146756 1487 {
mbed_official 76:aeb1df146756 1488 /* Check the parameters */
mbed_official 76:aeb1df146756 1489 assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
mbed_official 76:aeb1df146756 1490 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1491
mbed_official 76:aeb1df146756 1492 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1493 {
mbed_official 76:aeb1df146756 1494 RCC->APB2RSTR |= RCC_APB2Periph;
mbed_official 76:aeb1df146756 1495 }
mbed_official 76:aeb1df146756 1496 else
mbed_official 76:aeb1df146756 1497 {
mbed_official 76:aeb1df146756 1498 RCC->APB2RSTR &= ~RCC_APB2Periph;
mbed_official 76:aeb1df146756 1499 }
mbed_official 76:aeb1df146756 1500 }
mbed_official 76:aeb1df146756 1501
mbed_official 76:aeb1df146756 1502 /**
mbed_official 76:aeb1df146756 1503 * @brief Forces or releases Low Speed APB (APB1) peripheral reset.
mbed_official 76:aeb1df146756 1504 * @param RCC_APB1Periph: specifies the APB1 peripheral to reset.
mbed_official 76:aeb1df146756 1505 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1506 * @arg RCC_APB1Periph_TIM2: TIM2 clock, applicable only for STM32F051 and STM32F072 devices
mbed_official 76:aeb1df146756 1507 * @arg RCC_APB1Periph_TIM3: TIM3 clock
mbed_official 76:aeb1df146756 1508 * @arg RCC_APB1Periph_TIM6: TIM6 clock
mbed_official 76:aeb1df146756 1509 * @arg RCC_APB1Periph_TIM7: TIM7 clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1510 * @arg RCC_APB1Periph_TIM14: TIM14 clock
mbed_official 76:aeb1df146756 1511 * @arg RCC_APB1Periph_WWDG: WWDG clock
mbed_official 76:aeb1df146756 1512 * @arg RCC_APB1Periph_SPI2: SPI2 clock
mbed_official 76:aeb1df146756 1513 * @arg RCC_APB1Periph_USART2: USART2 clock
mbed_official 76:aeb1df146756 1514 * @arg RCC_APB1Periph_USART3: USART3 clock
mbed_official 76:aeb1df146756 1515 * @arg RCC_APB1Periph_USART4: USART4 clock
mbed_official 76:aeb1df146756 1516 * @arg RCC_APB1Periph_I2C1: I2C1 clock
mbed_official 76:aeb1df146756 1517 * @arg RCC_APB1Periph_I2C2: I2C2 clock
mbed_official 76:aeb1df146756 1518 * @arg RCC_APB1Periph_USB: USB clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1519 * @arg RCC_APB1Periph_CAN: CAN clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1520 * @arg RCC_APB1Periph_CRS: CRS clock, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1521 * @arg RCC_APB1Periph_PWR: PWR clock
mbed_official 76:aeb1df146756 1522 * @arg RCC_APB1Periph_DAC: DAC clock, applicable only for STM32F051 and STM32F072 devices
mbed_official 76:aeb1df146756 1523 * @arg RCC_APB1Periph_CEC: CEC clock, applicable only for STM32F051 and STM32F072 devices
mbed_official 76:aeb1df146756 1524 * @param NewState: new state of the specified peripheral clock.
mbed_official 76:aeb1df146756 1525 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1526 * @retval None
mbed_official 76:aeb1df146756 1527 */
mbed_official 76:aeb1df146756 1528 void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
mbed_official 76:aeb1df146756 1529 {
mbed_official 76:aeb1df146756 1530 /* Check the parameters */
mbed_official 76:aeb1df146756 1531 assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
mbed_official 76:aeb1df146756 1532 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1533
mbed_official 76:aeb1df146756 1534 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1535 {
mbed_official 76:aeb1df146756 1536 RCC->APB1RSTR |= RCC_APB1Periph;
mbed_official 76:aeb1df146756 1537 }
mbed_official 76:aeb1df146756 1538 else
mbed_official 76:aeb1df146756 1539 {
mbed_official 76:aeb1df146756 1540 RCC->APB1RSTR &= ~RCC_APB1Periph;
mbed_official 76:aeb1df146756 1541 }
mbed_official 76:aeb1df146756 1542 }
mbed_official 76:aeb1df146756 1543
mbed_official 76:aeb1df146756 1544 /**
mbed_official 76:aeb1df146756 1545 * @}
mbed_official 76:aeb1df146756 1546 */
mbed_official 76:aeb1df146756 1547
mbed_official 76:aeb1df146756 1548 /** @defgroup RCC_Group4 Interrupts and flags management functions
mbed_official 76:aeb1df146756 1549 * @brief Interrupts and flags management functions
mbed_official 76:aeb1df146756 1550 *
mbed_official 76:aeb1df146756 1551 @verbatim
mbed_official 76:aeb1df146756 1552 ===============================================================================
mbed_official 76:aeb1df146756 1553 ##### Interrupts and flags management functions #####
mbed_official 76:aeb1df146756 1554 ===============================================================================
mbed_official 76:aeb1df146756 1555 @endverbatim
mbed_official 76:aeb1df146756 1556 * @{
mbed_official 76:aeb1df146756 1557 */
mbed_official 76:aeb1df146756 1558
mbed_official 76:aeb1df146756 1559 /**
mbed_official 76:aeb1df146756 1560 * @brief Enables or disables the specified RCC interrupts.
mbed_official 76:aeb1df146756 1561 * @note The CSS interrupt doesn't have an enable bit; once the CSS is enabled
mbed_official 76:aeb1df146756 1562 * and if the HSE clock fails, the CSS interrupt occurs and an NMI is
mbed_official 76:aeb1df146756 1563 * automatically generated. The NMI will be executed indefinitely, and
mbed_official 76:aeb1df146756 1564 * since NMI has higher priority than any other IRQ (and main program)
mbed_official 76:aeb1df146756 1565 * the application will be stacked in the NMI ISR unless the CSS interrupt
mbed_official 76:aeb1df146756 1566 * pending bit is cleared.
mbed_official 76:aeb1df146756 1567 * @param RCC_IT: specifies the RCC interrupt sources to be enabled or disabled.
mbed_official 76:aeb1df146756 1568 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1569 * @arg RCC_IT_LSIRDY: LSI ready interrupt
mbed_official 76:aeb1df146756 1570 * @arg RCC_IT_LSERDY: LSE ready interrupt
mbed_official 76:aeb1df146756 1571 * @arg RCC_IT_HSIRDY: HSI ready interrupt
mbed_official 76:aeb1df146756 1572 * @arg RCC_IT_HSERDY: HSE ready interrupt
mbed_official 76:aeb1df146756 1573 * @arg RCC_IT_PLLRDY: PLL ready interrupt
mbed_official 76:aeb1df146756 1574 * @arg RCC_IT_HSI14RDY: HSI14 ready interrupt
mbed_official 76:aeb1df146756 1575 * @arg RCC_IT_HSI48RDY: HSI48 ready interrupt, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1576 * @param NewState: new state of the specified RCC interrupts.
mbed_official 76:aeb1df146756 1577 * This parameter can be: ENABLE or DISABLE.
mbed_official 76:aeb1df146756 1578 * @retval None
mbed_official 76:aeb1df146756 1579 */
mbed_official 76:aeb1df146756 1580 void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState)
mbed_official 76:aeb1df146756 1581 {
mbed_official 76:aeb1df146756 1582 /* Check the parameters */
mbed_official 76:aeb1df146756 1583 assert_param(IS_RCC_IT(RCC_IT));
mbed_official 76:aeb1df146756 1584 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 76:aeb1df146756 1585
mbed_official 76:aeb1df146756 1586 if (NewState != DISABLE)
mbed_official 76:aeb1df146756 1587 {
mbed_official 76:aeb1df146756 1588 /* Perform Byte access to RCC_CIR[13:8] bits to enable the selected interrupts */
mbed_official 76:aeb1df146756 1589 *(__IO uint8_t *) CIR_BYTE1_ADDRESS |= RCC_IT;
mbed_official 76:aeb1df146756 1590 }
mbed_official 76:aeb1df146756 1591 else
mbed_official 76:aeb1df146756 1592 {
mbed_official 76:aeb1df146756 1593 /* Perform Byte access to RCC_CIR[13:8] bits to disable the selected interrupts */
mbed_official 76:aeb1df146756 1594 *(__IO uint8_t *) CIR_BYTE1_ADDRESS &= (uint8_t)~RCC_IT;
mbed_official 76:aeb1df146756 1595 }
mbed_official 76:aeb1df146756 1596 }
mbed_official 76:aeb1df146756 1597
mbed_official 76:aeb1df146756 1598 /**
mbed_official 76:aeb1df146756 1599 * @brief Checks whether the specified RCC flag is set or not.
mbed_official 76:aeb1df146756 1600 * @param RCC_FLAG: specifies the flag to check.
mbed_official 76:aeb1df146756 1601 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 1602 * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready
mbed_official 76:aeb1df146756 1603 * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready
mbed_official 76:aeb1df146756 1604 * @arg RCC_FLAG_PLLRDY: PLL clock ready
mbed_official 76:aeb1df146756 1605 * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready
mbed_official 76:aeb1df146756 1606 * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready
mbed_official 76:aeb1df146756 1607 * @arg RCC_FLAG_OBLRST: Option Byte Loader (OBL) reset
mbed_official 76:aeb1df146756 1608 * @arg RCC_FLAG_PINRST: Pin reset
mbed_official 76:aeb1df146756 1609 * @arg RCC_FLAG_V18PWRRSTF: V1.8 power domain reset
mbed_official 76:aeb1df146756 1610 * @arg RCC_FLAG_PORRST: POR/PDR reset
mbed_official 76:aeb1df146756 1611 * @arg RCC_FLAG_SFTRST: Software reset
mbed_official 76:aeb1df146756 1612 * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset
mbed_official 76:aeb1df146756 1613 * @arg RCC_FLAG_WWDGRST: Window Watchdog reset
mbed_official 76:aeb1df146756 1614 * @arg RCC_FLAG_LPWRRST: Low Power reset
mbed_official 76:aeb1df146756 1615 * @arg RCC_FLAG_HSI14RDY: HSI14 oscillator clock ready
mbed_official 76:aeb1df146756 1616 * @arg RCC_FLAG_HSI48RDY: HSI48 oscillator clock ready, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1617 * @retval The new state of RCC_FLAG (SET or RESET).
mbed_official 76:aeb1df146756 1618 */
mbed_official 76:aeb1df146756 1619 FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
mbed_official 76:aeb1df146756 1620 {
mbed_official 76:aeb1df146756 1621 uint32_t tmp = 0;
mbed_official 76:aeb1df146756 1622 uint32_t statusreg = 0;
mbed_official 76:aeb1df146756 1623 FlagStatus bitstatus = RESET;
mbed_official 76:aeb1df146756 1624
mbed_official 76:aeb1df146756 1625 /* Check the parameters */
mbed_official 76:aeb1df146756 1626 assert_param(IS_RCC_FLAG(RCC_FLAG));
mbed_official 76:aeb1df146756 1627
mbed_official 76:aeb1df146756 1628 /* Get the RCC register index */
mbed_official 76:aeb1df146756 1629 tmp = RCC_FLAG >> 5;
mbed_official 76:aeb1df146756 1630
mbed_official 76:aeb1df146756 1631 if (tmp == 0) /* The flag to check is in CR register */
mbed_official 76:aeb1df146756 1632 {
mbed_official 76:aeb1df146756 1633 statusreg = RCC->CR;
mbed_official 76:aeb1df146756 1634 }
mbed_official 76:aeb1df146756 1635 else if (tmp == 1) /* The flag to check is in BDCR register */
mbed_official 76:aeb1df146756 1636 {
mbed_official 76:aeb1df146756 1637 statusreg = RCC->BDCR;
mbed_official 76:aeb1df146756 1638 }
mbed_official 76:aeb1df146756 1639 else if (tmp == 2) /* The flag to check is in CSR register */
mbed_official 76:aeb1df146756 1640 {
mbed_official 76:aeb1df146756 1641 statusreg = RCC->CSR;
mbed_official 76:aeb1df146756 1642 }
mbed_official 76:aeb1df146756 1643 else /* The flag to check is in CR2 register */
mbed_official 76:aeb1df146756 1644 {
mbed_official 76:aeb1df146756 1645 statusreg = RCC->CR2;
mbed_official 76:aeb1df146756 1646 }
mbed_official 76:aeb1df146756 1647
mbed_official 76:aeb1df146756 1648 /* Get the flag position */
mbed_official 76:aeb1df146756 1649 tmp = RCC_FLAG & FLAG_MASK;
mbed_official 76:aeb1df146756 1650
mbed_official 76:aeb1df146756 1651 if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)
mbed_official 76:aeb1df146756 1652 {
mbed_official 76:aeb1df146756 1653 bitstatus = SET;
mbed_official 76:aeb1df146756 1654 }
mbed_official 76:aeb1df146756 1655 else
mbed_official 76:aeb1df146756 1656 {
mbed_official 76:aeb1df146756 1657 bitstatus = RESET;
mbed_official 76:aeb1df146756 1658 }
mbed_official 76:aeb1df146756 1659 /* Return the flag status */
mbed_official 76:aeb1df146756 1660 return bitstatus;
mbed_official 76:aeb1df146756 1661 }
mbed_official 76:aeb1df146756 1662
mbed_official 76:aeb1df146756 1663 /**
mbed_official 76:aeb1df146756 1664 * @brief Clears the RCC reset flags.
mbed_official 76:aeb1df146756 1665 * The reset flags are: RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_V18PWRRSTF,
mbed_official 76:aeb1df146756 1666 * RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST,
mbed_official 76:aeb1df146756 1667 * RCC_FLAG_LPWRRST.
mbed_official 76:aeb1df146756 1668 * @param None
mbed_official 76:aeb1df146756 1669 * @retval None
mbed_official 76:aeb1df146756 1670 */
mbed_official 76:aeb1df146756 1671 void RCC_ClearFlag(void)
mbed_official 76:aeb1df146756 1672 {
mbed_official 76:aeb1df146756 1673 /* Set RMVF bit to clear the reset flags */
mbed_official 76:aeb1df146756 1674 RCC->CSR |= RCC_CSR_RMVF;
mbed_official 76:aeb1df146756 1675 }
mbed_official 76:aeb1df146756 1676
mbed_official 76:aeb1df146756 1677 /**
mbed_official 76:aeb1df146756 1678 * @brief Checks whether the specified RCC interrupt has occurred or not.
mbed_official 76:aeb1df146756 1679 * @param RCC_IT: specifies the RCC interrupt source to check.
mbed_official 76:aeb1df146756 1680 * This parameter can be one of the following values:
mbed_official 76:aeb1df146756 1681 * @arg RCC_IT_LSIRDY: LSI ready interrupt
mbed_official 76:aeb1df146756 1682 * @arg RCC_IT_LSERDY: LSE ready interrupt
mbed_official 76:aeb1df146756 1683 * @arg RCC_IT_HSIRDY: HSI ready interrupt
mbed_official 76:aeb1df146756 1684 * @arg RCC_IT_HSERDY: HSE ready interrupt
mbed_official 76:aeb1df146756 1685 * @arg RCC_IT_PLLRDY: PLL ready interrupt
mbed_official 76:aeb1df146756 1686 * @arg RCC_IT_HSI14RDY: HSI14 ready interrupt
mbed_official 76:aeb1df146756 1687 * @arg RCC_IT_HSI48RDY: HSI48 ready interrupt, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1688 * @arg RCC_IT_CSS: Clock Security System interrupt
mbed_official 76:aeb1df146756 1689 * @retval The new state of RCC_IT (SET or RESET).
mbed_official 76:aeb1df146756 1690 */
mbed_official 76:aeb1df146756 1691 ITStatus RCC_GetITStatus(uint8_t RCC_IT)
mbed_official 76:aeb1df146756 1692 {
mbed_official 76:aeb1df146756 1693 ITStatus bitstatus = RESET;
mbed_official 76:aeb1df146756 1694
mbed_official 76:aeb1df146756 1695 /* Check the parameters */
mbed_official 76:aeb1df146756 1696 assert_param(IS_RCC_GET_IT(RCC_IT));
mbed_official 76:aeb1df146756 1697
mbed_official 76:aeb1df146756 1698 /* Check the status of the specified RCC interrupt */
mbed_official 76:aeb1df146756 1699 if ((RCC->CIR & RCC_IT) != (uint32_t)RESET)
mbed_official 76:aeb1df146756 1700 {
mbed_official 76:aeb1df146756 1701 bitstatus = SET;
mbed_official 76:aeb1df146756 1702 }
mbed_official 76:aeb1df146756 1703 else
mbed_official 76:aeb1df146756 1704 {
mbed_official 76:aeb1df146756 1705 bitstatus = RESET;
mbed_official 76:aeb1df146756 1706 }
mbed_official 76:aeb1df146756 1707 /* Return the RCC_IT status */
mbed_official 76:aeb1df146756 1708 return bitstatus;
mbed_official 76:aeb1df146756 1709 }
mbed_official 76:aeb1df146756 1710
mbed_official 76:aeb1df146756 1711 /**
mbed_official 76:aeb1df146756 1712 * @brief Clears the RCC's interrupt pending bits.
mbed_official 76:aeb1df146756 1713 * @param RCC_IT: specifies the interrupt pending bit to clear.
mbed_official 76:aeb1df146756 1714 * This parameter can be any combination of the following values:
mbed_official 76:aeb1df146756 1715 * @arg RCC_IT_LSIRDY: LSI ready interrupt
mbed_official 76:aeb1df146756 1716 * @arg RCC_IT_LSERDY: LSE ready interrupt
mbed_official 76:aeb1df146756 1717 * @arg RCC_IT_HSIRDY: HSI ready interrupt
mbed_official 76:aeb1df146756 1718 * @arg RCC_IT_HSERDY: HSE ready interrupt
mbed_official 76:aeb1df146756 1719 * @arg RCC_IT_PLLRDY: PLL ready interrupt
mbed_official 76:aeb1df146756 1720 * @arg RCC_IT_HSI48RDY: HSI48 ready interrupt, applicable only for STM32F072 devices
mbed_official 76:aeb1df146756 1721 * @arg RCC_IT_HSI14RDY: HSI14 ready interrupt
mbed_official 76:aeb1df146756 1722 * @arg RCC_IT_CSS: Clock Security System interrupt
mbed_official 76:aeb1df146756 1723 * @retval None
mbed_official 76:aeb1df146756 1724 */
mbed_official 76:aeb1df146756 1725 void RCC_ClearITPendingBit(uint8_t RCC_IT)
mbed_official 76:aeb1df146756 1726 {
mbed_official 76:aeb1df146756 1727 /* Check the parameters */
mbed_official 76:aeb1df146756 1728 assert_param(IS_RCC_CLEAR_IT(RCC_IT));
mbed_official 76:aeb1df146756 1729
mbed_official 76:aeb1df146756 1730 /* Perform Byte access to RCC_CIR[23:16] bits to clear the selected interrupt
mbed_official 76:aeb1df146756 1731 pending bits */
mbed_official 76:aeb1df146756 1732 *(__IO uint8_t *) CIR_BYTE2_ADDRESS = RCC_IT;
mbed_official 76:aeb1df146756 1733 }
mbed_official 76:aeb1df146756 1734
mbed_official 76:aeb1df146756 1735 /**
mbed_official 76:aeb1df146756 1736 * @}
mbed_official 76:aeb1df146756 1737 */
mbed_official 76:aeb1df146756 1738
mbed_official 76:aeb1df146756 1739 /**
mbed_official 76:aeb1df146756 1740 * @}
mbed_official 76:aeb1df146756 1741 */
mbed_official 76:aeb1df146756 1742
mbed_official 76:aeb1df146756 1743 /**
mbed_official 76:aeb1df146756 1744 * @}
mbed_official 76:aeb1df146756 1745 */
mbed_official 76:aeb1df146756 1746
mbed_official 76:aeb1df146756 1747 /**
mbed_official 76:aeb1df146756 1748 * @}
mbed_official 76:aeb1df146756 1749 */
mbed_official 76:aeb1df146756 1750
mbed_official 76:aeb1df146756 1751 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/