mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Mon Nov 03 10:45:07 2014 +0000
Revision:
382:ee426a420dbb
Parent:
targets/cmsis/TARGET_STM/TARGET_DISCO_L053C8/stm32l0xx_hal_rcc_ex.h@376:cb4d9db17537
Child:
489:119543c9f674
Synchronized with git revision d54467eb07f62efd9ccdf44f1ede7fe1c1b0cf83

Full URL: https://github.com/mbedmicro/mbed/commit/d54467eb07f62efd9ccdf44f1ede7fe1c1b0cf83/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 376:cb4d9db17537 1 /**
mbed_official 376:cb4d9db17537 2 ******************************************************************************
mbed_official 376:cb4d9db17537 3 * @file stm32l0xx_hal_rcc_ex.h
mbed_official 376:cb4d9db17537 4 * @author MCD Application Team
mbed_official 376:cb4d9db17537 5 * @version V1.1.0
mbed_official 376:cb4d9db17537 6 * @date 18-June-2014
mbed_official 376:cb4d9db17537 7 * @brief Header file of RCC HAL Extension module.
mbed_official 376:cb4d9db17537 8 ******************************************************************************
mbed_official 376:cb4d9db17537 9 * @attention
mbed_official 376:cb4d9db17537 10 *
mbed_official 376:cb4d9db17537 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 376:cb4d9db17537 12 *
mbed_official 376:cb4d9db17537 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 376:cb4d9db17537 14 * are permitted provided that the following conditions are met:
mbed_official 376:cb4d9db17537 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 376:cb4d9db17537 16 * this list of conditions and the following disclaimer.
mbed_official 376:cb4d9db17537 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 376:cb4d9db17537 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 376:cb4d9db17537 19 * and/or other materials provided with the distribution.
mbed_official 376:cb4d9db17537 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 376:cb4d9db17537 21 * may be used to endorse or promote products derived from this software
mbed_official 376:cb4d9db17537 22 * without specific prior written permission.
mbed_official 376:cb4d9db17537 23 *
mbed_official 376:cb4d9db17537 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 376:cb4d9db17537 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 376:cb4d9db17537 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 376:cb4d9db17537 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 376:cb4d9db17537 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 376:cb4d9db17537 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 376:cb4d9db17537 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 376:cb4d9db17537 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 376:cb4d9db17537 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 376:cb4d9db17537 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 376:cb4d9db17537 34 *
mbed_official 376:cb4d9db17537 35 ******************************************************************************
mbed_official 376:cb4d9db17537 36 */
mbed_official 376:cb4d9db17537 37
mbed_official 376:cb4d9db17537 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 376:cb4d9db17537 39 #ifndef __STM32L0xx_HAL_RCC_EX_H
mbed_official 376:cb4d9db17537 40 #define __STM32L0xx_HAL_RCC_EX_H
mbed_official 376:cb4d9db17537 41
mbed_official 376:cb4d9db17537 42 #ifdef __cplusplus
mbed_official 376:cb4d9db17537 43 extern "C" {
mbed_official 376:cb4d9db17537 44 #endif
mbed_official 376:cb4d9db17537 45
mbed_official 376:cb4d9db17537 46 /* Includes ------------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 47 #include "stm32l0xx_hal_def.h"
mbed_official 376:cb4d9db17537 48
mbed_official 376:cb4d9db17537 49 /** @addtogroup STM32L0xx_HAL_Driver
mbed_official 376:cb4d9db17537 50 * @{
mbed_official 376:cb4d9db17537 51 */
mbed_official 376:cb4d9db17537 52
mbed_official 376:cb4d9db17537 53 /** @addtogroup RCCEx
mbed_official 376:cb4d9db17537 54 * @{
mbed_official 376:cb4d9db17537 55 */
mbed_official 376:cb4d9db17537 56
mbed_official 376:cb4d9db17537 57 /* Exported types ------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 58 /**
mbed_official 376:cb4d9db17537 59 * @brief RCC extended clocks structure definition
mbed_official 376:cb4d9db17537 60 */
mbed_official 376:cb4d9db17537 61 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 62 typedef struct
mbed_official 376:cb4d9db17537 63 {
mbed_official 376:cb4d9db17537 64 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
mbed_official 376:cb4d9db17537 65 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
mbed_official 376:cb4d9db17537 66 uint32_t Usart1ClockSelection; /*!< USART1 clock source
mbed_official 376:cb4d9db17537 67 This parameter can be a value of @ref RCCEx_USART1_Clock_Source */
mbed_official 376:cb4d9db17537 68
mbed_official 376:cb4d9db17537 69 uint32_t Usart2ClockSelection; /*!< USART2 clock source
mbed_official 376:cb4d9db17537 70 This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
mbed_official 376:cb4d9db17537 71
mbed_official 376:cb4d9db17537 72 uint32_t Lpuart1ClockSelection; /*!< LPUART1 clock source
mbed_official 376:cb4d9db17537 73 This parameter can be a value of @ref RCCEx_LPUART_Clock_Source */
mbed_official 376:cb4d9db17537 74
mbed_official 376:cb4d9db17537 75 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
mbed_official 376:cb4d9db17537 76 This parameter can be a value of @ref RCCEx_I2C1_Clock_Source */
mbed_official 376:cb4d9db17537 77
mbed_official 376:cb4d9db17537 78 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
mbed_official 376:cb4d9db17537 79 This parameter can be a value of @ref RCCEx_RTC_Clock_Source */
mbed_official 376:cb4d9db17537 80
mbed_official 376:cb4d9db17537 81 uint32_t UsbClockSelection; /*!< Specifies USB and RNG Clock Selection
mbed_official 376:cb4d9db17537 82 This parameter can be a value of @ref RCCEx_USB_Clock_Source */
mbed_official 376:cb4d9db17537 83
mbed_official 376:cb4d9db17537 84 uint32_t LptimClockSelection; /*!< LPTIM1 clock source
mbed_official 376:cb4d9db17537 85 This parameter can be a value of @ref RCCEx_LPTIM1_Clock_Source */
mbed_official 376:cb4d9db17537 86
mbed_official 376:cb4d9db17537 87 }RCC_PeriphCLKInitTypeDef;
mbed_official 376:cb4d9db17537 88 #endif /* !(STM32L051xx) && !(STM32L061xx) */
mbed_official 376:cb4d9db17537 89
mbed_official 376:cb4d9db17537 90 #if defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 91 typedef struct
mbed_official 376:cb4d9db17537 92 {
mbed_official 376:cb4d9db17537 93 uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
mbed_official 376:cb4d9db17537 94 This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
mbed_official 376:cb4d9db17537 95 uint32_t Usart1ClockSelection; /*!< USART1 clock source
mbed_official 376:cb4d9db17537 96 This parameter can be a value of @ref RCCEx_USART1_Clock_Source */
mbed_official 376:cb4d9db17537 97
mbed_official 376:cb4d9db17537 98 uint32_t Usart2ClockSelection; /*!< USART2 clock source
mbed_official 376:cb4d9db17537 99 This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
mbed_official 376:cb4d9db17537 100
mbed_official 376:cb4d9db17537 101 uint32_t Lpuart1ClockSelection; /*!< LPUART1 clock source
mbed_official 376:cb4d9db17537 102 This parameter can be a value of @ref RCCEx_LPUART1_Clock_Source */
mbed_official 376:cb4d9db17537 103
mbed_official 376:cb4d9db17537 104 uint32_t I2c1ClockSelection; /*!< I2C1 clock source
mbed_official 376:cb4d9db17537 105 This parameter can be a value of @ref RCCEx_I2C1_Clock_Source */
mbed_official 376:cb4d9db17537 106
mbed_official 376:cb4d9db17537 107 uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
mbed_official 376:cb4d9db17537 108 This parameter can be a value of @ref RCCEx_RTC_Clock_Source */
mbed_official 376:cb4d9db17537 109
mbed_official 376:cb4d9db17537 110 uint32_t LptimClockSelection; /*!< LPTIM1 clock source
mbed_official 376:cb4d9db17537 111 This parameter can be a value of @ref RCCEx_LPTIM1_Clock_Source */
mbed_official 376:cb4d9db17537 112
mbed_official 376:cb4d9db17537 113 }RCC_PeriphCLKInitTypeDef;
mbed_official 376:cb4d9db17537 114 #endif /* STM32L051xx || STM32L061xx */
mbed_official 376:cb4d9db17537 115
mbed_official 376:cb4d9db17537 116 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 117 /**
mbed_official 376:cb4d9db17537 118 * @brief RCC CRS Status structures definition
mbed_official 376:cb4d9db17537 119 */
mbed_official 376:cb4d9db17537 120 typedef enum
mbed_official 376:cb4d9db17537 121 {
mbed_official 376:cb4d9db17537 122 RCC_CRS_NONE = 0x00,
mbed_official 376:cb4d9db17537 123 RCC_CRS_TIMEOUT = 0x01,
mbed_official 376:cb4d9db17537 124 RCC_CRS_SYNCOK = 0x02,
mbed_official 376:cb4d9db17537 125 RCC_CRS_SYNCWARM = 0x04,
mbed_official 376:cb4d9db17537 126 RCC_CRS_SYNCERR = 0x08,
mbed_official 376:cb4d9db17537 127 RCC_CRS_SYNCMISS = 0x10,
mbed_official 376:cb4d9db17537 128 RCC_CRS_TRIMOV = 0x20
mbed_official 376:cb4d9db17537 129 } RCC_CRSStatusTypeDef;
mbed_official 376:cb4d9db17537 130
mbed_official 376:cb4d9db17537 131 /**
mbed_official 376:cb4d9db17537 132 * @brief RCC_CRS Init structure definition
mbed_official 376:cb4d9db17537 133 */
mbed_official 376:cb4d9db17537 134 typedef struct
mbed_official 376:cb4d9db17537 135 {
mbed_official 376:cb4d9db17537 136 uint32_t Prescaler; /*!< Specifies the division factor of the SYNC signal.
mbed_official 376:cb4d9db17537 137 This parameter can be a value of @ref RCCEx_CRS_SynchroDivider */
mbed_official 376:cb4d9db17537 138
mbed_official 376:cb4d9db17537 139 uint32_t Source; /*!< Specifies the SYNC signal source.
mbed_official 376:cb4d9db17537 140 This parameter can be a value of @ref RCCEx_CRS_SynchroSource */
mbed_official 376:cb4d9db17537 141
mbed_official 376:cb4d9db17537 142 uint32_t Polarity; /*!< Specifies the input polarity for the SYNC signal source.
mbed_official 376:cb4d9db17537 143 This parameter can be a value of @ref RCCEx_CRS_SynchroPolarity */
mbed_official 376:cb4d9db17537 144
mbed_official 376:cb4d9db17537 145 uint32_t ReloadValue; /*!< Specifies the value to be loaded in the frequency error counter with each SYNC event.
mbed_official 376:cb4d9db17537 146 It can be calculated in using macro __HAL_RCC_CRS_CALCULATE_RELOADVALUE(_FTARGET_, _FSYNC_)
mbed_official 376:cb4d9db17537 147 This parameter must be a number between 0 and 0xFFFF or a value of @ref RCCEx_CRS_ReloadValueDefault .*/
mbed_official 376:cb4d9db17537 148
mbed_official 376:cb4d9db17537 149 uint32_t ErrorLimitValue; /*!< Specifies the value to be used to evaluate the captured frequency error value.
mbed_official 376:cb4d9db17537 150 This parameter must be a number between 0 and 0xFF or a value of @ref RCCEx_CRS_ErrorLimitDefault */
mbed_official 376:cb4d9db17537 151
mbed_official 376:cb4d9db17537 152 uint32_t HSI48CalibrationValue; /*!< Specifies a user-programmable trimming value to the HSI48 oscillator.
mbed_official 376:cb4d9db17537 153 This parameter must be a number between 0 and 0x3F or a value of @ref RCCEx_CRS_HSI48CalibrationDefault */
mbed_official 376:cb4d9db17537 154
mbed_official 376:cb4d9db17537 155 }RCC_CRSInitTypeDef;
mbed_official 376:cb4d9db17537 156
mbed_official 376:cb4d9db17537 157 /**
mbed_official 376:cb4d9db17537 158 * @brief RCC_CRS Synchronization structure definition
mbed_official 376:cb4d9db17537 159 */
mbed_official 376:cb4d9db17537 160 typedef struct
mbed_official 376:cb4d9db17537 161 {
mbed_official 376:cb4d9db17537 162 uint32_t ReloadValue; /*!< Specifies the value loaded in the Counter reload value.
mbed_official 376:cb4d9db17537 163 This parameter must be a number between 0 and 0xFFFF*/
mbed_official 376:cb4d9db17537 164
mbed_official 376:cb4d9db17537 165 uint32_t HSI48CalibrationValue; /*!< Specifies value loaded in HSI48 oscillator smooth trimming.
mbed_official 376:cb4d9db17537 166 This parameter must be a number between 0 and 0x3F */
mbed_official 376:cb4d9db17537 167
mbed_official 376:cb4d9db17537 168 uint32_t FreqErrorCapture; /*!< Specifies the value loaded in the .FECAP, the frequency error counter
mbed_official 376:cb4d9db17537 169 value latched in the time of the last SYNC event.
mbed_official 376:cb4d9db17537 170 This parameter must be a number between 0 and 0xFFFF */
mbed_official 376:cb4d9db17537 171
mbed_official 376:cb4d9db17537 172 uint32_t FreqErrorDirection; /*!< Specifies the value loaded in the .FEDIR, the counting direction of the
mbed_official 376:cb4d9db17537 173 frequency error counter latched in the time of the last SYNC event.
mbed_official 376:cb4d9db17537 174 It shows whether the actual frequency is below or above the target.
mbed_official 376:cb4d9db17537 175 This parameter must be a value of @ref RCCEx_CRS_FreqErrorDirection*/
mbed_official 376:cb4d9db17537 176
mbed_official 376:cb4d9db17537 177 }RCC_CRSSynchroInfoTypeDef;
mbed_official 376:cb4d9db17537 178 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 179
mbed_official 376:cb4d9db17537 180 /* Exported constants --------------------------------------------------------*/
mbed_official 376:cb4d9db17537 181 /** @defgroup RCCEx_Exported_Constants
mbed_official 376:cb4d9db17537 182 * @{
mbed_official 376:cb4d9db17537 183 */
mbed_official 376:cb4d9db17537 184
mbed_official 376:cb4d9db17537 185 /** @defgroup RCCEx_Periph_Clock_Selection
mbed_official 376:cb4d9db17537 186 * @{
mbed_official 376:cb4d9db17537 187 */
mbed_official 376:cb4d9db17537 188 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 189 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
mbed_official 376:cb4d9db17537 190 #define RCC_PERIPHCLK_USART2 ((uint32_t)0x00000002)
mbed_official 376:cb4d9db17537 191 #define RCC_PERIPHCLK_LPUART1 ((uint32_t)0x00000004)
mbed_official 376:cb4d9db17537 192 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000008)
mbed_official 376:cb4d9db17537 193 #define RCC_PERIPHCLK_I2C2 ((uint32_t)0x00000010)
mbed_official 376:cb4d9db17537 194 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00000020)
mbed_official 376:cb4d9db17537 195 #define RCC_PERIPHCLK_USB ((uint32_t)0x00000040)
mbed_official 376:cb4d9db17537 196 #define RCC_PERIPHCLK_LPTIM1 ((uint32_t)0x00000080)
mbed_official 376:cb4d9db17537 197
mbed_official 376:cb4d9db17537 198
mbed_official 376:cb4d9db17537 199 #define IS_RCC_PERIPHCLK(CLK) ((CLK) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_LPUART1 | \
mbed_official 376:cb4d9db17537 200 RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_RTC | \
mbed_official 376:cb4d9db17537 201 RCC_PERIPHCLK_USB | RCC_PERIPHCLK_LPTIM1))
mbed_official 376:cb4d9db17537 202 #endif /* !(STM32L051xx) && !(STM32L061xx) */
mbed_official 376:cb4d9db17537 203
mbed_official 376:cb4d9db17537 204 #if defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 205 #define RCC_PERIPHCLK_USART1 ((uint32_t)0x00000001)
mbed_official 376:cb4d9db17537 206 #define RCC_PERIPHCLK_USART2 ((uint32_t)0x00000002)
mbed_official 376:cb4d9db17537 207 #define RCC_PERIPHCLK_LPUART1 ((uint32_t)0x00000004)
mbed_official 376:cb4d9db17537 208 #define RCC_PERIPHCLK_I2C1 ((uint32_t)0x00000008)
mbed_official 376:cb4d9db17537 209 #define RCC_PERIPHCLK_I2C2 ((uint32_t)0x00000010)
mbed_official 376:cb4d9db17537 210 #define RCC_PERIPHCLK_RTC ((uint32_t)0x00000020)
mbed_official 376:cb4d9db17537 211 #define RCC_PERIPHCLK_LPTIM1 ((uint32_t)0x00000080)
mbed_official 376:cb4d9db17537 212
mbed_official 376:cb4d9db17537 213
mbed_official 376:cb4d9db17537 214 #define IS_RCC_PERIPHCLK(CLK) ((CLK) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_LPUART1 | \
mbed_official 376:cb4d9db17537 215 RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_RTC | \
mbed_official 376:cb4d9db17537 216 RCC_PERIPHCLK_LPTIM1))
mbed_official 376:cb4d9db17537 217 #endif /* !(STM32L051xx) && !(STM32L061xx) */
mbed_official 376:cb4d9db17537 218 /**
mbed_official 376:cb4d9db17537 219 * @}
mbed_official 376:cb4d9db17537 220 */
mbed_official 376:cb4d9db17537 221
mbed_official 376:cb4d9db17537 222 /** @defgroup RCCEx_USART1_Clock_Source
mbed_official 376:cb4d9db17537 223 * @{
mbed_official 376:cb4d9db17537 224 */
mbed_official 376:cb4d9db17537 225 #define RCC_USART1CLKSOURCE_PCLK2 ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 226 #define RCC_USART1CLKSOURCE_SYSCLK RCC_CCIPR_USART1SEL_0
mbed_official 376:cb4d9db17537 227 #define RCC_USART1CLKSOURCE_HSI RCC_CCIPR_USART1SEL_1
mbed_official 376:cb4d9db17537 228 #define RCC_USART1CLKSOURCE_LSE (RCC_CCIPR_USART1SEL_0 | RCC_CCIPR_USART1SEL_1)
mbed_official 376:cb4d9db17537 229 #define IS_RCC_USART1CLKSOURCE(SOURCE) (((SOURCE) == RCC_USART1CLKSOURCE_PCLK2) || \
mbed_official 376:cb4d9db17537 230 ((SOURCE) == RCC_USART1CLKSOURCE_SYSCLK) || \
mbed_official 376:cb4d9db17537 231 ((SOURCE) == RCC_USART1CLKSOURCE_LSE) || \
mbed_official 376:cb4d9db17537 232 ((SOURCE) == RCC_USART1CLKSOURCE_HSI))
mbed_official 376:cb4d9db17537 233 /**
mbed_official 376:cb4d9db17537 234 * @}
mbed_official 376:cb4d9db17537 235 */
mbed_official 376:cb4d9db17537 236
mbed_official 376:cb4d9db17537 237 /** @defgroup RCCEx_USART2_Clock_Source
mbed_official 376:cb4d9db17537 238 * @{
mbed_official 376:cb4d9db17537 239 */
mbed_official 376:cb4d9db17537 240 #define RCC_USART2CLKSOURCE_PCLK1 ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 241 #define RCC_USART2CLKSOURCE_SYSCLK RCC_CCIPR_USART2SEL_0
mbed_official 376:cb4d9db17537 242 #define RCC_USART2CLKSOURCE_HSI RCC_CCIPR_USART2SEL_1
mbed_official 376:cb4d9db17537 243 #define RCC_USART2CLKSOURCE_LSE (RCC_CCIPR_USART2SEL_0 | RCC_CCIPR_USART2SEL_1)
mbed_official 376:cb4d9db17537 244 #define IS_RCC_USART2CLKSOURCE(SOURCE) (((SOURCE) == RCC_USART2CLKSOURCE_PCLK1) || \
mbed_official 376:cb4d9db17537 245 ((SOURCE) == RCC_USART2CLKSOURCE_SYSCLK) || \
mbed_official 376:cb4d9db17537 246 ((SOURCE) == RCC_USART2CLKSOURCE_LSE) || \
mbed_official 376:cb4d9db17537 247 ((SOURCE) == RCC_USART2CLKSOURCE_HSI))
mbed_official 376:cb4d9db17537 248 /**
mbed_official 376:cb4d9db17537 249 * @}
mbed_official 376:cb4d9db17537 250 */
mbed_official 376:cb4d9db17537 251
mbed_official 376:cb4d9db17537 252 /** @defgroup RCCEx_LPUART_Clock_Source
mbed_official 376:cb4d9db17537 253 * @{
mbed_official 376:cb4d9db17537 254 */
mbed_official 376:cb4d9db17537 255 #define RCC_LPUART1CLKSOURCE_PCLK1 ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 256 #define RCC_LPUART1CLKSOURCE_SYSCLK RCC_CCIPR_LPUART1SEL_0
mbed_official 376:cb4d9db17537 257 #define RCC_LPUART1CLKSOURCE_HSI RCC_CCIPR_LPUART1SEL_1
mbed_official 376:cb4d9db17537 258 #define RCC_LPUART1CLKSOURCE_LSE (RCC_CCIPR_LPUART1SEL_0 | RCC_CCIPR_LPUART1SEL_1)
mbed_official 376:cb4d9db17537 259 #define IS_RCC_LPUART1CLKSOURCE(SOURCE) (((SOURCE) == RCC_LPUART1CLKSOURCE_PCLK1) || \
mbed_official 376:cb4d9db17537 260 ((SOURCE) == RCC_LPUART1CLKSOURCE_SYSCLK) || \
mbed_official 376:cb4d9db17537 261 ((SOURCE) == RCC_LPUART1CLKSOURCE_LSE) || \
mbed_official 376:cb4d9db17537 262 ((SOURCE) == RCC_LPUART1CLKSOURCE_HSI))
mbed_official 376:cb4d9db17537 263 /**
mbed_official 376:cb4d9db17537 264 * @}
mbed_official 376:cb4d9db17537 265 */
mbed_official 376:cb4d9db17537 266
mbed_official 376:cb4d9db17537 267 /** @defgroup RCCEx_I2C1_Clock_Source
mbed_official 376:cb4d9db17537 268 * @{
mbed_official 376:cb4d9db17537 269 */
mbed_official 376:cb4d9db17537 270 #define RCC_I2C1CLKSOURCE_PCLK1 ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 271 #define RCC_I2C1CLKSOURCE_SYSCLK RCC_CCIPR_I2C1SEL_0
mbed_official 376:cb4d9db17537 272 #define RCC_I2C1CLKSOURCE_HSI RCC_CCIPR_I2C1SEL_1
mbed_official 376:cb4d9db17537 273 #define IS_RCC_I2C1CLKSOURCE(SOURCE) (((SOURCE) == RCC_I2C1CLKSOURCE_PCLK1) || \
mbed_official 376:cb4d9db17537 274 ((SOURCE) == RCC_I2C1CLKSOURCE_SYSCLK)|| \
mbed_official 376:cb4d9db17537 275 ((SOURCE) == RCC_I2C1CLKSOURCE_HSI))
mbed_official 376:cb4d9db17537 276 /**
mbed_official 376:cb4d9db17537 277 * @}
mbed_official 376:cb4d9db17537 278 */
mbed_official 376:cb4d9db17537 279
mbed_official 376:cb4d9db17537 280 /** @defgroup RCCEx_TIM_PRescaler_Selection
mbed_official 376:cb4d9db17537 281 * @{
mbed_official 376:cb4d9db17537 282 */
mbed_official 376:cb4d9db17537 283 #define RCC_TIMPRES_DESACTIVATED ((uint8_t)0x00)
mbed_official 376:cb4d9db17537 284 #define RCC_TIMPRES_ACTIVATED ((uint8_t)0x01)
mbed_official 376:cb4d9db17537 285 /**
mbed_official 376:cb4d9db17537 286 * @}
mbed_official 376:cb4d9db17537 287 */
mbed_official 376:cb4d9db17537 288
mbed_official 376:cb4d9db17537 289 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 290 /** @defgroup RCCEx_USB_Clock_Source
mbed_official 376:cb4d9db17537 291 * @{
mbed_official 376:cb4d9db17537 292 */
mbed_official 376:cb4d9db17537 293 #define RCC_USBCLKSOURCE_HSI48 RCC_CCIPR_HSI48SEL
mbed_official 376:cb4d9db17537 294 #define RCC_USBCLKSOURCE_PLLCLK ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 295
mbed_official 376:cb4d9db17537 296 #define IS_RCC_USBCLKSOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSOURCE_HSI48) || \
mbed_official 376:cb4d9db17537 297 ((SOURCE) == RCC_USBCLKSOURCE_PLLCLK))
mbed_official 376:cb4d9db17537 298 /**
mbed_official 376:cb4d9db17537 299 * @}
mbed_official 376:cb4d9db17537 300 */
mbed_official 376:cb4d9db17537 301
mbed_official 376:cb4d9db17537 302 /** @defgroup RCCEx_RNG_Clock_Source
mbed_official 376:cb4d9db17537 303 * @{
mbed_official 376:cb4d9db17537 304 */
mbed_official 376:cb4d9db17537 305 #define RCC_RNGCLKSOURCE_HSI48 RCC_CCIPR_HSI48SEL
mbed_official 376:cb4d9db17537 306 #define RCC_RNGCLKSOURCE_PLLCLK ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 307
mbed_official 376:cb4d9db17537 308 #define IS_RCC_RNGCLKSOURCE(SOURCE) (((SOURCE) == RCC_RNGCLKSOURCE_HSI48) || \
mbed_official 376:cb4d9db17537 309 ((SOURCE) == RCC_RNGCLKSOURCE_PLLCLK))
mbed_official 376:cb4d9db17537 310 /**
mbed_official 376:cb4d9db17537 311 * @}
mbed_official 376:cb4d9db17537 312 */
mbed_official 376:cb4d9db17537 313
mbed_official 376:cb4d9db17537 314 /** @defgroup RCCEx_HSI48M_Clock_Source
mbed_official 376:cb4d9db17537 315 * @{
mbed_official 376:cb4d9db17537 316 */
mbed_official 376:cb4d9db17537 317
mbed_official 376:cb4d9db17537 318 #define RCC_HSI48M_PLL ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 319 #define RCC_HSI48M_RC48 RCC_CCIPR_HSI48SEL
mbed_official 376:cb4d9db17537 320
mbed_official 376:cb4d9db17537 321 #define IS_RCC_HSI48MCLKSOURCE(HSI48MCLK) (((HSI48MCLK) == RCC_HSI48M_PLL) || ((HSI48MCLK) == RCC_HSI48M_RC48))
mbed_official 376:cb4d9db17537 322
mbed_official 376:cb4d9db17537 323 /**
mbed_official 376:cb4d9db17537 324 * @}
mbed_official 376:cb4d9db17537 325 */
mbed_official 376:cb4d9db17537 326 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 327
mbed_official 376:cb4d9db17537 328 /** @defgroup RCCEx_LPTIM1_Clock_Source
mbed_official 376:cb4d9db17537 329 * @{
mbed_official 376:cb4d9db17537 330 */
mbed_official 376:cb4d9db17537 331 #define RCC_LPTIM1CLKSOURCE_PCLK ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 332 #define RCC_LPTIM1CLKSOURCE_LSI RCC_CCIPR_LPTIM1SEL_0
mbed_official 376:cb4d9db17537 333 #define RCC_LPTIM1CLKSOURCE_HSI RCC_CCIPR_LPTIM1SEL_1
mbed_official 376:cb4d9db17537 334 #define RCC_LPTIM1CLKSOURCE_LSE RCC_CCIPR_LPTIM1SEL
mbed_official 376:cb4d9db17537 335
mbed_official 376:cb4d9db17537 336 #define IS_RCC_LPTIMCLK(LPTIMCLK) (((LPTIMCLK) == RCC_LPTIM1CLKSOURCE_PCLK) || \
mbed_official 376:cb4d9db17537 337 ((LPTIMCLK) == RCC_LPTIM1CLKSOURCE_LSI) || \
mbed_official 376:cb4d9db17537 338 ((LPTIMCLK) == RCC_LPTIM1CLKSOURCE_HSI) || \
mbed_official 376:cb4d9db17537 339 ((LPTIMCLK) == RCC_LPTIM1CLKSOURCE_LSE))
mbed_official 376:cb4d9db17537 340 /**
mbed_official 376:cb4d9db17537 341 * @}
mbed_official 376:cb4d9db17537 342 */
mbed_official 376:cb4d9db17537 343
mbed_official 376:cb4d9db17537 344 /** @defgroup RCCEx_StopWakeUp_Clock
mbed_official 376:cb4d9db17537 345 * @{
mbed_official 376:cb4d9db17537 346 */
mbed_official 376:cb4d9db17537 347
mbed_official 376:cb4d9db17537 348 #define RCC_StopWakeUpClock_MSI ((uint32_t)0x00)
mbed_official 376:cb4d9db17537 349 #define RCC_StopWakeUpClock_HSI RCC_CFGR_STOPWUCK
mbed_official 376:cb4d9db17537 350
mbed_official 376:cb4d9db17537 351 #define IS_RCC_STOPWAKEUP_CLOCK(SOURCE) (((SOURCE) == RCC_StopWakeUpClock_MSI) || \
mbed_official 376:cb4d9db17537 352 ((SOURCE) == RCC_StopWakeUpClock_HSI))
mbed_official 376:cb4d9db17537 353 /**
mbed_official 376:cb4d9db17537 354 * @}
mbed_official 376:cb4d9db17537 355 */
mbed_official 376:cb4d9db17537 356
mbed_official 376:cb4d9db17537 357 /** @defgroup RCCEx_LSEDrive_Configuration
mbed_official 376:cb4d9db17537 358 * @{
mbed_official 376:cb4d9db17537 359 */
mbed_official 376:cb4d9db17537 360
mbed_official 376:cb4d9db17537 361 #define RCC_LSEDRIVE_LOW ((uint32_t)0x00000000)
mbed_official 376:cb4d9db17537 362 #define RCC_LSEDRIVE_MEDIUMLOW RCC_CSR_LSEDRV_0
mbed_official 376:cb4d9db17537 363 #define RCC_LSEDRIVE_MEDIUMHIGH RCC_CSR_LSEDRV_1
mbed_official 376:cb4d9db17537 364 #define RCC_LSEDRIVE_HIGH RCC_CSR_LSEDRV
mbed_official 376:cb4d9db17537 365 #define IS_RCC_LSE_DRIVE(DRIVE) (((DRIVE) == RCC_LSEDRIVE_LOW) || ((DRIVE) == RCC_LSEDRIVE_MEDIUMLOW) || \
mbed_official 376:cb4d9db17537 366 ((DRIVE) == RCC_LSEDRIVE_MEDIUMHIGH) || ((DRIVE) == RCC_LSEDRIVE_HIGH))
mbed_official 376:cb4d9db17537 367 /**
mbed_official 376:cb4d9db17537 368 * @}
mbed_official 376:cb4d9db17537 369 */
mbed_official 376:cb4d9db17537 370
mbed_official 376:cb4d9db17537 371 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 372 /** @defgroup RCCEx_CRS_SynchroSource
mbed_official 376:cb4d9db17537 373 * @{
mbed_official 376:cb4d9db17537 374 */
mbed_official 376:cb4d9db17537 375 #define RCC_CRS_SYNC_SOURCE_GPIO ((uint32_t)0x00) /*!< Synchro Signal source GPIO */
mbed_official 376:cb4d9db17537 376 #define RCC_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */
mbed_official 376:cb4d9db17537 377 #define RCC_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/
mbed_official 376:cb4d9db17537 378
mbed_official 376:cb4d9db17537 379 #define IS_RCC_CRS_SYNC_SOURCE(_SOURCE_) (((_SOURCE_) == RCC_CRS_SYNC_SOURCE_GPIO) || \
mbed_official 376:cb4d9db17537 380 ((_SOURCE_) == RCC_CRS_SYNC_SOURCE_LSE) ||\
mbed_official 376:cb4d9db17537 381 ((_SOURCE_) == RCC_CRS_SYNC_SOURCE_USB))
mbed_official 376:cb4d9db17537 382 /**
mbed_official 376:cb4d9db17537 383 * @}
mbed_official 376:cb4d9db17537 384 */
mbed_official 376:cb4d9db17537 385
mbed_official 376:cb4d9db17537 386 /** @defgroup RCCEx_CRS_SynchroDivider
mbed_official 376:cb4d9db17537 387 * @{
mbed_official 376:cb4d9db17537 388 */
mbed_official 376:cb4d9db17537 389 #define RCC_CRS_SYNC_DIV1 ((uint32_t)0x00) /*!< Synchro Signal not divided (default) */
mbed_official 376:cb4d9db17537 390 #define RCC_CRS_SYNC_DIV2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */
mbed_official 376:cb4d9db17537 391 #define RCC_CRS_SYNC_DIV4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */
mbed_official 376:cb4d9db17537 392 #define RCC_CRS_SYNC_DIV8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
mbed_official 376:cb4d9db17537 393 #define RCC_CRS_SYNC_DIV16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */
mbed_official 376:cb4d9db17537 394 #define RCC_CRS_SYNC_DIV32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
mbed_official 376:cb4d9db17537 395 #define RCC_CRS_SYNC_DIV64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
mbed_official 376:cb4d9db17537 396 #define RCC_CRS_SYNC_DIV128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */
mbed_official 376:cb4d9db17537 397
mbed_official 376:cb4d9db17537 398 #define IS_RCC_CRS_SYNC_DIV(_DIV_) (((_DIV_) == RCC_CRS_SYNC_DIV1) || ((_DIV_) == RCC_CRS_SYNC_DIV2) ||\
mbed_official 376:cb4d9db17537 399 ((_DIV_) == RCC_CRS_SYNC_DIV4) || ((_DIV_) == RCC_CRS_SYNC_DIV8) || \
mbed_official 376:cb4d9db17537 400 ((_DIV_) == RCC_CRS_SYNC_DIV16) || ((_DIV_) == RCC_CRS_SYNC_DIV32) || \
mbed_official 376:cb4d9db17537 401 ((_DIV_) == RCC_CRS_SYNC_DIV64) || ((_DIV_) == RCC_CRS_SYNC_DIV128))
mbed_official 376:cb4d9db17537 402 /**
mbed_official 376:cb4d9db17537 403 * @}
mbed_official 376:cb4d9db17537 404 */
mbed_official 376:cb4d9db17537 405
mbed_official 376:cb4d9db17537 406 /** @defgroup RCCEx_CRS_SynchroPolarity
mbed_official 376:cb4d9db17537 407 * @{
mbed_official 376:cb4d9db17537 408 */
mbed_official 376:cb4d9db17537 409 #define RCC_CRS_SYNC_POLARITY_RISING ((uint32_t)0x00) /*!< Synchro Active on rising edge (default) */
mbed_official 376:cb4d9db17537 410 #define RCC_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */
mbed_official 376:cb4d9db17537 411
mbed_official 376:cb4d9db17537 412 #define IS_RCC_CRS_SYNC_POLARITY(_POLARITY_) (((_POLARITY_) == RCC_CRS_SYNC_POLARITY_RISING) || \
mbed_official 376:cb4d9db17537 413 ((_POLARITY_) == RCC_CRS_SYNC_POLARITY_FALLING))
mbed_official 376:cb4d9db17537 414 /**
mbed_official 376:cb4d9db17537 415 * @}
mbed_official 376:cb4d9db17537 416 */
mbed_official 376:cb4d9db17537 417
mbed_official 376:cb4d9db17537 418 /** @defgroup RCCEx_CRS_ReloadValueDefault
mbed_official 376:cb4d9db17537 419 * @{
mbed_official 376:cb4d9db17537 420 */
mbed_official 376:cb4d9db17537 421 #define RCC_CRS_RELOADVALUE_DEFAULT ((uint32_t)0xBB7F) /*!< The reset value of the RELOAD field corresponds
mbed_official 376:cb4d9db17537 422 to a target frequency of 48 MHz and a synchronization signal frequency of 1 kHz (SOF signal from USB). */
mbed_official 376:cb4d9db17537 423
mbed_official 376:cb4d9db17537 424 #define IS_RCC_CRS_RELOADVALUE(_VALUE_) (((_VALUE_) <= 0xFFFF))
mbed_official 376:cb4d9db17537 425 /**
mbed_official 376:cb4d9db17537 426 * @}
mbed_official 376:cb4d9db17537 427 */
mbed_official 376:cb4d9db17537 428
mbed_official 376:cb4d9db17537 429 /** @defgroup RCCEx_CRS_ErrorLimitDefault
mbed_official 376:cb4d9db17537 430 * @{
mbed_official 376:cb4d9db17537 431 */
mbed_official 376:cb4d9db17537 432 #define RCC_CRS_ERRORLIMIT_DEFAULT ((uint32_t)0x22) /*!< Default Frequency error limit */
mbed_official 376:cb4d9db17537 433
mbed_official 376:cb4d9db17537 434 #define IS_RCC_CRS_ERRORLIMIT(_VALUE_) (((_VALUE_) <= 0xFF))
mbed_official 376:cb4d9db17537 435 /**
mbed_official 376:cb4d9db17537 436 * @}
mbed_official 376:cb4d9db17537 437 */
mbed_official 376:cb4d9db17537 438
mbed_official 376:cb4d9db17537 439 /** @defgroup RCCEx_CRS_HSI48CalibrationDefault
mbed_official 376:cb4d9db17537 440 * @{
mbed_official 376:cb4d9db17537 441 */
mbed_official 376:cb4d9db17537 442 #define RCC_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)0x20) /*!< The default value is 32, which corresponds to the middle of the trimming interval.
mbed_official 376:cb4d9db17537 443 The trimming step is around 67 kHz between two consecutive TRIM steps. A higher TRIM value
mbed_official 376:cb4d9db17537 444 corresponds to a higher output frequency */
mbed_official 376:cb4d9db17537 445
mbed_official 376:cb4d9db17537 446 #define IS_RCC_CRS_HSI48CALIBRATION(_VALUE_) (((_VALUE_) <= 0x3F))
mbed_official 376:cb4d9db17537 447 /**
mbed_official 376:cb4d9db17537 448 * @}
mbed_official 376:cb4d9db17537 449 */
mbed_official 376:cb4d9db17537 450
mbed_official 376:cb4d9db17537 451 /** @defgroup RCCEx_CRS_FreqErrorDirection
mbed_official 376:cb4d9db17537 452 * @{
mbed_official 376:cb4d9db17537 453 */
mbed_official 376:cb4d9db17537 454 #define RCC_CRS_FREQERRORDIR_UP ((uint32_t)0x00) /*!< Upcounting direction, the actual frequency is above the target */
mbed_official 376:cb4d9db17537 455 #define RCC_CRS_FREQERRORDIR_DOWN ((uint32_t)CRS_ISR_FEDIR) /*!< Downcounting direction, the actual frequency is below the target */
mbed_official 376:cb4d9db17537 456
mbed_official 376:cb4d9db17537 457 #define IS_RCC_CRS_FREQERRORDIR(_DIR_) (((_DIR_) == RCC_CRS_FREQERRORDIR_UP) || \
mbed_official 376:cb4d9db17537 458 ((_DIR_) == RCC_CRS_FREQERRORDIR_DOWN))
mbed_official 376:cb4d9db17537 459 /**
mbed_official 376:cb4d9db17537 460 * @}
mbed_official 376:cb4d9db17537 461 */
mbed_official 376:cb4d9db17537 462
mbed_official 376:cb4d9db17537 463 /** @defgroup RCCEx_CRS_Interrupt_Sources
mbed_official 376:cb4d9db17537 464 * @{
mbed_official 376:cb4d9db17537 465 */
mbed_official 376:cb4d9db17537 466 #define RCC_CRS_IT_SYNCOK CRS_ISR_SYNCOKF /*!< SYNC event OK */
mbed_official 376:cb4d9db17537 467 #define RCC_CRS_IT_SYNCWARN CRS_ISR_SYNCWARNF /*!< SYNC warning */
mbed_official 376:cb4d9db17537 468 #define RCC_CRS_IT_ERR CRS_ISR_ERRF /*!< error */
mbed_official 376:cb4d9db17537 469 #define RCC_CRS_IT_ESYNC CRS_ISR_ESYNCF /*!< Expected SYNC */
mbed_official 376:cb4d9db17537 470 #define RCC_CRS_IT_TRIMOVF CRS_ISR_TRIMOVF /*!< Trimming overflow or underflow */
mbed_official 376:cb4d9db17537 471 #define RCC_CRS_IT_SYNCERR CRS_ISR_SYNCERR /*!< SYNC error */
mbed_official 376:cb4d9db17537 472 #define RCC_CRS_IT_SYNCMISS CRS_ISR_SYNCMISS /*!< SYNC missed*/
mbed_official 376:cb4d9db17537 473
mbed_official 376:cb4d9db17537 474 /**
mbed_official 376:cb4d9db17537 475 * @}
mbed_official 376:cb4d9db17537 476 */
mbed_official 376:cb4d9db17537 477
mbed_official 376:cb4d9db17537 478 /** @defgroup RCCEx_CRS_Flags
mbed_official 376:cb4d9db17537 479 * @{
mbed_official 376:cb4d9db17537 480 */
mbed_official 376:cb4d9db17537 481 #define RCC_CRS_FLAG_SYNCOK CRS_ISR_SYNCOKF /* SYNC event OK flag */
mbed_official 376:cb4d9db17537 482 #define RCC_CRS_FLAG_SYNCWARN CRS_ISR_SYNCWARNF /* SYNC warning flag */
mbed_official 376:cb4d9db17537 483 #define RCC_CRS_FLAG_ERR CRS_ISR_ERRF /* Error flag */
mbed_official 376:cb4d9db17537 484 #define RCC_CRS_FLAG_ESYNC CRS_ISR_ESYNCF /* Expected SYNC flag */
mbed_official 376:cb4d9db17537 485 #define RCC_CRS_FLAG_TRIMOVF CRS_ISR_TRIMOVF /*!< Trimming overflow or underflow */
mbed_official 376:cb4d9db17537 486 #define RCC_CRS_FLAG_SYNCERR CRS_ISR_SYNCERR /*!< SYNC error */
mbed_official 376:cb4d9db17537 487 #define RCC_CRS_FLAG_SYNCMISS CRS_ISR_SYNCMISS /*!< SYNC missed*/
mbed_official 376:cb4d9db17537 488
mbed_official 376:cb4d9db17537 489 /**
mbed_official 376:cb4d9db17537 490 * @}
mbed_official 376:cb4d9db17537 491 */
mbed_official 376:cb4d9db17537 492
mbed_official 376:cb4d9db17537 493 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 494 /**
mbed_official 376:cb4d9db17537 495 * @}
mbed_official 376:cb4d9db17537 496 */
mbed_official 376:cb4d9db17537 497
mbed_official 376:cb4d9db17537 498 /* Exported macro ------------------------------------------------------------*/
mbed_official 376:cb4d9db17537 499 /** @defgroup RCCEx_Exported_Macros
mbed_official 376:cb4d9db17537 500 * @{
mbed_official 376:cb4d9db17537 501 */
mbed_official 376:cb4d9db17537 502
mbed_official 376:cb4d9db17537 503 /** @brief Enable or disable the AHB peripheral clock.
mbed_official 376:cb4d9db17537 504 * @note After reset, the peripheral clock (used for registers read/write access)
mbed_official 376:cb4d9db17537 505 * is disabled and the application software has to enable this clock before
mbed_official 376:cb4d9db17537 506 * using it.
mbed_official 376:cb4d9db17537 507 */
mbed_official 376:cb4d9db17537 508
mbed_official 376:cb4d9db17537 509 #if defined(STM32L062xx) || defined(STM32L063xx)
mbed_official 376:cb4d9db17537 510 #define __CRYP_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_CRYPEN))
mbed_official 376:cb4d9db17537 511 #define __CRYP_CLK_DISABLE() (RCC->AHBENR &= ~ (RCC_AHBENR_CRYPEN))
mbed_official 376:cb4d9db17537 512 #endif /* STM32L062xx || STM32L063xx */
mbed_official 376:cb4d9db17537 513
mbed_official 376:cb4d9db17537 514 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 515 #define __TSC_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_TSCEN))
mbed_official 376:cb4d9db17537 516 #define __TSC_CLK_DISABLE() (RCC->AHBENR &= ~ (RCC_AHBENR_TSCEN))
mbed_official 376:cb4d9db17537 517
mbed_official 376:cb4d9db17537 518 #define __RNG_CLK_ENABLE() (RCC->AHBENR |= (RCC_AHBENR_RNGEN))
mbed_official 376:cb4d9db17537 519 #define __RNG_CLK_DISABLE() (RCC->AHBENR &= ~ (RCC_AHBENR_RNGEN))
mbed_official 376:cb4d9db17537 520 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 521
mbed_official 376:cb4d9db17537 522 /** @brief Enable or disable the APB1 peripheral clock.
mbed_official 376:cb4d9db17537 523 * @note After reset, the peripheral clock (used for registers read/write access)
mbed_official 376:cb4d9db17537 524 * is disabled and the application software has to enable this clock before
mbed_official 376:cb4d9db17537 525 * using it.
mbed_official 376:cb4d9db17537 526 */
mbed_official 376:cb4d9db17537 527
mbed_official 376:cb4d9db17537 528 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 529 #define __USB_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_USBEN))
mbed_official 376:cb4d9db17537 530 #define __USB_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_USBEN))
mbed_official 376:cb4d9db17537 531 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 532
mbed_official 376:cb4d9db17537 533 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 534 #define __CRS_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_CRSEN))
mbed_official 376:cb4d9db17537 535 #define __CRS_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CRSEN))
mbed_official 376:cb4d9db17537 536 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 537
mbed_official 376:cb4d9db17537 538
mbed_official 376:cb4d9db17537 539 #if defined(STM32L053xx) || defined(STM32L063xx)
mbed_official 376:cb4d9db17537 540 #define __LCD_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_LCDEN))
mbed_official 376:cb4d9db17537 541 #define __LCD_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_LCDEN))
mbed_official 376:cb4d9db17537 542 #endif /* STM32L053xx || STM32L063xx */
mbed_official 376:cb4d9db17537 543
mbed_official 376:cb4d9db17537 544 #if defined(STM32L053xx) || defined(STM32L063xx) || \
mbed_official 376:cb4d9db17537 545 defined(STM32L052xx) || defined(STM32L062xx) || \
mbed_official 376:cb4d9db17537 546 defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 547 #define __TIM2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_TIM2EN))
mbed_official 376:cb4d9db17537 548 #define __TIM6_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_TIM6EN))
mbed_official 376:cb4d9db17537 549 #define __SPI2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_SPI2EN))
mbed_official 376:cb4d9db17537 550 #define __USART2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_USART2EN))
mbed_official 376:cb4d9db17537 551 #define __LPUART1_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_LPUART1EN))
mbed_official 376:cb4d9db17537 552 #define __I2C1_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_I2C1EN))
mbed_official 376:cb4d9db17537 553 #define __I2C2_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_I2C2EN))
mbed_official 376:cb4d9db17537 554 #define __DAC_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_DACEN))
mbed_official 376:cb4d9db17537 555 #define __LPTIM1_CLK_ENABLE() (RCC->APB1ENR |= (RCC_APB1ENR_LPTIM1EN))
mbed_official 376:cb4d9db17537 556
mbed_official 376:cb4d9db17537 557 #define __TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_TIM2EN))
mbed_official 376:cb4d9db17537 558 #define __TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_TIM6EN))
mbed_official 376:cb4d9db17537 559 #define __SPI2_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_SPI2EN))
mbed_official 376:cb4d9db17537 560 #define __USART2_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_USART2EN))
mbed_official 376:cb4d9db17537 561 #define __LPUART1_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_LPUART1EN))
mbed_official 376:cb4d9db17537 562 #define __I2C1_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_I2C1EN))
mbed_official 376:cb4d9db17537 563 #define __I2C2_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_I2C2EN))
mbed_official 376:cb4d9db17537 564 #define __DAC_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_DACEN))
mbed_official 376:cb4d9db17537 565 #define __LPTIM1_CLK_DISABLE() (RCC->APB1ENR &= ~ (RCC_APB1ENR_LPTIM1EN))
mbed_official 376:cb4d9db17537 566 #endif /* STM32L051xx || STM32L061xx || */
mbed_official 376:cb4d9db17537 567 /* STM32L052xx || STM32L062xx || */
mbed_official 376:cb4d9db17537 568 /* STM32L053xx || STM32L063xx || */
mbed_official 376:cb4d9db17537 569
mbed_official 376:cb4d9db17537 570 /** @brief Enable or disable the APB2 peripheral clock.
mbed_official 376:cb4d9db17537 571 * @note After reset, the peripheral clock (used for registers read/write access)
mbed_official 376:cb4d9db17537 572 * is disabled and the application software has to enable this clock before
mbed_official 376:cb4d9db17537 573 * using it.
mbed_official 376:cb4d9db17537 574 */
mbed_official 376:cb4d9db17537 575
mbed_official 376:cb4d9db17537 576 #if defined(STM32L053xx) || defined(STM32L063xx) || \
mbed_official 376:cb4d9db17537 577 defined(STM32L052xx) || defined(STM32L062xx) || \
mbed_official 376:cb4d9db17537 578 defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 579 #define __TIM21_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_TIM21EN))
mbed_official 376:cb4d9db17537 580 #define __TIM22_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_TIM22EN))
mbed_official 376:cb4d9db17537 581 #define __FIREWALL_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_MIFIEN))
mbed_official 376:cb4d9db17537 582 #define __ADC1_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_ADC1EN))
mbed_official 376:cb4d9db17537 583 #define __SPI1_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_SPI1EN))
mbed_official 376:cb4d9db17537 584 #define __USART1_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_USART1EN))
mbed_official 376:cb4d9db17537 585
mbed_official 376:cb4d9db17537 586 #define __TIM21_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_TIM21EN))
mbed_official 376:cb4d9db17537 587 #define __TIM22_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_TIM22EN))
mbed_official 376:cb4d9db17537 588 #define __FIREWALL_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_MIFIEN))
mbed_official 376:cb4d9db17537 589 #define __ADC1_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_ADC1EN))
mbed_official 376:cb4d9db17537 590 #define __SPI1_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_SPI1EN))
mbed_official 376:cb4d9db17537 591 #define __USART1_CLK_DISABLE() (RCC->APB2ENR &= ~ (RCC_APB2ENR_USART1EN))
mbed_official 376:cb4d9db17537 592 #endif /* STM32L051xx || STM32L061xx || */
mbed_official 376:cb4d9db17537 593 /* STM32L052xx || STM32L062xx || */
mbed_official 376:cb4d9db17537 594 /* STM32L053xx || STM32L063xx || */
mbed_official 376:cb4d9db17537 595
mbed_official 376:cb4d9db17537 596 /** @brief Force or release AHB peripheral reset.
mbed_official 376:cb4d9db17537 597 */
mbed_official 376:cb4d9db17537 598 #if defined(STM32L062xx) || defined(STM32L063xx)
mbed_official 376:cb4d9db17537 599 #define __CRYP_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_CRYPRST))
mbed_official 376:cb4d9db17537 600 #define __CRYP_RELEASE_RESET() (RCC->AHBRSTR &= ~ (RCC_AHBRSTR_CRYPRST))
mbed_official 376:cb4d9db17537 601 #endif /* STM32L062xx || STM32L063xx */
mbed_official 376:cb4d9db17537 602
mbed_official 376:cb4d9db17537 603 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 604 #define __TSC_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_TSCRST))
mbed_official 376:cb4d9db17537 605 #define __TSC_RELEASE_RESET() (RCC->AHBRSTR &= ~ (RCC_AHBRSTR_TSCRST))
mbed_official 376:cb4d9db17537 606 #define __RNG_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_RNGRST))
mbed_official 376:cb4d9db17537 607 #define __RNG_RELEASE_RESET() (RCC->AHBRSTR &= ~ (RCC_AHBRSTR_RNGRST))
mbed_official 376:cb4d9db17537 608 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 609
mbed_official 376:cb4d9db17537 610 /** @brief Force or release APB1 peripheral reset.
mbed_official 376:cb4d9db17537 611 */
mbed_official 376:cb4d9db17537 612 #if defined(STM32L053xx) || defined(STM32L063xx) || \
mbed_official 376:cb4d9db17537 613 defined(STM32L052xx) || defined(STM32L062xx) || \
mbed_official 376:cb4d9db17537 614 defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 615 #define __TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
mbed_official 376:cb4d9db17537 616 #define __TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
mbed_official 376:cb4d9db17537 617 #define __LPTIM1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_LPTIM1RST))
mbed_official 376:cb4d9db17537 618 #define __I2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
mbed_official 376:cb4d9db17537 619 #define __I2C2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
mbed_official 376:cb4d9db17537 620 #define __USART2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
mbed_official 376:cb4d9db17537 621 #define __LPUART1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_LPUART1RST))
mbed_official 376:cb4d9db17537 622 #define __SPI2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
mbed_official 376:cb4d9db17537 623 #define __DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
mbed_official 376:cb4d9db17537 624
mbed_official 376:cb4d9db17537 625 #define __TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_TIM2RST))
mbed_official 376:cb4d9db17537 626 #define __TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_TIM6RST))
mbed_official 376:cb4d9db17537 627 #define __LPTIM1_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_LPTIM1RST))
mbed_official 376:cb4d9db17537 628 #define __I2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_I2C1RST))
mbed_official 376:cb4d9db17537 629 #define __I2C2_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_I2C2RST))
mbed_official 376:cb4d9db17537 630 #define __USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_USART2RST))
mbed_official 376:cb4d9db17537 631 #define __LPUART1_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_LPUART1RST))
mbed_official 376:cb4d9db17537 632 #define __SPI2_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_SPI2RST))
mbed_official 376:cb4d9db17537 633 #define __DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_DACRST))
mbed_official 376:cb4d9db17537 634 #endif /* STM32L051xx || STM32L061xx || */
mbed_official 376:cb4d9db17537 635 /* STM32L052xx || STM32L062xx || */
mbed_official 376:cb4d9db17537 636 /* STM32L053xx || STM32L063xx || */
mbed_official 376:cb4d9db17537 637
mbed_official 376:cb4d9db17537 638 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 639 #define __USB_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USBRST))
mbed_official 376:cb4d9db17537 640 #define __USB_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_USBRST))
mbed_official 376:cb4d9db17537 641 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 642
mbed_official 376:cb4d9db17537 643 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 644 #define __CRS_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CRSRST))
mbed_official 376:cb4d9db17537 645 #define __CRS_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CRSRST))
mbed_official 376:cb4d9db17537 646 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 647
mbed_official 376:cb4d9db17537 648 #if defined(STM32L053xx) || defined(STM32L063xx)
mbed_official 376:cb4d9db17537 649 #define __LCD_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_LCDRST))
mbed_official 376:cb4d9db17537 650 #define __LCD_RELEASE_RESET() (RCC->APB1RSTR &= ~ (RCC_APB1RSTR_LCDRST))
mbed_official 376:cb4d9db17537 651 #endif /* STM32L053xx || STM32L063xx */
mbed_official 376:cb4d9db17537 652
mbed_official 376:cb4d9db17537 653 /** @brief Force or release APB2 peripheral reset.
mbed_official 376:cb4d9db17537 654 */
mbed_official 376:cb4d9db17537 655 #if defined(STM32L053xx) || defined(STM32L063xx) || \
mbed_official 376:cb4d9db17537 656 defined(STM32L052xx) || defined(STM32L062xx) || \
mbed_official 376:cb4d9db17537 657 defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 658 #define __USART1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
mbed_official 376:cb4d9db17537 659 #define __ADC1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_ADC1RST))
mbed_official 376:cb4d9db17537 660 #define __SPI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
mbed_official 376:cb4d9db17537 661 #define __TIM21_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM21RST))
mbed_official 376:cb4d9db17537 662 #define __TIM22_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM22RST))
mbed_official 376:cb4d9db17537 663
mbed_official 376:cb4d9db17537 664 #define __USART1_RELEASE_RESET() (RCC->APB2RSTR &= ~ (RCC_APB2RSTR_USART1RST))
mbed_official 376:cb4d9db17537 665 #define __ADC1_RELEASE_RESET() (RCC->APB2RSTR &= ~ (RCC_APB2RSTR_ADC1RST))
mbed_official 376:cb4d9db17537 666 #define __SPI1_RELEASE_RESET() (RCC->APB2RSTR &= ~ (RCC_APB2RSTR_SPI1RST))
mbed_official 376:cb4d9db17537 667 #define __TIM21_RELEASE_RESET() (RCC->APB2RSTR &= ~ (RCC_APB2RSTR_TIM21RST))
mbed_official 376:cb4d9db17537 668 #define __TIM22_RELEASE_RESET() (RCC->APB2RSTR &= ~ (RCC_APB2RSTR_TIM22RST))
mbed_official 376:cb4d9db17537 669 #endif /* STM32L051xx || STM32L061xx || */
mbed_official 376:cb4d9db17537 670 /* STM32L052xx || STM32L062xx || */
mbed_official 376:cb4d9db17537 671 /* STM32L053xx || STM32L063xx || */
mbed_official 376:cb4d9db17537 672
mbed_official 376:cb4d9db17537 673 /** @brief Enable or disable the AHB peripheral clock during Low Power (Sleep) mode.
mbed_official 376:cb4d9db17537 674 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
mbed_official 376:cb4d9db17537 675 * power consumption.
mbed_official 376:cb4d9db17537 676 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
mbed_official 376:cb4d9db17537 677 * @note By default, all peripheral clocks are enabled during SLEEP mode.
mbed_official 376:cb4d9db17537 678 */
mbed_official 376:cb4d9db17537 679
mbed_official 376:cb4d9db17537 680 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 681 #define __TSC_CLK_SLEEP_ENABLE() (RCC->AHBSMENR |= (RCC_AHBSMENR_TSCSMEN))
mbed_official 376:cb4d9db17537 682 #define __RNG_CLK_SLEEP_ENABLE() (RCC->AHBSMENR |= (RCC_AHBSMENR_RNGSMEN))
mbed_official 376:cb4d9db17537 683 #define __TSC_CLK_SLEEP_DISABLE() (RCC->AHBSMENR &= ~ (RCC_AHBSMENR_TSCSMEN))
mbed_official 376:cb4d9db17537 684 #define __RNG_CLK_SLEEP_DISABLE() (RCC->AHBSMENR &= ~ (RCC_AHBSMENR_RNGSMEN))
mbed_official 376:cb4d9db17537 685 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 686
mbed_official 376:cb4d9db17537 687 #if defined(STM32L062xx) || defined(STM32L063xx)
mbed_official 376:cb4d9db17537 688 #define __CRYP_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBSMENR_CRYPSMEN))
mbed_official 376:cb4d9db17537 689 #define __CRYP_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~ (RCC_AHBSMENR_CRYPSMEN))
mbed_official 376:cb4d9db17537 690 #endif /* STM32L062xx || STM32L063xx */
mbed_official 376:cb4d9db17537 691
mbed_official 376:cb4d9db17537 692
mbed_official 376:cb4d9db17537 693 /** @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
mbed_official 376:cb4d9db17537 694 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
mbed_official 376:cb4d9db17537 695 * power consumption.
mbed_official 376:cb4d9db17537 696 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
mbed_official 376:cb4d9db17537 697 * @note By default, all peripheral clocks are enabled during SLEEP mode.
mbed_official 376:cb4d9db17537 698 */
mbed_official 376:cb4d9db17537 699
mbed_official 376:cb4d9db17537 700 #if defined(STM32L053xx) || defined(STM32L063xx) || \
mbed_official 376:cb4d9db17537 701 defined(STM32L052xx) || defined(STM32L062xx) || \
mbed_official 376:cb4d9db17537 702 defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 703 #define __TIM2_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_TIM2SMEN))
mbed_official 376:cb4d9db17537 704 #define __TIM6_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_TIM6SMEN))
mbed_official 376:cb4d9db17537 705 #define __SPI2_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_SPI2SMEN))
mbed_official 376:cb4d9db17537 706 #define __USART2_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_USART2SMEN))
mbed_official 376:cb4d9db17537 707 #define __LPUART1_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_LPUART1SMEN))
mbed_official 376:cb4d9db17537 708 #define __I2C1_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_I2C1SMEN))
mbed_official 376:cb4d9db17537 709 #define __I2C2_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_I2C2SMEN))
mbed_official 376:cb4d9db17537 710 #define __DAC_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_DACSMEN))
mbed_official 376:cb4d9db17537 711 #define __LPTIM1_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_LPTIM1SMEN))
mbed_official 376:cb4d9db17537 712
mbed_official 376:cb4d9db17537 713 #define __TIM2_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_TIM2SMEN))
mbed_official 376:cb4d9db17537 714 #define __TIM6_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_TIM6SMEN))
mbed_official 376:cb4d9db17537 715 #define __SPI2_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_SPI2SMEN))
mbed_official 376:cb4d9db17537 716 #define __USART2_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_USART2SMEN))
mbed_official 376:cb4d9db17537 717 #define __LPUART1_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_LPUART1SMEN))
mbed_official 376:cb4d9db17537 718 #define __I2C1_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_I2C1SMEN))
mbed_official 376:cb4d9db17537 719 #define __I2C2_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_I2C2SMEN))
mbed_official 376:cb4d9db17537 720 #define __DAC_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_DACSMEN))
mbed_official 376:cb4d9db17537 721 #define __LPTIM1_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_LPTIM1SMEN))
mbed_official 376:cb4d9db17537 722 #endif /* STM32L051xx || STM32L061xx || */
mbed_official 376:cb4d9db17537 723 /* STM32L052xx || STM32L062xx || */
mbed_official 376:cb4d9db17537 724 /* STM32L053xx || STM32L063xx || */
mbed_official 376:cb4d9db17537 725
mbed_official 376:cb4d9db17537 726 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 727 #define __USB_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_USBSMEN))
mbed_official 376:cb4d9db17537 728 #define __USB_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_USBSMEN))
mbed_official 376:cb4d9db17537 729
mbed_official 376:cb4d9db17537 730 #define __CRS_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_CRSSMEN))
mbed_official 376:cb4d9db17537 731 #define __CRS_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_CRSSMEN))
mbed_official 376:cb4d9db17537 732 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 733
mbed_official 376:cb4d9db17537 734 #if defined(STM32L053xx) || defined(STM32L063xx)
mbed_official 376:cb4d9db17537 735 #define __LCD_CLK_SLEEP_ENABLE() (RCC->APB1SMENR |= (RCC_APB1SMENR_LCDSMEN))
mbed_official 376:cb4d9db17537 736 #define __LCD_CLK_SLEEP_DISABLE() (RCC->APB1SMENR &= ~ (RCC_APB1SMENR_LCDSMEN))
mbed_official 376:cb4d9db17537 737 #endif /* STM32L053xx || STM32L063xx */
mbed_official 376:cb4d9db17537 738
mbed_official 376:cb4d9db17537 739 /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
mbed_official 376:cb4d9db17537 740 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
mbed_official 376:cb4d9db17537 741 * power consumption.
mbed_official 376:cb4d9db17537 742 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
mbed_official 376:cb4d9db17537 743 * @note By default, all peripheral clocks are enabled during SLEEP mode.
mbed_official 376:cb4d9db17537 744 */
mbed_official 376:cb4d9db17537 745 #if defined(STM32L053xx) || defined(STM32L063xx) || \
mbed_official 376:cb4d9db17537 746 defined(STM32L052xx) || defined(STM32L062xx) || \
mbed_official 376:cb4d9db17537 747 defined(STM32L051xx) || defined(STM32L061xx)
mbed_official 376:cb4d9db17537 748 #define __TIM21_CLK_SLEEP_ENABLE() (RCC->APB2SMENR |= (RCC_APB2SMENR_TIM21SMEN))
mbed_official 376:cb4d9db17537 749 #define __TIM22_CLK_SLEEP_ENABLE() (RCC->APB2SMENR |= (RCC_APB2SMENR_TIM22SMEN))
mbed_official 376:cb4d9db17537 750 #define __ADC1_CLK_SLEEP_ENABLE() (RCC->APB2SMENR |= (RCC_APB2SMENR_ADC1SMEN))
mbed_official 376:cb4d9db17537 751 #define __SPI1_CLK_SLEEP_ENABLE() (RCC->APB2SMENR |= (RCC_APB2SMENR_SPI1SMEN))
mbed_official 376:cb4d9db17537 752 #define __USART1_CLK_SLEEP_ENABLE() (RCC->APB2SMENR |= (RCC_APB2SMENR_USART1SMEN))
mbed_official 376:cb4d9db17537 753
mbed_official 376:cb4d9db17537 754 #define __TIM21_CLK_SLEEP_DISABLE() (RCC->APB2SMENR &= ~ (RCC_APB2SMENR_TIM21SMEN))
mbed_official 376:cb4d9db17537 755 #define __TIM22_CLK_SLEEP_DISABLE() (RCC->APB2SMENR &= ~ (RCC_APB2SMENR_TIM22SMEN))
mbed_official 376:cb4d9db17537 756 #define __ADC1_CLK_SLEEP_DISABLE() (RCC->APB2SMENR &= ~ (RCC_APB2SMENR_ADC1SMEN))
mbed_official 376:cb4d9db17537 757 #define __SPI1_CLK_SLEEP_DISABLE() (RCC->APB2SMENR &= ~ (RCC_APB2SMENR_SPI1SMEN))
mbed_official 376:cb4d9db17537 758 #define __USART1_CLK_SLEEP_DISABLE() (RCC->APB2SMENR &= ~ (RCC_APB2SMENR_USART1SMEN))
mbed_official 376:cb4d9db17537 759 #endif /* STM32L051xx || STM32L061xx || */
mbed_official 376:cb4d9db17537 760 /* STM32L052xx || STM32L062xx || */
mbed_official 376:cb4d9db17537 761 /* STM32L053xx || STM32L063xx || */
mbed_official 376:cb4d9db17537 762
mbed_official 376:cb4d9db17537 763 /** @brief macro to configure the I2C1 clock (I2C1CLK).
mbed_official 376:cb4d9db17537 764 *
mbed_official 376:cb4d9db17537 765 * @param __I2C1CLKSource__: specifies the I2C1 clock source.
mbed_official 376:cb4d9db17537 766 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 767 * @arg RCC_I2C1CLKSOURCE_PCLK1: PCLK1 selected as I2C1 clock
mbed_official 376:cb4d9db17537 768 * @arg RCC_I2C1CLKSOURCE_HSI: HSI selected as I2C1 clock
mbed_official 376:cb4d9db17537 769 * @arg RCC_I2C1CLKSOURCE_SYSCLK: System Clock selected as I2C1 clock
mbed_official 376:cb4d9db17537 770 */
mbed_official 376:cb4d9db17537 771 #define __HAL_RCC_I2C1_CONFIG(__I2C1CLKSource__) \
mbed_official 376:cb4d9db17537 772 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_I2C1SEL, (uint32_t)(__I2C1CLKSource__))
mbed_official 376:cb4d9db17537 773
mbed_official 376:cb4d9db17537 774 /** @brief macro to get the I2C1 clock source.
mbed_official 376:cb4d9db17537 775 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 776 * @arg RCC_I2C1CLKSOURCE_PCLK1: PCLK1 selected as I2C1 clock
mbed_official 376:cb4d9db17537 777 * @arg RCC_I2C1CLKSOURCE_HSI: HSI selected as I2C1 clock
mbed_official 376:cb4d9db17537 778 * @arg RCC_I2C1CLKSOURCE_SYSCLK: System Clock selected as I2C1 clock
mbed_official 376:cb4d9db17537 779 */
mbed_official 376:cb4d9db17537 780 #define __HAL_RCC_GET_I2C1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_I2C1SEL)))
mbed_official 376:cb4d9db17537 781
mbed_official 376:cb4d9db17537 782 /** @brief macro to configure the USART1 clock (USART1CLK).
mbed_official 376:cb4d9db17537 783 *
mbed_official 376:cb4d9db17537 784 * @param __USART1CLKSource__: specifies the USART1 clock source.
mbed_official 376:cb4d9db17537 785 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 786 * @arg RCC_USART1CLKSOURCE_PCLK2: PCLK2 selected as USART1 clock
mbed_official 376:cb4d9db17537 787 * @arg RCC_USART1CLKSOURCE_HSI: HSI selected as USART1 clock
mbed_official 376:cb4d9db17537 788 * @arg RCC_USART1CLKSOURCE_SYSCLK: System Clock selected as USART1 clock
mbed_official 376:cb4d9db17537 789 * @arg RCC_USART1CLKSOURCE_LSE: LSE selected as USART1 clock
mbed_official 376:cb4d9db17537 790 */
mbed_official 376:cb4d9db17537 791 #define __HAL_RCC_USART1_CONFIG(__USART1CLKSource__) \
mbed_official 376:cb4d9db17537 792 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_USART1SEL, (uint32_t)(__USART1CLKSource__))
mbed_official 376:cb4d9db17537 793
mbed_official 376:cb4d9db17537 794 /** @brief macro to get the USART1 clock source.
mbed_official 376:cb4d9db17537 795 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 796 * @arg RCC_USART1CLKSOURCE_PCLK2: PCLK2 selected as USART1 clock
mbed_official 376:cb4d9db17537 797 * @arg RCC_USART1CLKSOURCE_HSI: HSI selected as USART1 clock
mbed_official 376:cb4d9db17537 798 * @arg RCC_USART1CLKSOURCE_SYSCLK: System Clock selected as USART1 clock
mbed_official 376:cb4d9db17537 799 * @arg RCC_USART1CLKSOURCE_LSE: LSE selected as USART1 clock
mbed_official 376:cb4d9db17537 800 */
mbed_official 376:cb4d9db17537 801 #define __HAL_RCC_GET_USART1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_USART1SEL)))
mbed_official 376:cb4d9db17537 802
mbed_official 376:cb4d9db17537 803 /** @brief macro to configure the USART2 clock (USART2CLK).
mbed_official 376:cb4d9db17537 804 *
mbed_official 376:cb4d9db17537 805 * @param __USART2CLKSource__: specifies the USART2 clock source.
mbed_official 376:cb4d9db17537 806 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 807 * @arg RCC_USART2CLKSOURCE_PCLK1: PCLK1 selected as USART2 clock
mbed_official 376:cb4d9db17537 808 * @arg RCC_USART2CLKSOURCE_HSI: HSI selected as USART2 clock
mbed_official 376:cb4d9db17537 809 * @arg RCC_USART2CLKSOURCE_SYSCLK: System Clock selected as USART2 clock
mbed_official 376:cb4d9db17537 810 * @arg RCC_USART2CLKSOURCE_LSE: LSE selected as USART2 clock
mbed_official 376:cb4d9db17537 811 */
mbed_official 376:cb4d9db17537 812 #define __HAL_RCC_USART2_CONFIG(__USART2CLKSource__) \
mbed_official 376:cb4d9db17537 813 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_USART2SEL, (uint32_t)(__USART2CLKSource__))
mbed_official 376:cb4d9db17537 814
mbed_official 376:cb4d9db17537 815 /** @brief macro to get the USART2 clock source.
mbed_official 376:cb4d9db17537 816 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 817 * @arg RCC_USART2CLKSOURCE_PCLK1: PCLK1 selected as USART2 clock
mbed_official 376:cb4d9db17537 818 * @arg RCC_USART2CLKSOURCE_HSI: HSI selected as USART2 clock
mbed_official 376:cb4d9db17537 819 * @arg RCC_USART2CLKSOURCE_SYSCLK: System Clock selected as USART2 clock
mbed_official 376:cb4d9db17537 820 * @arg RCC_USART2CLKSOURCE_LSE: LSE selected as USART2 clock
mbed_official 376:cb4d9db17537 821 */
mbed_official 376:cb4d9db17537 822 #define __HAL_RCC_GET_USART2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_USART2SEL)))
mbed_official 376:cb4d9db17537 823
mbed_official 376:cb4d9db17537 824 /** @brief macro to configure the LPUART1 clock (LPUART1CLK).
mbed_official 376:cb4d9db17537 825 *
mbed_official 376:cb4d9db17537 826 * @param __LPUART1CLKSource__: specifies the LPUART1 clock source.
mbed_official 376:cb4d9db17537 827 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 828 * @arg RCC_LPUART1CLKSOURCE_PCLK1: PCLK1 selected as LPUART1 clock
mbed_official 376:cb4d9db17537 829 * @arg RCC_LPUART1CLKSOURCE_HSI: HSI selected as LPUART1 clock
mbed_official 376:cb4d9db17537 830 * @arg RCC_LPUART1CLKSOURCE_SYSCLK: System Clock selected as LPUART1 clock
mbed_official 376:cb4d9db17537 831 * @arg RCC_LPUART1CLKSOURCE_LSE: LSE selected as LPUART1 clock
mbed_official 376:cb4d9db17537 832 */
mbed_official 376:cb4d9db17537 833 #define __HAL_RCC_LPUART1_CONFIG(__LPUART1CLKSource__) \
mbed_official 376:cb4d9db17537 834 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPUART1SEL, (uint32_t)(__LPUART1CLKSource__))
mbed_official 376:cb4d9db17537 835
mbed_official 376:cb4d9db17537 836 /** @brief macro to get the LPUART1 clock source.
mbed_official 376:cb4d9db17537 837 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 838 * @arg RCC_LPUART1CLKSOURCE_PCLK1: PCLK1 selected as LPUART1 clock
mbed_official 376:cb4d9db17537 839 * @arg RCC_LPUART1CLKSOURCE_HSI: HSI selected as LPUART1 clock
mbed_official 376:cb4d9db17537 840 * @arg RCC_LPUART1CLKSOURCE_SYSCLK: System Clock selected as LPUART1 clock
mbed_official 376:cb4d9db17537 841 * @arg RCC_LPUART1CLKSOURCE_LSE: LSE selected as LPUART1 clock
mbed_official 376:cb4d9db17537 842 */
mbed_official 376:cb4d9db17537 843 #define __HAL_RCC_GET_LPUART1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_LPUART1SEL)))
mbed_official 376:cb4d9db17537 844
mbed_official 376:cb4d9db17537 845 /** @brief macro to configure the LPTIM1 clock (LPTIM1CLK).
mbed_official 376:cb4d9db17537 846 *
mbed_official 376:cb4d9db17537 847 * @param __LPTIM1CLKSource__: specifies the LPTIM1 clock source.
mbed_official 376:cb4d9db17537 848 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 849 * @arg RCC_LPTIM1CLKSOURCE_PCLK: PCLK selected as LPTIM1 clock
mbed_official 376:cb4d9db17537 850 * @arg RCC_LPTIM1CLKSOURCE_LSI : HSI selected as LPTIM1 clock
mbed_official 376:cb4d9db17537 851 * @arg RCC_LPTIM1CLKSOURCE_HSI : LSI selected as LPTIM1 clock
mbed_official 376:cb4d9db17537 852 * @arg RCC_LPTIM1CLKSOURCE_LSE : LSE selected as LPTIM1 clock
mbed_official 376:cb4d9db17537 853 */
mbed_official 376:cb4d9db17537 854 #define __HAL_RCC_LPTIM1_CONFIG(__LPTIM1CLKSource__) \
mbed_official 376:cb4d9db17537 855 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPTIM1SEL, (uint32_t)(__LPTIM1CLKSource__))
mbed_official 376:cb4d9db17537 856
mbed_official 376:cb4d9db17537 857 /** @brief macro to get the LPTIM1 clock source.
mbed_official 376:cb4d9db17537 858 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 859 * @arg RCC_LPTIM1CLKSOURCE_PCLK: PCLK selected as LPUART1 clock
mbed_official 376:cb4d9db17537 860 * @arg RCC_LPTIM1CLKSOURCE_LSI : HSI selected as LPUART1 clock
mbed_official 376:cb4d9db17537 861 * @arg RCC_LPTIM1CLKSOURCE_HSI : System Clock selected as LPUART1 clock
mbed_official 376:cb4d9db17537 862 * @arg RCC_LPTIM1CLKSOURCE_LSE : LSE selected as LPUART1 clock
mbed_official 376:cb4d9db17537 863 */
mbed_official 376:cb4d9db17537 864 #define __HAL_RCC_GET_LPTIM1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_LPTIM1SEL)))
mbed_official 376:cb4d9db17537 865
mbed_official 376:cb4d9db17537 866 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 867 /** @brief Macro to configure the USB clock (USBCLK).
mbed_official 376:cb4d9db17537 868 * @param __USBCLKSource__: specifies the USB clock source.
mbed_official 376:cb4d9db17537 869 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 870 * @arg RCC_USBCLKSOURCE_HSI48: HSI48 selected as USB clock
mbed_official 376:cb4d9db17537 871 * @arg RCC_USBCLKSOURCE_PLLCLK: PLL Clock selected as USB clock
mbed_official 376:cb4d9db17537 872 */
mbed_official 376:cb4d9db17537 873 #define __HAL_RCC_USB_CONFIG(__USBCLKSource__) \
mbed_official 376:cb4d9db17537 874 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_HSI48SEL, (uint32_t)(__USBCLKSource__))
mbed_official 376:cb4d9db17537 875
mbed_official 376:cb4d9db17537 876 /** @brief Macro to get the USB clock source.
mbed_official 376:cb4d9db17537 877 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 878 * @arg RCC_USBCLKSOURCE_HSI48: HSI48 selected as USB clock
mbed_official 376:cb4d9db17537 879 * @arg RCC_USBCLKSOURCE_PLLCLK: PLL Clock selected as USB clock
mbed_official 376:cb4d9db17537 880 */
mbed_official 376:cb4d9db17537 881 #define __HAL_RCC_GET_USB_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_HSI48SEL)))
mbed_official 376:cb4d9db17537 882
mbed_official 376:cb4d9db17537 883 /** @brief Macro to configure the RNG clock (RNGCLK).
mbed_official 376:cb4d9db17537 884 * @param __RNGCLKSource__: specifies the USB clock source.
mbed_official 376:cb4d9db17537 885 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 886 * @arg RCC_RNGCLKSOURCE_HSI48: HSI48 selected as RNG clock
mbed_official 376:cb4d9db17537 887 * @arg RCC_RNGCLKSOURCE_PLLCLK: PLL Clock selected as RNG clock
mbed_official 376:cb4d9db17537 888 */
mbed_official 376:cb4d9db17537 889 #define __HAL_RCC_RNG_CONFIG(__RNGCLKSource__) \
mbed_official 376:cb4d9db17537 890 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_HSI48SEL, (uint32_t)(__RNGCLKSource__))
mbed_official 376:cb4d9db17537 891
mbed_official 376:cb4d9db17537 892 /** @brief Macro to get the RNG clock source.
mbed_official 376:cb4d9db17537 893 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 894 * @arg RCC_RNGCLKSOURCE_HSI48: HSI48 selected as RNG clock
mbed_official 376:cb4d9db17537 895 * @arg RCC_RNGCLKSOURCE_PLLCLK: PLL Clock selected as RNG clock
mbed_official 376:cb4d9db17537 896 */
mbed_official 376:cb4d9db17537 897 #define __HAL_RCC_GET_RNG_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_HSI48SEL)))
mbed_official 376:cb4d9db17537 898
mbed_official 376:cb4d9db17537 899 /** @brief macro to select the HSI48M clock source
mbed_official 376:cb4d9db17537 900 * @note This macro can be replaced by either __HAL_RCC_RNG_CONFIG or
mbed_official 376:cb4d9db17537 901 * __HAL_RCC_USB_CONFIG to configure respectively RNG or UBS clock sources.
mbed_official 376:cb4d9db17537 902 *
mbed_official 376:cb4d9db17537 903 * @param __HSI48MCLKSource__: specifies the HSI48M clock source dedicated for
mbed_official 376:cb4d9db17537 904 * USB an RNG peripherals.
mbed_official 376:cb4d9db17537 905 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 906 * @arg RCC_HSI48M_PLL: A dedicated 48MHZ PLL output.
mbed_official 376:cb4d9db17537 907 * @arg RCC_HSI48M_RC48: 48MHZ issued from internal HSI48 oscillator.
mbed_official 376:cb4d9db17537 908 */
mbed_official 376:cb4d9db17537 909 #define __HAL_RCC_HSI48M_CONFIG(__HSI48MCLKSource__) \
mbed_official 376:cb4d9db17537 910 MODIFY_REG(RCC->CCIPR, RCC_CCIPR_HSI48SEL, (uint32_t)(__HSI48MCLKSource__))
mbed_official 376:cb4d9db17537 911
mbed_official 376:cb4d9db17537 912 /** @brief macro to get the HSI48M clock source.
mbed_official 376:cb4d9db17537 913 * @note This macro can be replaced by either __HAL_RCC_GET_RNG_SOURCE or
mbed_official 376:cb4d9db17537 914 * __HAL_RCC_GET_USB_SOURCE to get respectively RNG or UBS clock sources.
mbed_official 376:cb4d9db17537 915 * @retval The clock source can be one of the following values:
mbed_official 376:cb4d9db17537 916 * @arg RCC_HSI48M_PLL: A dedicated 48MHZ PLL output.
mbed_official 376:cb4d9db17537 917 * @arg RCC_HSI48M_RC48: 48MHZ issued from internal HSI48 oscillator.
mbed_official 376:cb4d9db17537 918 */
mbed_official 376:cb4d9db17537 919 #define __HAL_RCC_GET_HSI48M_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_HSI48SEL)))
mbed_official 376:cb4d9db17537 920 #endif /* !(STM32L051xx ) && !(STM32L061xx ) */
mbed_official 376:cb4d9db17537 921
mbed_official 376:cb4d9db17537 922 /**
mbed_official 376:cb4d9db17537 923 * @brief Macros to enable or disable the force of the Internal High Speed oscillator (HSI)
mbed_official 376:cb4d9db17537 924 * in STOP mode to be quickly available as kernel clock for USART and I2C.
mbed_official 376:cb4d9db17537 925 * @note The Enable of this function has not effect on the HSION bit.
mbed_official 376:cb4d9db17537 926 * This parameter can be: ENABLE or DISABLE.
mbed_official 376:cb4d9db17537 927 * @retval None
mbed_official 376:cb4d9db17537 928 */
mbed_official 376:cb4d9db17537 929 #define __HAL_RCC_HSISTOP_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIKERON)
mbed_official 376:cb4d9db17537 930 #define __HAL_RCC_HSISTOP_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIKERON)
mbed_official 376:cb4d9db17537 931
mbed_official 376:cb4d9db17537 932 /**
mbed_official 376:cb4d9db17537 933 * @brief Macro to configures the External Low Speed oscillator (LSE) drive capability.
mbed_official 376:cb4d9db17537 934 * @param RCC_LSEDrive: specifies the new state of the LSE drive capability.
mbed_official 376:cb4d9db17537 935 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 936 * @arg RCC_LSEDRIVE_LOW: LSE oscillator low drive capability.
mbed_official 376:cb4d9db17537 937 * @arg RCC_LSEDRIVE_MEDIUMLOW: LSE oscillator medium low drive capability.
mbed_official 376:cb4d9db17537 938 * @arg RCC_LSEDRIVE_MEDIUMHIGH: LSE oscillator medium high drive capability.
mbed_official 376:cb4d9db17537 939 * @arg RCC_LSEDRIVE_HIGH: LSE oscillator high drive capability.
mbed_official 376:cb4d9db17537 940 * @retval None
mbed_official 376:cb4d9db17537 941 */
mbed_official 376:cb4d9db17537 942 #define __HAL_RCC_LSEDRIVE_CONFIG(__RCC_LSEDrive__) (MODIFY_REG(RCC->CSR,\
mbed_official 376:cb4d9db17537 943 RCC_CSR_LSEDRV, (uint32_t)(__RCC_LSEDrive__) ))
mbed_official 376:cb4d9db17537 944
mbed_official 376:cb4d9db17537 945 /**
mbed_official 376:cb4d9db17537 946 * @brief Macro to configures the wake up from stop clock.
mbed_official 376:cb4d9db17537 947 * @param RCC_STOPWUCLK: specifies the clock source used after wake up from stop
mbed_official 376:cb4d9db17537 948 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 949 * @arg RCC_StopWakeUpClock_MSI: MSI selected as system clock source
mbed_official 376:cb4d9db17537 950 * @arg RCC_StopWakeUpClock_HSI: HSI selected as system clock source
mbed_official 376:cb4d9db17537 951 * @retval None
mbed_official 376:cb4d9db17537 952 */
mbed_official 376:cb4d9db17537 953 #define __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(__RCC_STOPWUCLK__) (MODIFY_REG(RCC->CFGR,\
mbed_official 376:cb4d9db17537 954 RCC_CFGR_STOPWUCK, (uint32_t)(__RCC_STOPWUCLK__) ))
mbed_official 376:cb4d9db17537 955
mbed_official 376:cb4d9db17537 956 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 957 /**
mbed_official 376:cb4d9db17537 958 * @brief Enables the specified CRS interrupts.
mbed_official 376:cb4d9db17537 959 * @param __INTERRUPT__: specifies the CRS interrupt sources to be enabled.
mbed_official 376:cb4d9db17537 960 * This parameter can be any combination of the following values:
mbed_official 376:cb4d9db17537 961 * @arg RCC_CRS_IT_SYNCOK
mbed_official 376:cb4d9db17537 962 * @arg RCC_CRS_IT_SYNCWARN
mbed_official 376:cb4d9db17537 963 * @arg RCC_CRS_IT_ERR
mbed_official 376:cb4d9db17537 964 * @arg RCC_CRS_IT_ESYNC
mbed_official 376:cb4d9db17537 965 * @retval None
mbed_official 376:cb4d9db17537 966 */
mbed_official 376:cb4d9db17537 967 #define __HAL_RCC_CRS_ENABLE_IT(__INTERRUPT__) (CRS->CR |= (__INTERRUPT__))
mbed_official 376:cb4d9db17537 968
mbed_official 376:cb4d9db17537 969 /**
mbed_official 376:cb4d9db17537 970 * @brief Disables the specified CRS interrupts.
mbed_official 376:cb4d9db17537 971 * @param __INTERRUPT__: specifies the CRS interrupt sources to be disabled.
mbed_official 376:cb4d9db17537 972 * This parameter can be any combination of the following values:
mbed_official 376:cb4d9db17537 973 * @arg RCC_CRS_IT_SYNCOK
mbed_official 376:cb4d9db17537 974 * @arg RCC_CRS_IT_SYNCWARN
mbed_official 376:cb4d9db17537 975 * @arg RCC_CRS_IT_ERR
mbed_official 376:cb4d9db17537 976 * @arg RCC_CRS_IT_ESYNC
mbed_official 376:cb4d9db17537 977 * @retval None
mbed_official 376:cb4d9db17537 978 */
mbed_official 376:cb4d9db17537 979 #define __HAL_RCC_CRS_DISABLE_IT(__INTERRUPT__) (CRS->CR &= ~(__INTERRUPT__))
mbed_official 376:cb4d9db17537 980
mbed_official 376:cb4d9db17537 981 /** @brief Check the CRS's interrupt has occurred or not.
mbed_official 376:cb4d9db17537 982 * @param __INTERRUPT__: specifies the CRS interrupt source to check.
mbed_official 376:cb4d9db17537 983 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 984 * @arg RCC_CRS_IT_SYNCOK
mbed_official 376:cb4d9db17537 985 * @arg RCC_CRS_IT_SYNCWARN
mbed_official 376:cb4d9db17537 986 * @arg RCC_CRS_IT_ERR
mbed_official 376:cb4d9db17537 987 * @arg RCC_CRS_IT_ESYNC
mbed_official 376:cb4d9db17537 988 * @retval The new state of __INTERRUPT__ (SET or RESET).
mbed_official 376:cb4d9db17537 989 */
mbed_official 376:cb4d9db17537 990 #define __HAL_RCC_CRS_GET_IT_SOURCE(__INTERRUPT__) ((CRS->CR & (__INTERRUPT__))? SET : RESET)
mbed_official 376:cb4d9db17537 991
mbed_official 376:cb4d9db17537 992 /** @brief Clear the CRS's interrupt pending bits
mbed_official 376:cb4d9db17537 993 * bits to clear the selected interrupt pending bits.
mbed_official 376:cb4d9db17537 994 * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
mbed_official 376:cb4d9db17537 995 * This parameter can be any combination of the following values:
mbed_official 376:cb4d9db17537 996 * @arg RCC_CRS_IT_SYNCOK
mbed_official 376:cb4d9db17537 997 * @arg RCC_CRS_IT_SYNCWARN
mbed_official 376:cb4d9db17537 998 * @arg RCC_CRS_IT_ERR
mbed_official 376:cb4d9db17537 999 * @arg RCC_CRS_IT_ESYNC
mbed_official 376:cb4d9db17537 1000 * @arg RCC_CRS_IT_TRIMOVF
mbed_official 376:cb4d9db17537 1001 * @arg RCC_CRS_IT_SYNCERR
mbed_official 376:cb4d9db17537 1002 * @arg RCC_CRS_IT_SYNCMISS
mbed_official 376:cb4d9db17537 1003 */
mbed_official 376:cb4d9db17537 1004 /* CRS IT Error Mask */
mbed_official 376:cb4d9db17537 1005 #define RCC_CRS_IT_ERROR_MASK ((uint32_t)(RCC_CRS_IT_TRIMOVF | RCC_CRS_IT_SYNCERR | RCC_CRS_IT_SYNCMISS))
mbed_official 376:cb4d9db17537 1006
mbed_official 376:cb4d9db17537 1007 #define __HAL_RCC_CRS_CLEAR_IT(__INTERRUPT__) ((((__INTERRUPT__) & RCC_CRS_IT_ERROR_MASK)!= 0) ? (CRS->ICR |= CRS_ICR_ERRC) : \
mbed_official 376:cb4d9db17537 1008 (CRS->ICR = (__INTERRUPT__)))
mbed_official 376:cb4d9db17537 1009
mbed_official 376:cb4d9db17537 1010 /**
mbed_official 376:cb4d9db17537 1011 * @brief Checks whether the specified CRS flag is set or not.
mbed_official 376:cb4d9db17537 1012 * @param _FLAG_: specifies the flag to check.
mbed_official 376:cb4d9db17537 1013 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 1014 * @arg RCC_CRS_FLAG_SYNCOK
mbed_official 376:cb4d9db17537 1015 * @arg RCC_CRS_FLAG_SYNCWARN
mbed_official 376:cb4d9db17537 1016 * @arg RCC_CRS_FLAG_ERR
mbed_official 376:cb4d9db17537 1017 * @arg RCC_CRS_FLAG_ESYNC
mbed_official 376:cb4d9db17537 1018 * @arg RCC_CRS_FLAG_TRIMOVF
mbed_official 376:cb4d9db17537 1019 * @arg RCC_CRS_FLAG_SYNCERR
mbed_official 376:cb4d9db17537 1020 * @arg RCC_CRS_FLAG_SYNCMISS
mbed_official 376:cb4d9db17537 1021 * @retval The new state of _FLAG_ (TRUE or FALSE).
mbed_official 376:cb4d9db17537 1022 */
mbed_official 376:cb4d9db17537 1023 #define __HAL_RCC_CRS_GET_FLAG(_FLAG_) ((CRS->ISR & (_FLAG_)) == (_FLAG_))
mbed_official 376:cb4d9db17537 1024
mbed_official 376:cb4d9db17537 1025 /**
mbed_official 376:cb4d9db17537 1026 * @brief Clears the CRS specified FLAG.
mbed_official 376:cb4d9db17537 1027 * @param _FLAG_: specifies the flag to clear.
mbed_official 376:cb4d9db17537 1028 * This parameter can be one of the following values:
mbed_official 376:cb4d9db17537 1029 * @arg RCC_CRS_FLAG_SYNCOK
mbed_official 376:cb4d9db17537 1030 * @arg RCC_CRS_FLAG_SYNCWARN
mbed_official 376:cb4d9db17537 1031 * @arg RCC_CRS_FLAG_ERR
mbed_official 376:cb4d9db17537 1032 * @arg RCC_CRS_FLAG_ESYNC
mbed_official 376:cb4d9db17537 1033 * @arg RCC_CRS_FLAG_TRIMOVF
mbed_official 376:cb4d9db17537 1034 * @arg RCC_CRS_FLAG_SYNCERR
mbed_official 376:cb4d9db17537 1035 * @arg RCC_CRS_FLAG_SYNCMISS
mbed_official 376:cb4d9db17537 1036 * @retval None
mbed_official 376:cb4d9db17537 1037 */
mbed_official 376:cb4d9db17537 1038
mbed_official 376:cb4d9db17537 1039 /* CRS Flag Error Mask */
mbed_official 376:cb4d9db17537 1040 #define RCC_CRS_FLAG_ERROR_MASK ((uint32_t)(RCC_CRS_FLAG_TRIMOVF | RCC_CRS_FLAG_SYNCERR | RCC_CRS_FLAG_SYNCMISS))
mbed_official 376:cb4d9db17537 1041
mbed_official 376:cb4d9db17537 1042 #define __HAL_RCC_CRS_CLEAR_FLAG(__FLAG__) ((((__FLAG__) & RCC_CRS_FLAG_ERROR_MASK)!= 0) ? (CRS->ICR |= CRS_ICR_ERRC) : \
mbed_official 376:cb4d9db17537 1043 (CRS->ICR = (__FLAG__)))
mbed_official 376:cb4d9db17537 1044
mbed_official 376:cb4d9db17537 1045
mbed_official 376:cb4d9db17537 1046 /**
mbed_official 376:cb4d9db17537 1047 * @brief Enables the oscillator clock for frequency error counter.
mbed_official 376:cb4d9db17537 1048 * @note when the CEN bit is set the CRS_CFGR register becomes write-protected.
mbed_official 376:cb4d9db17537 1049 * @param None
mbed_official 376:cb4d9db17537 1050 * @retval None
mbed_official 376:cb4d9db17537 1051 */
mbed_official 376:cb4d9db17537 1052 #define __HAL_RCC_CRS_ENABLE_FREQ_ERROR_COUNTER() (CRS->CR |= CRS_CR_CEN)
mbed_official 376:cb4d9db17537 1053
mbed_official 376:cb4d9db17537 1054 /**
mbed_official 376:cb4d9db17537 1055 * @brief Disables the oscillator clock for frequency error counter.
mbed_official 376:cb4d9db17537 1056 * @param None
mbed_official 376:cb4d9db17537 1057 * @retval None
mbed_official 376:cb4d9db17537 1058 */
mbed_official 376:cb4d9db17537 1059 #define __HAL_RCC_CRS_DISABLE_FREQ_ERROR_COUNTER() (CRS->CR &= ~CRS_CR_CEN)
mbed_official 376:cb4d9db17537 1060
mbed_official 376:cb4d9db17537 1061 /**
mbed_official 376:cb4d9db17537 1062 * @brief Enables the automatic hardware adjustment of TRIM bits.
mbed_official 376:cb4d9db17537 1063 * @note When the AUTOTRIMEN bit is set the CRS_CFGR register becomes write-protected.
mbed_official 376:cb4d9db17537 1064 * @param None
mbed_official 376:cb4d9db17537 1065 * @retval None
mbed_official 376:cb4d9db17537 1066 */
mbed_official 376:cb4d9db17537 1067 #define __HAL_RCC_CRS_ENABLE_AUTOMATIC_CALIB() (CRS->CR |= CRS_CR_AUTOTRIMEN)
mbed_official 376:cb4d9db17537 1068
mbed_official 376:cb4d9db17537 1069 /**
mbed_official 376:cb4d9db17537 1070 * @brief Enables or disables the automatic hardware adjustment of TRIM bits.
mbed_official 376:cb4d9db17537 1071 * @param None
mbed_official 376:cb4d9db17537 1072 * @retval None
mbed_official 376:cb4d9db17537 1073 */
mbed_official 376:cb4d9db17537 1074 #define __HAL_RCC_CRS_DISABLE_AUTOMATIC_CALIB() (CRS->CR &= ~CRS_CR_AUTOTRIMEN)
mbed_official 376:cb4d9db17537 1075
mbed_official 376:cb4d9db17537 1076 /**
mbed_official 376:cb4d9db17537 1077 * @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies
mbed_official 376:cb4d9db17537 1078 * @note The RELOAD value should be selected according to the ratio between the target frequency and the frequency
mbed_official 376:cb4d9db17537 1079 * of the synchronization source after prescaling. It is then decreased by one in order to
mbed_official 376:cb4d9db17537 1080 * reach the expected synchronization on the zero value. The formula is the following:
mbed_official 376:cb4d9db17537 1081 * RELOAD = (fTARGET / fSYNC) -1
mbed_official 376:cb4d9db17537 1082 * @param _FTARGET_ Target frequency (value in Hz)
mbed_official 376:cb4d9db17537 1083 * @param _FSYNC_ Synchronization signal frequency (value in Hz)
mbed_official 376:cb4d9db17537 1084 * @retval None
mbed_official 376:cb4d9db17537 1085 */
mbed_official 376:cb4d9db17537 1086 #define __HAL_RCC_CRS_CALCULATE_RELOADVALUE(_FTARGET_, _FSYNC_) (((_FTARGET_) / (_FSYNC_)) - 1)
mbed_official 376:cb4d9db17537 1087
mbed_official 376:cb4d9db17537 1088 #endif /* !(STM32L051xx) && !(STM32L061xx) */
mbed_official 376:cb4d9db17537 1089
mbed_official 376:cb4d9db17537 1090 /**
mbed_official 376:cb4d9db17537 1091 * @}
mbed_official 376:cb4d9db17537 1092 */
mbed_official 376:cb4d9db17537 1093
mbed_official 376:cb4d9db17537 1094
mbed_official 376:cb4d9db17537 1095 /* Exported functions --------------------------------------------------------*/
mbed_official 376:cb4d9db17537 1096 HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
mbed_official 376:cb4d9db17537 1097 void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
mbed_official 376:cb4d9db17537 1098 void HAL_RCCEx_EnableLSECSS(void);
mbed_official 376:cb4d9db17537 1099 void HAL_RCCEx_DisableLSECSS(void);
mbed_official 376:cb4d9db17537 1100 #if !defined(STM32L051xx) && !defined(STM32L061xx)
mbed_official 376:cb4d9db17537 1101 void HAL_RCCEx_CRSConfig(RCC_CRSInitTypeDef *pInit);
mbed_official 376:cb4d9db17537 1102 void HAL_RCCEx_CRSSoftwareSynchronizationGenerate(void);
mbed_official 376:cb4d9db17537 1103 void HAL_RCCEx_CRSGetSynchronizationInfo(RCC_CRSSynchroInfoTypeDef *pSynchroInfo);
mbed_official 376:cb4d9db17537 1104 RCC_CRSStatusTypeDef HAL_RCCEx_CRSWaitSynchronization(uint32_t Timeout);
mbed_official 376:cb4d9db17537 1105 #endif /* !(STM32L051xx) && !(STM32L061xx) */
mbed_official 376:cb4d9db17537 1106
mbed_official 376:cb4d9db17537 1107 /**
mbed_official 376:cb4d9db17537 1108 * @}
mbed_official 376:cb4d9db17537 1109 */
mbed_official 376:cb4d9db17537 1110
mbed_official 376:cb4d9db17537 1111 /**
mbed_official 376:cb4d9db17537 1112 * @}
mbed_official 376:cb4d9db17537 1113 */
mbed_official 376:cb4d9db17537 1114
mbed_official 376:cb4d9db17537 1115 #ifdef __cplusplus
mbed_official 376:cb4d9db17537 1116 }
mbed_official 376:cb4d9db17537 1117 #endif
mbed_official 376:cb4d9db17537 1118
mbed_official 376:cb4d9db17537 1119 #endif /* __STM32L0xx_HAL_RCC_EX_H */
mbed_official 376:cb4d9db17537 1120
mbed_official 376:cb4d9db17537 1121 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/