You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

3209 lines
161 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @version V1.3.0
  6. * @date 29-January-2016
  7. * @brief Header file of RCC HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L4xx_HAL_RCC_H
  39. #define __STM32L4xx_HAL_RCC_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l4xx_hal_def.h"
  45. /** @addtogroup STM32L4xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup RCC
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup RCC_Exported_Types RCC Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief RCC PLL configuration structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t PLLState; /*!< The new state of the PLL.
  61. This parameter can be a value of @ref RCC_PLL_Config */
  62. uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
  63. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  64. uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock.
  65. This parameter must be a number between Min_Data = 0 and Max_Data = 8 */
  66. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock.
  67. This parameter must be a number between Min_Data = 8 and Max_Data = 86 */
  68. uint32_t PLLP; /*!< PLLP: Division factor for SAI clock.
  69. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  70. uint32_t PLLQ; /*!< PLLQ: Division factor for SDMMC1, RNG and USB clocks.
  71. This parameter must be a value of @ref RCC_PLLQ_Clock_Divider */
  72. uint32_t PLLR; /*!< PLLR: Division for the main system clock.
  73. User have to set the PLLR parameter correctly to not exceed max frequency 80MHZ.
  74. This parameter must be a value of @ref RCC_PLLR_Clock_Divider */
  75. }RCC_PLLInitTypeDef;
  76. /**
  77. * @brief RCC Internal/External Oscillator (HSE, HSI, MSI, LSE and LSI) configuration structure definition
  78. */
  79. typedef struct
  80. {
  81. uint32_t OscillatorType; /*!< The oscillators to be configured.
  82. This parameter can be a value of @ref RCC_Oscillator_Type */
  83. uint32_t HSEState; /*!< The new state of the HSE.
  84. This parameter can be a value of @ref RCC_HSE_Config */
  85. uint32_t LSEState; /*!< The new state of the LSE.
  86. This parameter can be a value of @ref RCC_LSE_Config */
  87. uint32_t HSIState; /*!< The new state of the HSI.
  88. This parameter can be a value of @ref RCC_HSI_Config */
  89. uint32_t HSICalibrationValue; /*!< The calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  90. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
  91. uint32_t LSIState; /*!< The new state of the LSI.
  92. This parameter can be a value of @ref RCC_LSI_Config */
  93. uint32_t MSIState; /*!< The new state of the MSI.
  94. This parameter can be a value of @ref RCC_MSI_Config */
  95. uint32_t MSICalibrationValue; /*!< The calibration trimming value (default is RCC_MSICALIBRATION_DEFAULT).
  96. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */
  97. uint32_t MSIClockRange; /*!< The MSI frequency range.
  98. This parameter can be a value of @ref RCC_MSI_Clock_Range */
  99. RCC_PLLInitTypeDef PLL; /*!< Main PLL structure parameters */
  100. }RCC_OscInitTypeDef;
  101. /**
  102. * @brief RCC System, AHB and APB busses clock configuration structure definition
  103. */
  104. typedef struct
  105. {
  106. uint32_t ClockType; /*!< The clock to be configured.
  107. This parameter can be a value of @ref RCC_System_Clock_Type */
  108. uint32_t SYSCLKSource; /*!< The clock source used as system clock (SYSCLK).
  109. This parameter can be a value of @ref RCC_System_Clock_Source */
  110. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  111. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  112. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  113. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  114. uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
  115. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  116. }RCC_ClkInitTypeDef;
  117. /**
  118. * @}
  119. */
  120. /* Exported constants --------------------------------------------------------*/
  121. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  122. * @{
  123. */
  124. /** @defgroup RCC_Timeout_Value Timeout Values
  125. * @{
  126. */
  127. #define RCC_DBP_TIMEOUT_VALUE ((uint32_t)2U) /* 2 ms (minimum Tick + 1) */
  128. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
  129. /**
  130. * @}
  131. */
  132. /** @defgroup RCC_Oscillator_Type Oscillator Type
  133. * @{
  134. */
  135. #define RCC_OSCILLATORTYPE_NONE ((uint32_t)0x00000000U) /*!< Oscillator configuration unchanged */
  136. #define RCC_OSCILLATORTYPE_HSE ((uint32_t)0x00000001U) /*!< HSE to configure */
  137. #define RCC_OSCILLATORTYPE_HSI ((uint32_t)0x00000002U) /*!< HSI to configure */
  138. #define RCC_OSCILLATORTYPE_LSE ((uint32_t)0x00000004U) /*!< LSE to configure */
  139. #define RCC_OSCILLATORTYPE_LSI ((uint32_t)0x00000008U) /*!< LSI to configure */
  140. #define RCC_OSCILLATORTYPE_MSI ((uint32_t)0x00000010U) /*!< MSI to configure */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup RCC_HSE_Config HSE Config
  145. * @{
  146. */
  147. #define RCC_HSE_OFF ((uint32_t)0x00000000U) /*!< HSE clock deactivation */
  148. #define RCC_HSE_ON RCC_CR_HSEON /*!< HSE clock activation */
  149. #define RCC_HSE_BYPASS ((uint32_t)(RCC_CR_HSEBYP | RCC_CR_HSEON)) /*!< External clock source for HSE clock */
  150. /**
  151. * @}
  152. */
  153. /** @defgroup RCC_LSE_Config LSE Config
  154. * @{
  155. */
  156. #define RCC_LSE_OFF ((uint32_t)0x00000000U) /*!< LSE clock deactivation */
  157. #define RCC_LSE_ON RCC_BDCR_LSEON /*!< LSE clock activation */
  158. #define RCC_LSE_BYPASS ((uint32_t)(RCC_BDCR_LSEBYP | RCC_BDCR_LSEON)) /*!< External clock source for LSE clock */
  159. /**
  160. * @}
  161. */
  162. /** @defgroup RCC_HSI_Config HSI Config
  163. * @{
  164. */
  165. #define RCC_HSI_OFF ((uint32_t)0x00000000U) /*!< HSI clock deactivation */
  166. #define RCC_HSI_ON RCC_CR_HSION /*!< HSI clock activation */
  167. #define RCC_HSICALIBRATION_DEFAULT ((uint32_t)16) /*!< Default HSI calibration trimming value */
  168. /**
  169. * @}
  170. */
  171. /** @defgroup RCC_LSI_Config LSI Config
  172. * @{
  173. */
  174. #define RCC_LSI_OFF ((uint32_t)0x00000000U) /*!< LSI clock deactivation */
  175. #define RCC_LSI_ON RCC_CSR_LSION /*!< LSI clock activation */
  176. /**
  177. * @}
  178. */
  179. /** @defgroup RCC_MSI_Config MSI Config
  180. * @{
  181. */
  182. #define RCC_MSI_OFF ((uint32_t)0x00000000U) /*!< MSI clock deactivation */
  183. #define RCC_MSI_ON RCC_CR_MSION /*!< MSI clock activation */
  184. #define RCC_MSICALIBRATION_DEFAULT ((uint32_t)0) /*!< Default MSI calibration trimming value */
  185. /**
  186. * @}
  187. */
  188. /** @defgroup RCC_PLL_Config PLL Config
  189. * @{
  190. */
  191. #define RCC_PLL_NONE ((uint32_t)0x00000000U) /*!< PLL configuration unchanged */
  192. #define RCC_PLL_OFF ((uint32_t)0x00000001U) /*!< PLL deactivation */
  193. #define RCC_PLL_ON ((uint32_t)0x00000002U) /*!< PLL activation */
  194. /**
  195. * @}
  196. */
  197. /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
  198. * @{
  199. */
  200. #define RCC_PLLP_DIV7 ((uint32_t)0x00000007U) /*!< PLLP division factor = 7 */
  201. #define RCC_PLLP_DIV17 ((uint32_t)0x00000011U) /*!< PLLP division factor = 17 */
  202. /**
  203. * @}
  204. */
  205. /** @defgroup RCC_PLLQ_Clock_Divider PLLQ Clock Divider
  206. * @{
  207. */
  208. #define RCC_PLLQ_DIV2 ((uint32_t)0x00000002U) /*!< PLLQ division factor = 2 */
  209. #define RCC_PLLQ_DIV4 ((uint32_t)0x00000004U) /*!< PLLQ division factor = 4 */
  210. #define RCC_PLLQ_DIV6 ((uint32_t)0x00000006U) /*!< PLLQ division factor = 6 */
  211. #define RCC_PLLQ_DIV8 ((uint32_t)0x00000008U) /*!< PLLQ division factor = 8 */
  212. /**
  213. * @}
  214. */
  215. /** @defgroup RCC_PLLR_Clock_Divider PLLR Clock Divider
  216. * @{
  217. */
  218. #define RCC_PLLR_DIV2 ((uint32_t)0x00000002U) /*!< PLLR division factor = 2 */
  219. #define RCC_PLLR_DIV4 ((uint32_t)0x00000004U) /*!< PLLR division factor = 4 */
  220. #define RCC_PLLR_DIV6 ((uint32_t)0x00000006U) /*!< PLLR division factor = 6 */
  221. #define RCC_PLLR_DIV8 ((uint32_t)0x00000008U) /*!< PLLR division factor = 8 */
  222. /**
  223. * @}
  224. */
  225. /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
  226. * @{
  227. */
  228. #define RCC_PLLSOURCE_NONE ((uint32_t)0x00000000U) /*!< No clock selected as PLL entry clock source */
  229. #define RCC_PLLSOURCE_MSI RCC_PLLCFGR_PLLSRC_MSI /*!< MSI clock selected as PLL entry clock source */
  230. #define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI /*!< HSI clock selected as PLL entry clock source */
  231. #define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */
  232. /**
  233. * @}
  234. */
  235. /** @defgroup RCC_PLL_Clock_Output PLL Clock Output
  236. * @{
  237. */
  238. #define RCC_PLL_SAI3CLK RCC_PLLCFGR_PLLPEN /*!< PLLSAI3CLK selection from main PLL */
  239. #define RCC_PLL_48M1CLK RCC_PLLCFGR_PLLQEN /*!< PLL48M1CLK selection from main PLL */
  240. #define RCC_PLL_SYSCLK RCC_PLLCFGR_PLLREN /*!< PLLCLK selection from main PLL */
  241. /**
  242. * @}
  243. */
  244. /** @defgroup RCC_PLLSAI1_Clock_Output PLLSAI1 Clock Output
  245. * @{
  246. */
  247. #define RCC_PLLSAI1_SAI1CLK RCC_PLLSAI1CFGR_PLLSAI1PEN /*!< PLLSAI1CLK selection from PLLSAI1 */
  248. #define RCC_PLLSAI1_48M2CLK RCC_PLLSAI1CFGR_PLLSAI1QEN /*!< PLL48M2CLK selection from PLLSAI1 */
  249. #define RCC_PLLSAI1_ADC1CLK RCC_PLLSAI1CFGR_PLLSAI1REN /*!< PLLADC1CLK selection from PLLSAI1 */
  250. /**
  251. * @}
  252. */
  253. /** @defgroup RCC_PLLSAI2_Clock_Output PLLSAI2 Clock Output
  254. * @{
  255. */
  256. #define RCC_PLLSAI2_SAI2CLK RCC_PLLSAI2CFGR_PLLSAI2PEN /*!< PLLSAI2CLK selection from PLLSAI2 */
  257. #define RCC_PLLSAI2_ADC2CLK RCC_PLLSAI2CFGR_PLLSAI2REN /*!< PLLADC2CLK selection from PLLSAI2 */
  258. /**
  259. * @}
  260. */
  261. /** @defgroup RCC_MSI_Clock_Range MSI Clock Range
  262. * @{
  263. */
  264. #define RCC_MSIRANGE_0 RCC_CR_MSIRANGE_0 /*!< MSI = 100 KHz */
  265. #define RCC_MSIRANGE_1 RCC_CR_MSIRANGE_1 /*!< MSI = 200 KHz */
  266. #define RCC_MSIRANGE_2 RCC_CR_MSIRANGE_2 /*!< MSI = 400 KHz */
  267. #define RCC_MSIRANGE_3 RCC_CR_MSIRANGE_3 /*!< MSI = 800 KHz */
  268. #define RCC_MSIRANGE_4 RCC_CR_MSIRANGE_4 /*!< MSI = 1 MHz */
  269. #define RCC_MSIRANGE_5 RCC_CR_MSIRANGE_5 /*!< MSI = 2 MHz */
  270. #define RCC_MSIRANGE_6 RCC_CR_MSIRANGE_6 /*!< MSI = 4 MHz */
  271. #define RCC_MSIRANGE_7 RCC_CR_MSIRANGE_7 /*!< MSI = 8 MHz */
  272. #define RCC_MSIRANGE_8 RCC_CR_MSIRANGE_8 /*!< MSI = 16 MHz */
  273. #define RCC_MSIRANGE_9 RCC_CR_MSIRANGE_9 /*!< MSI = 24 MHz */
  274. #define RCC_MSIRANGE_10 RCC_CR_MSIRANGE_10 /*!< MSI = 32 MHz */
  275. #define RCC_MSIRANGE_11 RCC_CR_MSIRANGE_11 /*!< MSI = 48 MHz */
  276. /**
  277. * @}
  278. */
  279. /** @defgroup RCC_System_Clock_Type System Clock Type
  280. * @{
  281. */
  282. #define RCC_CLOCKTYPE_SYSCLK ((uint32_t)0x00000001U) /*!< SYSCLK to configure */
  283. #define RCC_CLOCKTYPE_HCLK ((uint32_t)0x00000002U) /*!< HCLK to configure */
  284. #define RCC_CLOCKTYPE_PCLK1 ((uint32_t)0x00000004U) /*!< PCLK1 to configure */
  285. #define RCC_CLOCKTYPE_PCLK2 ((uint32_t)0x00000008U) /*!< PCLK2 to configure */
  286. /**
  287. * @}
  288. */
  289. /** @defgroup RCC_System_Clock_Source System Clock Source
  290. * @{
  291. */
  292. #define RCC_SYSCLKSOURCE_MSI RCC_CFGR_SW_MSI /*!< MSI selection as system clock */
  293. #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI /*!< HSI selection as system clock */
  294. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE /*!< HSE selection as system clock */
  295. #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL /*!< PLL selection as system clock */
  296. /**
  297. * @}
  298. */
  299. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  300. * @{
  301. */
  302. #define RCC_SYSCLKSOURCE_STATUS_MSI RCC_CFGR_SWS_MSI /*!< MSI used as system clock */
  303. #define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  304. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  305. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  306. /**
  307. * @}
  308. */
  309. /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
  310. * @{
  311. */
  312. #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1 /*!< SYSCLK not divided */
  313. #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2 /*!< SYSCLK divided by 2 */
  314. #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4 /*!< SYSCLK divided by 4 */
  315. #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8 /*!< SYSCLK divided by 8 */
  316. #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16 /*!< SYSCLK divided by 16 */
  317. #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64 /*!< SYSCLK divided by 64 */
  318. #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128 /*!< SYSCLK divided by 128 */
  319. #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256 /*!< SYSCLK divided by 256 */
  320. #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
  321. /**
  322. * @}
  323. */
  324. /** @defgroup RCC_APB1_APB2_Clock_Source APB1 APB2 Clock Source
  325. * @{
  326. */
  327. #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1 /*!< HCLK not divided */
  328. #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2 /*!< HCLK divided by 2 */
  329. #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4 /*!< HCLK divided by 4 */
  330. #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8 /*!< HCLK divided by 8 */
  331. #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16 /*!< HCLK divided by 16 */
  332. /**
  333. * @}
  334. */
  335. /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
  336. * @{
  337. */
  338. #define RCC_RTCCLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
  339. #define RCC_RTCCLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
  340. #define RCC_RTCCLKSOURCE_HSE_DIV32 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 32 used as RTC clock */
  341. /**
  342. * @}
  343. */
  344. /** @defgroup RCC_MCO_Index MCO Index
  345. * @{
  346. */
  347. #define RCC_MCO1 ((uint32_t)0x00000000U)
  348. #define RCC_MCO RCC_MCO1 /*!< MCO1 to be compliant with other families with 2 MCOs*/
  349. /**
  350. * @}
  351. */
  352. /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
  353. * @{
  354. */
  355. #define RCC_MCO1SOURCE_NOCLOCK ((uint32_t)0x00000000U) /*!< MCO1 output disabled, no clock on MCO1 */
  356. #define RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCOSEL_0 /*!< SYSCLK selection as MCO1 source */
  357. #define RCC_MCO1SOURCE_MSI RCC_CFGR_MCOSEL_1 /*!< MSI selection as MCO1 source */
  358. #define RCC_MCO1SOURCE_HSI (RCC_CFGR_MCOSEL_0| RCC_CFGR_MCOSEL_1) /*!< HSI selection as MCO1 source */
  359. #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCOSEL_2 /*!< HSE selection as MCO1 source */
  360. #define RCC_MCO1SOURCE_PLLCLK (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_2) /*!< PLLCLK selection as MCO1 source */
  361. #define RCC_MCO1SOURCE_LSI (RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSI selection as MCO1 source */
  362. #define RCC_MCO1SOURCE_LSE (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSE selection as MCO1 source */
  363. /**
  364. * @}
  365. */
  366. /** @defgroup RCC_MCOx_Clock_Prescaler MCO1 Clock Prescaler
  367. * @{
  368. */
  369. #define RCC_MCODIV_1 RCC_CFGR_MCOPRE_DIV1 /*!< MCO not divided */
  370. #define RCC_MCODIV_2 RCC_CFGR_MCOPRE_DIV2 /*!< MCO divided by 2 */
  371. #define RCC_MCODIV_4 RCC_CFGR_MCOPRE_DIV4 /*!< MCO divided by 4 */
  372. #define RCC_MCODIV_8 RCC_CFGR_MCOPRE_DIV8 /*!< MCO divided by 8 */
  373. #define RCC_MCODIV_16 RCC_CFGR_MCOPRE_DIV16 /*!< MCO divided by 16 */
  374. /**
  375. * @}
  376. */
  377. /** @defgroup RCC_Interrupt Interrupts
  378. * @{
  379. */
  380. #define RCC_IT_LSIRDY RCC_CIFR_LSIRDYF /*!< LSI Ready Interrupt flag */
  381. #define RCC_IT_LSERDY RCC_CIFR_LSERDYF /*!< LSE Ready Interrupt flag */
  382. #define RCC_IT_MSIRDY RCC_CIFR_MSIRDYF /*!< MSI Ready Interrupt flag */
  383. #define RCC_IT_HSIRDY RCC_CIFR_HSIRDYF /*!< HSI16 Ready Interrupt flag */
  384. #define RCC_IT_HSERDY RCC_CIFR_HSERDYF /*!< HSE Ready Interrupt flag */
  385. #define RCC_IT_PLLRDY RCC_CIFR_PLLRDYF /*!< PLL Ready Interrupt flag */
  386. #define RCC_IT_PLLSAI1RDY RCC_CIFR_PLLSAI1RDYF /*!< PLLSAI1 Ready Interrupt flag */
  387. #define RCC_IT_PLLSAI2RDY RCC_CIFR_PLLSAI2RDYF /*!< PLLSAI2 Ready Interrupt flag */
  388. #define RCC_IT_CSS RCC_CIFR_CSSF /*!< Clock Security System Interrupt flag */
  389. #define RCC_IT_LSECSS RCC_CIFR_LSECSSF /*!< LSE Clock Security System Interrupt flag */
  390. /**
  391. * @}
  392. */
  393. /** @defgroup RCC_Flag Flags
  394. * Elements values convention: XXXYYYYYb
  395. * - YYYYY : Flag position in the register
  396. * - XXX : Register index
  397. * - 001: CR register
  398. * - 010: BDCR register
  399. * - 011: CSR register
  400. * @{
  401. */
  402. /* Flags in the CR register */
  403. #define RCC_FLAG_MSIRDY ((uint32_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_MSIRDY))) /*!< MSI Ready flag */
  404. #define RCC_FLAG_HSIRDY ((uint32_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_HSIRDY))) /*!< HSI Ready flag */
  405. #define RCC_FLAG_HSERDY ((uint32_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_HSERDY))) /*!< HSE Ready flag */
  406. #define RCC_FLAG_PLLRDY ((uint32_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_PLLRDY))) /*!< PLL Ready flag */
  407. #define RCC_FLAG_PLLSAI1RDY ((uint32_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_PLLSAI1RDY))) /*!< PLLSAI1 Ready flag */
  408. #define RCC_FLAG_PLLSAI2RDY ((uint32_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_PLLSAI2RDY))) /*!< PLLSAI2 Ready flag */
  409. /* Flags in the BDCR register */
  410. #define RCC_FLAG_LSERDY ((uint32_t)((BDCR_REG_INDEX << 5U) | POSITION_VAL(RCC_BDCR_LSERDY))) /*!< LSE Ready flag */
  411. #define RCC_FLAG_LSECSSD ((uint32_t)((BDCR_REG_INDEX << 5U) | POSITION_VAL(RCC_BDCR_LSECSSD))) /*!< LSE Clock Security System Interrupt flag */
  412. /* Flags in the CSR register */
  413. #define RCC_FLAG_LSIRDY ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_LSIRDY))) /*!< LSI Ready flag */
  414. #define RCC_FLAG_RMVF ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_RMVF))) /*!< Remove reset flag */
  415. #define RCC_FLAG_FWRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_FWRSTF))) /*!< Firewall reset flag */
  416. #define RCC_FLAG_OBLRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_OBLRSTF))) /*!< Option Byte Loader reset flag */
  417. #define RCC_FLAG_PINRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_PINRSTF))) /*!< PIN reset flag */
  418. #define RCC_FLAG_BORRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_BORRSTF))) /*!< BOR reset flag */
  419. #define RCC_FLAG_SFTRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_SFTRSTF))) /*!< Software Reset flag */
  420. #define RCC_FLAG_IWDGRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_IWDGRSTF))) /*!< Independent Watchdog reset flag */
  421. #define RCC_FLAG_WWDGRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_WWDGRSTF))) /*!< Window watchdog reset flag */
  422. #define RCC_FLAG_LPWRRST ((uint32_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_LPWRRSTF))) /*!< Low-Power reset flag */
  423. /**
  424. * @}
  425. */
  426. /** @defgroup RCC_LSEDrive_Config LSE Drive Config
  427. * @{
  428. */
  429. #define RCC_LSEDRIVE_LOW ((uint32_t)0x00000000U) /*!< LSE low drive capability */
  430. #define RCC_LSEDRIVE_MEDIUMLOW RCC_BDCR_LSEDRV_0 /*!< LSE medium low drive capability */
  431. #define RCC_LSEDRIVE_MEDIUMHIGH RCC_BDCR_LSEDRV_1 /*!< LSE medium high drive capability */
  432. #define RCC_LSEDRIVE_HIGH RCC_BDCR_LSEDRV /*!< LSE high drive capability */
  433. /**
  434. * @}
  435. */
  436. /** @defgroup RCC_Stop_WakeUpClock Wake-Up from STOP Clock
  437. * @{
  438. */
  439. #define RCC_STOP_WAKEUPCLOCK_MSI ((uint32_t)0x00000000U) /*!< MSI selection after wake-up from STOP */
  440. #define RCC_STOP_WAKEUPCLOCK_HSI RCC_CFGR_STOPWUCK /*!< HSI selection after wake-up from STOP */
  441. /**
  442. * @}
  443. */
  444. /**
  445. * @}
  446. */
  447. /* Exported macros -----------------------------------------------------------*/
  448. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  449. * @{
  450. */
  451. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  452. * @brief Enable or disable the AHB1 peripheral clock.
  453. * @note After reset, the peripheral clock (used for registers read/write access)
  454. * is disabled and the application software has to enable this clock before
  455. * using it.
  456. * @{
  457. */
  458. #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
  459. __IO uint32_t tmpreg; \
  460. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN); \
  461. /* Delay after an RCC peripheral clock enabling */ \
  462. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN); \
  463. UNUSED(tmpreg); \
  464. } while(0)
  465. #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
  466. __IO uint32_t tmpreg; \
  467. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN); \
  468. /* Delay after an RCC peripheral clock enabling */ \
  469. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN); \
  470. UNUSED(tmpreg); \
  471. } while(0)
  472. #define __HAL_RCC_FLASH_CLK_ENABLE() do { \
  473. __IO uint32_t tmpreg; \
  474. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN); \
  475. /* Delay after an RCC peripheral clock enabling */ \
  476. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN); \
  477. UNUSED(tmpreg); \
  478. } while(0)
  479. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  480. __IO uint32_t tmpreg; \
  481. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  482. /* Delay after an RCC peripheral clock enabling */ \
  483. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  484. UNUSED(tmpreg); \
  485. } while(0)
  486. #define __HAL_RCC_TSC_CLK_ENABLE() do { \
  487. __IO uint32_t tmpreg; \
  488. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN); \
  489. /* Delay after an RCC peripheral clock enabling */ \
  490. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN); \
  491. UNUSED(tmpreg); \
  492. } while(0)
  493. #define __HAL_RCC_DMA1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN)
  494. #define __HAL_RCC_DMA2_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN)
  495. #define __HAL_RCC_FLASH_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN)
  496. #define __HAL_RCC_CRC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN)
  497. #define __HAL_RCC_TSC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN)
  498. /**
  499. * @}
  500. */
  501. /** @defgroup RCC_AHB2_Peripheral_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  502. * @brief Enable or disable the AHB2 peripheral clock.
  503. * @note After reset, the peripheral clock (used for registers read/write access)
  504. * is disabled and the application software has to enable this clock before
  505. * using it.
  506. * @{
  507. */
  508. #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
  509. __IO uint32_t tmpreg; \
  510. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  511. /* Delay after an RCC peripheral clock enabling */ \
  512. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  513. UNUSED(tmpreg); \
  514. } while(0)
  515. #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
  516. __IO uint32_t tmpreg; \
  517. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  518. /* Delay after an RCC peripheral clock enabling */ \
  519. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  520. UNUSED(tmpreg); \
  521. } while(0)
  522. #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
  523. __IO uint32_t tmpreg; \
  524. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  525. /* Delay after an RCC peripheral clock enabling */ \
  526. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  527. UNUSED(tmpreg); \
  528. } while(0)
  529. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  530. __IO uint32_t tmpreg; \
  531. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  532. /* Delay after an RCC peripheral clock enabling */ \
  533. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  534. UNUSED(tmpreg); \
  535. } while(0)
  536. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  537. __IO uint32_t tmpreg; \
  538. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  539. /* Delay after an RCC peripheral clock enabling */ \
  540. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  541. UNUSED(tmpreg); \
  542. } while(0)
  543. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  544. __IO uint32_t tmpreg; \
  545. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  546. /* Delay after an RCC peripheral clock enabling */ \
  547. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  548. UNUSED(tmpreg); \
  549. } while(0)
  550. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  551. __IO uint32_t tmpreg; \
  552. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  553. /* Delay after an RCC peripheral clock enabling */ \
  554. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  555. UNUSED(tmpreg); \
  556. } while(0)
  557. #define __HAL_RCC_GPIOH_CLK_ENABLE() do { \
  558. __IO uint32_t tmpreg; \
  559. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN); \
  560. /* Delay after an RCC peripheral clock enabling */ \
  561. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN); \
  562. UNUSED(tmpreg); \
  563. } while(0)
  564. #if defined(USB_OTG_FS)
  565. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do { \
  566. __IO uint32_t tmpreg; \
  567. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN); \
  568. /* Delay after an RCC peripheral clock enabling */ \
  569. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN); \
  570. UNUSED(tmpreg); \
  571. } while(0)
  572. #endif /* USB_OTG_FS */
  573. #define __HAL_RCC_ADC_CLK_ENABLE() do { \
  574. __IO uint32_t tmpreg; \
  575. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN); \
  576. /* Delay after an RCC peripheral clock enabling */ \
  577. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN); \
  578. UNUSED(tmpreg); \
  579. } while(0)
  580. #if defined(AES)
  581. #define __HAL_RCC_AES_CLK_ENABLE() do { \
  582. __IO uint32_t tmpreg; \
  583. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  584. /* Delay after an RCC peripheral clock enabling */ \
  585. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  586. UNUSED(tmpreg); \
  587. } while(0)
  588. #endif /* AES */
  589. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  590. __IO uint32_t tmpreg; \
  591. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  592. /* Delay after an RCC peripheral clock enabling */ \
  593. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  594. UNUSED(tmpreg); \
  595. } while(0)
  596. #define __HAL_RCC_GPIOA_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN)
  597. #define __HAL_RCC_GPIOB_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN)
  598. #define __HAL_RCC_GPIOC_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN)
  599. #define __HAL_RCC_GPIOD_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN)
  600. #define __HAL_RCC_GPIOE_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN)
  601. #define __HAL_RCC_GPIOF_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN)
  602. #define __HAL_RCC_GPIOG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN)
  603. #define __HAL_RCC_GPIOH_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN)
  604. #if defined(USB_OTG_FS)
  605. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN);
  606. #endif /* USB_OTG_FS */
  607. #define __HAL_RCC_ADC_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN)
  608. #if defined(AES)
  609. #define __HAL_RCC_AES_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN);
  610. #endif /* AES */
  611. #define __HAL_RCC_RNG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN)
  612. /**
  613. * @}
  614. */
  615. /** @defgroup RCC_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  616. * @brief Enable or disable the AHB3 peripheral clock.
  617. * @note After reset, the peripheral clock (used for registers read/write access)
  618. * is disabled and the application software has to enable this clock before
  619. * using it.
  620. * @{
  621. */
  622. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  623. __IO uint32_t tmpreg; \
  624. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); \
  625. /* Delay after an RCC peripheral clock enabling */ \
  626. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); \
  627. UNUSED(tmpreg); \
  628. } while(0)
  629. #define __HAL_RCC_QSPI_CLK_ENABLE() do { \
  630. __IO uint32_t tmpreg; \
  631. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN); \
  632. /* Delay after an RCC peripheral clock enabling */ \
  633. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN); \
  634. UNUSED(tmpreg); \
  635. } while(0)
  636. #define __HAL_RCC_FMC_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN)
  637. #define __HAL_RCC_QSPI_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN)
  638. /**
  639. * @}
  640. */
  641. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  642. * @brief Enable or disable the APB1 peripheral clock.
  643. * @note After reset, the peripheral clock (used for registers read/write access)
  644. * is disabled and the application software has to enable this clock before
  645. * using it.
  646. * @{
  647. */
  648. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  649. __IO uint32_t tmpreg; \
  650. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN); \
  651. /* Delay after an RCC peripheral clock enabling */ \
  652. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN); \
  653. UNUSED(tmpreg); \
  654. } while(0)
  655. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  656. __IO uint32_t tmpreg; \
  657. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN); \
  658. /* Delay after an RCC peripheral clock enabling */ \
  659. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN); \
  660. UNUSED(tmpreg); \
  661. } while(0)
  662. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  663. __IO uint32_t tmpreg; \
  664. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN); \
  665. /* Delay after an RCC peripheral clock enabling */ \
  666. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN); \
  667. UNUSED(tmpreg); \
  668. } while(0)
  669. #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
  670. __IO uint32_t tmpreg; \
  671. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN); \
  672. /* Delay after an RCC peripheral clock enabling */ \
  673. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN); \
  674. UNUSED(tmpreg); \
  675. } while(0)
  676. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  677. __IO uint32_t tmpreg; \
  678. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN); \
  679. /* Delay after an RCC peripheral clock enabling */ \
  680. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN); \
  681. UNUSED(tmpreg); \
  682. } while(0)
  683. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  684. __IO uint32_t tmpreg; \
  685. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN); \
  686. /* Delay after an RCC peripheral clock enabling */ \
  687. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN); \
  688. UNUSED(tmpreg); \
  689. } while(0)
  690. #if defined(LCD)
  691. #define __HAL_RCC_LCD_CLK_ENABLE() do { \
  692. __IO uint32_t tmpreg; \
  693. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN); \
  694. /* Delay after an RCC peripheral clock enabling */ \
  695. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN); \
  696. UNUSED(tmpreg); \
  697. } while(0)
  698. #endif /* LCD */
  699. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  700. __IO uint32_t tmpreg; \
  701. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN); \
  702. /* Delay after an RCC peripheral clock enabling */ \
  703. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN); \
  704. UNUSED(tmpreg); \
  705. } while(0)
  706. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  707. __IO uint32_t tmpreg; \
  708. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN); \
  709. /* Delay after an RCC peripheral clock enabling */ \
  710. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN); \
  711. UNUSED(tmpreg); \
  712. } while(0)
  713. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  714. __IO uint32_t tmpreg; \
  715. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN); \
  716. /* Delay after an RCC peripheral clock enabling */ \
  717. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN); \
  718. UNUSED(tmpreg); \
  719. } while(0)
  720. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  721. __IO uint32_t tmpreg; \
  722. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN); \
  723. /* Delay after an RCC peripheral clock enabling */ \
  724. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN); \
  725. UNUSED(tmpreg); \
  726. } while(0)
  727. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  728. __IO uint32_t tmpreg; \
  729. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \
  730. /* Delay after an RCC peripheral clock enabling */ \
  731. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \
  732. UNUSED(tmpreg); \
  733. } while(0)
  734. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  735. __IO uint32_t tmpreg; \
  736. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN); \
  737. /* Delay after an RCC peripheral clock enabling */ \
  738. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN); \
  739. UNUSED(tmpreg); \
  740. } while(0)
  741. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  742. __IO uint32_t tmpreg; \
  743. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN); \
  744. /* Delay after an RCC peripheral clock enabling */ \
  745. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN); \
  746. UNUSED(tmpreg); \
  747. } while(0)
  748. #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
  749. __IO uint32_t tmpreg; \
  750. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN); \
  751. /* Delay after an RCC peripheral clock enabling */ \
  752. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN); \
  753. UNUSED(tmpreg); \
  754. } while(0)
  755. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  756. __IO uint32_t tmpreg; \
  757. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN); \
  758. /* Delay after an RCC peripheral clock enabling */ \
  759. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN); \
  760. UNUSED(tmpreg); \
  761. } while(0)
  762. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  763. __IO uint32_t tmpreg; \
  764. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN); \
  765. /* Delay after an RCC peripheral clock enabling */ \
  766. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN); \
  767. UNUSED(tmpreg); \
  768. } while(0)
  769. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  770. __IO uint32_t tmpreg; \
  771. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN); \
  772. /* Delay after an RCC peripheral clock enabling */ \
  773. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN); \
  774. UNUSED(tmpreg); \
  775. } while(0)
  776. #define __HAL_RCC_PWR_CLK_ENABLE() do { \
  777. __IO uint32_t tmpreg; \
  778. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN); \
  779. /* Delay after an RCC peripheral clock enabling */ \
  780. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN); \
  781. UNUSED(tmpreg); \
  782. } while(0)
  783. #define __HAL_RCC_DAC1_CLK_ENABLE() do { \
  784. __IO uint32_t tmpreg; \
  785. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN); \
  786. /* Delay after an RCC peripheral clock enabling */ \
  787. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN); \
  788. UNUSED(tmpreg); \
  789. } while(0)
  790. #define __HAL_RCC_OPAMP_CLK_ENABLE() do { \
  791. __IO uint32_t tmpreg; \
  792. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN); \
  793. /* Delay after an RCC peripheral clock enabling */ \
  794. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN); \
  795. UNUSED(tmpreg); \
  796. } while(0)
  797. #define __HAL_RCC_LPTIM1_CLK_ENABLE() do { \
  798. __IO uint32_t tmpreg; \
  799. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN); \
  800. /* Delay after an RCC peripheral clock enabling */ \
  801. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN); \
  802. UNUSED(tmpreg); \
  803. } while(0)
  804. #define __HAL_RCC_LPUART1_CLK_ENABLE() do { \
  805. __IO uint32_t tmpreg; \
  806. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN); \
  807. /* Delay after an RCC peripheral clock enabling */ \
  808. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN); \
  809. UNUSED(tmpreg); \
  810. } while(0)
  811. #define __HAL_RCC_SWPMI1_CLK_ENABLE() do { \
  812. __IO uint32_t tmpreg; \
  813. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN); \
  814. /* Delay after an RCC peripheral clock enabling */ \
  815. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN); \
  816. UNUSED(tmpreg); \
  817. } while(0)
  818. #define __HAL_RCC_LPTIM2_CLK_ENABLE() do { \
  819. __IO uint32_t tmpreg; \
  820. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN); \
  821. /* Delay after an RCC peripheral clock enabling */ \
  822. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN); \
  823. UNUSED(tmpreg); \
  824. } while(0)
  825. #define __HAL_RCC_TIM2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN)
  826. #define __HAL_RCC_TIM3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN)
  827. #define __HAL_RCC_TIM4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN)
  828. #define __HAL_RCC_TIM5_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN)
  829. #define __HAL_RCC_TIM6_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN)
  830. #define __HAL_RCC_TIM7_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN)
  831. #if defined(LCD)
  832. #define __HAL_RCC_LCD_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN);
  833. #endif /* LCD */
  834. #define __HAL_RCC_SPI2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN)
  835. #define __HAL_RCC_SPI3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN)
  836. #define __HAL_RCC_USART2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN)
  837. #define __HAL_RCC_USART3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN)
  838. #define __HAL_RCC_UART4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN)
  839. #define __HAL_RCC_UART5_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN)
  840. #define __HAL_RCC_I2C1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN)
  841. #define __HAL_RCC_I2C2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN)
  842. #define __HAL_RCC_I2C3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN)
  843. #define __HAL_RCC_CAN1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN)
  844. #define __HAL_RCC_PWR_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN)
  845. #define __HAL_RCC_DAC1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN)
  846. #define __HAL_RCC_OPAMP_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN)
  847. #define __HAL_RCC_LPTIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN)
  848. #define __HAL_RCC_LPUART1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN)
  849. #define __HAL_RCC_SWPMI1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN)
  850. #define __HAL_RCC_LPTIM2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN)
  851. /**
  852. * @}
  853. */
  854. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  855. * @brief Enable or disable the APB2 peripheral clock.
  856. * @note After reset, the peripheral clock (used for registers read/write access)
  857. * is disabled and the application software has to enable this clock before
  858. * using it.
  859. * @{
  860. */
  861. #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
  862. __IO uint32_t tmpreg; \
  863. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN); \
  864. /* Delay after an RCC peripheral clock enabling */ \
  865. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN); \
  866. UNUSED(tmpreg); \
  867. } while(0)
  868. #define __HAL_RCC_FIREWALL_CLK_ENABLE() do { \
  869. __IO uint32_t tmpreg; \
  870. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_FWEN); \
  871. /* Delay after an RCC peripheral clock enabling */ \
  872. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_FWEN); \
  873. UNUSED(tmpreg); \
  874. } while(0)
  875. #define __HAL_RCC_SDMMC1_CLK_ENABLE() do { \
  876. __IO uint32_t tmpreg; \
  877. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN); \
  878. /* Delay after an RCC peripheral clock enabling */ \
  879. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN); \
  880. UNUSED(tmpreg); \
  881. } while(0)
  882. #define __HAL_RCC_TIM1_CLK_ENABLE() do { \
  883. __IO uint32_t tmpreg; \
  884. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  885. /* Delay after an RCC peripheral clock enabling */ \
  886. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  887. UNUSED(tmpreg); \
  888. } while(0)
  889. #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
  890. __IO uint32_t tmpreg; \
  891. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  892. /* Delay after an RCC peripheral clock enabling */ \
  893. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  894. UNUSED(tmpreg); \
  895. } while(0)
  896. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  897. __IO uint32_t tmpreg; \
  898. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  899. /* Delay after an RCC peripheral clock enabling */ \
  900. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  901. UNUSED(tmpreg); \
  902. } while(0)
  903. #define __HAL_RCC_USART1_CLK_ENABLE() do { \
  904. __IO uint32_t tmpreg; \
  905. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  906. /* Delay after an RCC peripheral clock enabling */ \
  907. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  908. UNUSED(tmpreg); \
  909. } while(0)
  910. #define __HAL_RCC_TIM15_CLK_ENABLE() do { \
  911. __IO uint32_t tmpreg; \
  912. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  913. /* Delay after an RCC peripheral clock enabling */ \
  914. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  915. UNUSED(tmpreg); \
  916. } while(0)
  917. #define __HAL_RCC_TIM16_CLK_ENABLE() do { \
  918. __IO uint32_t tmpreg; \
  919. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  920. /* Delay after an RCC peripheral clock enabling */ \
  921. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  922. UNUSED(tmpreg); \
  923. } while(0)
  924. #define __HAL_RCC_TIM17_CLK_ENABLE() do { \
  925. __IO uint32_t tmpreg; \
  926. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  927. /* Delay after an RCC peripheral clock enabling */ \
  928. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  929. UNUSED(tmpreg); \
  930. } while(0)
  931. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  932. __IO uint32_t tmpreg; \
  933. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  934. /* Delay after an RCC peripheral clock enabling */ \
  935. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  936. UNUSED(tmpreg); \
  937. } while(0)
  938. #define __HAL_RCC_SAI2_CLK_ENABLE() do { \
  939. __IO uint32_t tmpreg; \
  940. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN); \
  941. /* Delay after an RCC peripheral clock enabling */ \
  942. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN); \
  943. UNUSED(tmpreg); \
  944. } while(0)
  945. #define __HAL_RCC_DFSDM_CLK_ENABLE() do { \
  946. __IO uint32_t tmpreg; \
  947. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDMEN); \
  948. /* Delay after an RCC peripheral clock enabling */ \
  949. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDMEN); \
  950. UNUSED(tmpreg); \
  951. } while(0)
  952. #define __HAL_RCC_SYSCFG_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN)
  953. #define __HAL_RCC_SDMMC1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN)
  954. #define __HAL_RCC_TIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN)
  955. #define __HAL_RCC_SPI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN)
  956. #define __HAL_RCC_TIM8_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN)
  957. #define __HAL_RCC_USART1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN)
  958. #define __HAL_RCC_TIM15_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN)
  959. #define __HAL_RCC_TIM16_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN)
  960. #define __HAL_RCC_TIM17_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN)
  961. #define __HAL_RCC_SAI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN)
  962. #define __HAL_RCC_SAI2_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN)
  963. #define __HAL_RCC_DFSDM_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDMEN)
  964. /**
  965. * @}
  966. */
  967. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enabled or Disabled Status
  968. * @brief Check whether the AHB1 peripheral clock is enabled or not.
  969. * @note After reset, the peripheral clock (used for registers read/write access)
  970. * is disabled and the application software has to enable this clock before
  971. * using it.
  972. * @{
  973. */
  974. #define __HAL_RCC_DMA1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN) != RESET)
  975. #define __HAL_RCC_DMA2_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN) != RESET)
  976. #define __HAL_RCC_FLASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN) != RESET)
  977. #define __HAL_RCC_CRC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) != RESET)
  978. #define __HAL_RCC_TSC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN) != RESET)
  979. #define __HAL_RCC_DMA1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN) == RESET)
  980. #define __HAL_RCC_DMA2_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN) == RESET)
  981. #define __HAL_RCC_FLASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN) == RESET)
  982. #define __HAL_RCC_CRC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) == RESET)
  983. #define __HAL_RCC_TSC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN) == RESET)
  984. /**
  985. * @}
  986. */
  987. /** @defgroup RCC_AHB2_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enabled or Disabled Status
  988. * @brief Check whether the AHB2 peripheral clock is enabled or not.
  989. * @note After reset, the peripheral clock (used for registers read/write access)
  990. * is disabled and the application software has to enable this clock before
  991. * using it.
  992. * @{
  993. */
  994. #define __HAL_RCC_GPIOA_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) != RESET)
  995. #define __HAL_RCC_GPIOB_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) != RESET)
  996. #define __HAL_RCC_GPIOC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) != RESET)
  997. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) != RESET)
  998. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) != RESET)
  999. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) != RESET)
  1000. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) != RESET)
  1001. #define __HAL_RCC_GPIOH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN) != RESET)
  1002. #if defined(USB_OTG_FS)
  1003. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN) != RESET)
  1004. #endif /* USB_OTG_FS */
  1005. #define __HAL_RCC_ADC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN) != RESET)
  1006. #if defined(AES)
  1007. #define __HAL_RCC_AES_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) != RESET)
  1008. #endif /* AES */
  1009. #define __HAL_RCC_RNG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) != RESET)
  1010. #define __HAL_RCC_GPIOA_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) == RESET)
  1011. #define __HAL_RCC_GPIOB_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN) == RESET)
  1012. #define __HAL_RCC_GPIOC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) == RESET)
  1013. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) == RESET)
  1014. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) == RESET)
  1015. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) == RESET)
  1016. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) == RESET)
  1017. #define __HAL_RCC_GPIOH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN) == RESET)
  1018. #if defined(USB_OTG_FS)
  1019. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN) == RESET)
  1020. #endif /* USB_OTG_FS */
  1021. #define __HAL_RCC_ADC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN) == RESET)
  1022. #if defined(AES)
  1023. #define __HAL_RCC_AES_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) == RESET)
  1024. #endif /* AES */
  1025. #define __HAL_RCC_RNG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) == RESET)
  1026. /**
  1027. * @}
  1028. */
  1029. /** @defgroup RCC_AHB3_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enabled or Disabled Status
  1030. * @brief Check whether the AHB3 peripheral clock is enabled or not.
  1031. * @note After reset, the peripheral clock (used for registers read/write access)
  1032. * is disabled and the application software has to enable this clock before
  1033. * using it.
  1034. * @{
  1035. */
  1036. #define __HAL_RCC_FMC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) != RESET)
  1037. #define __HAL_RCC_QSPI_IS_CLK_ENABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN) != RESET)
  1038. #define __HAL_RCC_FMC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) == RESET)
  1039. #define __HAL_RCC_QSPI_IS_CLK_DISABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN) == RESET)
  1040. /**
  1041. * @}
  1042. */
  1043. /** @defgroup RCC_APB1_Clock_Enable_Disable_Status APB1 Peripheral Clock Enabled or Disabled Status
  1044. * @brief Check whether the APB1 peripheral clock is enabled or not.
  1045. * @note After reset, the peripheral clock (used for registers read/write access)
  1046. * is disabled and the application software has to enable this clock before
  1047. * using it.
  1048. * @{
  1049. */
  1050. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN) != RESET)
  1051. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN) != RESET)
  1052. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN) != RESET)
  1053. #define __HAL_RCC_TIM5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN) != RESET)
  1054. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN) != RESET)
  1055. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN) != RESET)
  1056. #if defined(LCD)
  1057. #define __HAL_RCC_LCD_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN) != RESET)
  1058. #endif /* LCD */
  1059. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN) != RESET)
  1060. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN) != RESET)
  1061. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN) != RESET)
  1062. #define __HAL_RCC_USART2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN) != RESET)
  1063. #define __HAL_RCC_USART3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN) != RESET)
  1064. #define __HAL_RCC_UART4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN) != RESET)
  1065. #define __HAL_RCC_UART5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN) != RESET)
  1066. #define __HAL_RCC_I2C1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN) != RESET)
  1067. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN) != RESET)
  1068. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN) != RESET)
  1069. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN) != RESET)
  1070. #define __HAL_RCC_PWR_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN) != RESET)
  1071. #define __HAL_RCC_DAC1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN) != RESET)
  1072. #define __HAL_RCC_OPAMP_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN) != RESET)
  1073. #define __HAL_RCC_LPTIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN) != RESET)
  1074. #define __HAL_RCC_LPUART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN) != RESET)
  1075. #define __HAL_RCC_SWPMI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN) != RESET)
  1076. #define __HAL_RCC_LPTIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN) != RESET)
  1077. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN) == RESET)
  1078. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN) == RESET)
  1079. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN) == RESET)
  1080. #define __HAL_RCC_TIM5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN) == RESET)
  1081. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN) == RESET)
  1082. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN) == RESET)
  1083. #if defined(LCD)
  1084. #define __HAL_RCC_LCD_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN) == RESET)
  1085. #endif /* LCD */
  1086. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN) == RESET)
  1087. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN) == RESET)
  1088. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN) == RESET)
  1089. #define __HAL_RCC_USART2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN) == RESET)
  1090. #define __HAL_RCC_USART3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN) == RESET)
  1091. #define __HAL_RCC_UART4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN) == RESET)
  1092. #define __HAL_RCC_UART5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN) == RESET)
  1093. #define __HAL_RCC_I2C1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN) == RESET)
  1094. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN) == RESET)
  1095. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN) == RESET)
  1096. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN) == RESET)
  1097. #define __HAL_RCC_PWR_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN) == RESET)
  1098. #define __HAL_RCC_DAC1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN) == RESET)
  1099. #define __HAL_RCC_OPAMP_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN) == RESET)
  1100. #define __HAL_RCC_LPTIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN) == RESET)
  1101. #define __HAL_RCC_LPUART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN) == RESET)
  1102. #define __HAL_RCC_SWPMI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN) == RESET)
  1103. #define __HAL_RCC_LPTIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN) == RESET)
  1104. /**
  1105. * @}
  1106. */
  1107. /** @defgroup RCC_APB2_Clock_Enable_Disable_Status APB2 Peripheral Clock Enabled or Disabled Status
  1108. * @brief Check whether the APB2 peripheral clock is enabled or not.
  1109. * @note After reset, the peripheral clock (used for registers read/write access)
  1110. * is disabled and the application software has to enable this clock before
  1111. * using it.
  1112. * @{
  1113. */
  1114. #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN) != RESET)
  1115. #define __HAL_RCC_FIREWALL_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_FWEN) != RESET)
  1116. #define __HAL_RCC_SDMMC1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN) != RESET)
  1117. #define __HAL_RCC_TIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) != RESET)
  1118. #define __HAL_RCC_SPI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) != RESET)
  1119. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) != RESET)
  1120. #define __HAL_RCC_USART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) != RESET)
  1121. #define __HAL_RCC_TIM15_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) != RESET)
  1122. #define __HAL_RCC_TIM16_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) != RESET)
  1123. #define __HAL_RCC_TIM17_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) != RESET)
  1124. #define __HAL_RCC_SAI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) != RESET)
  1125. #define __HAL_RCC_SAI2_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN) != RESET)
  1126. #define __HAL_RCC_DFSDM_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDMEN) != RESET)
  1127. #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN) == RESET)
  1128. #define __HAL_RCC_SDMMC1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN) == RESET)
  1129. #define __HAL_RCC_TIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) == RESET)
  1130. #define __HAL_RCC_SPI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) == RESET)
  1131. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) == RESET)
  1132. #define __HAL_RCC_USART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) == RESET)
  1133. #define __HAL_RCC_TIM15_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) == RESET)
  1134. #define __HAL_RCC_TIM16_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) == RESET)
  1135. #define __HAL_RCC_TIM17_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) == RESET)
  1136. #define __HAL_RCC_SAI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) == RESET)
  1137. #define __HAL_RCC_SAI2_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN) == RESET)
  1138. #define __HAL_RCC_DFSDM_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDMEN) == RESET)
  1139. /**
  1140. * @}
  1141. */
  1142. /** @defgroup RCC_AHB1_Force_Release_Reset AHB1 Peripheral Force Release Reset
  1143. * @brief Force or release AHB1 peripheral reset.
  1144. * @{
  1145. */
  1146. #define __HAL_RCC_AHB1_FORCE_RESET() WRITE_REG(RCC->AHB1RSTR, 0xFFFFFFFFU)
  1147. #define __HAL_RCC_DMA1_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA1RST)
  1148. #define __HAL_RCC_DMA2_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2RST)
  1149. #define __HAL_RCC_FLASH_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FLASHRST)
  1150. #define __HAL_RCC_CRC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  1151. #define __HAL_RCC_TSC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_TSCRST)
  1152. #define __HAL_RCC_AHB1_RELEASE_RESET() WRITE_REG(RCC->AHB1RSTR, 0x00000000U)
  1153. #define __HAL_RCC_DMA1_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA1RST)
  1154. #define __HAL_RCC_DMA2_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2RST)
  1155. #define __HAL_RCC_FLASH_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FLASHRST)
  1156. #define __HAL_RCC_CRC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  1157. #define __HAL_RCC_TSC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_TSCRST)
  1158. /**
  1159. * @}
  1160. */
  1161. /** @defgroup RCC_AHB2_Force_Release_Reset AHB2 Peripheral Force Release Reset
  1162. * @brief Force or release AHB2 peripheral reset.
  1163. * @{
  1164. */
  1165. #define __HAL_RCC_AHB2_FORCE_RESET() WRITE_REG(RCC->AHB2RSTR, 0xFFFFFFFFU)
  1166. #define __HAL_RCC_GPIOA_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  1167. #define __HAL_RCC_GPIOB_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  1168. #define __HAL_RCC_GPIOC_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  1169. #define __HAL_RCC_GPIOD_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  1170. #define __HAL_RCC_GPIOE_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  1171. #define __HAL_RCC_GPIOF_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  1172. #define __HAL_RCC_GPIOG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  1173. #define __HAL_RCC_GPIOH_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOHRST)
  1174. #if defined(USB_OTG_FS)
  1175. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_OTGFSRST)
  1176. #endif /* USB_OTG_FS */
  1177. #define __HAL_RCC_ADC_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADCRST)
  1178. #if defined(AES)
  1179. #define __HAL_RCC_AES_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  1180. #endif /* AES */
  1181. #define __HAL_RCC_RNG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  1182. #define __HAL_RCC_AHB2_RELEASE_RESET() WRITE_REG(RCC->AHB2RSTR, 0x00000000U)
  1183. #define __HAL_RCC_GPIOA_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  1184. #define __HAL_RCC_GPIOB_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  1185. #define __HAL_RCC_GPIOC_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  1186. #define __HAL_RCC_GPIOD_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  1187. #define __HAL_RCC_GPIOE_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  1188. #define __HAL_RCC_GPIOF_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  1189. #define __HAL_RCC_GPIOG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  1190. #define __HAL_RCC_GPIOH_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOHRST)
  1191. #if defined(USB_OTG_FS)
  1192. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_OTGFSRST)
  1193. #endif /* USB_OTG_FS */
  1194. #define __HAL_RCC_ADC_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADCRST)
  1195. #if defined(AES)
  1196. #define __HAL_RCC_AES_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  1197. #endif /* AES */
  1198. #define __HAL_RCC_RNG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  1199. /**
  1200. * @}
  1201. */
  1202. /** @defgroup RCC_AHB3_Force_Release_Reset AHB3 Peripheral Force Release Reset
  1203. * @brief Force or release AHB3 peripheral reset.
  1204. * @{
  1205. */
  1206. #define __HAL_RCC_AHB3_FORCE_RESET() WRITE_REG(RCC->AHB3RSTR, 0xFFFFFFFFU)
  1207. #define __HAL_RCC_FMC_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_FMCRST)
  1208. #define __HAL_RCC_QSPI_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_QSPIRST)
  1209. #define __HAL_RCC_AHB3_RELEASE_RESET() WRITE_REG(RCC->AHB3RSTR, 0x00000000U)
  1210. #define __HAL_RCC_FMC_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_FMCRST)
  1211. #define __HAL_RCC_QSPI_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_QSPIRST)
  1212. /**
  1213. * @}
  1214. */
  1215. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Peripheral Force Release Reset
  1216. * @brief Force or release APB1 peripheral reset.
  1217. * @{
  1218. */
  1219. #define __HAL_RCC_APB1_FORCE_RESET() WRITE_REG(RCC->APB1RSTR1, 0xFFFFFFFFU)
  1220. #define __HAL_RCC_TIM2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM2RST)
  1221. #define __HAL_RCC_TIM3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM3RST)
  1222. #define __HAL_RCC_TIM4_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM4RST)
  1223. #define __HAL_RCC_TIM5_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM5RST)
  1224. #define __HAL_RCC_TIM6_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM6RST)
  1225. #define __HAL_RCC_TIM7_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM7RST)
  1226. #if defined(LCD)
  1227. #define __HAL_RCC_LCD_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LCDRST)
  1228. #endif /* LCD */
  1229. #define __HAL_RCC_SPI2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI2RST)
  1230. #define __HAL_RCC_SPI3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI3RST)
  1231. #define __HAL_RCC_USART2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART2RST)
  1232. #define __HAL_RCC_USART3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART3RST)
  1233. #define __HAL_RCC_UART4_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART4RST)
  1234. #define __HAL_RCC_UART5_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART5RST)
  1235. #define __HAL_RCC_I2C1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C1RST)
  1236. #define __HAL_RCC_I2C2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C2RST)
  1237. #define __HAL_RCC_I2C3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C3RST)
  1238. #define __HAL_RCC_CAN1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CAN1RST)
  1239. #define __HAL_RCC_PWR_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_PWRRST)
  1240. #define __HAL_RCC_DAC1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_DAC1RST)
  1241. #define __HAL_RCC_OPAMP_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_OPAMPRST)
  1242. #define __HAL_RCC_LPTIM1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LPTIM1RST)
  1243. #define __HAL_RCC_LPUART1_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPUART1RST)
  1244. #define __HAL_RCC_SWPMI1_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_SWPMI1RST)
  1245. #define __HAL_RCC_LPTIM2_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPTIM2RST)
  1246. #define __HAL_RCC_APB1_RELEASE_RESET() WRITE_REG(RCC->APB1RSTR1, 0x00000000U)
  1247. #define __HAL_RCC_TIM2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM2RST)
  1248. #define __HAL_RCC_TIM3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM3RST)
  1249. #define __HAL_RCC_TIM4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM4RST)
  1250. #define __HAL_RCC_TIM5_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM5RST)
  1251. #define __HAL_RCC_TIM6_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM6RST)
  1252. #define __HAL_RCC_TIM7_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM7RST)
  1253. #if defined(LCD)
  1254. #define __HAL_RCC_LCD_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LCDRST)
  1255. #endif /* LCD */
  1256. #define __HAL_RCC_SPI2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI2RST)
  1257. #define __HAL_RCC_SPI3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI3RST)
  1258. #define __HAL_RCC_USART2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART2RST)
  1259. #define __HAL_RCC_USART3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART3RST)
  1260. #define __HAL_RCC_UART4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART4RST)
  1261. #define __HAL_RCC_UART5_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART5RST)
  1262. #define __HAL_RCC_I2C1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C1RST)
  1263. #define __HAL_RCC_I2C2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C2RST)
  1264. #define __HAL_RCC_I2C3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C3RST)
  1265. #define __HAL_RCC_CAN1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CAN1RST)
  1266. #define __HAL_RCC_PWR_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_PWRRST)
  1267. #define __HAL_RCC_DAC1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_DAC1RST)
  1268. #define __HAL_RCC_OPAMP_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_OPAMPRST)
  1269. #define __HAL_RCC_LPTIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LPTIM1RST)
  1270. #define __HAL_RCC_LPUART1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPUART1RST)
  1271. #define __HAL_RCC_SWPMI1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_SWPMI1RST)
  1272. #define __HAL_RCC_LPTIM2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPTIM2RST)
  1273. /**
  1274. * @}
  1275. */
  1276. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Peripheral Force Release Reset
  1277. * @brief Force or release APB2 peripheral reset.
  1278. * @{
  1279. */
  1280. #define __HAL_RCC_APB2_FORCE_RESET() WRITE_REG(RCC->APB2RSTR, 0xFFFFFFFFU)
  1281. #define __HAL_RCC_SYSCFG_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SYSCFGRST)
  1282. #define __HAL_RCC_SDMMC1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SDMMC1RST)
  1283. #define __HAL_RCC_TIM1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  1284. #define __HAL_RCC_SPI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  1285. #define __HAL_RCC_TIM8_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  1286. #define __HAL_RCC_USART1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  1287. #define __HAL_RCC_TIM15_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  1288. #define __HAL_RCC_TIM16_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  1289. #define __HAL_RCC_TIM17_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  1290. #define __HAL_RCC_SAI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  1291. #define __HAL_RCC_SAI2_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI2RST)
  1292. #define __HAL_RCC_DFSDM_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_DFSDMRST)
  1293. #define __HAL_RCC_APB2_RELEASE_RESET() WRITE_REG(RCC->APB2RSTR, 0x00000000U)
  1294. #define __HAL_RCC_SYSCFG_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SYSCFGRST)
  1295. #define __HAL_RCC_SDMMC1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SDMMC1RST)
  1296. #define __HAL_RCC_TIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  1297. #define __HAL_RCC_SPI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  1298. #define __HAL_RCC_TIM8_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  1299. #define __HAL_RCC_USART1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  1300. #define __HAL_RCC_TIM15_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  1301. #define __HAL_RCC_TIM16_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  1302. #define __HAL_RCC_TIM17_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  1303. #define __HAL_RCC_SAI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  1304. #define __HAL_RCC_SAI2_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI2RST)
  1305. #define __HAL_RCC_DFSDM_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_DFSDMRST)
  1306. /**
  1307. * @}
  1308. */
  1309. /** @defgroup RCC_AHB1_Clock_Sleep_Enable_Disable AHB1 Peripheral Clock Sleep Enable Disable
  1310. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  1311. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1312. * power consumption.
  1313. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1314. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1315. * @{
  1316. */
  1317. #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN)
  1318. #define __HAL_RCC_DMA2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN)
  1319. #define __HAL_RCC_FLASH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN)
  1320. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN)
  1321. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN)
  1322. #define __HAL_RCC_TSC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN)
  1323. #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN)
  1324. #define __HAL_RCC_DMA2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN)
  1325. #define __HAL_RCC_FLASH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN)
  1326. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN)
  1327. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN)
  1328. #define __HAL_RCC_TSC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN)
  1329. /**
  1330. * @}
  1331. */
  1332. /** @defgroup RCC_AHB2_Clock_Sleep_Enable_Disable AHB2 Peripheral Clock Sleep Enable Disable
  1333. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  1334. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1335. * power consumption.
  1336. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1337. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1338. * @{
  1339. */
  1340. #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN)
  1341. #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN)
  1342. #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN)
  1343. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN)
  1344. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN)
  1345. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN)
  1346. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN)
  1347. #define __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN)
  1348. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN)
  1349. #if defined(USB_OTG_FS)
  1350. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN)
  1351. #endif /* USB_OTG_FS */
  1352. #define __HAL_RCC_ADC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN)
  1353. #if defined(AES)
  1354. #define __HAL_RCC_AES_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN)
  1355. #endif /* AES */
  1356. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN)
  1357. #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN)
  1358. #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN)
  1359. #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN)
  1360. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN)
  1361. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN)
  1362. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN)
  1363. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN)
  1364. #define __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN)
  1365. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN)
  1366. #if defined(USB_OTG_FS)
  1367. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN)
  1368. #endif /* USB_OTG_FS */
  1369. #define __HAL_RCC_ADC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN)
  1370. #if defined(AES)
  1371. #define __HAL_RCC_AES_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN)
  1372. #endif /* AES */
  1373. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN)
  1374. /**
  1375. * @}
  1376. */
  1377. /** @defgroup RCC_AHB3_Clock_Sleep_Enable_Disable AHB3 Peripheral Clock Sleep Enable Disable
  1378. * @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  1379. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1380. * power consumption.
  1381. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1382. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1383. * @{
  1384. */
  1385. #define __HAL_RCC_QSPI_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN)
  1386. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN)
  1387. #define __HAL_RCC_QSPI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN)
  1388. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN)
  1389. /**
  1390. * @}
  1391. */
  1392. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable APB1 Peripheral Clock Sleep Enable Disable
  1393. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  1394. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1395. * power consumption.
  1396. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1397. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1398. * @{
  1399. */
  1400. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN)
  1401. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN)
  1402. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN)
  1403. #define __HAL_RCC_TIM5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN)
  1404. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN)
  1405. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN)
  1406. #if defined(LCD)
  1407. #define __HAL_RCC_LCD_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN)
  1408. #endif /* LCD */
  1409. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN)
  1410. #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN)
  1411. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN)
  1412. #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN)
  1413. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN)
  1414. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN)
  1415. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN)
  1416. #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN)
  1417. #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN)
  1418. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN)
  1419. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN)
  1420. #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN)
  1421. #define __HAL_RCC_DAC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN)
  1422. #define __HAL_RCC_OPAMP_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN)
  1423. #define __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN)
  1424. #define __HAL_RCC_LPUART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN)
  1425. #define __HAL_RCC_SWPMI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN)
  1426. #define __HAL_RCC_LPTIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN)
  1427. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN)
  1428. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN)
  1429. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN)
  1430. #define __HAL_RCC_TIM5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN)
  1431. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN)
  1432. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN)
  1433. #if defined(LCD)
  1434. #define __HAL_RCC_LCD_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN)
  1435. #endif /* LCD */
  1436. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN)
  1437. #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN)
  1438. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN)
  1439. #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN)
  1440. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN)
  1441. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN)
  1442. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN)
  1443. #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN)
  1444. #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN)
  1445. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN)
  1446. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN)
  1447. #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN)
  1448. #define __HAL_RCC_DAC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN)
  1449. #define __HAL_RCC_OPAMP_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN)
  1450. #define __HAL_RCC_LPTIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN)
  1451. #define __HAL_RCC_LPUART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN)
  1452. #define __HAL_RCC_SWPMI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN)
  1453. #define __HAL_RCC_LPTIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN)
  1454. /**
  1455. * @}
  1456. */
  1457. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable APB2 Peripheral Clock Sleep Enable Disable
  1458. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1459. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1460. * power consumption.
  1461. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1462. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1463. * @{
  1464. */
  1465. #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN)
  1466. #define __HAL_RCC_SDMMC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN)
  1467. #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN)
  1468. #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN)
  1469. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN)
  1470. #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN)
  1471. #define __HAL_RCC_TIM15_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN)
  1472. #define __HAL_RCC_TIM16_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN)
  1473. #define __HAL_RCC_TIM17_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN)
  1474. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN)
  1475. #define __HAL_RCC_SAI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN)
  1476. #define __HAL_RCC_DFSDM_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDMSMEN)
  1477. #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN)
  1478. #define __HAL_RCC_SDMMC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN)
  1479. #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN)
  1480. #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN)
  1481. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN)
  1482. #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN)
  1483. #define __HAL_RCC_TIM15_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN)
  1484. #define __HAL_RCC_TIM16_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN)
  1485. #define __HAL_RCC_TIM17_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN)
  1486. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN)
  1487. #define __HAL_RCC_SAI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN)
  1488. #define __HAL_RCC_DFSDM_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDMSMEN)
  1489. /**
  1490. * @}
  1491. */
  1492. /** @defgroup RCC_AHB1_Clock_Sleep_Enable_Disable_Status AHB1 Peripheral Clock Sleep Enabled or Disabled Status
  1493. * @brief Check whether the AHB1 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1494. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1495. * power consumption.
  1496. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1497. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1498. * @{
  1499. */
  1500. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN) != RESET)
  1501. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN) != RESET)
  1502. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN) != RESET)
  1503. #define __HAL_RCC_SRAM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN) != RESET)
  1504. #define __HAL_RCC_CRC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN) != RESET)
  1505. #define __HAL_RCC_TSC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN) != RESET)
  1506. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN) == RESET)
  1507. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN) == RESET)
  1508. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN) == RESET)
  1509. #define __HAL_RCC_SRAM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN) == RESET)
  1510. #define __HAL_RCC_CRC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN) == RESET)
  1511. #define __HAL_RCC_TSC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN) == RESET)
  1512. /**
  1513. * @}
  1514. */
  1515. /** @defgroup RCC_AHB2_Clock_Sleep_Enable_Disable_Status AHB2 Peripheral Clock Sleep Enabled or Disabled Status
  1516. * @brief Check whether the AHB2 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1517. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1518. * power consumption.
  1519. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1520. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1521. * @{
  1522. */
  1523. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN) != RESET)
  1524. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN) != RESET)
  1525. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN) != RESET)
  1526. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN) != RESET)
  1527. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN) != RESET)
  1528. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN) != RESET)
  1529. #define __HAL_RCC_GPIOG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN) != RESET)
  1530. #define __HAL_RCC_GPIOH_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN) != RESET)
  1531. #define __HAL_RCC_SRAM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN) != RESET)
  1532. #if defined(USB_OTG_FS)
  1533. #define __HAL_RCC_USB_OTG_FS_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN) != RESET)
  1534. #endif /* USB_OTG_FS */
  1535. #define __HAL_RCC_ADC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN) != RESET)
  1536. #if defined(AES)
  1537. #define __HAL_RCC_AES_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN) != RESET)
  1538. #endif /* AES */
  1539. #define __HAL_RCC_RNG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN) != RESET)
  1540. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN) == RESET)
  1541. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN) == RESET)
  1542. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN) == RESET)
  1543. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN) == RESET)
  1544. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN) == RESET)
  1545. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN) == RESET)
  1546. #define __HAL_RCC_GPIOG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN) == RESET)
  1547. #define __HAL_RCC_GPIOH_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN) == RESET)
  1548. #define __HAL_RCC_SRAM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN) == RESET)
  1549. #if defined(USB_OTG_FS)
  1550. #define __HAL_RCC_USB_OTG_FS_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN) == RESET)
  1551. #endif /* USB_OTG_FS */
  1552. #define __HAL_RCC_ADC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN) == RESET)
  1553. #if defined(AES)
  1554. #define __HAL_RCC_AES_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN) == RESET)
  1555. #endif /* AES */
  1556. #define __HAL_RCC_RNG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN) == RESET)
  1557. /**
  1558. * @}
  1559. */
  1560. /** @defgroup RCC_AHB3_Clock_Sleep_Enable_Disable_Status AHB3 Peripheral Clock Sleep Enabled or Disabled Status
  1561. * @brief Check whether the AHB3 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1562. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1563. * power consumption.
  1564. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1565. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1566. * @{
  1567. */
  1568. #define __HAL_RCC_QSPI_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN) != RESET)
  1569. #define __HAL_RCC_FMC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN) != RESET)
  1570. #define __HAL_RCC_QSPI_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN) == RESET)
  1571. #define __HAL_RCC_FMC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN) == RESET)
  1572. /**
  1573. * @}
  1574. */
  1575. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable_Status APB1 Peripheral Clock Sleep Enabled or Disabled Status
  1576. * @brief Check whether the APB1 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1577. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1578. * power consumption.
  1579. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1580. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1581. * @{
  1582. */
  1583. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN) != RESET)
  1584. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN) != RESET)
  1585. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN) != RESET)
  1586. #define __HAL_RCC_TIM5_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN) != RESET)
  1587. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN) != RESET)
  1588. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN) != RESET)
  1589. #if defined(LCD)
  1590. #define __HAL_RCC_LCD_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN) != RESET)
  1591. #endif /* LCD */
  1592. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN) != RESET)
  1593. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN) != RESET)
  1594. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN) != RESET)
  1595. #define __HAL_RCC_USART2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN) != RESET)
  1596. #define __HAL_RCC_USART3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN) != RESET)
  1597. #define __HAL_RCC_UART4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN) != RESET)
  1598. #define __HAL_RCC_UART5_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN) != RESET)
  1599. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN) != RESET)
  1600. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN) != RESET)
  1601. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN) != RESET)
  1602. #define __HAL_RCC_CAN1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN) != RESET)
  1603. #define __HAL_RCC_PWR_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN) != RESET)
  1604. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN) != RESET)
  1605. #define __HAL_RCC_OPAMP_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN) != RESET)
  1606. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN) != RESET)
  1607. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN) != RESET)
  1608. #define __HAL_RCC_SWPMI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN) != RESET)
  1609. #define __HAL_RCC_LPTIM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN) != RESET)
  1610. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN) == RESET)
  1611. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN) == RESET)
  1612. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN) == RESET)
  1613. #define __HAL_RCC_TIM5_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN) == RESET)
  1614. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN) == RESET)
  1615. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN) == RESET)
  1616. #if defined(LCD)
  1617. #define __HAL_RCC_LCD_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN) == RESET)
  1618. #endif /* LCD */
  1619. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN) == RESET)
  1620. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN) == RESET)
  1621. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN) == RESET)
  1622. #define __HAL_RCC_USART2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN) == RESET)
  1623. #define __HAL_RCC_USART3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN) == RESET)
  1624. #define __HAL_RCC_UART4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN) == RESET)
  1625. #define __HAL_RCC_UART5_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN) == RESET)
  1626. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN) == RESET)
  1627. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN) == RESET)
  1628. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN) == RESET)
  1629. #define __HAL_RCC_CAN1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN) == RESET)
  1630. #define __HAL_RCC_PWR_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN) == RESET)
  1631. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN) == RESET)
  1632. #define __HAL_RCC_OPAMP_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN) == RESET)
  1633. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN) == RESET)
  1634. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN) == RESET)
  1635. #define __HAL_RCC_SWPMI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN) == RESET)
  1636. #define __HAL_RCC_LPTIM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN) == RESET)
  1637. /**
  1638. * @}
  1639. */
  1640. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable_Status APB2 Peripheral Clock Sleep Enabled or Disabled Status
  1641. * @brief Check whether the APB2 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1642. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1643. * power consumption.
  1644. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1645. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1646. * @{
  1647. */
  1648. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN) != RESET)
  1649. #define __HAL_RCC_SDMMC1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN) != RESET)
  1650. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN) != RESET)
  1651. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN) != RESET)
  1652. #define __HAL_RCC_TIM8_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN) != RESET)
  1653. #define __HAL_RCC_USART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN) != RESET)
  1654. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN) != RESET)
  1655. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN) != RESET)
  1656. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN) != RESET)
  1657. #define __HAL_RCC_SAI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN) != RESET)
  1658. #define __HAL_RCC_SAI2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN) != RESET)
  1659. #define __HAL_RCC_DFSDM_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDMSMEN) != RESET)
  1660. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN) == RESET)
  1661. #define __HAL_RCC_SDMMC1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN) == RESET)
  1662. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN) == RESET)
  1663. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN) == RESET)
  1664. #define __HAL_RCC_TIM8_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN) == RESET)
  1665. #define __HAL_RCC_USART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN) == RESET)
  1666. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN) == RESET)
  1667. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN) == RESET)
  1668. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN) == RESET)
  1669. #define __HAL_RCC_SAI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN) == RESET)
  1670. #define __HAL_RCC_SAI2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN) == RESET)
  1671. #define __HAL_RCC_DFSDM_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDMSMEN) == RESET)
  1672. /**
  1673. * @}
  1674. */
  1675. /** @defgroup RCC_Backup_Domain_Reset RCC Backup Domain Reset
  1676. * @{
  1677. */
  1678. /** @brief Macros to force or release the Backup domain reset.
  1679. * @note This function resets the RTC peripheral (including the backup registers)
  1680. * and the RTC clock source selection in RCC_CSR register.
  1681. * @note The BKPSRAM is not affected by this reset.
  1682. * @retval None
  1683. */
  1684. #define __HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  1685. #define __HAL_RCC_BACKUPRESET_RELEASE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  1686. /**
  1687. * @}
  1688. */
  1689. /** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
  1690. * @{
  1691. */
  1692. /** @brief Macros to enable or disable the RTC clock.
  1693. * @note As the RTC is in the Backup domain and write access is denied to
  1694. * this domain after reset, you have to enable write access using
  1695. * HAL_PWR_EnableBkUpAccess() function before to configure the RTC
  1696. * (to be done once after reset).
  1697. * @note These macros must be used after the RTC clock source was selected.
  1698. * @retval None
  1699. */
  1700. #define __HAL_RCC_RTC_ENABLE() SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  1701. #define __HAL_RCC_RTC_DISABLE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  1702. /**
  1703. * @}
  1704. */
  1705. /** @brief Macros to enable or disable the Internal High Speed 16MHz oscillator (HSI).
  1706. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  1707. * It is used (enabled by hardware) as system clock source after startup
  1708. * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
  1709. * of the HSE used directly or indirectly as system clock (if the Clock
  1710. * Security System CSS is enabled).
  1711. * @note HSI can not be stopped if it is used as system clock source. In this case,
  1712. * you have to select another source of the system clock then stop the HSI.
  1713. * @note After enabling the HSI, the application software should wait on HSIRDY
  1714. * flag to be set indicating that HSI clock is stable and can be used as
  1715. * system clock source.
  1716. * This parameter can be: ENABLE or DISABLE.
  1717. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  1718. * clock cycles.
  1719. * @retval None
  1720. */
  1721. #define __HAL_RCC_HSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSION)
  1722. #define __HAL_RCC_HSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSION)
  1723. /** @brief Macro to adjust the Internal High Speed 16MHz oscillator (HSI) calibration value.
  1724. * @note The calibration is used to compensate for the variations in voltage
  1725. * and temperature that influence the frequency of the internal HSI RC.
  1726. * @param __HSICALIBRATIONVALUE__: specifies the calibration trimming value
  1727. * (default is RCC_HSICALIBRATION_DEFAULT).
  1728. * This parameter must be a number between 0 and 31.
  1729. * @retval None
  1730. */
  1731. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICALIBRATIONVALUE__) \
  1732. MODIFY_REG(RCC->ICSCR, RCC_ICSCR_HSITRIM, (uint32_t)(__HSICALIBRATIONVALUE__) << POSITION_VAL(RCC_ICSCR_HSITRIM))
  1733. /**
  1734. * @brief Macros to enable or disable the wakeup the Internal High Speed oscillator (HSI)
  1735. * in parallel to the Internal Multi Speed oscillator (MSI) used at system wakeup.
  1736. * @note The enable of this function has not effect on the HSION bit.
  1737. * This parameter can be: ENABLE or DISABLE.
  1738. * @retval None
  1739. */
  1740. #define __HAL_RCC_HSIAUTOMATIC_START_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIASFS)
  1741. #define __HAL_RCC_HSIAUTOMATIC_START_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIASFS)
  1742. /**
  1743. * @brief Macros to enable or disable the force of the Internal High Speed oscillator (HSI)
  1744. * in STOP mode to be quickly available as kernel clock for USARTs and I2Cs.
  1745. * @note Keeping the HSI ON in STOP mode allows to avoid slowing down the communication
  1746. * speed because of the HSI startup time.
  1747. * @note The enable of this function has not effect on the HSION bit.
  1748. * This parameter can be: ENABLE or DISABLE.
  1749. * @retval None
  1750. */
  1751. #define __HAL_RCC_HSISTOP_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIKERON)
  1752. #define __HAL_RCC_HSISTOP_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIKERON)
  1753. /**
  1754. * @brief Macros to enable or disable the Internal Multi Speed oscillator (MSI).
  1755. * @note The MSI is stopped by hardware when entering STOP and STANDBY modes.
  1756. * It is used (enabled by hardware) as system clock source after
  1757. * startup from Reset, wakeup from STOP and STANDBY mode, or in case
  1758. * of failure of the HSE used directly or indirectly as system clock
  1759. * (if the Clock Security System CSS is enabled).
  1760. * @note MSI can not be stopped if it is used as system clock source.
  1761. * In this case, you have to select another source of the system
  1762. * clock then stop the MSI.
  1763. * @note After enabling the MSI, the application software should wait on
  1764. * MSIRDY flag to be set indicating that MSI clock is stable and can
  1765. * be used as system clock source.
  1766. * @note When the MSI is stopped, MSIRDY flag goes low after 6 MSI oscillator
  1767. * clock cycles.
  1768. * @retval None
  1769. */
  1770. #define __HAL_RCC_MSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_MSION)
  1771. #define __HAL_RCC_MSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_MSION)
  1772. /** @brief Macro Adjusts the Internal Multi Speed oscillator (MSI) calibration value.
  1773. * @note The calibration is used to compensate for the variations in voltage
  1774. * and temperature that influence the frequency of the internal MSI RC.
  1775. * Refer to the Application Note AN3300 for more details on how to
  1776. * calibrate the MSI.
  1777. * @param __MSICALIBRATIONVALUE__: specifies the calibration trimming value
  1778. * (default is RCC_MSICALIBRATION_DEFAULT).
  1779. * This parameter must be a number between 0 and 255.
  1780. * @retval None
  1781. */
  1782. #define __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(__MSICALIBRATIONVALUE__) \
  1783. MODIFY_REG(RCC->ICSCR, RCC_ICSCR_MSITRIM, (uint32_t)(__MSICALIBRATIONVALUE__) << 8)
  1784. /**
  1785. * @brief Macro configures the Internal Multi Speed oscillator (MSI) clock range in run mode
  1786. * @note After restart from Reset , the MSI clock is around 4 MHz.
  1787. * After stop the startup clock can be MSI (at any of its possible
  1788. * frequencies, the one that was used before entering stop mode) or HSI.
  1789. * After Standby its frequency can be selected between 4 possible values
  1790. * (1, 2, 4 or 8 MHz).
  1791. * @note MSIRANGE can be modified when MSI is OFF (MSION=0) or when MSI is ready
  1792. * (MSIRDY=1).
  1793. * @note The MSI clock range after reset can be modified on the fly.
  1794. * @param __MSIRANGEVALUE__: specifies the MSI clock range.
  1795. * This parameter must be one of the following values:
  1796. * @arg @ref RCC_MSIRANGE_0 MSI clock is around 100 KHz
  1797. * @arg @ref RCC_MSIRANGE_1 MSI clock is around 200 KHz
  1798. * @arg @ref RCC_MSIRANGE_2 MSI clock is around 400 KHz
  1799. * @arg @ref RCC_MSIRANGE_3 MSI clock is around 800 KHz
  1800. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1 MHz
  1801. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2MHz
  1802. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4MHz (default after Reset)
  1803. * @arg @ref RCC_MSIRANGE_7 MSI clock is around 8 MHz
  1804. * @arg @ref RCC_MSIRANGE_8 MSI clock is around 16 MHz
  1805. * @arg @ref RCC_MSIRANGE_9 MSI clock is around 24 MHz
  1806. * @arg @ref RCC_MSIRANGE_10 MSI clock is around 32 MHz
  1807. * @arg @ref RCC_MSIRANGE_11 MSI clock is around 48 MHz
  1808. * @retval None
  1809. */
  1810. #define __HAL_RCC_MSI_RANGE_CONFIG(__MSIRANGEVALUE__) \
  1811. do { \
  1812. SET_BIT(RCC->CR, RCC_CR_MSIRGSEL); \
  1813. MODIFY_REG(RCC->CR, RCC_CR_MSIRANGE, (__MSIRANGEVALUE__)); \
  1814. } while(0)
  1815. /**
  1816. * @brief Macro configures the Internal Multi Speed oscillator (MSI) clock range after Standby mode
  1817. * After Standby its frequency can be selected between 4 possible values (1, 2, 4 or 8 MHz).
  1818. * @param __MSIRANGEVALUE__: specifies the MSI clock range.
  1819. * This parameter must be one of the following values:
  1820. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1 MHz
  1821. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2MHz
  1822. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4MHz (default after Reset)
  1823. * @arg @ref RCC_MSIRANGE_7 MSI clock is around 8 MHz
  1824. * @retval None
  1825. */
  1826. #define __HAL_RCC_MSI_STANDBY_RANGE_CONFIG(__MSIRANGEVALUE__) \
  1827. MODIFY_REG(RCC->CSR, RCC_CSR_MSISRANGE, (__MSIRANGEVALUE__) << 4U)
  1828. /** @brief Macro to get the Internal Multi Speed oscillator (MSI) clock range in run mode
  1829. * @retval MSI clock range.
  1830. * This parameter must be one of the following values:
  1831. * @arg @ref RCC_MSIRANGE_0 MSI clock is around 100 KHz
  1832. * @arg @ref RCC_MSIRANGE_1 MSI clock is around 200 KHz
  1833. * @arg @ref RCC_MSIRANGE_2 MSI clock is around 400 KHz
  1834. * @arg @ref RCC_MSIRANGE_3 MSI clock is around 800 KHz
  1835. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1 MHz
  1836. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2MHz
  1837. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4MHz (default after Reset)
  1838. * @arg @ref RCC_MSIRANGE_7 MSI clock is around 8 MHz
  1839. * @arg @ref RCC_MSIRANGE_8 MSI clock is around 16 MHz
  1840. * @arg @ref RCC_MSIRANGE_9 MSI clock is around 24 MHz
  1841. * @arg @ref RCC_MSIRANGE_10 MSI clock is around 32 MHz
  1842. * @arg @ref RCC_MSIRANGE_11 MSI clock is around 48 MHz
  1843. */
  1844. #define __HAL_RCC_GET_MSI_RANGE() \
  1845. ((READ_BIT(RCC->CR, RCC_CR_MSIRGSEL) != RESET) ? \
  1846. (uint32_t)(READ_BIT(RCC->CR, RCC_CR_MSIRANGE)) : \
  1847. (uint32_t)(READ_BIT(RCC->CSR, RCC_CSR_MSISRANGE) >> 4))
  1848. /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
  1849. * @note After enabling the LSI, the application software should wait on
  1850. * LSIRDY flag to be set indicating that LSI clock is stable and can
  1851. * be used to clock the IWDG and/or the RTC.
  1852. * @note LSI can not be disabled if the IWDG is running.
  1853. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  1854. * clock cycles.
  1855. * @retval None
  1856. */
  1857. #define __HAL_RCC_LSI_ENABLE() SET_BIT(RCC->CSR, RCC_CSR_LSION)
  1858. #define __HAL_RCC_LSI_DISABLE() CLEAR_BIT(RCC->CSR, RCC_CSR_LSION)
  1859. /**
  1860. * @brief Macro to configure the External High Speed oscillator (HSE).
  1861. * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
  1862. * supported by this macro. User should request a transition to HSE Off
  1863. * first and then HSE On or HSE Bypass.
  1864. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  1865. * software should wait on HSERDY flag to be set indicating that HSE clock
  1866. * is stable and can be used to clock the PLL and/or system clock.
  1867. * @note HSE state can not be changed if it is used directly or through the
  1868. * PLL as system clock. In this case, you have to select another source
  1869. * of the system clock then change the HSE state (ex. disable it).
  1870. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  1871. * @note This function reset the CSSON bit, so if the clock security system(CSS)
  1872. * was previously enabled you have to enable it again after calling this
  1873. * function.
  1874. * @param __STATE__: specifies the new state of the HSE.
  1875. * This parameter can be one of the following values:
  1876. * @arg @ref RCC_HSE_OFF Turn OFF the HSE oscillator, HSERDY flag goes low after
  1877. * 6 HSE oscillator clock cycles.
  1878. * @arg @ref RCC_HSE_ON Turn ON the HSE oscillator.
  1879. * @arg @ref RCC_HSE_BYPASS HSE oscillator bypassed with external clock.
  1880. * @retval None
  1881. */
  1882. #define __HAL_RCC_HSE_CONFIG(__STATE__) \
  1883. do { \
  1884. if((__STATE__) == RCC_HSE_ON) \
  1885. { \
  1886. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  1887. } \
  1888. else if((__STATE__) == RCC_HSE_BYPASS) \
  1889. { \
  1890. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  1891. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  1892. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  1893. } \
  1894. else \
  1895. { \
  1896. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  1897. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  1898. } \
  1899. } while(0)
  1900. /**
  1901. * @brief Macro to configure the External Low Speed oscillator (LSE).
  1902. * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
  1903. * supported by this macro. User should request a transition to LSE Off
  1904. * first and then LSE On or LSE Bypass.
  1905. * @note As the LSE is in the Backup domain and write access is denied to
  1906. * this domain after reset, you have to enable write access using
  1907. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  1908. * (to be done once after reset).
  1909. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  1910. * software should wait on LSERDY flag to be set indicating that LSE clock
  1911. * is stable and can be used to clock the RTC.
  1912. * @param __STATE__: specifies the new state of the LSE.
  1913. * This parameter can be one of the following values:
  1914. * @arg @ref RCC_LSE_OFF Turn OFF the LSE oscillator, LSERDY flag goes low after
  1915. * 6 LSE oscillator clock cycles.
  1916. * @arg @ref RCC_LSE_ON Turn ON the LSE oscillator.
  1917. * @arg @ref RCC_LSE_BYPASS LSE oscillator bypassed with external clock.
  1918. * @retval None
  1919. */
  1920. #define __HAL_RCC_LSE_CONFIG(__STATE__) \
  1921. do { \
  1922. if((__STATE__) == RCC_LSE_ON) \
  1923. { \
  1924. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  1925. } \
  1926. else if((__STATE__) == RCC_LSE_OFF) \
  1927. { \
  1928. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  1929. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  1930. } \
  1931. else if((__STATE__) == RCC_LSE_BYPASS) \
  1932. { \
  1933. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  1934. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  1935. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  1936. } \
  1937. else \
  1938. { \
  1939. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  1940. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  1941. } \
  1942. } while(0)
  1943. /** @brief Macros to configure the RTC clock (RTCCLK).
  1944. * @note As the RTC clock configuration bits are in the Backup domain and write
  1945. * access is denied to this domain after reset, you have to enable write
  1946. * access using the Power Backup Access macro before to configure
  1947. * the RTC clock source (to be done once after reset).
  1948. * @note Once the RTC clock is configured it cannot be changed unless the
  1949. * Backup domain is reset using __HAL_RCC_BACKUPRESET_FORCE() macro, or by
  1950. * a Power On Reset (POR).
  1951. *
  1952. * @param __RTC_CLKSOURCE__: specifies the RTC clock source.
  1953. * This parameter can be one of the following values:
  1954. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  1955. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  1956. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  1957. *
  1958. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  1959. * work in STOP and STANDBY modes, and can be used as wakeup source.
  1960. * However, when the HSE clock is used as RTC clock source, the RTC
  1961. * cannot be used in STOP and STANDBY modes.
  1962. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  1963. * RTC clock source).
  1964. * @retval None
  1965. */
  1966. #define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) \
  1967. MODIFY_REG( RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
  1968. /** @brief Macro to get the RTC clock source.
  1969. * @retval The returned value can be one of the following:
  1970. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  1971. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  1972. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  1973. */
  1974. #define __HAL_RCC_GET_RTC_SOURCE() ((uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL)))
  1975. /** @brief Macros to enable or disable the main PLL.
  1976. * @note After enabling the main PLL, the application software should wait on
  1977. * PLLRDY flag to be set indicating that PLL clock is stable and can
  1978. * be used as system clock source.
  1979. * @note The main PLL can not be disabled if it is used as system clock source
  1980. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  1981. * @retval None
  1982. */
  1983. #define __HAL_RCC_PLL_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLON)
  1984. #define __HAL_RCC_PLL_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLON)
  1985. /** @brief Macro to configure the PLL clock source.
  1986. * @note This function must be used only when the main PLL is disabled.
  1987. * @param __PLLSOURCE__: specifies the PLL entry clock source.
  1988. * This parameter can be one of the following values:
  1989. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  1990. * @arg @ref RCC_PLLSOURCE_MSI MSI oscillator clock selected as PLL clock entry
  1991. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  1992. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  1993. * @note This clock source is common for the main PLL and audio PLL (PLLSAI1 and PLLSAI2).
  1994. * @retval None
  1995. *
  1996. */
  1997. #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) \
  1998. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
  1999. /** @brief Macro to configure the PLL multiplication factor.
  2000. * @note This function must be used only when the main PLL is disabled.
  2001. * @param __PLLM__: specifies the division factor for PLL VCO input clock
  2002. * This parameter must be a number between Min_Data = 1 and Max_Data = 8.
  2003. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  2004. * frequency ranges from 4 to 16 MHz. It is recommended to select a frequency
  2005. * of 16 MHz to limit PLL jitter.
  2006. * @retval None
  2007. *
  2008. */
  2009. #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) \
  2010. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, ((__PLLM__) - 1) << 4U)
  2011. /**
  2012. * @brief Macro to configure the main PLL clock source, multiplication and division factors.
  2013. * @note This function must be used only when the main PLL is disabled.
  2014. *
  2015. * @param __PLLSOURCE__: specifies the PLL entry clock source.
  2016. * This parameter can be one of the following values:
  2017. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  2018. * @arg @ref RCC_PLLSOURCE_MSI MSI oscillator clock selected as PLL clock entry
  2019. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  2020. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  2021. * @note This clock source is common for the main PLL and audio PLL (PLLSAI1 and PLLSAI2).
  2022. *
  2023. * @param __PLLM__: specifies the division factor for PLL VCO input clock.
  2024. * This parameter must be a number between 1 and 8.
  2025. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  2026. * frequency ranges from 4 to 16 MHz. It is recommended to select a frequency
  2027. * of 16 MHz to limit PLL jitter.
  2028. *
  2029. * @param __PLLN__: specifies the multiplication factor for PLL VCO output clock.
  2030. * This parameter must be a number between 8 and 86.
  2031. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  2032. * output frequency is between 64 and 344 MHz.
  2033. *
  2034. * @param __PLLP__: specifies the division factor for SAI clock.
  2035. * This parameter must be a number in the range (7 or 17).
  2036. *
  2037. * @param __PLLQ__: specifies the division factor for OTG FS, SDMMC1 and RNG clocks.
  2038. * This parameter must be in the range (2, 4, 6 or 8).
  2039. * @note If the USB OTG FS is used in your application, you have to set the
  2040. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  2041. * the SDMMC1 and RNG need a frequency lower than or equal to 48 MHz to work
  2042. * correctly.
  2043. * @param __PLLR__: specifies the division factor for the main system clock.
  2044. * @note You have to set the PLLR parameter correctly to not exceed 80MHZ.
  2045. * This parameter must be in the range (2, 4, 6 or 8).
  2046. * @retval None
  2047. */
  2048. #define __HAL_RCC_PLL_CONFIG(__PLLSOURCE__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__,__PLLR__ ) \
  2049. (RCC->PLLCFGR = (uint32_t)(((__PLLM__) - 1U) << 4U) | (uint32_t)((__PLLN__) << 8U) | (uint32_t)(((__PLLP__) >> 4U ) << 17U) | \
  2050. (uint32_t)(__PLLSOURCE__) | (uint32_t)((((__PLLQ__) >> 1U) - 1U) << 21U) | (uint32_t)((((__PLLR__) >> 1U) - 1U) << 25U))
  2051. /** @brief Macro to get the oscillator used as PLL clock source.
  2052. * @retval The oscillator used as PLL clock source. The returned value can be one
  2053. * of the following:
  2054. * - RCC_PLLSOURCE_NONE: No oscillator is used as PLL clock source.
  2055. * - RCC_PLLSOURCE_MSI: MSI oscillator is used as PLL clock source.
  2056. * - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source.
  2057. * - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source.
  2058. */
  2059. #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC))
  2060. /**
  2061. * @brief Enable or disable each clock output (RCC_PLL_SYSCLK, RCC_PLL_48M1CLK, RCC_PLL_SAI3CLK)
  2062. * @note Enabling/disabling clock outputs RCC_PLL_SAI3CLK and RCC_PLL_48M1CLK can be done at anytime
  2063. * without the need to stop the PLL in order to save power. But RCC_PLL_SYSCLK cannot
  2064. * be stopped if used as System Clock.
  2065. * @param __PLLCLOCKOUT__: specifies the PLL clock to be output.
  2066. * This parameter can be one or a combination of the following values:
  2067. * @arg @ref RCC_PLL_SAI3CLK This clock is used to generate an accurate clock to achieve
  2068. * high-quality audio performance on SAI interface in case.
  2069. * @arg @ref RCC_PLL_48M1CLK This Clock is used to generate the clock for the USB OTG FS (48 MHz),
  2070. * the random analog generator (<=48 MHz) and the SDMMC1 (<= 48 MHz).
  2071. * @arg @ref RCC_PLL_SYSCLK This Clock is used to generate the high speed system clock (up to 80MHz)
  2072. * @retval None
  2073. */
  2074. #define __HAL_RCC_PLLCLKOUT_ENABLE(__PLLCLOCKOUT__) SET_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2075. #define __HAL_RCC_PLLCLKOUT_DISABLE(__PLLCLOCKOUT__) CLEAR_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2076. /**
  2077. * @brief Get clock output enable status (RCC_PLL_SYSCLK, RCC_PLL_48M1CLK, RCC_PLL_SAI3CLK)
  2078. * @param __PLLCLOCKOUT__: specifies the output PLL clock to be checked.
  2079. * This parameter can be one of the following values:
  2080. * @arg @ref RCC_PLL_SAI3CLK This clock is used to generate an accurate clock to achieve
  2081. * high-quality audio performance on SAI interface in case.
  2082. * @arg @ref RCC_PLL_48M1CLK This Clock is used to generate the clock for the USB OTG FS (48 MHz),
  2083. * the random analog generator (<=48 MHz) and the SDMMC1 (<= 48 MHz).
  2084. * @arg @ref RCC_PLL_SYSCLK This Clock is used to generate the high speed system clock (up to 80MHz)
  2085. * @retval SET / RESET
  2086. */
  2087. #define __HAL_RCC_GET_PLLCLKOUT_CONFIG(__PLLCLOCKOUT__) READ_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2088. /**
  2089. * @brief Macro to configure the system clock source.
  2090. * @param __SYSCLKSOURCE__: specifies the system clock source.
  2091. * This parameter can be one of the following values:
  2092. * - RCC_SYSCLKSOURCE_MSI: MSI oscillator is used as system clock source.
  2093. * - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
  2094. * - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
  2095. * - RCC_SYSCLKSOURCE_PLLCLK: PLL output is used as system clock source.
  2096. * @retval None
  2097. */
  2098. #define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
  2099. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__SYSCLKSOURCE__))
  2100. /** @brief Macro to get the clock source used as system clock.
  2101. * @retval The clock source used as system clock. The returned value can be one
  2102. * of the following:
  2103. * - RCC_SYSCLKSOURCE_STATUS_MSI: MSI used as system clock.
  2104. * - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
  2105. * - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
  2106. * - RCC_SYSCLKSOURCE_STATUS_PLLCLK: PLL used as system clock.
  2107. */
  2108. #define __HAL_RCC_GET_SYSCLK_SOURCE() ((uint32_t)(RCC->CFGR & RCC_CFGR_SWS))
  2109. /**
  2110. * @brief Macro to configure the External Low Speed oscillator (LSE) drive capability.
  2111. * @note As the LSE is in the Backup domain and write access is denied to
  2112. * this domain after reset, you have to enable write access using
  2113. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  2114. * (to be done once after reset).
  2115. * @param __LSEDRIVE__: specifies the new state of the LSE drive capability.
  2116. * This parameter can be one of the following values:
  2117. * @arg @ref RCC_LSEDRIVE_LOW LSE oscillator low drive capability.
  2118. * @arg @ref RCC_LSEDRIVE_MEDIUMLOW LSE oscillator medium low drive capability.
  2119. * @arg @ref RCC_LSEDRIVE_MEDIUMHIGH LSE oscillator medium high drive capability.
  2120. * @arg @ref RCC_LSEDRIVE_HIGH LSE oscillator high drive capability.
  2121. * @retval None
  2122. */
  2123. #define __HAL_RCC_LSEDRIVE_CONFIG(__LSEDRIVE__) \
  2124. MODIFY_REG(RCC->BDCR, RCC_BDCR_LSEDRV, (uint32_t)(__LSEDRIVE__))
  2125. /**
  2126. * @brief Macro to configure the wake up from stop clock.
  2127. * @param __STOPWUCLK__: specifies the clock source used after wake up from stop.
  2128. * This parameter can be one of the following values:
  2129. * @arg @ref RCC_STOP_WAKEUPCLOCK_MSI MSI selected as system clock source
  2130. * @arg @ref RCC_STOP_WAKEUPCLOCK_HSI HSI selected as system clock source
  2131. * @retval None
  2132. */
  2133. #define __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(__STOPWUCLK__) \
  2134. MODIFY_REG(RCC->CFGR, RCC_CFGR_STOPWUCK, (__STOPWUCLK__))
  2135. /** @brief Macro to configure the MCO clock.
  2136. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  2137. * This parameter can be one of the following values:
  2138. * @arg @ref RCC_MCO1SOURCE_NOCLOCK MCO output disabled
  2139. * @arg @ref RCC_MCO1SOURCE_SYSCLK System clock selected as MCO source
  2140. * @arg @ref RCC_MCO1SOURCE_MSI MSI clock selected as MCO source
  2141. * @arg @ref RCC_MCO1SOURCE_HSI HSI clock selected as MCO source
  2142. * @arg @ref RCC_MCO1SOURCE_HSE HSE clock selected as MCO sourcee
  2143. * @arg @ref RCC_MCO1SOURCE_PLLCLK Main PLL clock selected as MCO source
  2144. * @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO source
  2145. * @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO source
  2146. * @param __MCODIV__ specifies the MCO clock prescaler.
  2147. * This parameter can be one of the following values:
  2148. * @arg @ref RCC_MCODIV_1 MCO clock source is divided by 1
  2149. * @arg @ref RCC_MCODIV_2 MCO clock source is divided by 2
  2150. * @arg @ref RCC_MCODIV_4 MCO clock source is divided by 4
  2151. * @arg @ref RCC_MCODIV_8 MCO clock source is divided by 8
  2152. * @arg @ref RCC_MCODIV_16 MCO clock source is divided by 16
  2153. */
  2154. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  2155. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  2156. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  2157. * @brief macros to manage the specified RCC Flags and interrupts.
  2158. * @{
  2159. */
  2160. /** @brief Enable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to enable
  2161. * the selected interrupts).
  2162. * @param __INTERRUPT__: specifies the RCC interrupt sources to be enabled.
  2163. * This parameter can be any combination of the following values:
  2164. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2165. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2166. * @arg @ref RCC_IT_MSIRDY HSI ready interrupt
  2167. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2168. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2169. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2170. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt
  2171. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt
  2172. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2173. * @retval None
  2174. */
  2175. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) SET_BIT(RCC->CIER, (__INTERRUPT__))
  2176. /** @brief Disable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to disable
  2177. * the selected interrupts).
  2178. * @param __INTERRUPT__: specifies the RCC interrupt sources to be disabled.
  2179. * This parameter can be any combination of the following values:
  2180. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2181. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2182. * @arg @ref RCC_IT_MSIRDY HSI ready interrupt
  2183. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2184. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2185. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2186. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt
  2187. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt
  2188. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2189. * @retval None
  2190. */
  2191. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(RCC->CIER, (__INTERRUPT__))
  2192. /** @brief Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CIR[23:16]
  2193. * bits to clear the selected interrupt pending bits.
  2194. * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
  2195. * This parameter can be any combination of the following values:
  2196. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2197. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2198. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  2199. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2200. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2201. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2202. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt
  2203. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt
  2204. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  2205. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2206. * @retval None
  2207. */
  2208. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (RCC->CICR = (__INTERRUPT__))
  2209. /** @brief Check whether the RCC interrupt has occurred or not.
  2210. * @param __INTERRUPT__: specifies the RCC interrupt source to check.
  2211. * This parameter can be one of the following values:
  2212. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2213. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2214. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  2215. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2216. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2217. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2218. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt
  2219. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt
  2220. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  2221. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2222. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  2223. */
  2224. #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIFR & (__INTERRUPT__)) == (__INTERRUPT__))
  2225. /** @brief Set RMVF bit to clear the reset flags.
  2226. * The reset flags are: RCC_FLAG_FWRRST, RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_BORRST,
  2227. * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
  2228. * @retval None
  2229. */
  2230. #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
  2231. /** @brief Check whether the selected RCC flag is set or not.
  2232. * @param __FLAG__: specifies the flag to check.
  2233. * This parameter can be one of the following values:
  2234. * @arg @ref RCC_FLAG_MSIRDY MSI oscillator clock ready
  2235. * @arg @ref RCC_FLAG_HSIRDY HSI oscillator clock ready
  2236. * @arg @ref RCC_FLAG_HSERDY HSE oscillator clock ready
  2237. * @arg @ref RCC_FLAG_PLLRDY Main PLL clock ready
  2238. * @arg @ref RCC_FLAG_PLLSAI1RDY PLLSAI1 clock ready
  2239. * @arg @ref RCC_FLAG_PLLSAI2RDY PLLSAI2 clock ready
  2240. * @arg @ref RCC_FLAG_LSERDY LSE oscillator clock ready
  2241. * @arg @ref RCC_FLAG_LSECSSD Clock security system failure on LSE oscillator detection
  2242. * @arg @ref RCC_FLAG_LSIRDY LSI oscillator clock ready
  2243. * @arg @ref RCC_FLAG_BORRST BOR reset
  2244. * @arg @ref RCC_FLAG_OBLRST OBLRST reset
  2245. * @arg @ref RCC_FLAG_PINRST Pin reset
  2246. * @arg @ref RCC_FLAG_FWRST FIREWALL reset
  2247. * @arg @ref RCC_FLAG_RMVF Remove reset Flag
  2248. * @arg @ref RCC_FLAG_SFTRST Software reset
  2249. * @arg @ref RCC_FLAG_IWDGRST Independent Watchdog reset
  2250. * @arg @ref RCC_FLAG_WWDGRST Window Watchdog reset
  2251. * @arg @ref RCC_FLAG_LPWRRST Low Power reset
  2252. * @retval The new state of __FLAG__ (TRUE or FALSE).
  2253. */
  2254. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U) ? RCC->CR : \
  2255. ((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR : \
  2256. ((((__FLAG__) >> 5U) == 3U) ? RCC->CSR : RCC->CIFR))) & \
  2257. ((uint32_t)1 << ((__FLAG__) & RCC_FLAG_MASK))) != RESET) \
  2258. ? 1U : 0U)
  2259. /**
  2260. * @}
  2261. */
  2262. /**
  2263. * @}
  2264. */
  2265. /* Private constants ---------------------------------------------------------*/
  2266. /** @defgroup RCC_Private_Constants RCC Private Constants
  2267. * @{
  2268. */
  2269. /* Defines used for Flags */
  2270. #define CR_REG_INDEX ((uint32_t)1U)
  2271. #define BDCR_REG_INDEX ((uint32_t)2U)
  2272. #define CSR_REG_INDEX ((uint32_t)3U)
  2273. #define RCC_FLAG_MASK ((uint32_t)0x1FU)
  2274. /**
  2275. * @}
  2276. */
  2277. /* Private macros ------------------------------------------------------------*/
  2278. /** @addtogroup RCC_Private_Macros
  2279. * @{
  2280. */
  2281. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  2282. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  2283. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  2284. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_MSI) == RCC_OSCILLATORTYPE_MSI) || \
  2285. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  2286. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
  2287. #define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
  2288. ((__HSE__) == RCC_HSE_BYPASS))
  2289. #define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
  2290. ((__LSE__) == RCC_LSE_BYPASS))
  2291. #define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
  2292. #define IS_RCC_HSI_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= (uint32_t)31U)
  2293. #define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
  2294. #define IS_RCC_MSI(__MSI__) (((__MSI__) == RCC_MSI_OFF) || ((__MSI__) == RCC_MSI_ON))
  2295. #define IS_RCC_MSICALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= (uint32_t)255U)
  2296. #define IS_RCC_PLL(__PLL__) (((__PLL__) == RCC_PLL_NONE) ||((__PLL__) == RCC_PLL_OFF) || \
  2297. ((__PLL__) == RCC_PLL_ON))
  2298. #define IS_RCC_PLLSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLSOURCE_NONE) || \
  2299. ((__SOURCE__) == RCC_PLLSOURCE_MSI) || \
  2300. ((__SOURCE__) == RCC_PLLSOURCE_HSI) || \
  2301. ((__SOURCE__) == RCC_PLLSOURCE_HSE))
  2302. #define IS_RCC_PLLM_VALUE(__VALUE__) ((__VALUE__) <= 8U)
  2303. #define IS_RCC_PLLN_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 86U))
  2304. #define IS_RCC_PLLP_VALUE(__VALUE__) (((__VALUE__) == 7U) || ((__VALUE__) == 17U))
  2305. #define IS_RCC_PLLQ_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2306. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2307. #define IS_RCC_PLLR_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2308. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2309. #define IS_RCC_PLLSAI1CLOCKOUT_VALUE(__VALUE__) (((((__VALUE__) & RCC_PLLSAI1_SAI1CLK) == RCC_PLLSAI1_SAI1CLK) || \
  2310. (((__VALUE__) & RCC_PLLSAI1_48M2CLK) == RCC_PLLSAI1_48M2CLK) || \
  2311. (((__VALUE__) & RCC_PLLSAI1_ADC1CLK) == RCC_PLLSAI1_ADC1CLK)) && \
  2312. (((__VALUE__) & ~(RCC_PLLSAI1_SAI1CLK|RCC_PLLSAI1_48M2CLK|RCC_PLLSAI1_ADC1CLK)) == 0U))
  2313. #define IS_RCC_PLLSAI2CLOCKOUT_VALUE(__VALUE__) (((((__VALUE__) & RCC_PLLSAI2_SAI2CLK) == RCC_PLLSAI2_SAI2CLK ) || \
  2314. (((__VALUE__) & RCC_PLLSAI2_ADC2CLK) == RCC_PLLSAI2_ADC2CLK)) && \
  2315. (((__VALUE__) & ~(RCC_PLLSAI2_SAI2CLK|RCC_PLLSAI2_ADC2CLK)) == 0U))
  2316. #define IS_RCC_MSI_CLOCK_RANGE(__RANGE__) (((__RANGE__) == RCC_MSIRANGE_0) || \
  2317. ((__RANGE__) == RCC_MSIRANGE_1) || \
  2318. ((__RANGE__) == RCC_MSIRANGE_2) || \
  2319. ((__RANGE__) == RCC_MSIRANGE_3) || \
  2320. ((__RANGE__) == RCC_MSIRANGE_4) || \
  2321. ((__RANGE__) == RCC_MSIRANGE_5) || \
  2322. ((__RANGE__) == RCC_MSIRANGE_6) || \
  2323. ((__RANGE__) == RCC_MSIRANGE_7) || \
  2324. ((__RANGE__) == RCC_MSIRANGE_8) || \
  2325. ((__RANGE__) == RCC_MSIRANGE_9) || \
  2326. ((__RANGE__) == RCC_MSIRANGE_10) || \
  2327. ((__RANGE__) == RCC_MSIRANGE_11))
  2328. #define IS_RCC_MSI_STANDBY_CLOCK_RANGE(__RANGE__) (((__RANGE__) == RCC_MSIRANGE_4) || \
  2329. ((__RANGE__) == RCC_MSIRANGE_5) || \
  2330. ((__RANGE__) == RCC_MSIRANGE_6) || \
  2331. ((__RANGE__) == RCC_MSIRANGE_7))
  2332. #define IS_RCC_CLOCKTYPE(__CLK__) ((1U <= (__CLK__)) && ((__CLK__) <= 15U))
  2333. #define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_MSI) || \
  2334. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
  2335. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
  2336. ((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
  2337. #define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
  2338. ((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
  2339. ((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
  2340. ((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
  2341. ((__HCLK__) == RCC_SYSCLK_DIV512))
  2342. #define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
  2343. ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
  2344. ((__PCLK__) == RCC_HCLK_DIV16))
  2345. #define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
  2346. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
  2347. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV32))
  2348. #define IS_RCC_MCO(__MCOX__) ((__MCOX__) == RCC_MCO1)
  2349. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
  2350. ((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
  2351. ((__SOURCE__) == RCC_MCO1SOURCE_MSI) || \
  2352. ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
  2353. ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
  2354. ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
  2355. ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
  2356. ((__SOURCE__) == RCC_MCO1SOURCE_LSE))
  2357. #define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1) || ((__DIV__) == RCC_MCODIV_2) || \
  2358. ((__DIV__) == RCC_MCODIV_4) || ((__DIV__) == RCC_MCODIV_8) || \
  2359. ((__DIV__) == RCC_MCODIV_16))
  2360. #define IS_RCC_LSE_DRIVE(__DRIVE__) (((__DRIVE__) == RCC_LSEDRIVE_LOW) || \
  2361. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMLOW) || \
  2362. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMHIGH) || \
  2363. ((__DRIVE__) == RCC_LSEDRIVE_HIGH))
  2364. #define IS_RCC_STOP_WAKEUPCLOCK(__SOURCE__) (((__SOURCE__) == RCC_STOP_WAKEUPCLOCK_MSI) || \
  2365. ((__SOURCE__) == RCC_STOP_WAKEUPCLOCK_HSI))
  2366. /**
  2367. * @}
  2368. */
  2369. /* Include RCC HAL Extended module */
  2370. #include "stm32l4xx_hal_rcc_ex.h"
  2371. /* Exported functions --------------------------------------------------------*/
  2372. /** @addtogroup RCC_Exported_Functions
  2373. * @{
  2374. */
  2375. /** @addtogroup RCC_Exported_Functions_Group1
  2376. * @{
  2377. */
  2378. /* Initialization and de-initialization functions ******************************/
  2379. void HAL_RCC_DeInit(void);
  2380. HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  2381. HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
  2382. /**
  2383. * @}
  2384. */
  2385. /** @addtogroup RCC_Exported_Functions_Group2
  2386. * @{
  2387. */
  2388. /* Peripheral Control functions ************************************************/
  2389. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  2390. void HAL_RCC_EnableCSS(void);
  2391. uint32_t HAL_RCC_GetSysClockFreq(void);
  2392. uint32_t HAL_RCC_GetHCLKFreq(void);
  2393. uint32_t HAL_RCC_GetPCLK1Freq(void);
  2394. uint32_t HAL_RCC_GetPCLK2Freq(void);
  2395. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  2396. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
  2397. /* CSS NMI IRQ handler */
  2398. void HAL_RCC_NMI_IRQHandler(void);
  2399. /* User Callbacks in non blocking mode (IT mode) */
  2400. void HAL_RCC_CSSCallback(void);
  2401. /**
  2402. * @}
  2403. */
  2404. /**
  2405. * @}
  2406. */
  2407. /**
  2408. * @}
  2409. */
  2410. /**
  2411. * @}
  2412. */
  2413. #ifdef __cplusplus
  2414. }
  2415. #endif
  2416. #endif /* __STM32L4xx_HAL_RCC_H */
  2417. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/