No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

7139 líneas
425 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_rcc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL Extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F4xx_HAL_RCC_EX_H
  21. #define __STM32F4xx_HAL_RCC_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f4xx_hal_def.h"
  27. /** @addtogroup STM32F4xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup RCCEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup RCCEx_Exported_Types RCCEx Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief RCC PLL configuration structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t PLLState; /*!< The new state of the PLL.
  43. This parameter can be a value of @ref RCC_PLL_Config */
  44. uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
  45. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  46. uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock.
  47. This parameter must be a number between Min_Data = 0 and Max_Data = 63 */
  48. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock.
  49. This parameter must be a number between Min_Data = 50 and Max_Data = 432
  50. except for STM32F411xE devices where the Min_Data = 192 */
  51. uint32_t PLLP; /*!< PLLP: Division factor for main system clock (SYSCLK).
  52. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  53. uint32_t PLLQ; /*!< PLLQ: Division factor for OTG FS, SDIO and RNG clocks.
  54. This parameter must be a number between Min_Data = 2 and Max_Data = 15 */
  55. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  56. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
  57. defined(STM32F413xx) || defined(STM32F423xx)
  58. uint32_t PLLR; /*!< PLLR: PLL division factor for I2S, SAI, SYSTEM, SPDIFRX clocks.
  59. This parameter is only available in STM32F410xx/STM32F446xx/STM32F469xx/STM32F479xx
  60. and STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/STM32F413xx/STM32F423xx devices.
  61. This parameter must be a number between Min_Data = 2 and Max_Data = 7 */
  62. #endif /* STM32F410xx || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  63. }RCC_PLLInitTypeDef;
  64. #if defined(STM32F446xx)
  65. /**
  66. * @brief PLLI2S Clock structure definition
  67. */
  68. typedef struct
  69. {
  70. uint32_t PLLI2SM; /*!< Specifies division factor for PLL VCO input clock.
  71. This parameter must be a number between Min_Data = 2 and Max_Data = 63 */
  72. uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  73. This parameter must be a number between Min_Data = 50 and Max_Data = 432 */
  74. uint32_t PLLI2SP; /*!< Specifies division factor for SPDIFRX Clock.
  75. This parameter must be a value of @ref RCCEx_PLLI2SP_Clock_Divider */
  76. uint32_t PLLI2SQ; /*!< Specifies the division factor for SAI clock.
  77. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  78. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  79. uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock.
  80. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  81. This parameter will be used only when PLLI2S is selected as Clock Source I2S */
  82. }RCC_PLLI2SInitTypeDef;
  83. /**
  84. * @brief PLLSAI Clock structure definition
  85. */
  86. typedef struct
  87. {
  88. uint32_t PLLSAIM; /*!< Spcifies division factor for PLL VCO input clock.
  89. This parameter must be a number between Min_Data = 2 and Max_Data = 63 */
  90. uint32_t PLLSAIN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  91. This parameter must be a number between Min_Data = 50 and Max_Data = 432 */
  92. uint32_t PLLSAIP; /*!< Specifies division factor for OTG FS, SDIO and RNG clocks.
  93. This parameter must be a value of @ref RCCEx_PLLSAIP_Clock_Divider */
  94. uint32_t PLLSAIQ; /*!< Specifies the division factor for SAI clock.
  95. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  96. This parameter will be used only when PLLSAI is selected as Clock Source SAI */
  97. }RCC_PLLSAIInitTypeDef;
  98. /**
  99. * @brief RCC extended clocks structure definition
  100. */
  101. typedef struct
  102. {
  103. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  104. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  105. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters.
  106. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  107. RCC_PLLSAIInitTypeDef PLLSAI; /*!< PLL SAI structure parameters.
  108. This parameter will be used only when PLLI2S is selected as Clock Source SAI or LTDC */
  109. uint32_t PLLI2SDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  110. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  111. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  112. uint32_t PLLSAIDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  113. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  114. This parameter will be used only when PLLSAI is selected as Clock Source SAI */
  115. uint32_t Sai1ClockSelection; /*!< Specifies SAI1 Clock Source Selection.
  116. This parameter can be a value of @ref RCCEx_SAI1_Clock_Source */
  117. uint32_t Sai2ClockSelection; /*!< Specifies SAI2 Clock Source Selection.
  118. This parameter can be a value of @ref RCCEx_SAI2_Clock_Source */
  119. uint32_t I2sApb1ClockSelection; /*!< Specifies I2S APB1 Clock Source Selection.
  120. This parameter can be a value of @ref RCCEx_I2SAPB1_Clock_Source */
  121. uint32_t I2sApb2ClockSelection; /*!< Specifies I2S APB2 Clock Source Selection.
  122. This parameter can be a value of @ref RCCEx_I2SAPB2_Clock_Source */
  123. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Source Selection.
  124. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  125. uint32_t SdioClockSelection; /*!< Specifies SDIO Clock Source Selection.
  126. This parameter can be a value of @ref RCCEx_SDIO_Clock_Source */
  127. uint32_t CecClockSelection; /*!< Specifies CEC Clock Source Selection.
  128. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  129. uint32_t Fmpi2c1ClockSelection; /*!< Specifies FMPI2C1 Clock Source Selection.
  130. This parameter can be a value of @ref RCCEx_FMPI2C1_Clock_Source */
  131. uint32_t SpdifClockSelection; /*!< Specifies SPDIFRX Clock Source Selection.
  132. This parameter can be a value of @ref RCCEx_SPDIFRX_Clock_Source */
  133. uint32_t Clk48ClockSelection; /*!< Specifies CLK48 Clock Selection this clock used OTG FS, SDIO and RNG clocks.
  134. This parameter can be a value of @ref RCCEx_CLK48_Clock_Source */
  135. uint8_t TIMPresSelection; /*!< Specifies TIM Clock Source Selection.
  136. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */
  137. }RCC_PeriphCLKInitTypeDef;
  138. #endif /* STM32F446xx */
  139. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  140. /**
  141. * @brief RCC extended clocks structure definition
  142. */
  143. typedef struct
  144. {
  145. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  146. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  147. uint32_t I2SClockSelection; /*!< Specifies RTC Clock Source Selection.
  148. This parameter can be a value of @ref RCCEx_I2S_APB_Clock_Source */
  149. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Source Selection.
  150. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  151. uint32_t Lptim1ClockSelection; /*!< Specifies LPTIM1 Clock Source Selection.
  152. This parameter can be a value of @ref RCCEx_LPTIM1_Clock_Source */
  153. uint32_t Fmpi2c1ClockSelection; /*!< Specifies FMPI2C1 Clock Source Selection.
  154. This parameter can be a value of @ref RCCEx_FMPI2C1_Clock_Source */
  155. uint8_t TIMPresSelection; /*!< Specifies TIM Clock Source Selection.
  156. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */
  157. }RCC_PeriphCLKInitTypeDef;
  158. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  159. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  160. /**
  161. * @brief PLLI2S Clock structure definition
  162. */
  163. typedef struct
  164. {
  165. uint32_t PLLI2SM; /*!< Specifies division factor for PLL VCO input clock.
  166. This parameter must be a number between Min_Data = 2 and Max_Data = 63 */
  167. uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  168. This parameter must be a number between Min_Data = 50 and Max_Data = 432 */
  169. uint32_t PLLI2SQ; /*!< Specifies the division factor for SAI clock.
  170. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  171. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  172. uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock.
  173. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  174. This parameter will be used only when PLLI2S is selected as Clock Source I2S */
  175. }RCC_PLLI2SInitTypeDef;
  176. /**
  177. * @brief RCC extended clocks structure definition
  178. */
  179. typedef struct
  180. {
  181. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  182. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  183. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters.
  184. This parameter will be used only when PLLI2S is selected as Clock Source I2S */
  185. #if defined(STM32F413xx) || defined(STM32F423xx)
  186. uint32_t PLLDivR; /*!< Specifies the PLL division factor for SAI1 clock.
  187. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  188. This parameter will be used only when PLL is selected as Clock Source SAI */
  189. uint32_t PLLI2SDivR; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  190. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  191. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  192. #endif /* STM32F413xx || STM32F423xx */
  193. uint32_t I2sApb1ClockSelection; /*!< Specifies I2S APB1 Clock Source Selection.
  194. This parameter can be a value of @ref RCCEx_I2SAPB1_Clock_Source */
  195. uint32_t I2sApb2ClockSelection; /*!< Specifies I2S APB2 Clock Source Selection.
  196. This parameter can be a value of @ref RCCEx_I2SAPB2_Clock_Source */
  197. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Source Selection.
  198. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  199. uint32_t SdioClockSelection; /*!< Specifies SDIO Clock Source Selection.
  200. This parameter can be a value of @ref RCCEx_SDIO_Clock_Source */
  201. uint32_t Fmpi2c1ClockSelection; /*!< Specifies FMPI2C1 Clock Source Selection.
  202. This parameter can be a value of @ref RCCEx_FMPI2C1_Clock_Source */
  203. uint32_t Clk48ClockSelection; /*!< Specifies CLK48 Clock Selection this clock used OTG FS, SDIO and RNG clocks.
  204. This parameter can be a value of @ref RCCEx_CLK48_Clock_Source */
  205. uint32_t Dfsdm1ClockSelection; /*!< Specifies DFSDM1 Clock Selection.
  206. This parameter can be a value of @ref RCCEx_DFSDM1_Kernel_Clock_Source */
  207. uint32_t Dfsdm1AudioClockSelection;/*!< Specifies DFSDM1 Audio Clock Selection.
  208. This parameter can be a value of @ref RCCEx_DFSDM1_Audio_Clock_Source */
  209. #if defined(STM32F413xx) || defined(STM32F423xx)
  210. uint32_t Dfsdm2ClockSelection; /*!< Specifies DFSDM2 Clock Selection.
  211. This parameter can be a value of @ref RCCEx_DFSDM2_Kernel_Clock_Source */
  212. uint32_t Dfsdm2AudioClockSelection;/*!< Specifies DFSDM2 Audio Clock Selection.
  213. This parameter can be a value of @ref RCCEx_DFSDM2_Audio_Clock_Source */
  214. uint32_t Lptim1ClockSelection; /*!< Specifies LPTIM1 Clock Source Selection.
  215. This parameter can be a value of @ref RCCEx_LPTIM1_Clock_Source */
  216. uint32_t SaiAClockSelection; /*!< Specifies SAI1_A Clock Prescalers Selection
  217. This parameter can be a value of @ref RCCEx_SAI1_BlockA_Clock_Source */
  218. uint32_t SaiBClockSelection; /*!< Specifies SAI1_B Clock Prescalers Selection
  219. This parameter can be a value of @ref RCCEx_SAI1_BlockB_Clock_Source */
  220. #endif /* STM32F413xx || STM32F423xx */
  221. uint32_t PLLI2SSelection; /*!< Specifies PLL I2S Clock Source Selection.
  222. This parameter can be a value of @ref RCCEx_PLL_I2S_Clock_Source */
  223. uint8_t TIMPresSelection; /*!< Specifies TIM Clock Source Selection.
  224. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */
  225. }RCC_PeriphCLKInitTypeDef;
  226. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  227. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  228. /**
  229. * @brief PLLI2S Clock structure definition
  230. */
  231. typedef struct
  232. {
  233. uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  234. This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  235. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  236. uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock.
  237. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  238. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  239. uint32_t PLLI2SQ; /*!< Specifies the division factor for SAI1 clock.
  240. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  241. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  242. }RCC_PLLI2SInitTypeDef;
  243. /**
  244. * @brief PLLSAI Clock structure definition
  245. */
  246. typedef struct
  247. {
  248. uint32_t PLLSAIN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  249. This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  250. This parameter will be used only when PLLSAI is selected as Clock Source SAI or LTDC */
  251. #if defined(STM32F469xx) || defined(STM32F479xx)
  252. uint32_t PLLSAIP; /*!< Specifies division factor for OTG FS and SDIO clocks.
  253. This parameter is only available in STM32F469xx/STM32F479xx devices.
  254. This parameter must be a value of @ref RCCEx_PLLSAIP_Clock_Divider */
  255. #endif /* STM32F469xx || STM32F479xx */
  256. uint32_t PLLSAIQ; /*!< Specifies the division factor for SAI1 clock.
  257. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  258. This parameter will be used only when PLLSAI is selected as Clock Source SAI or LTDC */
  259. uint32_t PLLSAIR; /*!< specifies the division factor for LTDC clock
  260. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  261. This parameter will be used only when PLLSAI is selected as Clock Source LTDC */
  262. }RCC_PLLSAIInitTypeDef;
  263. /**
  264. * @brief RCC extended clocks structure definition
  265. */
  266. typedef struct
  267. {
  268. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  269. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  270. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters.
  271. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  272. RCC_PLLSAIInitTypeDef PLLSAI; /*!< PLL SAI structure parameters.
  273. This parameter will be used only when PLLI2S is selected as Clock Source SAI or LTDC */
  274. uint32_t PLLI2SDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  275. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  276. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  277. uint32_t PLLSAIDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  278. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  279. This parameter will be used only when PLLSAI is selected as Clock Source SAI */
  280. uint32_t PLLSAIDivR; /*!< Specifies the PLLSAI division factor for LTDC clock.
  281. This parameter must be one value of @ref RCCEx_PLLSAI_DIVR */
  282. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection.
  283. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  284. uint8_t TIMPresSelection; /*!< Specifies TIM Clock Prescalers Selection.
  285. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */
  286. #if defined(STM32F469xx) || defined(STM32F479xx)
  287. uint32_t Clk48ClockSelection; /*!< Specifies CLK48 Clock Selection this clock used OTG FS, SDIO and RNG clocks.
  288. This parameter can be a value of @ref RCCEx_CLK48_Clock_Source */
  289. uint32_t SdioClockSelection; /*!< Specifies SDIO Clock Source Selection.
  290. This parameter can be a value of @ref RCCEx_SDIO_Clock_Source */
  291. #endif /* STM32F469xx || STM32F479xx */
  292. }RCC_PeriphCLKInitTypeDef;
  293. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  294. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  295. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  296. /**
  297. * @brief PLLI2S Clock structure definition
  298. */
  299. typedef struct
  300. {
  301. #if defined(STM32F411xE)
  302. uint32_t PLLI2SM; /*!< PLLM: Division factor for PLLI2S VCO input clock.
  303. This parameter must be a number between Min_Data = 2 and Max_Data = 62 */
  304. #endif /* STM32F411xE */
  305. uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  306. This parameter must be a number between Min_Data = 50 and Max_Data = 432
  307. Except for STM32F411xE devices where the Min_Data = 192.
  308. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  309. uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock.
  310. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  311. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  312. }RCC_PLLI2SInitTypeDef;
  313. /**
  314. * @brief RCC extended clocks structure definition
  315. */
  316. typedef struct
  317. {
  318. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  319. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  320. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters.
  321. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  322. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection.
  323. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  324. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  325. uint8_t TIMPresSelection; /*!< Specifies TIM Clock Source Selection.
  326. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */
  327. #endif /* STM32F401xC || STM32F401xE || STM32F411xE */
  328. }RCC_PeriphCLKInitTypeDef;
  329. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */
  330. /**
  331. * @}
  332. */
  333. /* Exported constants --------------------------------------------------------*/
  334. /** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
  335. * @{
  336. */
  337. /** @defgroup RCCEx_Periph_Clock_Selection RCC Periph Clock Selection
  338. * @{
  339. */
  340. /* Peripheral Clock source for STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx */
  341. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
  342. defined(STM32F413xx) || defined(STM32F423xx)
  343. #define RCC_PERIPHCLK_I2S_APB1 0x00000001U
  344. #define RCC_PERIPHCLK_I2S_APB2 0x00000002U
  345. #define RCC_PERIPHCLK_TIM 0x00000004U
  346. #define RCC_PERIPHCLK_RTC 0x00000008U
  347. #define RCC_PERIPHCLK_FMPI2C1 0x00000010U
  348. #define RCC_PERIPHCLK_CLK48 0x00000020U
  349. #define RCC_PERIPHCLK_SDIO 0x00000040U
  350. #define RCC_PERIPHCLK_PLLI2S 0x00000080U
  351. #define RCC_PERIPHCLK_DFSDM1 0x00000100U
  352. #define RCC_PERIPHCLK_DFSDM1_AUDIO 0x00000200U
  353. #endif /* STM32F412Zx || STM32F412Vx) || STM32F412Rx || STM32F412Cx */
  354. #if defined(STM32F413xx) || defined(STM32F423xx)
  355. #define RCC_PERIPHCLK_DFSDM2 0x00000400U
  356. #define RCC_PERIPHCLK_DFSDM2_AUDIO 0x00000800U
  357. #define RCC_PERIPHCLK_LPTIM1 0x00001000U
  358. #define RCC_PERIPHCLK_SAIA 0x00002000U
  359. #define RCC_PERIPHCLK_SAIB 0x00004000U
  360. #endif /* STM32F413xx || STM32F423xx */
  361. /*----------------------------------------------------------------------------*/
  362. /*------------------- Peripheral Clock source for STM32F410xx ----------------*/
  363. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  364. #define RCC_PERIPHCLK_I2S 0x00000001U
  365. #define RCC_PERIPHCLK_TIM 0x00000002U
  366. #define RCC_PERIPHCLK_RTC 0x00000004U
  367. #define RCC_PERIPHCLK_FMPI2C1 0x00000008U
  368. #define RCC_PERIPHCLK_LPTIM1 0x00000010U
  369. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  370. /*----------------------------------------------------------------------------*/
  371. /*------------------- Peripheral Clock source for STM32F446xx ----------------*/
  372. #if defined(STM32F446xx)
  373. #define RCC_PERIPHCLK_I2S_APB1 0x00000001U
  374. #define RCC_PERIPHCLK_I2S_APB2 0x00000002U
  375. #define RCC_PERIPHCLK_SAI1 0x00000004U
  376. #define RCC_PERIPHCLK_SAI2 0x00000008U
  377. #define RCC_PERIPHCLK_TIM 0x00000010U
  378. #define RCC_PERIPHCLK_RTC 0x00000020U
  379. #define RCC_PERIPHCLK_CEC 0x00000040U
  380. #define RCC_PERIPHCLK_FMPI2C1 0x00000080U
  381. #define RCC_PERIPHCLK_CLK48 0x00000100U
  382. #define RCC_PERIPHCLK_SDIO 0x00000200U
  383. #define RCC_PERIPHCLK_SPDIFRX 0x00000400U
  384. #define RCC_PERIPHCLK_PLLI2S 0x00000800U
  385. #endif /* STM32F446xx */
  386. /*-----------------------------------------------------------------------------*/
  387. /*----------- Peripheral Clock source for STM32F469xx/STM32F479xx -------------*/
  388. #if defined(STM32F469xx) || defined(STM32F479xx)
  389. #define RCC_PERIPHCLK_I2S 0x00000001U
  390. #define RCC_PERIPHCLK_SAI_PLLI2S 0x00000002U
  391. #define RCC_PERIPHCLK_SAI_PLLSAI 0x00000004U
  392. #define RCC_PERIPHCLK_LTDC 0x00000008U
  393. #define RCC_PERIPHCLK_TIM 0x00000010U
  394. #define RCC_PERIPHCLK_RTC 0x00000020U
  395. #define RCC_PERIPHCLK_PLLI2S 0x00000040U
  396. #define RCC_PERIPHCLK_CLK48 0x00000080U
  397. #define RCC_PERIPHCLK_SDIO 0x00000100U
  398. #endif /* STM32F469xx || STM32F479xx */
  399. /*----------------------------------------------------------------------------*/
  400. /*-------- Peripheral Clock source for STM32F42xxx/STM32F43xxx ---------------*/
  401. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  402. #define RCC_PERIPHCLK_I2S 0x00000001U
  403. #define RCC_PERIPHCLK_SAI_PLLI2S 0x00000002U
  404. #define RCC_PERIPHCLK_SAI_PLLSAI 0x00000004U
  405. #define RCC_PERIPHCLK_LTDC 0x00000008U
  406. #define RCC_PERIPHCLK_TIM 0x00000010U
  407. #define RCC_PERIPHCLK_RTC 0x00000020U
  408. #define RCC_PERIPHCLK_PLLI2S 0x00000040U
  409. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  410. /*----------------------------------------------------------------------------*/
  411. /*-------- Peripheral Clock source for STM32F40xxx/STM32F41xxx ---------------*/
  412. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) ||\
  413. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  414. #define RCC_PERIPHCLK_I2S 0x00000001U
  415. #define RCC_PERIPHCLK_RTC 0x00000002U
  416. #define RCC_PERIPHCLK_PLLI2S 0x00000004U
  417. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */
  418. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  419. #define RCC_PERIPHCLK_TIM 0x00000008U
  420. #endif /* STM32F401xC || STM32F401xE || STM32F411xE */
  421. /*----------------------------------------------------------------------------*/
  422. /**
  423. * @}
  424. */
  425. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  426. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  427. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) || \
  428. defined(STM32F479xx)
  429. /** @defgroup RCCEx_I2S_Clock_Source I2S Clock Source
  430. * @{
  431. */
  432. #define RCC_I2SCLKSOURCE_PLLI2S 0x00000000U
  433. #define RCC_I2SCLKSOURCE_EXT 0x00000001U
  434. /**
  435. * @}
  436. */
  437. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  438. STM32F401xC || STM32F401xE || STM32F411xE || STM32F469xx || STM32F479xx */
  439. /** @defgroup RCCEx_PLLSAI_DIVR RCC PLLSAI DIVR
  440. * @{
  441. */
  442. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) ||\
  443. defined(STM32F469xx) || defined(STM32F479xx)
  444. #define RCC_PLLSAIDIVR_2 0x00000000U
  445. #define RCC_PLLSAIDIVR_4 0x00010000U
  446. #define RCC_PLLSAIDIVR_8 0x00020000U
  447. #define RCC_PLLSAIDIVR_16 0x00030000U
  448. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  449. /**
  450. * @}
  451. */
  452. /** @defgroup RCCEx_PLLI2SP_Clock_Divider RCC PLLI2SP Clock Divider
  453. * @{
  454. */
  455. #if defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  456. defined(STM32F412Rx) || defined(STM32F412Cx)
  457. #define RCC_PLLI2SP_DIV2 0x00000002U
  458. #define RCC_PLLI2SP_DIV4 0x00000004U
  459. #define RCC_PLLI2SP_DIV6 0x00000006U
  460. #define RCC_PLLI2SP_DIV8 0x00000008U
  461. #endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  462. /**
  463. * @}
  464. */
  465. /** @defgroup RCCEx_PLLSAIP_Clock_Divider RCC PLLSAIP Clock Divider
  466. * @{
  467. */
  468. #if defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  469. #define RCC_PLLSAIP_DIV2 0x00000002U
  470. #define RCC_PLLSAIP_DIV4 0x00000004U
  471. #define RCC_PLLSAIP_DIV6 0x00000006U
  472. #define RCC_PLLSAIP_DIV8 0x00000008U
  473. #endif /* STM32F446xx || STM32F469xx || STM32F479xx */
  474. /**
  475. * @}
  476. */
  477. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  478. /** @defgroup RCCEx_SAI_BlockA_Clock_Source RCC SAI BlockA Clock Source
  479. * @{
  480. */
  481. #define RCC_SAIACLKSOURCE_PLLSAI 0x00000000U
  482. #define RCC_SAIACLKSOURCE_PLLI2S 0x00100000U
  483. #define RCC_SAIACLKSOURCE_EXT 0x00200000U
  484. /**
  485. * @}
  486. */
  487. /** @defgroup RCCEx_SAI_BlockB_Clock_Source RCC SAI BlockB Clock Source
  488. * @{
  489. */
  490. #define RCC_SAIBCLKSOURCE_PLLSAI 0x00000000U
  491. #define RCC_SAIBCLKSOURCE_PLLI2S 0x00400000U
  492. #define RCC_SAIBCLKSOURCE_EXT 0x00800000U
  493. /**
  494. * @}
  495. */
  496. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  497. #if defined(STM32F469xx) || defined(STM32F479xx)
  498. /** @defgroup RCCEx_CLK48_Clock_Source RCC CLK48 Clock Source
  499. * @{
  500. */
  501. #define RCC_CLK48CLKSOURCE_PLLQ 0x00000000U
  502. #define RCC_CLK48CLKSOURCE_PLLSAIP ((uint32_t)RCC_DCKCFGR_CK48MSEL)
  503. /**
  504. * @}
  505. */
  506. /** @defgroup RCCEx_SDIO_Clock_Source RCC SDIO Clock Source
  507. * @{
  508. */
  509. #define RCC_SDIOCLKSOURCE_CLK48 0x00000000U
  510. #define RCC_SDIOCLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR_SDIOSEL)
  511. /**
  512. * @}
  513. */
  514. /** @defgroup RCCEx_DSI_Clock_Source RCC DSI Clock Source
  515. * @{
  516. */
  517. #define RCC_DSICLKSOURCE_DSIPHY 0x00000000U
  518. #define RCC_DSICLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_DSISEL)
  519. /**
  520. * @}
  521. */
  522. #endif /* STM32F469xx || STM32F479xx */
  523. #if defined(STM32F446xx)
  524. /** @defgroup RCCEx_SAI1_Clock_Source RCC SAI1 Clock Source
  525. * @{
  526. */
  527. #define RCC_SAI1CLKSOURCE_PLLSAI 0x00000000U
  528. #define RCC_SAI1CLKSOURCE_PLLI2S ((uint32_t)RCC_DCKCFGR_SAI1SRC_0)
  529. #define RCC_SAI1CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_SAI1SRC_1)
  530. #define RCC_SAI1CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_SAI1SRC)
  531. /**
  532. * @}
  533. */
  534. /** @defgroup RCCEx_SAI2_Clock_Source RCC SAI2 Clock Source
  535. * @{
  536. */
  537. #define RCC_SAI2CLKSOURCE_PLLSAI 0x00000000U
  538. #define RCC_SAI2CLKSOURCE_PLLI2S ((uint32_t)RCC_DCKCFGR_SAI2SRC_0)
  539. #define RCC_SAI2CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_SAI2SRC_1)
  540. #define RCC_SAI2CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_SAI2SRC)
  541. /**
  542. * @}
  543. */
  544. /** @defgroup RCCEx_I2SAPB1_Clock_Source RCC I2S APB1 Clock Source
  545. * @{
  546. */
  547. #define RCC_I2SAPB1CLKSOURCE_PLLI2S 0x00000000U
  548. #define RCC_I2SAPB1CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_I2S1SRC_0)
  549. #define RCC_I2SAPB1CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_I2S1SRC_1)
  550. #define RCC_I2SAPB1CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_I2S1SRC)
  551. /**
  552. * @}
  553. */
  554. /** @defgroup RCCEx_I2SAPB2_Clock_Source RCC I2S APB2 Clock Source
  555. * @{
  556. */
  557. #define RCC_I2SAPB2CLKSOURCE_PLLI2S 0x00000000U
  558. #define RCC_I2SAPB2CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_I2S2SRC_0)
  559. #define RCC_I2SAPB2CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_I2S2SRC_1)
  560. #define RCC_I2SAPB2CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_I2S2SRC)
  561. /**
  562. * @}
  563. */
  564. /** @defgroup RCCEx_FMPI2C1_Clock_Source RCC FMPI2C1 Clock Source
  565. * @{
  566. */
  567. #define RCC_FMPI2C1CLKSOURCE_PCLK1 0x00000000U
  568. #define RCC_FMPI2C1CLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_0)
  569. #define RCC_FMPI2C1CLKSOURCE_HSI ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_1)
  570. /**
  571. * @}
  572. */
  573. /** @defgroup RCCEx_CEC_Clock_Source RCC CEC Clock Source
  574. * @{
  575. */
  576. #define RCC_CECCLKSOURCE_HSI 0x00000000U
  577. #define RCC_CECCLKSOURCE_LSE ((uint32_t)RCC_DCKCFGR2_CECSEL)
  578. /**
  579. * @}
  580. */
  581. /** @defgroup RCCEx_CLK48_Clock_Source RCC CLK48 Clock Source
  582. * @{
  583. */
  584. #define RCC_CLK48CLKSOURCE_PLLQ 0x00000000U
  585. #define RCC_CLK48CLKSOURCE_PLLSAIP ((uint32_t)RCC_DCKCFGR2_CK48MSEL)
  586. /**
  587. * @}
  588. */
  589. /** @defgroup RCCEx_SDIO_Clock_Source RCC SDIO Clock Source
  590. * @{
  591. */
  592. #define RCC_SDIOCLKSOURCE_CLK48 0x00000000U
  593. #define RCC_SDIOCLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR2_SDIOSEL)
  594. /**
  595. * @}
  596. */
  597. /** @defgroup RCCEx_SPDIFRX_Clock_Source RCC SPDIFRX Clock Source
  598. * @{
  599. */
  600. #define RCC_SPDIFRXCLKSOURCE_PLLR 0x00000000U
  601. #define RCC_SPDIFRXCLKSOURCE_PLLI2SP ((uint32_t)RCC_DCKCFGR2_SPDIFRXSEL)
  602. /**
  603. * @}
  604. */
  605. #endif /* STM32F446xx */
  606. #if defined(STM32F413xx) || defined(STM32F423xx)
  607. /** @defgroup RCCEx_SAI1_BlockA_Clock_Source RCC SAI BlockA Clock Source
  608. * @{
  609. */
  610. #define RCC_SAIACLKSOURCE_PLLI2SR 0x00000000U
  611. #define RCC_SAIACLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_SAI1ASRC_0)
  612. #define RCC_SAIACLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_SAI1ASRC_1)
  613. #define RCC_SAIACLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_SAI1ASRC_0 | RCC_DCKCFGR_SAI1ASRC_1)
  614. /**
  615. * @}
  616. */
  617. /** @defgroup RCCEx_SAI1_BlockB_Clock_Source RCC SAI BlockB Clock Source
  618. * @{
  619. */
  620. #define RCC_SAIBCLKSOURCE_PLLI2SR 0x00000000U
  621. #define RCC_SAIBCLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_SAI1BSRC_0)
  622. #define RCC_SAIBCLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_SAI1BSRC_1)
  623. #define RCC_SAIBCLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_SAI1BSRC_0 | RCC_DCKCFGR_SAI1BSRC_1)
  624. /**
  625. * @}
  626. */
  627. /** @defgroup RCCEx_LPTIM1_Clock_Source RCC LPTIM1 Clock Source
  628. * @{
  629. */
  630. #define RCC_LPTIM1CLKSOURCE_PCLK1 0x00000000U
  631. #define RCC_LPTIM1CLKSOURCE_HSI ((uint32_t)RCC_DCKCFGR2_LPTIM1SEL_0)
  632. #define RCC_LPTIM1CLKSOURCE_LSI ((uint32_t)RCC_DCKCFGR2_LPTIM1SEL_1)
  633. #define RCC_LPTIM1CLKSOURCE_LSE ((uint32_t)RCC_DCKCFGR2_LPTIM1SEL_0 | RCC_DCKCFGR2_LPTIM1SEL_1)
  634. /**
  635. * @}
  636. */
  637. /** @defgroup RCCEx_DFSDM2_Audio_Clock_Source RCC DFSDM2 Audio Clock Source
  638. * @{
  639. */
  640. #define RCC_DFSDM2AUDIOCLKSOURCE_I2S1 0x00000000U
  641. #define RCC_DFSDM2AUDIOCLKSOURCE_I2S2 ((uint32_t)RCC_DCKCFGR_CKDFSDM2ASEL)
  642. /**
  643. * @}
  644. */
  645. /** @defgroup RCCEx_DFSDM2_Kernel_Clock_Source RCC DFSDM2 Kernel Clock Source
  646. * @{
  647. */
  648. #define RCC_DFSDM2CLKSOURCE_PCLK2 0x00000000U
  649. #define RCC_DFSDM2CLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR_CKDFSDM1SEL)
  650. /**
  651. * @}
  652. */
  653. #endif /* STM32F413xx || STM32F423xx */
  654. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  655. /** @defgroup RCCEx_PLL_I2S_Clock_Source PLL I2S Clock Source
  656. * @{
  657. */
  658. #define RCC_PLLI2SCLKSOURCE_PLLSRC 0x00000000U
  659. #define RCC_PLLI2SCLKSOURCE_EXT ((uint32_t)RCC_PLLI2SCFGR_PLLI2SSRC)
  660. /**
  661. * @}
  662. */
  663. /** @defgroup RCCEx_DFSDM1_Audio_Clock_Source RCC DFSDM1 Audio Clock Source
  664. * @{
  665. */
  666. #define RCC_DFSDM1AUDIOCLKSOURCE_I2S1 0x00000000U
  667. #define RCC_DFSDM1AUDIOCLKSOURCE_I2S2 ((uint32_t)RCC_DCKCFGR_CKDFSDM1ASEL)
  668. /**
  669. * @}
  670. */
  671. /** @defgroup RCCEx_DFSDM1_Kernel_Clock_Source RCC DFSDM1 Kernel Clock Source
  672. * @{
  673. */
  674. #define RCC_DFSDM1CLKSOURCE_PCLK2 0x00000000U
  675. #define RCC_DFSDM1CLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR_CKDFSDM1SEL)
  676. /**
  677. * @}
  678. */
  679. /** @defgroup RCCEx_I2SAPB1_Clock_Source RCC I2S APB1 Clock Source
  680. * @{
  681. */
  682. #define RCC_I2SAPB1CLKSOURCE_PLLI2S 0x00000000U
  683. #define RCC_I2SAPB1CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_I2S1SRC_0)
  684. #define RCC_I2SAPB1CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_I2S1SRC_1)
  685. #define RCC_I2SAPB1CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_I2S1SRC)
  686. /**
  687. * @}
  688. */
  689. /** @defgroup RCCEx_I2SAPB2_Clock_Source RCC I2S APB2 Clock Source
  690. * @{
  691. */
  692. #define RCC_I2SAPB2CLKSOURCE_PLLI2S 0x00000000U
  693. #define RCC_I2SAPB2CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_I2S2SRC_0)
  694. #define RCC_I2SAPB2CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_I2S2SRC_1)
  695. #define RCC_I2SAPB2CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_I2S2SRC)
  696. /**
  697. * @}
  698. */
  699. /** @defgroup RCCEx_FMPI2C1_Clock_Source RCC FMPI2C1 Clock Source
  700. * @{
  701. */
  702. #define RCC_FMPI2C1CLKSOURCE_PCLK1 0x00000000U
  703. #define RCC_FMPI2C1CLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_0)
  704. #define RCC_FMPI2C1CLKSOURCE_HSI ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_1)
  705. /**
  706. * @}
  707. */
  708. /** @defgroup RCCEx_CLK48_Clock_Source RCC CLK48 Clock Source
  709. * @{
  710. */
  711. #define RCC_CLK48CLKSOURCE_PLLQ 0x00000000U
  712. #define RCC_CLK48CLKSOURCE_PLLI2SQ ((uint32_t)RCC_DCKCFGR2_CK48MSEL)
  713. /**
  714. * @}
  715. */
  716. /** @defgroup RCCEx_SDIO_Clock_Source RCC SDIO Clock Source
  717. * @{
  718. */
  719. #define RCC_SDIOCLKSOURCE_CLK48 0x00000000U
  720. #define RCC_SDIOCLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR2_SDIOSEL)
  721. /**
  722. * @}
  723. */
  724. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  725. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  726. /** @defgroup RCCEx_I2S_APB_Clock_Source RCC I2S APB Clock Source
  727. * @{
  728. */
  729. #define RCC_I2SAPBCLKSOURCE_PLLR 0x00000000U
  730. #define RCC_I2SAPBCLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_I2SSRC_0)
  731. #define RCC_I2SAPBCLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_I2SSRC_1)
  732. /**
  733. * @}
  734. */
  735. /** @defgroup RCCEx_FMPI2C1_Clock_Source RCC FMPI2C1 Clock Source
  736. * @{
  737. */
  738. #define RCC_FMPI2C1CLKSOURCE_PCLK1 0x00000000U
  739. #define RCC_FMPI2C1CLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_0)
  740. #define RCC_FMPI2C1CLKSOURCE_HSI ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_1)
  741. /**
  742. * @}
  743. */
  744. /** @defgroup RCCEx_LPTIM1_Clock_Source RCC LPTIM1 Clock Source
  745. * @{
  746. */
  747. #define RCC_LPTIM1CLKSOURCE_PCLK1 0x00000000U
  748. #define RCC_LPTIM1CLKSOURCE_HSI ((uint32_t)RCC_DCKCFGR2_LPTIM1SEL_0)
  749. #define RCC_LPTIM1CLKSOURCE_LSI ((uint32_t)RCC_DCKCFGR2_LPTIM1SEL_1)
  750. #define RCC_LPTIM1CLKSOURCE_LSE ((uint32_t)RCC_DCKCFGR2_LPTIM1SEL_0 | RCC_DCKCFGR2_LPTIM1SEL_1)
  751. /**
  752. * @}
  753. */
  754. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  755. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  756. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  757. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  758. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  759. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  760. /** @defgroup RCCEx_TIM_PRescaler_Selection RCC TIM PRescaler Selection
  761. * @{
  762. */
  763. #define RCC_TIMPRES_DESACTIVATED ((uint8_t)0x00)
  764. #define RCC_TIMPRES_ACTIVATED ((uint8_t)0x01)
  765. /**
  766. * @}
  767. */
  768. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
  769. STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  770. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  771. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) ||\
  772. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) ||\
  773. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
  774. defined(STM32F423xx)
  775. /** @defgroup RCCEx_LSE_Dual_Mode_Selection RCC LSE Dual Mode Selection
  776. * @{
  777. */
  778. #define RCC_LSE_LOWPOWER_MODE ((uint8_t)0x00)
  779. #define RCC_LSE_HIGHDRIVE_MODE ((uint8_t)0x01)
  780. /**
  781. * @}
  782. */
  783. #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx ||\
  784. STM32F412Rx || STM32F412Cx */
  785. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  786. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  787. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
  788. defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  789. defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  790. /** @defgroup RCC_MCO2_Clock_Source MCO2 Clock Source
  791. * @{
  792. */
  793. #define RCC_MCO2SOURCE_SYSCLK 0x00000000U
  794. #define RCC_MCO2SOURCE_PLLI2SCLK RCC_CFGR_MCO2_0
  795. #define RCC_MCO2SOURCE_HSE RCC_CFGR_MCO2_1
  796. #define RCC_MCO2SOURCE_PLLCLK RCC_CFGR_MCO2
  797. /**
  798. * @}
  799. */
  800. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  801. STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx ||
  802. STM32F412Rx || STM32F413xx | STM32F423xx */
  803. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  804. /** @defgroup RCC_MCO2_Clock_Source MCO2 Clock Source
  805. * @{
  806. */
  807. #define RCC_MCO2SOURCE_SYSCLK 0x00000000U
  808. #define RCC_MCO2SOURCE_I2SCLK RCC_CFGR_MCO2_0
  809. #define RCC_MCO2SOURCE_HSE RCC_CFGR_MCO2_1
  810. #define RCC_MCO2SOURCE_PLLCLK RCC_CFGR_MCO2
  811. /**
  812. * @}
  813. */
  814. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  815. /**
  816. * @}
  817. */
  818. /* Exported macro ------------------------------------------------------------*/
  819. /** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
  820. * @{
  821. */
  822. /*------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx --------*/
  823. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  824. /** @defgroup RCCEx_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  825. * @brief Enables or disables the AHB1 peripheral clock.
  826. * @note After reset, the peripheral clock (used for registers read/write access)
  827. * is disabled and the application software has to enable this clock before
  828. * using it.
  829. * @{
  830. */
  831. #define __HAL_RCC_BKPSRAM_CLK_ENABLE() do { \
  832. __IO uint32_t tmpreg = 0x00U; \
  833. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  834. /* Delay after an RCC peripheral clock enabling */ \
  835. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  836. UNUSED(tmpreg); \
  837. } while(0U)
  838. #define __HAL_RCC_CCMDATARAMEN_CLK_ENABLE() do { \
  839. __IO uint32_t tmpreg = 0x00U; \
  840. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  841. /* Delay after an RCC peripheral clock enabling */ \
  842. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  843. UNUSED(tmpreg); \
  844. } while(0U)
  845. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  846. __IO uint32_t tmpreg = 0x00U; \
  847. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  848. /* Delay after an RCC peripheral clock enabling */ \
  849. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  850. UNUSED(tmpreg); \
  851. } while(0U)
  852. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  853. __IO uint32_t tmpreg = 0x00U; \
  854. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  855. /* Delay after an RCC peripheral clock enabling */ \
  856. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  857. UNUSED(tmpreg); \
  858. } while(0U)
  859. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  860. __IO uint32_t tmpreg = 0x00U; \
  861. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  862. /* Delay after an RCC peripheral clock enabling */ \
  863. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  864. UNUSED(tmpreg); \
  865. } while(0U)
  866. #define __HAL_RCC_GPIOI_CLK_ENABLE() do { \
  867. __IO uint32_t tmpreg = 0x00U; \
  868. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  869. /* Delay after an RCC peripheral clock enabling */ \
  870. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  871. UNUSED(tmpreg); \
  872. } while(0U)
  873. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  874. __IO uint32_t tmpreg = 0x00U; \
  875. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  876. /* Delay after an RCC peripheral clock enabling */ \
  877. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  878. UNUSED(tmpreg); \
  879. } while(0U)
  880. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  881. __IO uint32_t tmpreg = 0x00U; \
  882. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  883. /* Delay after an RCC peripheral clock enabling */ \
  884. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  885. UNUSED(tmpreg); \
  886. } while(0U)
  887. #define __HAL_RCC_GPIOJ_CLK_ENABLE() do { \
  888. __IO uint32_t tmpreg = 0x00U; \
  889. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOJEN);\
  890. /* Delay after an RCC peripheral clock enabling */ \
  891. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOJEN);\
  892. UNUSED(tmpreg); \
  893. } while(0U)
  894. #define __HAL_RCC_GPIOK_CLK_ENABLE() do { \
  895. __IO uint32_t tmpreg = 0x00U; \
  896. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOKEN);\
  897. /* Delay after an RCC peripheral clock enabling */ \
  898. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOKEN);\
  899. UNUSED(tmpreg); \
  900. } while(0U)
  901. #define __HAL_RCC_DMA2D_CLK_ENABLE() do { \
  902. __IO uint32_t tmpreg = 0x00U; \
  903. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN);\
  904. /* Delay after an RCC peripheral clock enabling */ \
  905. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN);\
  906. UNUSED(tmpreg); \
  907. } while(0U)
  908. #define __HAL_RCC_ETHMAC_CLK_ENABLE() do { \
  909. __IO uint32_t tmpreg = 0x00U; \
  910. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  911. /* Delay after an RCC peripheral clock enabling */ \
  912. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  913. UNUSED(tmpreg); \
  914. } while(0U)
  915. #define __HAL_RCC_ETHMACTX_CLK_ENABLE() do { \
  916. __IO uint32_t tmpreg = 0x00U; \
  917. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  918. /* Delay after an RCC peripheral clock enabling */ \
  919. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  920. UNUSED(tmpreg); \
  921. } while(0U)
  922. #define __HAL_RCC_ETHMACRX_CLK_ENABLE() do { \
  923. __IO uint32_t tmpreg = 0x00U; \
  924. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  925. /* Delay after an RCC peripheral clock enabling */ \
  926. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  927. UNUSED(tmpreg); \
  928. } while(0U)
  929. #define __HAL_RCC_ETHMACPTP_CLK_ENABLE() do { \
  930. __IO uint32_t tmpreg = 0x00U; \
  931. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  932. /* Delay after an RCC peripheral clock enabling */ \
  933. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  934. UNUSED(tmpreg); \
  935. } while(0U)
  936. #define __HAL_RCC_USB_OTG_HS_CLK_ENABLE() do { \
  937. __IO uint32_t tmpreg = 0x00U; \
  938. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  939. /* Delay after an RCC peripheral clock enabling */ \
  940. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  941. UNUSED(tmpreg); \
  942. } while(0U)
  943. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE() do { \
  944. __IO uint32_t tmpreg = 0x00U; \
  945. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  946. /* Delay after an RCC peripheral clock enabling */ \
  947. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  948. UNUSED(tmpreg); \
  949. } while(0U)
  950. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIODEN))
  951. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOEEN))
  952. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  953. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  954. #define __HAL_RCC_GPIOI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOIEN))
  955. #define __HAL_RCC_GPIOJ_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOJEN))
  956. #define __HAL_RCC_GPIOK_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOKEN))
  957. #define __HAL_RCC_DMA2D_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA2DEN))
  958. #define __HAL_RCC_ETHMAC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACEN))
  959. #define __HAL_RCC_ETHMACTX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACTXEN))
  960. #define __HAL_RCC_ETHMACRX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACRXEN))
  961. #define __HAL_RCC_ETHMACPTP_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACPTPEN))
  962. #define __HAL_RCC_USB_OTG_HS_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSEN))
  963. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSULPIEN))
  964. #define __HAL_RCC_BKPSRAM_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_BKPSRAMEN))
  965. #define __HAL_RCC_CCMDATARAMEN_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CCMDATARAMEN))
  966. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  967. /**
  968. * @brief Enable ETHERNET clock.
  969. */
  970. #define __HAL_RCC_ETH_CLK_ENABLE() do { \
  971. __HAL_RCC_ETHMAC_CLK_ENABLE(); \
  972. __HAL_RCC_ETHMACTX_CLK_ENABLE(); \
  973. __HAL_RCC_ETHMACRX_CLK_ENABLE(); \
  974. } while(0U)
  975. /**
  976. * @brief Disable ETHERNET clock.
  977. */
  978. #define __HAL_RCC_ETH_CLK_DISABLE() do { \
  979. __HAL_RCC_ETHMACTX_CLK_DISABLE(); \
  980. __HAL_RCC_ETHMACRX_CLK_DISABLE(); \
  981. __HAL_RCC_ETHMAC_CLK_DISABLE(); \
  982. } while(0U)
  983. /**
  984. * @}
  985. */
  986. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  987. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  988. * @note After reset, the peripheral clock (used for registers read/write access)
  989. * is disabled and the application software has to enable this clock before
  990. * using it.
  991. * @{
  992. */
  993. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) != RESET)
  994. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) != RESET)
  995. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) != RESET)
  996. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) != RESET)
  997. #define __HAL_RCC_GPIOI_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOIEN)) != RESET)
  998. #define __HAL_RCC_GPIOJ_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOJEN)) != RESET)
  999. #define __HAL_RCC_GPIOK_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOKEN)) != RESET)
  1000. #define __HAL_RCC_DMA2D_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_DMA2DEN)) != RESET)
  1001. #define __HAL_RCC_ETHMAC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACEN)) != RESET)
  1002. #define __HAL_RCC_ETHMACTX_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACTXEN)) != RESET)
  1003. #define __HAL_RCC_ETHMACRX_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACRXEN)) != RESET)
  1004. #define __HAL_RCC_ETHMACPTP_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACPTPEN)) != RESET)
  1005. #define __HAL_RCC_USB_OTG_HS_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSEN)) != RESET)
  1006. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSULPIEN)) != RESET)
  1007. #define __HAL_RCC_BKPSRAM_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_BKPSRAMEN)) != RESET)
  1008. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) != RESET)
  1009. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  1010. #define __HAL_RCC_ETH_IS_CLK_ENABLED() (__HAL_RCC_ETHMAC_IS_CLK_ENABLED() && \
  1011. __HAL_RCC_ETHMACTX_IS_CLK_ENABLED() && \
  1012. __HAL_RCC_ETHMACRX_IS_CLK_ENABLED())
  1013. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) == RESET)
  1014. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) == RESET)
  1015. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) == RESET)
  1016. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) == RESET)
  1017. #define __HAL_RCC_GPIOI_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOIEN)) == RESET)
  1018. #define __HAL_RCC_GPIOJ_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOJEN)) == RESET)
  1019. #define __HAL_RCC_GPIOK_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOKEN)) == RESET)
  1020. #define __HAL_RCC_DMA2D_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_DMA2DEN)) == RESET)
  1021. #define __HAL_RCC_ETHMAC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACEN)) == RESET)
  1022. #define __HAL_RCC_ETHMACTX_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACTXEN)) == RESET)
  1023. #define __HAL_RCC_ETHMACRX_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACRXEN)) == RESET)
  1024. #define __HAL_RCC_ETHMACPTP_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACPTPEN)) == RESET)
  1025. #define __HAL_RCC_USB_OTG_HS_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSEN)) == RESET)
  1026. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSULPIEN)) == RESET)
  1027. #define __HAL_RCC_BKPSRAM_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_BKPSRAMEN)) == RESET)
  1028. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) == RESET)
  1029. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  1030. #define __HAL_RCC_ETH_IS_CLK_DISABLED() (__HAL_RCC_ETHMAC_IS_CLK_DISABLED() && \
  1031. __HAL_RCC_ETHMACTX_IS_CLK_DISABLED() && \
  1032. __HAL_RCC_ETHMACRX_IS_CLK_DISABLED())
  1033. /**
  1034. * @}
  1035. */
  1036. /** @defgroup RCCEx_AHB2_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  1037. * @brief Enable or disable the AHB2 peripheral clock.
  1038. * @note After reset, the peripheral clock (used for registers read/write access)
  1039. * is disabled and the application software has to enable this clock before
  1040. * using it.
  1041. * @{
  1042. */
  1043. #define __HAL_RCC_DCMI_CLK_ENABLE() do { \
  1044. __IO uint32_t tmpreg = 0x00U; \
  1045. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  1046. /* Delay after an RCC peripheral clock enabling */ \
  1047. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  1048. UNUSED(tmpreg); \
  1049. } while(0U)
  1050. #define __HAL_RCC_DCMI_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_DCMIEN))
  1051. #if defined(STM32F437xx)|| defined(STM32F439xx) || defined(STM32F479xx)
  1052. #define __HAL_RCC_CRYP_CLK_ENABLE() do { \
  1053. __IO uint32_t tmpreg = 0x00U; \
  1054. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  1055. /* Delay after an RCC peripheral clock enabling */ \
  1056. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  1057. UNUSED(tmpreg); \
  1058. } while(0U)
  1059. #define __HAL_RCC_HASH_CLK_ENABLE() do { \
  1060. __IO uint32_t tmpreg = 0x00U; \
  1061. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  1062. /* Delay after an RCC peripheral clock enabling */ \
  1063. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  1064. UNUSED(tmpreg); \
  1065. } while(0U)
  1066. #define __HAL_RCC_CRYP_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_CRYPEN))
  1067. #define __HAL_RCC_HASH_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_HASHEN))
  1068. #endif /* STM32F437xx || STM32F439xx || STM32F479xx */
  1069. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do {(RCC->AHB2ENR |= (RCC_AHB2ENR_OTGFSEN));\
  1070. __HAL_RCC_SYSCFG_CLK_ENABLE();\
  1071. }while(0U)
  1072. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_OTGFSEN))
  1073. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  1074. __IO uint32_t tmpreg = 0x00U; \
  1075. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  1076. /* Delay after an RCC peripheral clock enabling */ \
  1077. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  1078. UNUSED(tmpreg); \
  1079. } while(0U)
  1080. #define __HAL_RCC_RNG_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_RNGEN))
  1081. /**
  1082. * @}
  1083. */
  1084. /** @defgroup RCCEx_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enable Disable Status
  1085. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  1086. * @note After reset, the peripheral clock (used for registers read/write access)
  1087. * is disabled and the application software has to enable this clock before
  1088. * using it.
  1089. * @{
  1090. */
  1091. #define __HAL_RCC_DCMI_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_DCMIEN)) != RESET)
  1092. #define __HAL_RCC_DCMI_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_DCMIEN)) == RESET)
  1093. #if defined(STM32F437xx)|| defined(STM32F439xx) || defined(STM32F479xx)
  1094. #define __HAL_RCC_CRYP_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_CRYPEN)) != RESET)
  1095. #define __HAL_RCC_CRYP_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_CRYPEN)) == RESET)
  1096. #define __HAL_RCC_HASH_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_HASHEN)) != RESET)
  1097. #define __HAL_RCC_HASH_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_HASHEN)) == RESET)
  1098. #endif /* STM32F437xx || STM32F439xx || STM32F479xx */
  1099. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) != RESET)
  1100. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) == RESET)
  1101. #define __HAL_RCC_RNG_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) != RESET)
  1102. #define __HAL_RCC_RNG_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) == RESET)
  1103. /**
  1104. * @}
  1105. */
  1106. /** @defgroup RCCEx_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  1107. * @brief Enables or disables the AHB3 peripheral clock.
  1108. * @note After reset, the peripheral clock (used for registers read/write access)
  1109. * is disabled and the application software has to enable this clock before
  1110. * using it.
  1111. * @{
  1112. */
  1113. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  1114. __IO uint32_t tmpreg = 0x00U; \
  1115. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  1116. /* Delay after an RCC peripheral clock enabling */ \
  1117. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  1118. UNUSED(tmpreg); \
  1119. } while(0U)
  1120. #define __HAL_RCC_FMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FMCEN))
  1121. #if defined(STM32F469xx) || defined(STM32F479xx)
  1122. #define __HAL_RCC_QSPI_CLK_ENABLE() do { \
  1123. __IO uint32_t tmpreg = 0x00U; \
  1124. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  1125. /* Delay after an RCC peripheral clock enabling */ \
  1126. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  1127. UNUSED(tmpreg); \
  1128. } while(0U)
  1129. #define __HAL_RCC_QSPI_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_QSPIEN))
  1130. #endif /* STM32F469xx || STM32F479xx */
  1131. /**
  1132. * @}
  1133. */
  1134. /** @defgroup RCCEx_AHB3_Peripheral_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enable Disable Status
  1135. * @brief Get the enable or disable status of the AHB3 peripheral clock.
  1136. * @note After reset, the peripheral clock (used for registers read/write access)
  1137. * is disabled and the application software has to enable this clock before
  1138. * using it.
  1139. * @{
  1140. */
  1141. #define __HAL_RCC_FMC_IS_CLK_ENABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FMCEN)) != RESET)
  1142. #define __HAL_RCC_FMC_IS_CLK_DISABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FMCEN)) == RESET)
  1143. #if defined(STM32F469xx) || defined(STM32F479xx)
  1144. #define __HAL_RCC_QSPI_IS_CLK_ENABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_QSPIEN)) != RESET)
  1145. #define __HAL_RCC_QSPI_IS_CLK_DISABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_QSPIEN)) == RESET)
  1146. #endif /* STM32F469xx || STM32F479xx */
  1147. /**
  1148. * @}
  1149. */
  1150. /** @defgroup RCCEx_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  1151. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  1152. * @note After reset, the peripheral clock (used for registers read/write access)
  1153. * is disabled and the application software has to enable this clock before
  1154. * using it.
  1155. * @{
  1156. */
  1157. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  1158. __IO uint32_t tmpreg = 0x00U; \
  1159. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  1160. /* Delay after an RCC peripheral clock enabling */ \
  1161. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  1162. UNUSED(tmpreg); \
  1163. } while(0U)
  1164. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  1165. __IO uint32_t tmpreg = 0x00U; \
  1166. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  1167. /* Delay after an RCC peripheral clock enabling */ \
  1168. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  1169. UNUSED(tmpreg); \
  1170. } while(0U)
  1171. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  1172. __IO uint32_t tmpreg = 0x00U; \
  1173. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  1174. /* Delay after an RCC peripheral clock enabling */ \
  1175. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  1176. UNUSED(tmpreg); \
  1177. } while(0U)
  1178. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  1179. __IO uint32_t tmpreg = 0x00U; \
  1180. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  1181. /* Delay after an RCC peripheral clock enabling */ \
  1182. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  1183. UNUSED(tmpreg); \
  1184. } while(0U)
  1185. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  1186. __IO uint32_t tmpreg = 0x00U; \
  1187. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1188. /* Delay after an RCC peripheral clock enabling */ \
  1189. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1190. UNUSED(tmpreg); \
  1191. } while(0U)
  1192. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  1193. __IO uint32_t tmpreg = 0x00U; \
  1194. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1195. /* Delay after an RCC peripheral clock enabling */ \
  1196. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1197. UNUSED(tmpreg); \
  1198. } while(0U)
  1199. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  1200. __IO uint32_t tmpreg = 0x00U; \
  1201. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  1202. /* Delay after an RCC peripheral clock enabling */ \
  1203. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  1204. UNUSED(tmpreg); \
  1205. } while(0U)
  1206. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  1207. __IO uint32_t tmpreg = 0x00U; \
  1208. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  1209. /* Delay after an RCC peripheral clock enabling */ \
  1210. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  1211. UNUSED(tmpreg); \
  1212. } while(0U)
  1213. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  1214. __IO uint32_t tmpreg = 0x00U; \
  1215. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  1216. /* Delay after an RCC peripheral clock enabling */ \
  1217. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  1218. UNUSED(tmpreg); \
  1219. } while(0U)
  1220. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  1221. __IO uint32_t tmpreg = 0x00U; \
  1222. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  1223. /* Delay after an RCC peripheral clock enabling */ \
  1224. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  1225. UNUSED(tmpreg); \
  1226. } while(0U)
  1227. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  1228. __IO uint32_t tmpreg = 0x00U; \
  1229. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  1230. /* Delay after an RCC peripheral clock enabling */ \
  1231. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  1232. UNUSED(tmpreg); \
  1233. } while(0U)
  1234. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  1235. __IO uint32_t tmpreg = 0x00U; \
  1236. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  1237. /* Delay after an RCC peripheral clock enabling */ \
  1238. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  1239. UNUSED(tmpreg); \
  1240. } while(0U)
  1241. #define __HAL_RCC_UART7_CLK_ENABLE() do { \
  1242. __IO uint32_t tmpreg = 0x00U; \
  1243. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART7EN);\
  1244. /* Delay after an RCC peripheral clock enabling */ \
  1245. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART7EN);\
  1246. UNUSED(tmpreg); \
  1247. } while(0U)
  1248. #define __HAL_RCC_UART8_CLK_ENABLE() do { \
  1249. __IO uint32_t tmpreg = 0x00U; \
  1250. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART8EN);\
  1251. /* Delay after an RCC peripheral clock enabling */ \
  1252. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART8EN);\
  1253. UNUSED(tmpreg); \
  1254. } while(0U)
  1255. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  1256. __IO uint32_t tmpreg = 0x00U; \
  1257. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  1258. /* Delay after an RCC peripheral clock enabling */ \
  1259. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  1260. UNUSED(tmpreg); \
  1261. } while(0U)
  1262. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  1263. __IO uint32_t tmpreg = 0x00U; \
  1264. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  1265. /* Delay after an RCC peripheral clock enabling */ \
  1266. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  1267. UNUSED(tmpreg); \
  1268. } while(0U)
  1269. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  1270. __IO uint32_t tmpreg = 0x00U; \
  1271. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  1272. /* Delay after an RCC peripheral clock enabling */ \
  1273. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  1274. UNUSED(tmpreg); \
  1275. } while(0U)
  1276. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  1277. __IO uint32_t tmpreg = 0x00U; \
  1278. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  1279. /* Delay after an RCC peripheral clock enabling */ \
  1280. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  1281. UNUSED(tmpreg); \
  1282. } while(0U)
  1283. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  1284. __IO uint32_t tmpreg = 0x00U; \
  1285. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  1286. /* Delay after an RCC peripheral clock enabling */ \
  1287. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  1288. UNUSED(tmpreg); \
  1289. } while(0U)
  1290. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  1291. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  1292. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  1293. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  1294. #define __HAL_RCC_I2C3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C3EN))
  1295. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  1296. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  1297. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  1298. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  1299. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  1300. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  1301. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  1302. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  1303. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  1304. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  1305. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  1306. #define __HAL_RCC_UART7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART7EN))
  1307. #define __HAL_RCC_UART8_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART8EN))
  1308. /**
  1309. * @}
  1310. */
  1311. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  1312. * @brief Get the enable or disable status of the APB1 peripheral clock.
  1313. * @note After reset, the peripheral clock (used for registers read/write access)
  1314. * is disabled and the application software has to enable this clock before
  1315. * using it.
  1316. * @{
  1317. */
  1318. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  1319. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
  1320. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  1321. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  1322. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) != RESET)
  1323. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  1324. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  1325. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) != RESET)
  1326. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) != RESET)
  1327. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) != RESET)
  1328. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
  1329. #define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) != RESET)
  1330. #define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) != RESET)
  1331. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) != RESET)
  1332. #define __HAL_RCC_CAN2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) != RESET)
  1333. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  1334. #define __HAL_RCC_UART7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART7EN)) != RESET)
  1335. #define __HAL_RCC_UART8_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART8EN)) != RESET)
  1336. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  1337. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
  1338. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  1339. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  1340. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) == RESET)
  1341. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  1342. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  1343. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) == RESET)
  1344. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) == RESET)
  1345. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) == RESET)
  1346. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
  1347. #define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) == RESET)
  1348. #define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) == RESET)
  1349. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) == RESET)
  1350. #define __HAL_RCC_CAN2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) == RESET)
  1351. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  1352. #define __HAL_RCC_UART7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART7EN)) == RESET)
  1353. #define __HAL_RCC_UART8_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART8EN)) == RESET)
  1354. /**
  1355. * @}
  1356. */
  1357. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  1358. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  1359. * @note After reset, the peripheral clock (used for registers read/write access)
  1360. * is disabled and the application software has to enable this clock before
  1361. * using it.
  1362. * @{
  1363. */
  1364. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  1365. __IO uint32_t tmpreg = 0x00U; \
  1366. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1367. /* Delay after an RCC peripheral clock enabling */ \
  1368. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1369. UNUSED(tmpreg); \
  1370. } while(0U)
  1371. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  1372. __IO uint32_t tmpreg = 0x00U; \
  1373. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1374. /* Delay after an RCC peripheral clock enabling */ \
  1375. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1376. UNUSED(tmpreg); \
  1377. } while(0U)
  1378. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  1379. __IO uint32_t tmpreg = 0x00U; \
  1380. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1381. /* Delay after an RCC peripheral clock enabling */ \
  1382. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1383. UNUSED(tmpreg); \
  1384. } while(0U)
  1385. #define __HAL_RCC_SPI5_CLK_ENABLE() do { \
  1386. __IO uint32_t tmpreg = 0x00U; \
  1387. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  1388. /* Delay after an RCC peripheral clock enabling */ \
  1389. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  1390. UNUSED(tmpreg); \
  1391. } while(0U)
  1392. #define __HAL_RCC_SPI6_CLK_ENABLE() do { \
  1393. __IO uint32_t tmpreg = 0x00U; \
  1394. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN);\
  1395. /* Delay after an RCC peripheral clock enabling */ \
  1396. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN);\
  1397. UNUSED(tmpreg); \
  1398. } while(0U)
  1399. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  1400. __IO uint32_t tmpreg = 0x00U; \
  1401. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  1402. /* Delay after an RCC peripheral clock enabling */ \
  1403. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  1404. UNUSED(tmpreg); \
  1405. } while(0U)
  1406. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  1407. __IO uint32_t tmpreg = 0x00U; \
  1408. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  1409. /* Delay after an RCC peripheral clock enabling */ \
  1410. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  1411. UNUSED(tmpreg); \
  1412. } while(0U)
  1413. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  1414. __IO uint32_t tmpreg = 0x00U; \
  1415. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  1416. /* Delay after an RCC peripheral clock enabling */ \
  1417. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  1418. UNUSED(tmpreg); \
  1419. } while(0U)
  1420. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  1421. __IO uint32_t tmpreg = 0x00U; \
  1422. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  1423. /* Delay after an RCC peripheral clock enabling */ \
  1424. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  1425. UNUSED(tmpreg); \
  1426. } while(0U)
  1427. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SDIOEN))
  1428. #define __HAL_RCC_SPI4_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI4EN))
  1429. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  1430. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  1431. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  1432. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  1433. #define __HAL_RCC_SPI5_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI5EN))
  1434. #define __HAL_RCC_SPI6_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI6EN))
  1435. #define __HAL_RCC_SAI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SAI1EN))
  1436. #if defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  1437. #define __HAL_RCC_LTDC_CLK_ENABLE() do { \
  1438. __IO uint32_t tmpreg = 0x00U; \
  1439. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_LTDCEN);\
  1440. /* Delay after an RCC peripheral clock enabling */ \
  1441. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_LTDCEN);\
  1442. UNUSED(tmpreg); \
  1443. } while(0U)
  1444. #define __HAL_RCC_LTDC_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_LTDCEN))
  1445. #endif /* STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  1446. #if defined(STM32F469xx) || defined(STM32F479xx)
  1447. #define __HAL_RCC_DSI_CLK_ENABLE() do { \
  1448. __IO uint32_t tmpreg = 0x00U; \
  1449. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_DSIEN);\
  1450. /* Delay after an RCC peripheral clock enabling */ \
  1451. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DSIEN);\
  1452. UNUSED(tmpreg); \
  1453. } while(0U)
  1454. #define __HAL_RCC_DSI_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_DSIEN))
  1455. #endif /* STM32F469xx || STM32F479xx */
  1456. /**
  1457. * @}
  1458. */
  1459. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  1460. * @brief Get the enable or disable status of the APB2 peripheral clock.
  1461. * @note After reset, the peripheral clock (used for registers read/write access)
  1462. * is disabled and the application software has to enable this clock before
  1463. * using it.
  1464. * @{
  1465. */
  1466. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) != RESET)
  1467. #define __HAL_RCC_ADC2_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) != RESET)
  1468. #define __HAL_RCC_ADC3_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) != RESET)
  1469. #define __HAL_RCC_SPI5_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) != RESET)
  1470. #define __HAL_RCC_SPI6_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI6EN)) != RESET)
  1471. #define __HAL_RCC_SAI1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI1EN)) != RESET)
  1472. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) != RESET)
  1473. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) != RESET)
  1474. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN))!= RESET)
  1475. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) == RESET)
  1476. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) == RESET)
  1477. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN))== RESET)
  1478. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) == RESET)
  1479. #define __HAL_RCC_ADC2_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) == RESET)
  1480. #define __HAL_RCC_ADC3_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) == RESET)
  1481. #define __HAL_RCC_SPI5_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) == RESET)
  1482. #define __HAL_RCC_SPI6_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI6EN)) == RESET)
  1483. #define __HAL_RCC_SAI1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI1EN)) == RESET)
  1484. #if defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  1485. #define __HAL_RCC_LTDC_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_LTDCEN)) != RESET)
  1486. #define __HAL_RCC_LTDC_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_LTDCEN)) == RESET)
  1487. #endif /* STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  1488. #if defined(STM32F469xx) || defined(STM32F479xx)
  1489. #define __HAL_RCC_DSI_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_DSIEN)) != RESET)
  1490. #define __HAL_RCC_DSI_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_DSIEN)) == RESET)
  1491. #endif /* STM32F469xx || STM32F479xx */
  1492. /**
  1493. * @}
  1494. */
  1495. /** @defgroup RCCEx_AHB1_Force_Release_Reset AHB1 Force Release Reset
  1496. * @brief Force or release AHB1 peripheral reset.
  1497. * @{
  1498. */
  1499. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIODRST))
  1500. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOERST))
  1501. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  1502. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  1503. #define __HAL_RCC_GPIOI_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOIRST))
  1504. #define __HAL_RCC_ETHMAC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_ETHMACRST))
  1505. #define __HAL_RCC_USB_OTG_HS_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHRST))
  1506. #define __HAL_RCC_GPIOJ_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOJRST))
  1507. #define __HAL_RCC_GPIOK_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOKRST))
  1508. #define __HAL_RCC_DMA2D_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA2DRST))
  1509. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  1510. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST))
  1511. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOERST))
  1512. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  1513. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  1514. #define __HAL_RCC_GPIOI_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOIRST))
  1515. #define __HAL_RCC_ETHMAC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_ETHMACRST))
  1516. #define __HAL_RCC_USB_OTG_HS_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHRST))
  1517. #define __HAL_RCC_GPIOJ_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOJRST))
  1518. #define __HAL_RCC_GPIOK_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOKRST))
  1519. #define __HAL_RCC_DMA2D_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA2DRST))
  1520. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  1521. /**
  1522. * @}
  1523. */
  1524. /** @defgroup RCCEx_AHB2_Force_Release_Reset AHB2 Force Release Reset
  1525. * @brief Force or release AHB2 peripheral reset.
  1526. * @{
  1527. */
  1528. #define __HAL_RCC_AHB2_FORCE_RESET() (RCC->AHB2RSTR = 0xFFFFFFFFU)
  1529. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_OTGFSRST))
  1530. #define __HAL_RCC_RNG_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_RNGRST))
  1531. #define __HAL_RCC_DCMI_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_DCMIRST))
  1532. #define __HAL_RCC_AHB2_RELEASE_RESET() (RCC->AHB2RSTR = 0x00U)
  1533. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_OTGFSRST))
  1534. #define __HAL_RCC_RNG_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_RNGRST))
  1535. #define __HAL_RCC_DCMI_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_DCMIRST))
  1536. #if defined(STM32F437xx)|| defined(STM32F439xx) || defined(STM32F479xx)
  1537. #define __HAL_RCC_CRYP_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_CRYPRST))
  1538. #define __HAL_RCC_HASH_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_HASHRST))
  1539. #define __HAL_RCC_CRYP_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_CRYPRST))
  1540. #define __HAL_RCC_HASH_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_HASHRST))
  1541. #endif /* STM32F437xx || STM32F439xx || STM32F479xx */
  1542. /**
  1543. * @}
  1544. */
  1545. /** @defgroup RCCEx_AHB3_Force_Release_Reset AHB3 Force Release Reset
  1546. * @brief Force or release AHB3 peripheral reset.
  1547. * @{
  1548. */
  1549. #define __HAL_RCC_AHB3_FORCE_RESET() (RCC->AHB3RSTR = 0xFFFFFFFFU)
  1550. #define __HAL_RCC_AHB3_RELEASE_RESET() (RCC->AHB3RSTR = 0x00U)
  1551. #define __HAL_RCC_FMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FMCRST))
  1552. #define __HAL_RCC_FMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FMCRST))
  1553. #if defined(STM32F469xx) || defined(STM32F479xx)
  1554. #define __HAL_RCC_QSPI_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_QSPIRST))
  1555. #define __HAL_RCC_QSPI_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_QSPIRST))
  1556. #endif /* STM32F469xx || STM32F479xx */
  1557. /**
  1558. * @}
  1559. */
  1560. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  1561. * @brief Force or release APB1 peripheral reset.
  1562. * @{
  1563. */
  1564. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  1565. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  1566. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  1567. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  1568. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  1569. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  1570. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  1571. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  1572. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  1573. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  1574. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  1575. #define __HAL_RCC_UART7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART7RST))
  1576. #define __HAL_RCC_UART8_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART8RST))
  1577. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  1578. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  1579. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  1580. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  1581. #define __HAL_RCC_I2C3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C3RST))
  1582. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  1583. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  1584. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  1585. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  1586. #define __HAL_RCC_I2C3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C3RST))
  1587. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  1588. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  1589. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  1590. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  1591. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  1592. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  1593. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  1594. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  1595. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  1596. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  1597. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  1598. #define __HAL_RCC_UART7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART7RST))
  1599. #define __HAL_RCC_UART8_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART8RST))
  1600. /**
  1601. * @}
  1602. */
  1603. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  1604. * @brief Force or release APB2 peripheral reset.
  1605. * @{
  1606. */
  1607. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  1608. #define __HAL_RCC_SPI5_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI5RST))
  1609. #define __HAL_RCC_SPI6_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI6RST))
  1610. #define __HAL_RCC_SAI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SAI1RST))
  1611. #define __HAL_RCC_SDIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SDIORST))
  1612. #define __HAL_RCC_SPI4_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI4RST))
  1613. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  1614. #define __HAL_RCC_SDIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SDIORST))
  1615. #define __HAL_RCC_SPI4_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI4RST))
  1616. #define __HAL_RCC_TIM10_RELEASE_RESET()(RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  1617. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  1618. #define __HAL_RCC_SPI5_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI5RST))
  1619. #define __HAL_RCC_SPI6_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI6RST))
  1620. #define __HAL_RCC_SAI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SAI1RST))
  1621. #if defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  1622. #define __HAL_RCC_LTDC_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_LTDCRST))
  1623. #define __HAL_RCC_LTDC_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_LTDCRST))
  1624. #endif /* STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  1625. #if defined(STM32F469xx) || defined(STM32F479xx)
  1626. #define __HAL_RCC_DSI_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_DSIRST))
  1627. #define __HAL_RCC_DSI_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_DSIRST))
  1628. #endif /* STM32F469xx || STM32F479xx */
  1629. /**
  1630. * @}
  1631. */
  1632. /** @defgroup RCCEx_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  1633. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  1634. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1635. * power consumption.
  1636. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1637. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1638. * @{
  1639. */
  1640. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIODLPEN))
  1641. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOELPEN))
  1642. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  1643. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  1644. #define __HAL_RCC_GPIOI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOILPEN))
  1645. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  1646. #define __HAL_RCC_ETHMAC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACLPEN))
  1647. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACTXLPEN))
  1648. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACRXLPEN))
  1649. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACPTPLPEN))
  1650. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSLPEN))
  1651. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSULPILPEN))
  1652. #define __HAL_RCC_GPIOJ_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOJLPEN))
  1653. #define __HAL_RCC_GPIOK_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOKLPEN))
  1654. #define __HAL_RCC_SRAM3_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM3LPEN))
  1655. #define __HAL_RCC_DMA2D_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA2DLPEN))
  1656. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  1657. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  1658. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  1659. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_BKPSRAMLPEN))
  1660. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIODLPEN))
  1661. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOELPEN))
  1662. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  1663. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  1664. #define __HAL_RCC_GPIOI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOILPEN))
  1665. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  1666. #define __HAL_RCC_ETHMAC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACLPEN))
  1667. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACTXLPEN))
  1668. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACRXLPEN))
  1669. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACPTPLPEN))
  1670. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSLPEN))
  1671. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSULPILPEN))
  1672. #define __HAL_RCC_GPIOJ_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOJLPEN))
  1673. #define __HAL_RCC_GPIOK_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOKLPEN))
  1674. #define __HAL_RCC_DMA2D_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA2DLPEN))
  1675. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  1676. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  1677. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  1678. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_BKPSRAMLPEN))
  1679. /**
  1680. * @}
  1681. */
  1682. /** @defgroup RCCEx_AHB2_LowPower_Enable_Disable AHB2 Peripheral Low Power Enable Disable
  1683. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  1684. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1685. * power consumption.
  1686. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  1687. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1688. * @{
  1689. */
  1690. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_OTGFSLPEN))
  1691. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_OTGFSLPEN))
  1692. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_RNGLPEN))
  1693. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_RNGLPEN))
  1694. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_DCMILPEN))
  1695. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_DCMILPEN))
  1696. #if defined(STM32F437xx)|| defined(STM32F439xx) || defined(STM32F479xx)
  1697. #define __HAL_RCC_CRYP_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_CRYPLPEN))
  1698. #define __HAL_RCC_HASH_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_HASHLPEN))
  1699. #define __HAL_RCC_CRYP_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_CRYPLPEN))
  1700. #define __HAL_RCC_HASH_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_HASHLPEN))
  1701. #endif /* STM32F437xx || STM32F439xx || STM32F479xx */
  1702. /**
  1703. * @}
  1704. */
  1705. /** @defgroup RCCEx_AHB3_LowPower_Enable_Disable AHB3 Peripheral Low Power Enable Disable
  1706. * @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  1707. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1708. * power consumption.
  1709. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1710. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1711. * @{
  1712. */
  1713. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FMCLPEN))
  1714. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FMCLPEN))
  1715. #if defined(STM32F469xx) || defined(STM32F479xx)
  1716. #define __HAL_RCC_QSPI_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_QSPILPEN))
  1717. #define __HAL_RCC_QSPI_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_QSPILPEN))
  1718. #endif /* STM32F469xx || STM32F479xx */
  1719. /**
  1720. * @}
  1721. */
  1722. /** @defgroup RCCEx_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  1723. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  1724. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1725. * power consumption.
  1726. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1727. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1728. * @{
  1729. */
  1730. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  1731. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  1732. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  1733. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  1734. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  1735. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  1736. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  1737. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  1738. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  1739. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  1740. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  1741. #define __HAL_RCC_UART7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART7LPEN))
  1742. #define __HAL_RCC_UART8_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART8LPEN))
  1743. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  1744. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  1745. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  1746. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
  1747. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C3LPEN))
  1748. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  1749. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  1750. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  1751. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
  1752. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C3LPEN))
  1753. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  1754. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  1755. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  1756. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  1757. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  1758. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  1759. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  1760. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  1761. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  1762. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  1763. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  1764. #define __HAL_RCC_UART7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART7LPEN))
  1765. #define __HAL_RCC_UART8_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART8LPEN))
  1766. /**
  1767. * @}
  1768. */
  1769. /** @defgroup RCCEx_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  1770. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1771. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1772. * power consumption.
  1773. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1774. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1775. * @{
  1776. */
  1777. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  1778. #define __HAL_RCC_ADC2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC2LPEN))
  1779. #define __HAL_RCC_ADC3_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC3LPEN))
  1780. #define __HAL_RCC_SPI5_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI5LPEN))
  1781. #define __HAL_RCC_SPI6_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI6LPEN))
  1782. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SAI1LPEN))
  1783. #define __HAL_RCC_SDIO_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SDIOLPEN))
  1784. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI4LPEN))
  1785. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE()(RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  1786. #define __HAL_RCC_SDIO_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SDIOLPEN))
  1787. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI4LPEN))
  1788. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE()(RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  1789. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  1790. #define __HAL_RCC_ADC2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC2LPEN))
  1791. #define __HAL_RCC_ADC3_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC3LPEN))
  1792. #define __HAL_RCC_SPI5_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI5LPEN))
  1793. #define __HAL_RCC_SPI6_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI6LPEN))
  1794. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SAI1LPEN))
  1795. #if defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  1796. #define __HAL_RCC_LTDC_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_LTDCLPEN))
  1797. #define __HAL_RCC_LTDC_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_LTDCLPEN))
  1798. #endif /* STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  1799. #if defined(STM32F469xx) || defined(STM32F479xx)
  1800. #define __HAL_RCC_DSI_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_DSILPEN))
  1801. #define __HAL_RCC_DSI_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_DSILPEN))
  1802. #endif /* STM32F469xx || STM32F479xx */
  1803. /**
  1804. * @}
  1805. */
  1806. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
  1807. /*----------------------------------------------------------------------------*/
  1808. /*----------------------------------- STM32F40xxx/STM32F41xxx-----------------*/
  1809. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)
  1810. /** @defgroup RCCEx_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  1811. * @brief Enables or disables the AHB1 peripheral clock.
  1812. * @note After reset, the peripheral clock (used for registers read/write access)
  1813. * is disabled and the application software has to enable this clock before
  1814. * using it.
  1815. * @{
  1816. */
  1817. #define __HAL_RCC_BKPSRAM_CLK_ENABLE() do { \
  1818. __IO uint32_t tmpreg = 0x00U; \
  1819. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  1820. /* Delay after an RCC peripheral clock enabling */ \
  1821. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  1822. UNUSED(tmpreg); \
  1823. } while(0U)
  1824. #define __HAL_RCC_CCMDATARAMEN_CLK_ENABLE() do { \
  1825. __IO uint32_t tmpreg = 0x00U; \
  1826. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  1827. /* Delay after an RCC peripheral clock enabling */ \
  1828. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  1829. UNUSED(tmpreg); \
  1830. } while(0U)
  1831. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  1832. __IO uint32_t tmpreg = 0x00U; \
  1833. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  1834. /* Delay after an RCC peripheral clock enabling */ \
  1835. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  1836. UNUSED(tmpreg); \
  1837. } while(0U)
  1838. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  1839. __IO uint32_t tmpreg = 0x00U; \
  1840. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  1841. /* Delay after an RCC peripheral clock enabling */ \
  1842. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  1843. UNUSED(tmpreg); \
  1844. } while(0U)
  1845. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  1846. __IO uint32_t tmpreg = 0x00U; \
  1847. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  1848. /* Delay after an RCC peripheral clock enabling */ \
  1849. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  1850. UNUSED(tmpreg); \
  1851. } while(0U)
  1852. #define __HAL_RCC_GPIOI_CLK_ENABLE() do { \
  1853. __IO uint32_t tmpreg = 0x00U; \
  1854. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  1855. /* Delay after an RCC peripheral clock enabling */ \
  1856. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  1857. UNUSED(tmpreg); \
  1858. } while(0U)
  1859. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  1860. __IO uint32_t tmpreg = 0x00U; \
  1861. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  1862. /* Delay after an RCC peripheral clock enabling */ \
  1863. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  1864. UNUSED(tmpreg); \
  1865. } while(0U)
  1866. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  1867. __IO uint32_t tmpreg = 0x00U; \
  1868. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  1869. /* Delay after an RCC peripheral clock enabling */ \
  1870. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  1871. UNUSED(tmpreg); \
  1872. } while(0U)
  1873. #define __HAL_RCC_USB_OTG_HS_CLK_ENABLE() do { \
  1874. __IO uint32_t tmpreg = 0x00U; \
  1875. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  1876. /* Delay after an RCC peripheral clock enabling */ \
  1877. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  1878. UNUSED(tmpreg); \
  1879. } while(0U)
  1880. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE() do { \
  1881. __IO uint32_t tmpreg = 0x00U; \
  1882. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  1883. /* Delay after an RCC peripheral clock enabling */ \
  1884. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  1885. UNUSED(tmpreg); \
  1886. } while(0U)
  1887. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIODEN))
  1888. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOEEN))
  1889. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  1890. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  1891. #define __HAL_RCC_GPIOI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOIEN))
  1892. #define __HAL_RCC_USB_OTG_HS_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSEN))
  1893. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSULPIEN))
  1894. #define __HAL_RCC_BKPSRAM_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_BKPSRAMEN))
  1895. #define __HAL_RCC_CCMDATARAMEN_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CCMDATARAMEN))
  1896. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  1897. #if defined(STM32F407xx)|| defined(STM32F417xx)
  1898. /**
  1899. * @brief Enable ETHERNET clock.
  1900. */
  1901. #define __HAL_RCC_ETHMAC_CLK_ENABLE() do { \
  1902. __IO uint32_t tmpreg = 0x00U; \
  1903. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  1904. /* Delay after an RCC peripheral clock enabling */ \
  1905. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  1906. UNUSED(tmpreg); \
  1907. } while(0U)
  1908. #define __HAL_RCC_ETHMACTX_CLK_ENABLE() do { \
  1909. __IO uint32_t tmpreg = 0x00U; \
  1910. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  1911. /* Delay after an RCC peripheral clock enabling */ \
  1912. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  1913. UNUSED(tmpreg); \
  1914. } while(0U)
  1915. #define __HAL_RCC_ETHMACRX_CLK_ENABLE() do { \
  1916. __IO uint32_t tmpreg = 0x00U; \
  1917. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  1918. /* Delay after an RCC peripheral clock enabling */ \
  1919. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  1920. UNUSED(tmpreg); \
  1921. } while(0U)
  1922. #define __HAL_RCC_ETHMACPTP_CLK_ENABLE() do { \
  1923. __IO uint32_t tmpreg = 0x00U; \
  1924. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  1925. /* Delay after an RCC peripheral clock enabling */ \
  1926. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  1927. UNUSED(tmpreg); \
  1928. } while(0U)
  1929. #define __HAL_RCC_ETH_CLK_ENABLE() do { \
  1930. __HAL_RCC_ETHMAC_CLK_ENABLE(); \
  1931. __HAL_RCC_ETHMACTX_CLK_ENABLE(); \
  1932. __HAL_RCC_ETHMACRX_CLK_ENABLE(); \
  1933. } while(0U)
  1934. /**
  1935. * @brief Disable ETHERNET clock.
  1936. */
  1937. #define __HAL_RCC_ETHMAC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACEN))
  1938. #define __HAL_RCC_ETHMACTX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACTXEN))
  1939. #define __HAL_RCC_ETHMACRX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACRXEN))
  1940. #define __HAL_RCC_ETHMACPTP_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACPTPEN))
  1941. #define __HAL_RCC_ETH_CLK_DISABLE() do { \
  1942. __HAL_RCC_ETHMACTX_CLK_DISABLE(); \
  1943. __HAL_RCC_ETHMACRX_CLK_DISABLE(); \
  1944. __HAL_RCC_ETHMAC_CLK_DISABLE(); \
  1945. } while(0U)
  1946. #endif /* STM32F407xx || STM32F417xx */
  1947. /**
  1948. * @}
  1949. */
  1950. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  1951. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  1952. * @note After reset, the peripheral clock (used for registers read/write access)
  1953. * is disabled and the application software has to enable this clock before
  1954. * using it.
  1955. * @{
  1956. */
  1957. #define __HAL_RCC_BKPSRAM_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_BKPSRAMEN)) != RESET)
  1958. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) != RESET)
  1959. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  1960. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) != RESET)
  1961. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) != RESET)
  1962. #define __HAL_RCC_GPIOI_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOIEN)) != RESET)
  1963. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) != RESET)
  1964. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) != RESET)
  1965. #define __HAL_RCC_USB_OTG_HS_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSEN)) != RESET)
  1966. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSULPIEN)) != RESET)
  1967. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) == RESET)
  1968. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) == RESET)
  1969. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) == RESET)
  1970. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) == RESET)
  1971. #define __HAL_RCC_GPIOI_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOIEN)) == RESET)
  1972. #define __HAL_RCC_USB_OTG_HS_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSEN)) == RESET)
  1973. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSULPIEN))== RESET)
  1974. #define __HAL_RCC_BKPSRAM_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_BKPSRAMEN)) == RESET)
  1975. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) == RESET)
  1976. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  1977. #if defined(STM32F407xx)|| defined(STM32F417xx)
  1978. /**
  1979. * @brief Enable ETHERNET clock.
  1980. */
  1981. #define __HAL_RCC_ETHMAC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACEN)) != RESET)
  1982. #define __HAL_RCC_ETHMACTX_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACTXEN)) != RESET)
  1983. #define __HAL_RCC_ETHMACRX_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACRXEN)) != RESET)
  1984. #define __HAL_RCC_ETHMACPTP_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACPTPEN)) != RESET)
  1985. #define __HAL_RCC_ETH_IS_CLK_ENABLED() (__HAL_RCC_ETHMAC_IS_CLK_ENABLED() && \
  1986. __HAL_RCC_ETHMACTX_IS_CLK_ENABLED() && \
  1987. __HAL_RCC_ETHMACRX_IS_CLK_ENABLED())
  1988. /**
  1989. * @brief Disable ETHERNET clock.
  1990. */
  1991. #define __HAL_RCC_ETHMAC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACEN)) == RESET)
  1992. #define __HAL_RCC_ETHMACTX_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACTXEN)) == RESET)
  1993. #define __HAL_RCC_ETHMACRX_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACRXEN)) == RESET)
  1994. #define __HAL_RCC_ETHMACPTP_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_ETHMACPTPEN)) == RESET)
  1995. #define __HAL_RCC_ETH_IS_CLK_DISABLED() (__HAL_RCC_ETHMAC_IS_CLK_DISABLED() && \
  1996. __HAL_RCC_ETHMACTX_IS_CLK_DISABLED() && \
  1997. __HAL_RCC_ETHMACRX_IS_CLK_DISABLED())
  1998. #endif /* STM32F407xx || STM32F417xx */
  1999. /**
  2000. * @}
  2001. */
  2002. /** @defgroup RCCEx_AHB2_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  2003. * @brief Enable or disable the AHB2 peripheral clock.
  2004. * @note After reset, the peripheral clock (used for registers read/write access)
  2005. * is disabled and the application software has to enable this clock before
  2006. * using it.
  2007. * @{
  2008. */
  2009. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do {(RCC->AHB2ENR |= (RCC_AHB2ENR_OTGFSEN));\
  2010. __HAL_RCC_SYSCFG_CLK_ENABLE();\
  2011. }while(0U)
  2012. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_OTGFSEN))
  2013. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  2014. __IO uint32_t tmpreg = 0x00U; \
  2015. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  2016. /* Delay after an RCC peripheral clock enabling */ \
  2017. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  2018. UNUSED(tmpreg); \
  2019. } while(0U)
  2020. #define __HAL_RCC_RNG_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_RNGEN))
  2021. #if defined(STM32F407xx)|| defined(STM32F417xx)
  2022. #define __HAL_RCC_DCMI_CLK_ENABLE() do { \
  2023. __IO uint32_t tmpreg = 0x00U; \
  2024. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  2025. /* Delay after an RCC peripheral clock enabling */ \
  2026. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  2027. UNUSED(tmpreg); \
  2028. } while(0U)
  2029. #define __HAL_RCC_DCMI_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_DCMIEN))
  2030. #endif /* STM32F407xx || STM32F417xx */
  2031. #if defined(STM32F415xx) || defined(STM32F417xx)
  2032. #define __HAL_RCC_CRYP_CLK_ENABLE() do { \
  2033. __IO uint32_t tmpreg = 0x00U; \
  2034. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  2035. /* Delay after an RCC peripheral clock enabling */ \
  2036. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  2037. UNUSED(tmpreg); \
  2038. } while(0U)
  2039. #define __HAL_RCC_HASH_CLK_ENABLE() do { \
  2040. __IO uint32_t tmpreg = 0x00U; \
  2041. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  2042. /* Delay after an RCC peripheral clock enabling */ \
  2043. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  2044. UNUSED(tmpreg); \
  2045. } while(0U)
  2046. #define __HAL_RCC_CRYP_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_CRYPEN))
  2047. #define __HAL_RCC_HASH_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_HASHEN))
  2048. #endif /* STM32F415xx || STM32F417xx */
  2049. /**
  2050. * @}
  2051. */
  2052. /** @defgroup RCCEx_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enable Disable Status
  2053. * @brief Get the enable or disable status of the AHB2 peripheral clock.
  2054. * @note After reset, the peripheral clock (used for registers read/write access)
  2055. * is disabled and the application software has to enable this clock before
  2056. * using it.
  2057. * @{
  2058. */
  2059. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) != RESET)
  2060. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) == RESET)
  2061. #define __HAL_RCC_RNG_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) != RESET)
  2062. #define __HAL_RCC_RNG_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) == RESET)
  2063. #if defined(STM32F407xx)|| defined(STM32F417xx)
  2064. #define __HAL_RCC_DCMI_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_DCMIEN)) != RESET)
  2065. #define __HAL_RCC_DCMI_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_DCMIEN)) == RESET)
  2066. #endif /* STM32F407xx || STM32F417xx */
  2067. #if defined(STM32F415xx) || defined(STM32F417xx)
  2068. #define __HAL_RCC_CRYP_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_CRYPEN)) != RESET)
  2069. #define __HAL_RCC_HASH_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_HASHEN)) != RESET)
  2070. #define __HAL_RCC_CRYP_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_CRYPEN)) == RESET)
  2071. #define __HAL_RCC_HASH_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_HASHEN)) == RESET)
  2072. #endif /* STM32F415xx || STM32F417xx */
  2073. /**
  2074. * @}
  2075. */
  2076. /** @defgroup RCCEx_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  2077. * @brief Enables or disables the AHB3 peripheral clock.
  2078. * @note After reset, the peripheral clock (used for registers read/write access)
  2079. * is disabled and the application software has to enable this clock before
  2080. * using it.
  2081. * @{
  2082. */
  2083. #define __HAL_RCC_FSMC_CLK_ENABLE() do { \
  2084. __IO uint32_t tmpreg = 0x00U; \
  2085. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  2086. /* Delay after an RCC peripheral clock enabling */ \
  2087. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  2088. UNUSED(tmpreg); \
  2089. } while(0U)
  2090. #define __HAL_RCC_FSMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FSMCEN))
  2091. /**
  2092. * @}
  2093. */
  2094. /** @defgroup RCCEx_AHB3_Peripheral_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enable Disable Status
  2095. * @brief Get the enable or disable status of the AHB3 peripheral clock.
  2096. * @note After reset, the peripheral clock (used for registers read/write access)
  2097. * is disabled and the application software has to enable this clock before
  2098. * using it.
  2099. * @{
  2100. */
  2101. #define __HAL_RCC_FSMC_IS_CLK_ENABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FSMCEN)) != RESET)
  2102. #define __HAL_RCC_FSMC_IS_CLK_DISABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FSMCEN)) == RESET)
  2103. /**
  2104. * @}
  2105. */
  2106. /** @defgroup RCCEx_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  2107. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  2108. * @note After reset, the peripheral clock (used for registers read/write access)
  2109. * is disabled and the application software has to enable this clock before
  2110. * using it.
  2111. * @{
  2112. */
  2113. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  2114. __IO uint32_t tmpreg = 0x00U; \
  2115. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  2116. /* Delay after an RCC peripheral clock enabling */ \
  2117. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  2118. UNUSED(tmpreg); \
  2119. } while(0U)
  2120. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  2121. __IO uint32_t tmpreg = 0x00U; \
  2122. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  2123. /* Delay after an RCC peripheral clock enabling */ \
  2124. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  2125. UNUSED(tmpreg); \
  2126. } while(0U)
  2127. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  2128. __IO uint32_t tmpreg = 0x00U; \
  2129. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  2130. /* Delay after an RCC peripheral clock enabling */ \
  2131. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  2132. UNUSED(tmpreg); \
  2133. } while(0U)
  2134. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  2135. __IO uint32_t tmpreg = 0x00U; \
  2136. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  2137. /* Delay after an RCC peripheral clock enabling */ \
  2138. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  2139. UNUSED(tmpreg); \
  2140. } while(0U)
  2141. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  2142. __IO uint32_t tmpreg = 0x00U; \
  2143. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  2144. /* Delay after an RCC peripheral clock enabling */ \
  2145. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  2146. UNUSED(tmpreg); \
  2147. } while(0U)
  2148. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  2149. __IO uint32_t tmpreg = 0x00U; \
  2150. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  2151. /* Delay after an RCC peripheral clock enabling */ \
  2152. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  2153. UNUSED(tmpreg); \
  2154. } while(0U)
  2155. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  2156. __IO uint32_t tmpreg = 0x00U; \
  2157. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  2158. /* Delay after an RCC peripheral clock enabling */ \
  2159. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  2160. UNUSED(tmpreg); \
  2161. } while(0U)
  2162. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  2163. __IO uint32_t tmpreg = 0x00U; \
  2164. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  2165. /* Delay after an RCC peripheral clock enabling */ \
  2166. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  2167. UNUSED(tmpreg); \
  2168. } while(0U)
  2169. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  2170. __IO uint32_t tmpreg = 0x00U; \
  2171. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  2172. /* Delay after an RCC peripheral clock enabling */ \
  2173. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  2174. UNUSED(tmpreg); \
  2175. } while(0U)
  2176. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  2177. __IO uint32_t tmpreg = 0x00U; \
  2178. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  2179. /* Delay after an RCC peripheral clock enabling */ \
  2180. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  2181. UNUSED(tmpreg); \
  2182. } while(0U)
  2183. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  2184. __IO uint32_t tmpreg = 0x00U; \
  2185. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  2186. /* Delay after an RCC peripheral clock enabling */ \
  2187. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  2188. UNUSED(tmpreg); \
  2189. } while(0U)
  2190. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  2191. __IO uint32_t tmpreg = 0x00U; \
  2192. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  2193. /* Delay after an RCC peripheral clock enabling */ \
  2194. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  2195. UNUSED(tmpreg); \
  2196. } while(0U)
  2197. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  2198. __IO uint32_t tmpreg = 0x00U; \
  2199. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  2200. /* Delay after an RCC peripheral clock enabling */ \
  2201. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  2202. UNUSED(tmpreg); \
  2203. } while(0U)
  2204. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  2205. __IO uint32_t tmpreg = 0x00U; \
  2206. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  2207. /* Delay after an RCC peripheral clock enabling */ \
  2208. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  2209. UNUSED(tmpreg); \
  2210. } while(0U)
  2211. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  2212. __IO uint32_t tmpreg = 0x00U; \
  2213. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  2214. /* Delay after an RCC peripheral clock enabling */ \
  2215. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  2216. UNUSED(tmpreg); \
  2217. } while(0U)
  2218. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  2219. __IO uint32_t tmpreg = 0x00U; \
  2220. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  2221. /* Delay after an RCC peripheral clock enabling */ \
  2222. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  2223. UNUSED(tmpreg); \
  2224. } while(0U)
  2225. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  2226. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  2227. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  2228. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  2229. #define __HAL_RCC_I2C3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C3EN))
  2230. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  2231. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  2232. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  2233. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  2234. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  2235. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  2236. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  2237. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  2238. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  2239. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  2240. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  2241. /**
  2242. * @}
  2243. */
  2244. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  2245. * @brief Get the enable or disable status of the APB1 peripheral clock.
  2246. * @note After reset, the peripheral clock (used for registers read/write access)
  2247. * is disabled and the application software has to enable this clock before
  2248. * using it.
  2249. * @{
  2250. */
  2251. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  2252. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
  2253. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  2254. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  2255. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) != RESET)
  2256. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  2257. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  2258. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) != RESET)
  2259. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) != RESET)
  2260. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) != RESET)
  2261. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
  2262. #define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) != RESET)
  2263. #define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) != RESET)
  2264. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) != RESET)
  2265. #define __HAL_RCC_CAN2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) != RESET)
  2266. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  2267. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  2268. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
  2269. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  2270. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  2271. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) == RESET)
  2272. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  2273. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  2274. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) == RESET)
  2275. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) == RESET)
  2276. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) == RESET)
  2277. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
  2278. #define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) == RESET)
  2279. #define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) == RESET)
  2280. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) == RESET)
  2281. #define __HAL_RCC_CAN2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) == RESET)
  2282. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  2283. /**
  2284. * @}
  2285. */
  2286. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  2287. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  2288. * @note After reset, the peripheral clock (used for registers read/write access)
  2289. * is disabled and the application software has to enable this clock before
  2290. * using it.
  2291. * @{
  2292. */
  2293. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  2294. __IO uint32_t tmpreg = 0x00U; \
  2295. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  2296. /* Delay after an RCC peripheral clock enabling */ \
  2297. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  2298. UNUSED(tmpreg); \
  2299. } while(0U)
  2300. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  2301. __IO uint32_t tmpreg = 0x00U; \
  2302. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  2303. /* Delay after an RCC peripheral clock enabling */ \
  2304. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  2305. UNUSED(tmpreg); \
  2306. } while(0U)
  2307. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  2308. __IO uint32_t tmpreg = 0x00U; \
  2309. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  2310. /* Delay after an RCC peripheral clock enabling */ \
  2311. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  2312. UNUSED(tmpreg); \
  2313. } while(0U)
  2314. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  2315. __IO uint32_t tmpreg = 0x00U; \
  2316. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  2317. /* Delay after an RCC peripheral clock enabling */ \
  2318. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  2319. UNUSED(tmpreg); \
  2320. } while(0U)
  2321. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  2322. __IO uint32_t tmpreg = 0x00U; \
  2323. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  2324. /* Delay after an RCC peripheral clock enabling */ \
  2325. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  2326. UNUSED(tmpreg); \
  2327. } while(0U)
  2328. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  2329. __IO uint32_t tmpreg = 0x00U; \
  2330. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  2331. /* Delay after an RCC peripheral clock enabling */ \
  2332. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  2333. UNUSED(tmpreg); \
  2334. } while(0U)
  2335. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SDIOEN))
  2336. #define __HAL_RCC_SPI4_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI4EN))
  2337. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  2338. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  2339. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  2340. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  2341. /**
  2342. * @}
  2343. */
  2344. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  2345. * @brief Get the enable or disable status of the APB2 peripheral clock.
  2346. * @note After reset, the peripheral clock (used for registers read/write access)
  2347. * is disabled and the application software has to enable this clock before
  2348. * using it.
  2349. * @{
  2350. */
  2351. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) != RESET)
  2352. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) != RESET)
  2353. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) != RESET)
  2354. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) != RESET)
  2355. #define __HAL_RCC_ADC2_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) != RESET)
  2356. #define __HAL_RCC_ADC3_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) != RESET)
  2357. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) == RESET)
  2358. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) == RESET)
  2359. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) == RESET)
  2360. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) == RESET)
  2361. #define __HAL_RCC_ADC2_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) == RESET)
  2362. #define __HAL_RCC_ADC3_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) == RESET)
  2363. /**
  2364. * @}
  2365. */
  2366. /** @defgroup RCCEx_AHB1_Force_Release_Reset AHB1 Force Release Reset
  2367. * @brief Force or release AHB1 peripheral reset.
  2368. * @{
  2369. */
  2370. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIODRST))
  2371. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOERST))
  2372. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  2373. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  2374. #define __HAL_RCC_GPIOI_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOIRST))
  2375. #define __HAL_RCC_ETHMAC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_ETHMACRST))
  2376. #define __HAL_RCC_USB_OTG_HS_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHRST))
  2377. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  2378. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST))
  2379. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOERST))
  2380. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  2381. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  2382. #define __HAL_RCC_GPIOI_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOIRST))
  2383. #define __HAL_RCC_ETHMAC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_ETHMACRST))
  2384. #define __HAL_RCC_USB_OTG_HS_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHRST))
  2385. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  2386. /**
  2387. * @}
  2388. */
  2389. /** @defgroup RCCEx_AHB2_Force_Release_Reset AHB2 Force Release Reset
  2390. * @brief Force or release AHB2 peripheral reset.
  2391. * @{
  2392. */
  2393. #define __HAL_RCC_AHB2_FORCE_RESET() (RCC->AHB2RSTR = 0xFFFFFFFFU)
  2394. #define __HAL_RCC_AHB2_RELEASE_RESET() (RCC->AHB2RSTR = 0x00U)
  2395. #if defined(STM32F407xx)|| defined(STM32F417xx)
  2396. #define __HAL_RCC_DCMI_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_DCMIRST))
  2397. #define __HAL_RCC_DCMI_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_DCMIRST))
  2398. #endif /* STM32F407xx || STM32F417xx */
  2399. #if defined(STM32F415xx) || defined(STM32F417xx)
  2400. #define __HAL_RCC_CRYP_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_CRYPRST))
  2401. #define __HAL_RCC_HASH_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_HASHRST))
  2402. #define __HAL_RCC_CRYP_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_CRYPRST))
  2403. #define __HAL_RCC_HASH_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_HASHRST))
  2404. #endif /* STM32F415xx || STM32F417xx */
  2405. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_OTGFSRST))
  2406. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_OTGFSRST))
  2407. #define __HAL_RCC_RNG_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_RNGRST))
  2408. #define __HAL_RCC_RNG_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_RNGRST))
  2409. /**
  2410. * @}
  2411. */
  2412. /** @defgroup RCCEx_AHB3_Force_Release_Reset AHB3 Force Release Reset
  2413. * @brief Force or release AHB3 peripheral reset.
  2414. * @{
  2415. */
  2416. #define __HAL_RCC_AHB3_FORCE_RESET() (RCC->AHB3RSTR = 0xFFFFFFFFU)
  2417. #define __HAL_RCC_AHB3_RELEASE_RESET() (RCC->AHB3RSTR = 0x00U)
  2418. #define __HAL_RCC_FSMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FSMCRST))
  2419. #define __HAL_RCC_FSMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FSMCRST))
  2420. /**
  2421. * @}
  2422. */
  2423. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  2424. * @brief Force or release APB1 peripheral reset.
  2425. * @{
  2426. */
  2427. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  2428. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  2429. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  2430. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  2431. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  2432. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  2433. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  2434. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  2435. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  2436. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  2437. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  2438. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  2439. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  2440. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  2441. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  2442. #define __HAL_RCC_I2C3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C3RST))
  2443. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  2444. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  2445. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  2446. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  2447. #define __HAL_RCC_I2C3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C3RST))
  2448. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  2449. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  2450. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  2451. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  2452. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  2453. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  2454. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  2455. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  2456. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  2457. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  2458. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  2459. /**
  2460. * @}
  2461. */
  2462. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  2463. * @brief Force or release APB2 peripheral reset.
  2464. * @{
  2465. */
  2466. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  2467. #define __HAL_RCC_SDIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SDIORST))
  2468. #define __HAL_RCC_SPI4_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI4RST))
  2469. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  2470. #define __HAL_RCC_SDIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SDIORST))
  2471. #define __HAL_RCC_SPI4_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI4RST))
  2472. #define __HAL_RCC_TIM10_RELEASE_RESET()(RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  2473. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  2474. /**
  2475. * @}
  2476. */
  2477. /** @defgroup RCCEx_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  2478. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  2479. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2480. * power consumption.
  2481. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2482. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2483. * @{
  2484. */
  2485. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIODLPEN))
  2486. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOELPEN))
  2487. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  2488. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  2489. #define __HAL_RCC_GPIOI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOILPEN))
  2490. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  2491. #define __HAL_RCC_ETHMAC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACLPEN))
  2492. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACTXLPEN))
  2493. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACRXLPEN))
  2494. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACPTPLPEN))
  2495. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSLPEN))
  2496. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSULPILPEN))
  2497. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  2498. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  2499. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  2500. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_BKPSRAMLPEN))
  2501. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIODLPEN))
  2502. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOELPEN))
  2503. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  2504. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  2505. #define __HAL_RCC_GPIOI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOILPEN))
  2506. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  2507. #define __HAL_RCC_ETHMAC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACLPEN))
  2508. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACTXLPEN))
  2509. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACRXLPEN))
  2510. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACPTPLPEN))
  2511. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSLPEN))
  2512. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSULPILPEN))
  2513. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  2514. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  2515. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  2516. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_BKPSRAMLPEN))
  2517. /**
  2518. * @}
  2519. */
  2520. /** @defgroup RCCEx_AHB2_LowPower_Enable_Disable AHB2 Peripheral Low Power Enable Disable
  2521. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  2522. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2523. * power consumption.
  2524. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  2525. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2526. * @{
  2527. */
  2528. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_OTGFSLPEN))
  2529. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_OTGFSLPEN))
  2530. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_RNGLPEN))
  2531. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_RNGLPEN))
  2532. #if defined(STM32F407xx)|| defined(STM32F417xx)
  2533. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_DCMILPEN))
  2534. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_DCMILPEN))
  2535. #endif /* STM32F407xx || STM32F417xx */
  2536. #if defined(STM32F415xx) || defined(STM32F417xx)
  2537. #define __HAL_RCC_CRYP_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_CRYPLPEN))
  2538. #define __HAL_RCC_HASH_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_HASHLPEN))
  2539. #define __HAL_RCC_CRYP_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_CRYPLPEN))
  2540. #define __HAL_RCC_HASH_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_HASHLPEN))
  2541. #endif /* STM32F415xx || STM32F417xx */
  2542. /**
  2543. * @}
  2544. */
  2545. /** @defgroup RCCEx_AHB3_LowPower_Enable_Disable AHB3 Peripheral Low Power Enable Disable
  2546. * @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  2547. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2548. * power consumption.
  2549. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2550. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2551. * @{
  2552. */
  2553. #define __HAL_RCC_FSMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FSMCLPEN))
  2554. #define __HAL_RCC_FSMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FSMCLPEN))
  2555. /**
  2556. * @}
  2557. */
  2558. /** @defgroup RCCEx_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  2559. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  2560. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2561. * power consumption.
  2562. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2563. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2564. * @{
  2565. */
  2566. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  2567. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  2568. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  2569. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  2570. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  2571. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  2572. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  2573. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  2574. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  2575. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  2576. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  2577. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  2578. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  2579. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  2580. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
  2581. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C3LPEN))
  2582. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  2583. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  2584. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  2585. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
  2586. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C3LPEN))
  2587. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  2588. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  2589. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  2590. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  2591. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  2592. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  2593. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  2594. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  2595. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  2596. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  2597. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  2598. /**
  2599. * @}
  2600. */
  2601. /** @defgroup RCCEx_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  2602. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  2603. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2604. * power consumption.
  2605. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2606. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2607. * @{
  2608. */
  2609. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  2610. #define __HAL_RCC_ADC2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC2LPEN))
  2611. #define __HAL_RCC_ADC3_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC3LPEN))
  2612. #define __HAL_RCC_SDIO_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SDIOLPEN))
  2613. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI4LPEN))
  2614. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE()(RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  2615. #define __HAL_RCC_SDIO_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SDIOLPEN))
  2616. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI4LPEN))
  2617. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE()(RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  2618. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  2619. #define __HAL_RCC_ADC2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC2LPEN))
  2620. #define __HAL_RCC_ADC3_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC3LPEN))
  2621. /**
  2622. * @}
  2623. */
  2624. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  2625. /*----------------------------------------------------------------------------*/
  2626. /*------------------------- STM32F401xE/STM32F401xC --------------------------*/
  2627. #if defined(STM32F401xC) || defined(STM32F401xE)
  2628. /** @defgroup RCCEx_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  2629. * @brief Enable or disable the AHB1 peripheral clock.
  2630. * @note After reset, the peripheral clock (used for registers read/write access)
  2631. * is disabled and the application software has to enable this clock before
  2632. * using it.
  2633. * @{
  2634. */
  2635. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  2636. __IO uint32_t tmpreg = 0x00U; \
  2637. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  2638. /* Delay after an RCC peripheral clock enabling */ \
  2639. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  2640. UNUSED(tmpreg); \
  2641. } while(0U)
  2642. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  2643. __IO uint32_t tmpreg = 0x00U; \
  2644. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  2645. /* Delay after an RCC peripheral clock enabling */ \
  2646. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  2647. UNUSED(tmpreg); \
  2648. } while(0U)
  2649. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  2650. __IO uint32_t tmpreg = 0x00U; \
  2651. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  2652. /* Delay after an RCC peripheral clock enabling */ \
  2653. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  2654. UNUSED(tmpreg); \
  2655. } while(0U)
  2656. #define __HAL_RCC_CCMDATARAMEN_CLK_ENABLE() do { \
  2657. __IO uint32_t tmpreg = 0x00U; \
  2658. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  2659. /* Delay after an RCC peripheral clock enabling */ \
  2660. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  2661. UNUSED(tmpreg); \
  2662. } while(0U)
  2663. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIODEN))
  2664. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOEEN))
  2665. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  2666. #define __HAL_RCC_CCMDATARAMEN_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CCMDATARAMEN))
  2667. /**
  2668. * @}
  2669. */
  2670. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  2671. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  2672. * @note After reset, the peripheral clock (used for registers read/write access)
  2673. * is disabled and the application software has to enable this clock before
  2674. * using it.
  2675. * @{
  2676. */
  2677. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) != RESET)
  2678. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) != RESET)
  2679. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  2680. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) != RESET)
  2681. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) == RESET)
  2682. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) == RESET)
  2683. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  2684. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) == RESET)
  2685. /**
  2686. * @}
  2687. */
  2688. /** @defgroup RCCEx_AHB2_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  2689. * @brief Enable or disable the AHB2 peripheral clock.
  2690. * @note After reset, the peripheral clock (used for registers read/write access)
  2691. * is disabled and the application software has to enable this clock before
  2692. * using it.
  2693. * @{
  2694. */
  2695. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do {(RCC->AHB2ENR |= (RCC_AHB2ENR_OTGFSEN));\
  2696. __HAL_RCC_SYSCFG_CLK_ENABLE();\
  2697. }while(0U)
  2698. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_OTGFSEN))
  2699. /**
  2700. * @}
  2701. */
  2702. /** @defgroup RCCEx_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enable Disable Status
  2703. * @brief Get the enable or disable status of the AHB2 peripheral clock.
  2704. * @note After reset, the peripheral clock (used for registers read/write access)
  2705. * is disabled and the application software has to enable this clock before
  2706. * using it.
  2707. * @{
  2708. */
  2709. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) != RESET)
  2710. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) == RESET)
  2711. /**
  2712. * @}
  2713. */
  2714. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  2715. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  2716. * @note After reset, the peripheral clock (used for registers read/write access)
  2717. * is disabled and the application software has to enable this clock before
  2718. * using it.
  2719. * @{
  2720. */
  2721. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  2722. __IO uint32_t tmpreg = 0x00U; \
  2723. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  2724. /* Delay after an RCC peripheral clock enabling */ \
  2725. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  2726. UNUSED(tmpreg); \
  2727. } while(0U)
  2728. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  2729. __IO uint32_t tmpreg = 0x00U; \
  2730. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  2731. /* Delay after an RCC peripheral clock enabling */ \
  2732. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  2733. UNUSED(tmpreg); \
  2734. } while(0U)
  2735. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  2736. __IO uint32_t tmpreg = 0x00U; \
  2737. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  2738. /* Delay after an RCC peripheral clock enabling */ \
  2739. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  2740. UNUSED(tmpreg); \
  2741. } while(0U)
  2742. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  2743. __IO uint32_t tmpreg = 0x00U; \
  2744. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  2745. /* Delay after an RCC peripheral clock enabling */ \
  2746. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  2747. UNUSED(tmpreg); \
  2748. } while(0U)
  2749. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  2750. __IO uint32_t tmpreg = 0x00U; \
  2751. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  2752. /* Delay after an RCC peripheral clock enabling */ \
  2753. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  2754. UNUSED(tmpreg); \
  2755. } while(0U)
  2756. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  2757. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  2758. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  2759. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  2760. #define __HAL_RCC_I2C3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C3EN))
  2761. /**
  2762. * @}
  2763. */
  2764. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  2765. * @brief Get the enable or disable status of the APB1 peripheral clock.
  2766. * @note After reset, the peripheral clock (used for registers read/write access)
  2767. * is disabled and the application software has to enable this clock before
  2768. * using it.
  2769. * @{
  2770. */
  2771. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  2772. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
  2773. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  2774. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  2775. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) != RESET)
  2776. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  2777. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
  2778. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  2779. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  2780. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) == RESET)
  2781. /**
  2782. * @}
  2783. */
  2784. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  2785. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  2786. * @note After reset, the peripheral clock (used for registers read/write access)
  2787. * is disabled and the application software has to enable this clock before
  2788. * using it.
  2789. * @{
  2790. */
  2791. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  2792. __IO uint32_t tmpreg = 0x00U; \
  2793. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  2794. /* Delay after an RCC peripheral clock enabling */ \
  2795. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  2796. UNUSED(tmpreg); \
  2797. } while(0U)
  2798. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  2799. __IO uint32_t tmpreg = 0x00U; \
  2800. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  2801. /* Delay after an RCC peripheral clock enabling */ \
  2802. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  2803. UNUSED(tmpreg); \
  2804. } while(0U)
  2805. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  2806. __IO uint32_t tmpreg = 0x00U; \
  2807. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  2808. /* Delay after an RCC peripheral clock enabling */ \
  2809. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  2810. UNUSED(tmpreg); \
  2811. } while(0U)
  2812. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SDIOEN))
  2813. #define __HAL_RCC_SPI4_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI4EN))
  2814. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  2815. /**
  2816. * @}
  2817. */
  2818. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  2819. * @brief Get the enable or disable status of the APB2 peripheral clock.
  2820. * @note After reset, the peripheral clock (used for registers read/write access)
  2821. * is disabled and the application software has to enable this clock before
  2822. * using it.
  2823. * @{
  2824. */
  2825. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) != RESET)
  2826. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) != RESET)
  2827. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) != RESET)
  2828. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) == RESET)
  2829. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) == RESET)
  2830. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) == RESET)
  2831. /**
  2832. * @}
  2833. */
  2834. /** @defgroup RCCEx_AHB1_Force_Release_Reset AHB1 Force Release Reset
  2835. * @brief Force or release AHB1 peripheral reset.
  2836. * @{
  2837. */
  2838. #define __HAL_RCC_AHB1_FORCE_RESET() (RCC->AHB1RSTR = 0xFFFFFFFFU)
  2839. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIODRST))
  2840. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOERST))
  2841. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  2842. #define __HAL_RCC_AHB1_RELEASE_RESET() (RCC->AHB1RSTR = 0x00U)
  2843. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST))
  2844. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOERST))
  2845. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  2846. /**
  2847. * @}
  2848. */
  2849. /** @defgroup RCCEx_AHB2_Force_Release_Reset AHB2 Force Release Reset
  2850. * @brief Force or release AHB2 peripheral reset.
  2851. * @{
  2852. */
  2853. #define __HAL_RCC_AHB2_FORCE_RESET() (RCC->AHB2RSTR = 0xFFFFFFFFU)
  2854. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_OTGFSRST))
  2855. #define __HAL_RCC_AHB2_RELEASE_RESET() (RCC->AHB2RSTR = 0x00U)
  2856. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_OTGFSRST))
  2857. /**
  2858. * @}
  2859. */
  2860. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  2861. * @brief Force or release APB1 peripheral reset.
  2862. * @{
  2863. */
  2864. #define __HAL_RCC_APB1_FORCE_RESET() (RCC->APB1RSTR = 0xFFFFFFFFU)
  2865. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  2866. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  2867. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  2868. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  2869. #define __HAL_RCC_I2C3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C3RST))
  2870. #define __HAL_RCC_APB1_RELEASE_RESET() (RCC->APB1RSTR = 0x00U)
  2871. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  2872. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  2873. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  2874. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  2875. #define __HAL_RCC_I2C3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C3RST))
  2876. /**
  2877. * @}
  2878. */
  2879. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  2880. * @brief Force or release APB2 peripheral reset.
  2881. * @{
  2882. */
  2883. #define __HAL_RCC_APB2_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFFU)
  2884. #define __HAL_RCC_SDIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SDIORST))
  2885. #define __HAL_RCC_SPI4_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI4RST))
  2886. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  2887. #define __HAL_RCC_APB2_RELEASE_RESET() (RCC->APB2RSTR = 0x00U)
  2888. #define __HAL_RCC_SDIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SDIORST))
  2889. #define __HAL_RCC_SPI4_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI4RST))
  2890. #define __HAL_RCC_TIM10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  2891. /**
  2892. * @}
  2893. */
  2894. /** @defgroup RCCEx_AHB3_Force_Release_Reset AHB3 Force Release Reset
  2895. * @brief Force or release AHB3 peripheral reset.
  2896. * @{
  2897. */
  2898. #define __HAL_RCC_AHB3_FORCE_RESET() (RCC->AHB3RSTR = 0xFFFFFFFFU)
  2899. #define __HAL_RCC_AHB3_RELEASE_RESET() (RCC->AHB3RSTR = 0x00U)
  2900. /**
  2901. * @}
  2902. */
  2903. /** @defgroup RCCEx_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  2904. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  2905. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2906. * power consumption.
  2907. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  2908. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2909. * @{
  2910. */
  2911. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIODLPEN))
  2912. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOELPEN))
  2913. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  2914. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  2915. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  2916. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIODLPEN))
  2917. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOELPEN))
  2918. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  2919. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  2920. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  2921. /**
  2922. * @}
  2923. */
  2924. /** @defgroup RCCEx_AHB2_LowPower_Enable_Disable AHB2 Peripheral Low Power Enable Disable
  2925. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  2926. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2927. * power consumption.
  2928. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  2929. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2930. * @{
  2931. */
  2932. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_OTGFSLPEN))
  2933. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_OTGFSLPEN))
  2934. /**
  2935. * @}
  2936. */
  2937. /** @defgroup RCCEx_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  2938. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  2939. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2940. * power consumption.
  2941. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  2942. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2943. * @{
  2944. */
  2945. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  2946. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  2947. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  2948. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
  2949. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C3LPEN))
  2950. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  2951. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  2952. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  2953. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
  2954. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C3LPEN))
  2955. /**
  2956. * @}
  2957. */
  2958. /** @defgroup RCCEx_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  2959. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  2960. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2961. * power consumption.
  2962. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  2963. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2964. * @{
  2965. */
  2966. #define __HAL_RCC_SDIO_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SDIOLPEN))
  2967. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI4LPEN))
  2968. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  2969. #define __HAL_RCC_SDIO_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SDIOLPEN))
  2970. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI4LPEN))
  2971. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  2972. /**
  2973. * @}
  2974. */
  2975. #endif /* STM32F401xC || STM32F401xE*/
  2976. /*----------------------------------------------------------------------------*/
  2977. /*-------------------------------- STM32F410xx -------------------------------*/
  2978. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  2979. /** @defgroup RCCEx_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  2980. * @brief Enables or disables the AHB1 peripheral clock.
  2981. * @note After reset, the peripheral clock (used for registers read/write access)
  2982. * is disabled and the application software has to enable this clock before
  2983. * using it.
  2984. * @{
  2985. */
  2986. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  2987. __IO uint32_t tmpreg = 0x00U; \
  2988. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  2989. /* Delay after an RCC peripheral clock enabling */ \
  2990. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  2991. UNUSED(tmpreg); \
  2992. } while(0U)
  2993. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  2994. __IO uint32_t tmpreg = 0x00U; \
  2995. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_RNGEN);\
  2996. /* Delay after an RCC peripheral clock enabling */ \
  2997. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_RNGEN);\
  2998. UNUSED(tmpreg); \
  2999. } while(0U)
  3000. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  3001. #define __HAL_RCC_RNG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_RNGEN))
  3002. /**
  3003. * @}
  3004. */
  3005. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  3006. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  3007. * @note After reset, the peripheral clock (used for registers read/write access)
  3008. * is disabled and the application software has to enable this clock before
  3009. * using it.
  3010. * @{
  3011. */
  3012. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  3013. #define __HAL_RCC_RNG_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_RNGEN)) != RESET)
  3014. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  3015. #define __HAL_RCC_RNG_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_RNGEN)) == RESET)
  3016. /**
  3017. * @}
  3018. */
  3019. /** @defgroup RCCEx_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  3020. * @brief Enable or disable the High Speed APB (APB1) peripheral clock.
  3021. * @{
  3022. */
  3023. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  3024. __IO uint32_t tmpreg = 0x00U; \
  3025. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  3026. /* Delay after an RCC peripheral clock enabling */ \
  3027. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  3028. UNUSED(tmpreg); \
  3029. } while(0U)
  3030. #define __HAL_RCC_LPTIM1_CLK_ENABLE() do { \
  3031. __IO uint32_t tmpreg = 0x00U; \
  3032. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_LPTIM1EN);\
  3033. /* Delay after an RCC peripheral clock enabling */ \
  3034. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_LPTIM1EN);\
  3035. UNUSED(tmpreg); \
  3036. } while(0U)
  3037. #define __HAL_RCC_RTCAPB_CLK_ENABLE() do { \
  3038. __IO uint32_t tmpreg = 0x00U; \
  3039. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_RTCAPBEN);\
  3040. /* Delay after an RCC peripheral clock enabling */ \
  3041. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_RTCAPBEN);\
  3042. UNUSED(tmpreg); \
  3043. } while(0U)
  3044. #define __HAL_RCC_FMPI2C1_CLK_ENABLE() do { \
  3045. __IO uint32_t tmpreg = 0x00U; \
  3046. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  3047. /* Delay after an RCC peripheral clock enabling */ \
  3048. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  3049. UNUSED(tmpreg); \
  3050. } while(0U)
  3051. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  3052. __IO uint32_t tmpreg = 0x00U; \
  3053. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  3054. /* Delay after an RCC peripheral clock enabling */ \
  3055. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  3056. UNUSED(tmpreg); \
  3057. } while(0U)
  3058. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  3059. #define __HAL_RCC_RTCAPB_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_RTCAPBEN))
  3060. #define __HAL_RCC_LPTIM1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_LPTIM1EN))
  3061. #define __HAL_RCC_FMPI2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_FMPI2C1EN))
  3062. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  3063. /**
  3064. * @}
  3065. */
  3066. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  3067. * @brief Get the enable or disable status of the APB1 peripheral clock.
  3068. * @note After reset, the peripheral clock (used for registers read/write access)
  3069. * is disabled and the application software has to enable this clock before
  3070. * using it.
  3071. * @{
  3072. */
  3073. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  3074. #define __HAL_RCC_RTCAPB_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_RTCAPBEN)) != RESET)
  3075. #define __HAL_RCC_LPTIM1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_LPTIM1EN)) != RESET)
  3076. #define __HAL_RCC_FMPI2C1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_FMPI2C1EN)) != RESET)
  3077. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  3078. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  3079. #define __HAL_RCC_RTCAPB_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_RTCAPBEN)) == RESET)
  3080. #define __HAL_RCC_LPTIM1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_LPTIM1EN)) == RESET)
  3081. #define __HAL_RCC_FMPI2C1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_FMPI2C1EN)) == RESET)
  3082. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  3083. /**
  3084. * @}
  3085. */
  3086. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  3087. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  3088. * @{
  3089. */
  3090. #define __HAL_RCC_SPI5_CLK_ENABLE() do { \
  3091. __IO uint32_t tmpreg = 0x00U; \
  3092. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  3093. /* Delay after an RCC peripheral clock enabling */ \
  3094. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  3095. UNUSED(tmpreg); \
  3096. } while(0U)
  3097. #define __HAL_RCC_EXTIT_CLK_ENABLE() do { \
  3098. __IO uint32_t tmpreg = 0x00U; \
  3099. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_EXTITEN);\
  3100. /* Delay after an RCC peripheral clock enabling */ \
  3101. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_EXTITEN);\
  3102. UNUSED(tmpreg); \
  3103. } while(0U)
  3104. #define __HAL_RCC_SPI5_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI5EN))
  3105. #define __HAL_RCC_EXTIT_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_EXTITEN))
  3106. /**
  3107. * @}
  3108. */
  3109. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  3110. * @brief Get the enable or disable status of the APB2 peripheral clock.
  3111. * @note After reset, the peripheral clock (used for registers read/write access)
  3112. * is disabled and the application software has to enable this clock before
  3113. * using it.
  3114. * @{
  3115. */
  3116. #define __HAL_RCC_SPI5_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) != RESET)
  3117. #define __HAL_RCC_EXTIT_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_EXTITEN)) != RESET)
  3118. #define __HAL_RCC_SPI5_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) == RESET)
  3119. #define __HAL_RCC_EXTIT_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_EXTITEN)) == RESET)
  3120. /**
  3121. * @}
  3122. */
  3123. /** @defgroup RCCEx_AHB1_Force_Release_Reset AHB1 Force Release Reset
  3124. * @brief Force or release AHB1 peripheral reset.
  3125. * @{
  3126. */
  3127. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  3128. #define __HAL_RCC_RNG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_RNGRST))
  3129. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  3130. #define __HAL_RCC_RNG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_RNGRST))
  3131. /**
  3132. * @}
  3133. */
  3134. /** @defgroup RCCEx_AHB2_Force_Release_Reset AHB2 Force Release Reset
  3135. * @brief Force or release AHB2 peripheral reset.
  3136. * @{
  3137. */
  3138. #define __HAL_RCC_AHB2_FORCE_RESET()
  3139. #define __HAL_RCC_AHB2_RELEASE_RESET()
  3140. /**
  3141. * @}
  3142. */
  3143. /** @defgroup RCCEx_AHB3_Force_Release_Reset AHB3 Force Release Reset
  3144. * @brief Force or release AHB3 peripheral reset.
  3145. * @{
  3146. */
  3147. #define __HAL_RCC_AHB3_FORCE_RESET()
  3148. #define __HAL_RCC_AHB3_RELEASE_RESET()
  3149. /**
  3150. * @}
  3151. */
  3152. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  3153. * @brief Force or release APB1 peripheral reset.
  3154. * @{
  3155. */
  3156. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  3157. #define __HAL_RCC_LPTIM1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_LPTIM1RST))
  3158. #define __HAL_RCC_FMPI2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_FMPI2C1RST))
  3159. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  3160. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  3161. #define __HAL_RCC_LPTIM1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_LPTIM1RST))
  3162. #define __HAL_RCC_FMPI2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_FMPI2C1RST))
  3163. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  3164. /**
  3165. * @}
  3166. */
  3167. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  3168. * @brief Force or release APB2 peripheral reset.
  3169. * @{
  3170. */
  3171. #define __HAL_RCC_SPI5_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI5RST))
  3172. #define __HAL_RCC_SPI5_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI5RST))
  3173. /**
  3174. * @}
  3175. */
  3176. /** @defgroup RCCEx_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  3177. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  3178. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  3179. * power consumption.
  3180. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  3181. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  3182. * @{
  3183. */
  3184. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_RNGLPEN))
  3185. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  3186. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  3187. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  3188. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_RNGLPEN))
  3189. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  3190. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  3191. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  3192. /**
  3193. * @}
  3194. */
  3195. /** @defgroup RCCEx_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  3196. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  3197. * @{
  3198. */
  3199. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  3200. #define __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_LPTIM1LPEN))
  3201. #define __HAL_RCC_RTCAPB_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_RTCAPBLPEN))
  3202. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_FMPI2C1LPEN))
  3203. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  3204. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  3205. #define __HAL_RCC_LPTIM1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_LPTIM1LPEN))
  3206. #define __HAL_RCC_RTCAPB_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_RTCAPBLPEN))
  3207. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_FMPI2C1LPEN))
  3208. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  3209. /**
  3210. * @}
  3211. */
  3212. /** @defgroup RCCEx_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  3213. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  3214. * @{
  3215. */
  3216. #define __HAL_RCC_SPI5_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI5LPEN))
  3217. #define __HAL_RCC_EXTIT_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_EXTITLPEN))
  3218. #define __HAL_RCC_SPI5_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI5LPEN))
  3219. #define __HAL_RCC_EXTIT_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_EXTITLPEN))
  3220. /**
  3221. * @}
  3222. */
  3223. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  3224. /*----------------------------------------------------------------------------*/
  3225. /*-------------------------------- STM32F411xx -------------------------------*/
  3226. #if defined(STM32F411xE)
  3227. /** @defgroup RCCEx_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  3228. * @brief Enables or disables the AHB1 peripheral clock.
  3229. * @note After reset, the peripheral clock (used for registers read/write access)
  3230. * is disabled and the application software has to enable this clock before
  3231. * using it.
  3232. * @{
  3233. */
  3234. #define __HAL_RCC_CCMDATARAMEN_CLK_ENABLE() do { \
  3235. __IO uint32_t tmpreg = 0x00U; \
  3236. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  3237. /* Delay after an RCC peripheral clock enabling */ \
  3238. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  3239. UNUSED(tmpreg); \
  3240. } while(0U)
  3241. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  3242. __IO uint32_t tmpreg = 0x00U; \
  3243. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  3244. /* Delay after an RCC peripheral clock enabling */ \
  3245. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  3246. UNUSED(tmpreg); \
  3247. } while(0U)
  3248. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  3249. __IO uint32_t tmpreg = 0x00U; \
  3250. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  3251. /* Delay after an RCC peripheral clock enabling */ \
  3252. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  3253. UNUSED(tmpreg); \
  3254. } while(0U)
  3255. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  3256. __IO uint32_t tmpreg = 0x00U; \
  3257. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  3258. /* Delay after an RCC peripheral clock enabling */ \
  3259. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  3260. UNUSED(tmpreg); \
  3261. } while(0U)
  3262. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIODEN))
  3263. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOEEN))
  3264. #define __HAL_RCC_CCMDATARAMEN_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CCMDATARAMEN))
  3265. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  3266. /**
  3267. * @}
  3268. */
  3269. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  3270. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  3271. * @note After reset, the peripheral clock (used for registers read/write access)
  3272. * is disabled and the application software has to enable this clock before
  3273. * using it.
  3274. * @{
  3275. */
  3276. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) != RESET)
  3277. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) != RESET)
  3278. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) != RESET)
  3279. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  3280. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) == RESET)
  3281. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) == RESET)
  3282. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) == RESET)
  3283. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  3284. /**
  3285. * @}
  3286. */
  3287. /** @defgroup RCCEX_AHB2_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  3288. * @brief Enable or disable the AHB2 peripheral clock.
  3289. * @note After reset, the peripheral clock (used for registers read/write access)
  3290. * is disabled and the application software has to enable this clock before
  3291. * using it.
  3292. * @{
  3293. */
  3294. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do {(RCC->AHB2ENR |= (RCC_AHB2ENR_OTGFSEN));\
  3295. __HAL_RCC_SYSCFG_CLK_ENABLE();\
  3296. }while(0U)
  3297. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_OTGFSEN))
  3298. /**
  3299. * @}
  3300. */
  3301. /** @defgroup RCCEx_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enable Disable Status
  3302. * @brief Get the enable or disable status of the AHB2 peripheral clock.
  3303. * @note After reset, the peripheral clock (used for registers read/write access)
  3304. * is disabled and the application software has to enable this clock before
  3305. * using it.
  3306. * @{
  3307. */
  3308. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) != RESET)
  3309. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) == RESET)
  3310. /**
  3311. * @}
  3312. */
  3313. /** @defgroup RCCEx_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  3314. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  3315. * @note After reset, the peripheral clock (used for registers read/write access)
  3316. * is disabled and the application software has to enable this clock before
  3317. * using it.
  3318. * @{
  3319. */
  3320. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  3321. __IO uint32_t tmpreg = 0x00U; \
  3322. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  3323. /* Delay after an RCC peripheral clock enabling */ \
  3324. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  3325. UNUSED(tmpreg); \
  3326. } while(0U)
  3327. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  3328. __IO uint32_t tmpreg = 0x00U; \
  3329. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  3330. /* Delay after an RCC peripheral clock enabling */ \
  3331. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  3332. UNUSED(tmpreg); \
  3333. } while(0U)
  3334. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  3335. __IO uint32_t tmpreg = 0x00U; \
  3336. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  3337. /* Delay after an RCC peripheral clock enabling */ \
  3338. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  3339. UNUSED(tmpreg); \
  3340. } while(0U)
  3341. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  3342. __IO uint32_t tmpreg = 0x00U; \
  3343. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  3344. /* Delay after an RCC peripheral clock enabling */ \
  3345. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  3346. UNUSED(tmpreg); \
  3347. } while(0U)
  3348. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  3349. __IO uint32_t tmpreg = 0x00U; \
  3350. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  3351. /* Delay after an RCC peripheral clock enabling */ \
  3352. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  3353. UNUSED(tmpreg); \
  3354. } while(0U)
  3355. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  3356. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  3357. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  3358. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  3359. #define __HAL_RCC_I2C3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C3EN))
  3360. /**
  3361. * @}
  3362. */
  3363. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  3364. * @brief Get the enable or disable status of the APB1 peripheral clock.
  3365. * @note After reset, the peripheral clock (used for registers read/write access)
  3366. * is disabled and the application software has to enable this clock before
  3367. * using it.
  3368. * @{
  3369. */
  3370. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  3371. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
  3372. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  3373. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  3374. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) != RESET)
  3375. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  3376. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
  3377. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  3378. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  3379. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) == RESET)
  3380. /**
  3381. * @}
  3382. */
  3383. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  3384. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  3385. * @{
  3386. */
  3387. #define __HAL_RCC_SPI5_CLK_ENABLE() do { \
  3388. __IO uint32_t tmpreg = 0x00U; \
  3389. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  3390. /* Delay after an RCC peripheral clock enabling */ \
  3391. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  3392. UNUSED(tmpreg); \
  3393. } while(0U)
  3394. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  3395. __IO uint32_t tmpreg = 0x00U; \
  3396. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  3397. /* Delay after an RCC peripheral clock enabling */ \
  3398. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  3399. UNUSED(tmpreg); \
  3400. } while(0U)
  3401. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  3402. __IO uint32_t tmpreg = 0x00U; \
  3403. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  3404. /* Delay after an RCC peripheral clock enabling */ \
  3405. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  3406. UNUSED(tmpreg); \
  3407. } while(0U)
  3408. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  3409. __IO uint32_t tmpreg = 0x00U; \
  3410. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  3411. /* Delay after an RCC peripheral clock enabling */ \
  3412. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  3413. UNUSED(tmpreg); \
  3414. } while(0U)
  3415. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SDIOEN))
  3416. #define __HAL_RCC_SPI4_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI4EN))
  3417. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  3418. #define __HAL_RCC_SPI5_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI5EN))
  3419. /**
  3420. * @}
  3421. */
  3422. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  3423. * @brief Get the enable or disable status of the APB2 peripheral clock.
  3424. * @note After reset, the peripheral clock (used for registers read/write access)
  3425. * is disabled and the application software has to enable this clock before
  3426. * using it.
  3427. * @{
  3428. */
  3429. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) != RESET)
  3430. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) != RESET)
  3431. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) != RESET)
  3432. #define __HAL_RCC_SPI5_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) != RESET)
  3433. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) == RESET)
  3434. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) == RESET)
  3435. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) == RESET)
  3436. #define __HAL_RCC_SPI5_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) == RESET)
  3437. /**
  3438. * @}
  3439. */
  3440. /** @defgroup RCCEx_AHB1_Force_Release_Reset AHB1 Force Release Reset
  3441. * @brief Force or release AHB1 peripheral reset.
  3442. * @{
  3443. */
  3444. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIODRST))
  3445. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOERST))
  3446. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  3447. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST))
  3448. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOERST))
  3449. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  3450. /**
  3451. * @}
  3452. */
  3453. /** @defgroup RCCEx_AHB2_Force_Release_Reset AHB2 Force Release Reset
  3454. * @brief Force or release AHB2 peripheral reset.
  3455. * @{
  3456. */
  3457. #define __HAL_RCC_AHB2_FORCE_RESET() (RCC->AHB2RSTR = 0xFFFFFFFFU)
  3458. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_OTGFSRST))
  3459. #define __HAL_RCC_AHB2_RELEASE_RESET() (RCC->AHB2RSTR = 0x00U)
  3460. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_OTGFSRST))
  3461. /**
  3462. * @}
  3463. */
  3464. /** @defgroup RCCEx_AHB3_Force_Release_Reset AHB3 Force Release Reset
  3465. * @brief Force or release AHB3 peripheral reset.
  3466. * @{
  3467. */
  3468. #define __HAL_RCC_AHB3_FORCE_RESET() (RCC->AHB3RSTR = 0xFFFFFFFFU)
  3469. #define __HAL_RCC_AHB3_RELEASE_RESET() (RCC->AHB3RSTR = 0x00U)
  3470. /**
  3471. * @}
  3472. */
  3473. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  3474. * @brief Force or release APB1 peripheral reset.
  3475. * @{
  3476. */
  3477. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  3478. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  3479. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  3480. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  3481. #define __HAL_RCC_I2C3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C3RST))
  3482. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  3483. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  3484. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  3485. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  3486. #define __HAL_RCC_I2C3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C3RST))
  3487. /**
  3488. * @}
  3489. */
  3490. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  3491. * @brief Force or release APB2 peripheral reset.
  3492. * @{
  3493. */
  3494. #define __HAL_RCC_SPI5_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI5RST))
  3495. #define __HAL_RCC_SDIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SDIORST))
  3496. #define __HAL_RCC_SPI4_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI4RST))
  3497. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  3498. #define __HAL_RCC_SDIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SDIORST))
  3499. #define __HAL_RCC_SPI4_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI4RST))
  3500. #define __HAL_RCC_TIM10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  3501. #define __HAL_RCC_SPI5_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI5RST))
  3502. /**
  3503. * @}
  3504. */
  3505. /** @defgroup RCCEx_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  3506. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  3507. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  3508. * power consumption.
  3509. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  3510. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  3511. * @{
  3512. */
  3513. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIODLPEN))
  3514. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOELPEN))
  3515. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  3516. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  3517. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  3518. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIODLPEN))
  3519. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOELPEN))
  3520. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  3521. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  3522. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  3523. /**
  3524. * @}
  3525. */
  3526. /** @defgroup RCCEx_AHB2_LowPower_Enable_Disable AHB2 Peripheral Low Power Enable Disable
  3527. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  3528. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  3529. * power consumption.
  3530. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  3531. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  3532. * @{
  3533. */
  3534. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_OTGFSLPEN))
  3535. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_OTGFSLPEN))
  3536. /**
  3537. * @}
  3538. */
  3539. /** @defgroup RCCEx_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  3540. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  3541. * @{
  3542. */
  3543. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  3544. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  3545. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  3546. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
  3547. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C3LPEN))
  3548. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  3549. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  3550. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  3551. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
  3552. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C3LPEN))
  3553. /**
  3554. * @}
  3555. */
  3556. /** @defgroup RCCEx_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  3557. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  3558. * @{
  3559. */
  3560. #define __HAL_RCC_SPI5_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI5LPEN))
  3561. #define __HAL_RCC_SDIO_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SDIOLPEN))
  3562. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI4LPEN))
  3563. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  3564. #define __HAL_RCC_SDIO_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SDIOLPEN))
  3565. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI4LPEN))
  3566. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  3567. #define __HAL_RCC_SPI5_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI5LPEN))
  3568. /**
  3569. * @}
  3570. */
  3571. #endif /* STM32F411xE */
  3572. /*----------------------------------------------------------------------------*/
  3573. /*---------------------------------- STM32F446xx -----------------------------*/
  3574. #if defined(STM32F446xx)
  3575. /** @defgroup RCCEx_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  3576. * @brief Enables or disables the AHB1 peripheral clock.
  3577. * @note After reset, the peripheral clock (used for registers read/write access)
  3578. * is disabled and the application software has to enable this clock before
  3579. * using it.
  3580. * @{
  3581. */
  3582. #define __HAL_RCC_BKPSRAM_CLK_ENABLE() do { \
  3583. __IO uint32_t tmpreg = 0x00U; \
  3584. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  3585. /* Delay after an RCC peripheral clock enabling */ \
  3586. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  3587. UNUSED(tmpreg); \
  3588. } while(0U)
  3589. #define __HAL_RCC_CCMDATARAMEN_CLK_ENABLE() do { \
  3590. __IO uint32_t tmpreg = 0x00U; \
  3591. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  3592. /* Delay after an RCC peripheral clock enabling */ \
  3593. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CCMDATARAMEN);\
  3594. UNUSED(tmpreg); \
  3595. } while(0U)
  3596. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  3597. __IO uint32_t tmpreg = 0x00U; \
  3598. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  3599. /* Delay after an RCC peripheral clock enabling */ \
  3600. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  3601. UNUSED(tmpreg); \
  3602. } while(0U)
  3603. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  3604. __IO uint32_t tmpreg = 0x00U; \
  3605. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  3606. /* Delay after an RCC peripheral clock enabling */ \
  3607. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  3608. UNUSED(tmpreg); \
  3609. } while(0U)
  3610. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  3611. __IO uint32_t tmpreg = 0x00U; \
  3612. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  3613. /* Delay after an RCC peripheral clock enabling */ \
  3614. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  3615. UNUSED(tmpreg); \
  3616. } while(0U)
  3617. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  3618. __IO uint32_t tmpreg = 0x00U; \
  3619. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  3620. /* Delay after an RCC peripheral clock enabling */ \
  3621. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  3622. UNUSED(tmpreg); \
  3623. } while(0U)
  3624. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  3625. __IO uint32_t tmpreg = 0x00U; \
  3626. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  3627. /* Delay after an RCC peripheral clock enabling */ \
  3628. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  3629. UNUSED(tmpreg); \
  3630. } while(0U)
  3631. #define __HAL_RCC_USB_OTG_HS_CLK_ENABLE() do { \
  3632. __IO uint32_t tmpreg = 0x00U; \
  3633. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  3634. /* Delay after an RCC peripheral clock enabling */ \
  3635. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  3636. UNUSED(tmpreg); \
  3637. } while(0U)
  3638. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE() do { \
  3639. __IO uint32_t tmpreg = 0x00U; \
  3640. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  3641. /* Delay after an RCC peripheral clock enabling */ \
  3642. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  3643. UNUSED(tmpreg); \
  3644. } while(0U)
  3645. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIODEN))
  3646. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOEEN))
  3647. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  3648. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  3649. #define __HAL_RCC_USB_OTG_HS_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSEN))
  3650. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSULPIEN))
  3651. #define __HAL_RCC_BKPSRAM_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_BKPSRAMEN))
  3652. #define __HAL_RCC_CCMDATARAMEN_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CCMDATARAMEN))
  3653. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  3654. /**
  3655. * @}
  3656. */
  3657. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  3658. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  3659. * @note After reset, the peripheral clock (used for registers read/write access)
  3660. * is disabled and the application software has to enable this clock before
  3661. * using it.
  3662. * @{
  3663. */
  3664. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) != RESET)
  3665. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) != RESET)
  3666. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) != RESET)
  3667. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) != RESET)
  3668. #define __HAL_RCC_USB_OTG_HS_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSEN)) != RESET)
  3669. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSULPIEN)) != RESET)
  3670. #define __HAL_RCC_BKPSRAM_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_BKPSRAMEN)) != RESET)
  3671. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN))!= RESET)
  3672. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  3673. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) == RESET)
  3674. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) == RESET)
  3675. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) == RESET)
  3676. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) == RESET)
  3677. #define __HAL_RCC_USB_OTG_HS_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSEN)) == RESET)
  3678. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_OTGHSULPIEN)) == RESET)
  3679. #define __HAL_RCC_BKPSRAM_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_BKPSRAMEN)) == RESET)
  3680. #define __HAL_RCC_CCMDATARAMEN_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CCMDATARAMEN)) == RESET)
  3681. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  3682. /**
  3683. * @}
  3684. */
  3685. /** @defgroup RCCEx_AHB2_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  3686. * @brief Enable or disable the AHB2 peripheral clock.
  3687. * @note After reset, the peripheral clock (used for registers read/write access)
  3688. * is disabled and the application software has to enable this clock before
  3689. * using it.
  3690. * @{
  3691. */
  3692. #define __HAL_RCC_DCMI_CLK_ENABLE() do { \
  3693. __IO uint32_t tmpreg = 0x00U; \
  3694. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  3695. /* Delay after an RCC peripheral clock enabling */ \
  3696. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  3697. UNUSED(tmpreg); \
  3698. } while(0U)
  3699. #define __HAL_RCC_DCMI_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_DCMIEN))
  3700. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do {(RCC->AHB2ENR |= (RCC_AHB2ENR_OTGFSEN));\
  3701. __HAL_RCC_SYSCFG_CLK_ENABLE();\
  3702. }while(0U)
  3703. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_OTGFSEN))
  3704. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  3705. __IO uint32_t tmpreg = 0x00U; \
  3706. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  3707. /* Delay after an RCC peripheral clock enabling */ \
  3708. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  3709. UNUSED(tmpreg); \
  3710. } while(0U)
  3711. #define __HAL_RCC_RNG_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_RNGEN))
  3712. /**
  3713. * @}
  3714. */
  3715. /** @defgroup RCCEx_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enable Disable Status
  3716. * @brief Get the enable or disable status of the AHB2 peripheral clock.
  3717. * @note After reset, the peripheral clock (used for registers read/write access)
  3718. * is disabled and the application software has to enable this clock before
  3719. * using it.
  3720. * @{
  3721. */
  3722. #define __HAL_RCC_DCMI_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_DCMIEN)) != RESET)
  3723. #define __HAL_RCC_DCMI_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_DCMIEN)) == RESET)
  3724. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) != RESET)
  3725. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) == RESET)
  3726. #define __HAL_RCC_RNG_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) != RESET)
  3727. #define __HAL_RCC_RNG_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) == RESET)
  3728. /**
  3729. * @}
  3730. */
  3731. /** @defgroup RCCEx_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  3732. * @brief Enables or disables the AHB3 peripheral clock.
  3733. * @note After reset, the peripheral clock (used for registers read/write access)
  3734. * is disabled and the application software has to enable this clock before
  3735. * using it.
  3736. * @{
  3737. */
  3738. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  3739. __IO uint32_t tmpreg = 0x00U; \
  3740. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  3741. /* Delay after an RCC peripheral clock enabling */ \
  3742. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  3743. UNUSED(tmpreg); \
  3744. } while(0U)
  3745. #define __HAL_RCC_QSPI_CLK_ENABLE() do { \
  3746. __IO uint32_t tmpreg = 0x00U; \
  3747. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  3748. /* Delay after an RCC peripheral clock enabling */ \
  3749. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  3750. UNUSED(tmpreg); \
  3751. } while(0U)
  3752. #define __HAL_RCC_FMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FMCEN))
  3753. #define __HAL_RCC_QSPI_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_QSPIEN))
  3754. /**
  3755. * @}
  3756. */
  3757. /** @defgroup RCCEx_AHB3_Peripheral_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enable Disable Status
  3758. * @brief Get the enable or disable status of the AHB3 peripheral clock.
  3759. * @note After reset, the peripheral clock (used for registers read/write access)
  3760. * is disabled and the application software has to enable this clock before
  3761. * using it.
  3762. * @{
  3763. */
  3764. #define __HAL_RCC_FMC_IS_CLK_ENABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FMCEN)) != RESET)
  3765. #define __HAL_RCC_QSPI_IS_CLK_ENABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_QSPIEN)) != RESET)
  3766. #define __HAL_RCC_FMC_IS_CLK_DISABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FMCEN)) == RESET)
  3767. #define __HAL_RCC_QSPI_IS_CLK_DISABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_QSPIEN)) == RESET)
  3768. /**
  3769. * @}
  3770. */
  3771. /** @defgroup RCCEx_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  3772. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  3773. * @note After reset, the peripheral clock (used for registers read/write access)
  3774. * is disabled and the application software has to enable this clock before
  3775. * using it.
  3776. * @{
  3777. */
  3778. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  3779. __IO uint32_t tmpreg = 0x00U; \
  3780. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  3781. /* Delay after an RCC peripheral clock enabling */ \
  3782. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  3783. UNUSED(tmpreg); \
  3784. } while(0U)
  3785. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  3786. __IO uint32_t tmpreg = 0x00U; \
  3787. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  3788. /* Delay after an RCC peripheral clock enabling */ \
  3789. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  3790. UNUSED(tmpreg); \
  3791. } while(0U)
  3792. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  3793. __IO uint32_t tmpreg = 0x00U; \
  3794. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  3795. /* Delay after an RCC peripheral clock enabling */ \
  3796. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  3797. UNUSED(tmpreg); \
  3798. } while(0U)
  3799. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  3800. __IO uint32_t tmpreg = 0x00U; \
  3801. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  3802. /* Delay after an RCC peripheral clock enabling */ \
  3803. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  3804. UNUSED(tmpreg); \
  3805. } while(0U)
  3806. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  3807. __IO uint32_t tmpreg = 0x00U; \
  3808. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  3809. /* Delay after an RCC peripheral clock enabling */ \
  3810. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  3811. UNUSED(tmpreg); \
  3812. } while(0U)
  3813. #define __HAL_RCC_SPDIFRX_CLK_ENABLE() do { \
  3814. __IO uint32_t tmpreg = 0x00U; \
  3815. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPDIFRXEN);\
  3816. /* Delay after an RCC peripheral clock enabling */ \
  3817. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPDIFRXEN);\
  3818. UNUSED(tmpreg); \
  3819. } while(0U)
  3820. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  3821. __IO uint32_t tmpreg = 0x00U; \
  3822. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  3823. /* Delay after an RCC peripheral clock enabling */ \
  3824. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  3825. UNUSED(tmpreg); \
  3826. } while(0U)
  3827. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  3828. __IO uint32_t tmpreg = 0x00U; \
  3829. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  3830. /* Delay after an RCC peripheral clock enabling */ \
  3831. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  3832. UNUSED(tmpreg); \
  3833. } while(0U)
  3834. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  3835. __IO uint32_t tmpreg = 0x00U; \
  3836. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  3837. /* Delay after an RCC peripheral clock enabling */ \
  3838. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  3839. UNUSED(tmpreg); \
  3840. } while(0U)
  3841. #define __HAL_RCC_FMPI2C1_CLK_ENABLE() do { \
  3842. __IO uint32_t tmpreg = 0x00U; \
  3843. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  3844. /* Delay after an RCC peripheral clock enabling */ \
  3845. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  3846. UNUSED(tmpreg); \
  3847. } while(0U)
  3848. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  3849. __IO uint32_t tmpreg = 0x00U; \
  3850. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  3851. /* Delay after an RCC peripheral clock enabling */ \
  3852. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  3853. UNUSED(tmpreg); \
  3854. } while(0U)
  3855. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  3856. __IO uint32_t tmpreg = 0x00U; \
  3857. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  3858. /* Delay after an RCC peripheral clock enabling */ \
  3859. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  3860. UNUSED(tmpreg); \
  3861. } while(0U)
  3862. #define __HAL_RCC_CEC_CLK_ENABLE() do { \
  3863. __IO uint32_t tmpreg = 0x00U; \
  3864. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  3865. /* Delay after an RCC peripheral clock enabling */ \
  3866. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  3867. UNUSED(tmpreg); \
  3868. } while(0U)
  3869. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  3870. __IO uint32_t tmpreg = 0x00U; \
  3871. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  3872. /* Delay after an RCC peripheral clock enabling */ \
  3873. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  3874. UNUSED(tmpreg); \
  3875. } while(0U)
  3876. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  3877. __IO uint32_t tmpreg = 0x00U; \
  3878. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  3879. /* Delay after an RCC peripheral clock enabling */ \
  3880. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  3881. UNUSED(tmpreg); \
  3882. } while(0U)
  3883. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  3884. __IO uint32_t tmpreg = 0x00U; \
  3885. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  3886. /* Delay after an RCC peripheral clock enabling */ \
  3887. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  3888. UNUSED(tmpreg); \
  3889. } while(0U)
  3890. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  3891. __IO uint32_t tmpreg = 0x00U; \
  3892. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  3893. /* Delay after an RCC peripheral clock enabling */ \
  3894. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  3895. UNUSED(tmpreg); \
  3896. } while(0U)
  3897. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  3898. __IO uint32_t tmpreg = 0x00U; \
  3899. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  3900. /* Delay after an RCC peripheral clock enabling */ \
  3901. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  3902. UNUSED(tmpreg); \
  3903. } while(0U)
  3904. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  3905. __IO uint32_t tmpreg = 0x00U; \
  3906. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  3907. /* Delay after an RCC peripheral clock enabling */ \
  3908. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  3909. UNUSED(tmpreg); \
  3910. } while(0U)
  3911. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  3912. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  3913. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  3914. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  3915. #define __HAL_RCC_I2C3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C3EN))
  3916. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  3917. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  3918. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  3919. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  3920. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  3921. #define __HAL_RCC_SPDIFRX_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPDIFRXEN))
  3922. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  3923. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  3924. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  3925. #define __HAL_RCC_FMPI2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_FMPI2C1EN))
  3926. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  3927. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  3928. #define __HAL_RCC_CEC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CECEN))
  3929. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  3930. /**
  3931. * @}
  3932. */
  3933. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  3934. * @brief Get the enable or disable status of the APB1 peripheral clock.
  3935. * @note After reset, the peripheral clock (used for registers read/write access)
  3936. * is disabled and the application software has to enable this clock before
  3937. * using it.
  3938. * @{
  3939. */
  3940. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  3941. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
  3942. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  3943. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  3944. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) != RESET)
  3945. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  3946. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  3947. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) != RESET)
  3948. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) != RESET)
  3949. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) != RESET)
  3950. #define __HAL_RCC_SPDIFRX_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPDIFRXEN)) != RESET)
  3951. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
  3952. #define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) != RESET)
  3953. #define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) != RESET)
  3954. #define __HAL_RCC_FMPI2C1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_FMPI2C1EN)) != RESET)
  3955. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) != RESET)
  3956. #define __HAL_RCC_CAN2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) != RESET)
  3957. #define __HAL_RCC_CEC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CECEN)) != RESET)
  3958. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  3959. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  3960. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
  3961. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  3962. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  3963. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) == RESET)
  3964. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  3965. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  3966. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) == RESET)
  3967. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) == RESET)
  3968. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) == RESET)
  3969. #define __HAL_RCC_SPDIFRX_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPDIFRXEN)) == RESET)
  3970. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
  3971. #define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) == RESET)
  3972. #define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) == RESET)
  3973. #define __HAL_RCC_FMPI2C1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_FMPI2C1EN)) == RESET)
  3974. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) == RESET)
  3975. #define __HAL_RCC_CAN2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) == RESET)
  3976. #define __HAL_RCC_CEC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CECEN)) == RESET)
  3977. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  3978. /**
  3979. * @}
  3980. */
  3981. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  3982. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  3983. * @note After reset, the peripheral clock (used for registers read/write access)
  3984. * is disabled and the application software has to enable this clock before
  3985. * using it.
  3986. * @{
  3987. */
  3988. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  3989. __IO uint32_t tmpreg = 0x00U; \
  3990. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  3991. /* Delay after an RCC peripheral clock enabling */ \
  3992. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  3993. UNUSED(tmpreg); \
  3994. } while(0U)
  3995. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  3996. __IO uint32_t tmpreg = 0x00U; \
  3997. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  3998. /* Delay after an RCC peripheral clock enabling */ \
  3999. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  4000. UNUSED(tmpreg); \
  4001. } while(0U)
  4002. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  4003. __IO uint32_t tmpreg = 0x00U; \
  4004. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  4005. /* Delay after an RCC peripheral clock enabling */ \
  4006. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  4007. UNUSED(tmpreg); \
  4008. } while(0U)
  4009. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  4010. __IO uint32_t tmpreg = 0x00U; \
  4011. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  4012. /* Delay after an RCC peripheral clock enabling */ \
  4013. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  4014. UNUSED(tmpreg); \
  4015. } while(0U)
  4016. #define __HAL_RCC_SAI2_CLK_ENABLE() do { \
  4017. __IO uint32_t tmpreg = 0x00U; \
  4018. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN);\
  4019. /* Delay after an RCC peripheral clock enabling */ \
  4020. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN);\
  4021. UNUSED(tmpreg); \
  4022. } while(0U)
  4023. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  4024. __IO uint32_t tmpreg = 0x00U; \
  4025. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  4026. /* Delay after an RCC peripheral clock enabling */ \
  4027. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  4028. UNUSED(tmpreg); \
  4029. } while(0U)
  4030. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  4031. __IO uint32_t tmpreg = 0x00U; \
  4032. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  4033. /* Delay after an RCC peripheral clock enabling */ \
  4034. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  4035. UNUSED(tmpreg); \
  4036. } while(0U)
  4037. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  4038. __IO uint32_t tmpreg = 0x00U; \
  4039. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  4040. /* Delay after an RCC peripheral clock enabling */ \
  4041. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  4042. UNUSED(tmpreg); \
  4043. } while(0U)
  4044. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SDIOEN))
  4045. #define __HAL_RCC_SPI4_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI4EN))
  4046. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  4047. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  4048. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  4049. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  4050. #define __HAL_RCC_SAI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SAI1EN))
  4051. #define __HAL_RCC_SAI2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SAI2EN))
  4052. /**
  4053. * @}
  4054. */
  4055. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  4056. * @brief Get the enable or disable status of the APB2 peripheral clock.
  4057. * @note After reset, the peripheral clock (used for registers read/write access)
  4058. * is disabled and the application software has to enable this clock before
  4059. * using it.
  4060. * @{
  4061. */
  4062. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) != RESET)
  4063. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) != RESET)
  4064. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) != RESET)
  4065. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) != RESET)
  4066. #define __HAL_RCC_ADC2_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) != RESET)
  4067. #define __HAL_RCC_ADC3_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) != RESET)
  4068. #define __HAL_RCC_SAI1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI1EN)) != RESET)
  4069. #define __HAL_RCC_SAI2_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI2EN)) != RESET)
  4070. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) == RESET)
  4071. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) == RESET)
  4072. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) == RESET)
  4073. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) == RESET)
  4074. #define __HAL_RCC_ADC2_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) == RESET)
  4075. #define __HAL_RCC_ADC3_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) == RESET)
  4076. #define __HAL_RCC_SAI1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI1EN)) == RESET)
  4077. #define __HAL_RCC_SAI2_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI2EN)) == RESET)
  4078. /**
  4079. * @}
  4080. */
  4081. /** @defgroup RCCEx_AHB1_Force_Release_Reset AHB1 Force Release Reset
  4082. * @brief Force or release AHB1 peripheral reset.
  4083. * @{
  4084. */
  4085. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIODRST))
  4086. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOERST))
  4087. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  4088. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  4089. #define __HAL_RCC_USB_OTG_HS_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHRST))
  4090. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  4091. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST))
  4092. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOERST))
  4093. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  4094. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  4095. #define __HAL_RCC_USB_OTG_HS_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHRST))
  4096. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  4097. /**
  4098. * @}
  4099. */
  4100. /** @defgroup RCCEx_AHB2_Force_Release_Reset AHB2 Force Release Reset
  4101. * @brief Force or release AHB2 peripheral reset.
  4102. * @{
  4103. */
  4104. #define __HAL_RCC_AHB2_FORCE_RESET() (RCC->AHB2RSTR = 0xFFFFFFFFU)
  4105. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_OTGFSRST))
  4106. #define __HAL_RCC_RNG_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_RNGRST))
  4107. #define __HAL_RCC_DCMI_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_DCMIRST))
  4108. #define __HAL_RCC_AHB2_RELEASE_RESET() (RCC->AHB2RSTR = 0x00U)
  4109. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_OTGFSRST))
  4110. #define __HAL_RCC_RNG_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_RNGRST))
  4111. #define __HAL_RCC_DCMI_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_DCMIRST))
  4112. /**
  4113. * @}
  4114. */
  4115. /** @defgroup RCCEx_AHB3_Force_Release_Reset AHB3 Force Release Reset
  4116. * @brief Force or release AHB3 peripheral reset.
  4117. * @{
  4118. */
  4119. #define __HAL_RCC_AHB3_FORCE_RESET() (RCC->AHB3RSTR = 0xFFFFFFFFU)
  4120. #define __HAL_RCC_AHB3_RELEASE_RESET() (RCC->AHB3RSTR = 0x00U)
  4121. #define __HAL_RCC_FMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FMCRST))
  4122. #define __HAL_RCC_QSPI_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_QSPIRST))
  4123. #define __HAL_RCC_FMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FMCRST))
  4124. #define __HAL_RCC_QSPI_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_QSPIRST))
  4125. /**
  4126. * @}
  4127. */
  4128. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  4129. * @brief Force or release APB1 peripheral reset.
  4130. * @{
  4131. */
  4132. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  4133. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  4134. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  4135. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  4136. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  4137. #define __HAL_RCC_SPDIFRX_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPDIFRXRST))
  4138. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  4139. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  4140. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  4141. #define __HAL_RCC_FMPI2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_FMPI2C1RST))
  4142. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  4143. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  4144. #define __HAL_RCC_CEC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CECRST))
  4145. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  4146. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  4147. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  4148. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  4149. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  4150. #define __HAL_RCC_I2C3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C3RST))
  4151. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  4152. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  4153. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  4154. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  4155. #define __HAL_RCC_I2C3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C3RST))
  4156. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  4157. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  4158. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  4159. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  4160. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  4161. #define __HAL_RCC_SPDIFRX_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPDIFRXRST))
  4162. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  4163. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  4164. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  4165. #define __HAL_RCC_FMPI2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_FMPI2C1RST))
  4166. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  4167. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  4168. #define __HAL_RCC_CEC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CECRST))
  4169. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  4170. /**
  4171. * @}
  4172. */
  4173. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  4174. * @brief Force or release APB2 peripheral reset.
  4175. * @{
  4176. */
  4177. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  4178. #define __HAL_RCC_SAI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SAI1RST))
  4179. #define __HAL_RCC_SAI2_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SAI2RST))
  4180. #define __HAL_RCC_SDIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SDIORST))
  4181. #define __HAL_RCC_SPI4_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI4RST))
  4182. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  4183. #define __HAL_RCC_SDIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SDIORST))
  4184. #define __HAL_RCC_SPI4_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI4RST))
  4185. #define __HAL_RCC_TIM10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  4186. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  4187. #define __HAL_RCC_SAI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SAI1RST))
  4188. #define __HAL_RCC_SAI2_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SAI2RST))
  4189. /**
  4190. * @}
  4191. */
  4192. /** @defgroup RCCEx_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  4193. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  4194. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  4195. * power consumption.
  4196. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  4197. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  4198. * @{
  4199. */
  4200. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIODLPEN))
  4201. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOELPEN))
  4202. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  4203. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  4204. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  4205. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSLPEN))
  4206. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSULPILPEN))
  4207. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  4208. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  4209. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  4210. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_BKPSRAMLPEN))
  4211. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIODLPEN))
  4212. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOELPEN))
  4213. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  4214. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  4215. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  4216. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSLPEN))
  4217. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSULPILPEN))
  4218. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  4219. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  4220. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  4221. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_BKPSRAMLPEN))
  4222. /**
  4223. * @}
  4224. */
  4225. /** @defgroup RCCEx_AHB2_LowPower_Enable_Disable AHB2 Peripheral Low Power Enable Disable
  4226. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  4227. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  4228. * power consumption.
  4229. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  4230. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  4231. * @{
  4232. */
  4233. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_OTGFSLPEN))
  4234. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_OTGFSLPEN))
  4235. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_RNGLPEN))
  4236. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_RNGLPEN))
  4237. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_DCMILPEN))
  4238. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_DCMILPEN))
  4239. /**
  4240. * @}
  4241. */
  4242. /** @defgroup RCCEx_AHB3_LowPower_Enable_Disable AHB3 Peripheral Low Power Enable Disable
  4243. * @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  4244. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  4245. * power consumption.
  4246. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  4247. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  4248. * @{
  4249. */
  4250. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FMCLPEN))
  4251. #define __HAL_RCC_QSPI_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_QSPILPEN))
  4252. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FMCLPEN))
  4253. #define __HAL_RCC_QSPI_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_QSPILPEN))
  4254. /**
  4255. * @}
  4256. */
  4257. /** @defgroup RCCEx_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  4258. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  4259. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  4260. * power consumption.
  4261. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  4262. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  4263. * @{
  4264. */
  4265. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  4266. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  4267. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  4268. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  4269. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  4270. #define __HAL_RCC_SPDIFRX_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPDIFRXLPEN))
  4271. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  4272. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  4273. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  4274. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_FMPI2C1LPEN))
  4275. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  4276. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  4277. #define __HAL_RCC_CEC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CECLPEN))
  4278. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  4279. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  4280. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  4281. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  4282. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
  4283. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C3LPEN))
  4284. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  4285. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  4286. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  4287. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
  4288. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C3LPEN))
  4289. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  4290. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  4291. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  4292. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  4293. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  4294. #define __HAL_RCC_SPDIFRX_CLK_SLEEP_DISABLE()(RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPDIFRXLPEN))
  4295. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  4296. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  4297. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  4298. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_DISABLE()(RCC->APB1LPENR &= ~(RCC_APB1LPENR_FMPI2C1LPEN))
  4299. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  4300. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  4301. #define __HAL_RCC_CEC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CECLPEN))
  4302. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  4303. /**
  4304. * @}
  4305. */
  4306. /** @defgroup RCCEx_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  4307. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  4308. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  4309. * power consumption.
  4310. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  4311. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  4312. * @{
  4313. */
  4314. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  4315. #define __HAL_RCC_ADC2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC2LPEN))
  4316. #define __HAL_RCC_ADC3_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC3LPEN))
  4317. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SAI1LPEN))
  4318. #define __HAL_RCC_SAI2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SAI2LPEN))
  4319. #define __HAL_RCC_SDIO_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SDIOLPEN))
  4320. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI4LPEN))
  4321. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE()(RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  4322. #define __HAL_RCC_SDIO_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SDIOLPEN))
  4323. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI4LPEN))
  4324. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE()(RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  4325. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  4326. #define __HAL_RCC_ADC2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC2LPEN))
  4327. #define __HAL_RCC_ADC3_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC3LPEN))
  4328. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SAI1LPEN))
  4329. #define __HAL_RCC_SAI2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SAI2LPEN))
  4330. /**
  4331. * @}
  4332. */
  4333. #endif /* STM32F446xx */
  4334. /*----------------------------------------------------------------------------*/
  4335. /*-------STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx-------*/
  4336. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  4337. /** @defgroup RCCEx_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  4338. * @brief Enables or disables the AHB1 peripheral clock.
  4339. * @note After reset, the peripheral clock (used for registers read/write access)
  4340. * is disabled and the application software has to enable this clock before
  4341. * using it.
  4342. * @{
  4343. */
  4344. #if defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4345. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  4346. __IO uint32_t tmpreg = 0x00U; \
  4347. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  4348. /* Delay after an RCC peripheral clock enabling */ \
  4349. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  4350. UNUSED(tmpreg); \
  4351. } while(0U)
  4352. #endif /* STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4353. #if defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4354. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  4355. __IO uint32_t tmpreg = 0x00U; \
  4356. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  4357. /* Delay after an RCC peripheral clock enabling */ \
  4358. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  4359. UNUSED(tmpreg); \
  4360. } while(0U)
  4361. #endif /* STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4362. #if defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4363. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  4364. __IO uint32_t tmpreg = 0x00U; \
  4365. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  4366. /* Delay after an RCC peripheral clock enabling */ \
  4367. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  4368. UNUSED(tmpreg); \
  4369. } while(0U)
  4370. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  4371. __IO uint32_t tmpreg = 0x00U; \
  4372. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  4373. /* Delay after an RCC peripheral clock enabling */ \
  4374. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  4375. UNUSED(tmpreg); \
  4376. } while(0U)
  4377. #endif /* STM32F412Zx || STM32F413xx || STM32F423xx */
  4378. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  4379. __IO uint32_t tmpreg = 0x00U; \
  4380. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  4381. /* Delay after an RCC peripheral clock enabling */ \
  4382. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  4383. UNUSED(tmpreg); \
  4384. } while(0U)
  4385. #if defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4386. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIODEN))
  4387. #endif /* STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4388. #if defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4389. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOEEN))
  4390. #endif /* STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4391. #if defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4392. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  4393. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  4394. #endif /* STM32F412Zx || STM32F413xx || STM32F423xx */
  4395. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  4396. /**
  4397. * @}
  4398. */
  4399. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  4400. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  4401. * @note After reset, the peripheral clock (used for registers read/write access)
  4402. * is disabled and the application software has to enable this clock before
  4403. * using it.
  4404. * @{
  4405. */
  4406. #if defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4407. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) != RESET)
  4408. #endif /* STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4409. #if defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4410. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) != RESET)
  4411. #endif /* STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4412. #if defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4413. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) != RESET)
  4414. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) != RESET)
  4415. #endif /* STM32F412Zx || STM32F413xx || STM32F423xx */
  4416. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  4417. #if defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4418. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIODEN)) == RESET)
  4419. #endif /* STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4420. #if defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4421. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOEEN)) == RESET)
  4422. #endif /* STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4423. #if defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4424. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOFEN)) == RESET)
  4425. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_GPIOGEN)) == RESET)
  4426. #endif /* STM32F412Zx || STM32F413xx || STM32F423xx */
  4427. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  4428. /**
  4429. * @}
  4430. */
  4431. /** @defgroup RCCEx_AHB2_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  4432. * @brief Enable or disable the AHB2 peripheral clock.
  4433. * @note After reset, the peripheral clock (used for registers read/write access)
  4434. * is disabled and the application software has to enable this clock before
  4435. * using it.
  4436. * @{
  4437. */
  4438. #if defined(STM32F423xx)
  4439. #define __HAL_RCC_AES_CLK_ENABLE() do { \
  4440. __IO uint32_t tmpreg = 0x00U; \
  4441. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN);\
  4442. /* Delay after an RCC peripheral clock enabling */ \
  4443. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN);\
  4444. UNUSED(tmpreg); \
  4445. } while(0U)
  4446. #define __HAL_RCC_AES_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_AESEN))
  4447. #endif /* STM32F423xx */
  4448. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  4449. __IO uint32_t tmpreg = 0x00U; \
  4450. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  4451. /* Delay after an RCC peripheral clock enabling */ \
  4452. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  4453. UNUSED(tmpreg); \
  4454. } while(0U)
  4455. #define __HAL_RCC_RNG_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_RNGEN))
  4456. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do {(RCC->AHB2ENR |= (RCC_AHB2ENR_OTGFSEN));\
  4457. __HAL_RCC_SYSCFG_CLK_ENABLE();\
  4458. }while(0U)
  4459. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_OTGFSEN))
  4460. /**
  4461. * @}
  4462. */
  4463. /** @defgroup RCCEx_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enable Disable Status
  4464. * @brief Get the enable or disable status of the AHB2 peripheral clock.
  4465. * @note After reset, the peripheral clock (used for registers read/write access)
  4466. * is disabled and the application software has to enable this clock before
  4467. * using it.
  4468. * @{
  4469. */
  4470. #if defined(STM32F423xx)
  4471. #define __HAL_RCC_AES_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_AESEN)) != RESET)
  4472. #define __HAL_RCC_AES_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_AESEN)) == RESET)
  4473. #endif /* STM32F423xx */
  4474. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) != RESET)
  4475. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_OTGFSEN)) == RESET)
  4476. #define __HAL_RCC_RNG_IS_CLK_ENABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) != RESET)
  4477. #define __HAL_RCC_RNG_IS_CLK_DISABLED() ((RCC->AHB2ENR & (RCC_AHB2ENR_RNGEN)) == RESET)
  4478. /**
  4479. * @}
  4480. */
  4481. /** @defgroup RCCEx_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  4482. * @brief Enables or disables the AHB3 peripheral clock.
  4483. * @note After reset, the peripheral clock (used for registers read/write access)
  4484. * is disabled and the application software has to enable this clock before
  4485. * using it.
  4486. * @{
  4487. */
  4488. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  4489. #define __HAL_RCC_FSMC_CLK_ENABLE() do { \
  4490. __IO uint32_t tmpreg = 0x00U; \
  4491. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  4492. /* Delay after an RCC peripheral clock enabling */ \
  4493. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  4494. UNUSED(tmpreg); \
  4495. } while(0U)
  4496. #define __HAL_RCC_QSPI_CLK_ENABLE() do { \
  4497. __IO uint32_t tmpreg = 0x00U; \
  4498. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  4499. /* Delay after an RCC peripheral clock enabling */ \
  4500. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  4501. UNUSED(tmpreg); \
  4502. } while(0U)
  4503. #define __HAL_RCC_FSMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FSMCEN))
  4504. #define __HAL_RCC_QSPI_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_QSPIEN))
  4505. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  4506. /**
  4507. * @}
  4508. */
  4509. /** @defgroup RCCEx_AHB3_Peripheral_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enable Disable Status
  4510. * @brief Get the enable or disable status of the AHB3 peripheral clock.
  4511. * @note After reset, the peripheral clock (used for registers read/write access)
  4512. * is disabled and the application software has to enable this clock before
  4513. * using it.
  4514. * @{
  4515. */
  4516. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  4517. #define __HAL_RCC_FSMC_IS_CLK_ENABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FSMCEN)) != RESET)
  4518. #define __HAL_RCC_QSPI_IS_CLK_ENABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_QSPIEN)) != RESET)
  4519. #define __HAL_RCC_FSMC_IS_CLK_DISABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_FSMCEN)) == RESET)
  4520. #define __HAL_RCC_QSPI_IS_CLK_DISABLED() ((RCC->AHB3ENR & (RCC_AHB3ENR_QSPIEN)) == RESET)
  4521. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  4522. /**
  4523. * @}
  4524. */
  4525. /** @defgroup RCCEx_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  4526. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  4527. * @note After reset, the peripheral clock (used for registers read/write access)
  4528. * is disabled and the application software has to enable this clock before
  4529. * using it.
  4530. * @{
  4531. */
  4532. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  4533. __IO uint32_t tmpreg = 0x00U; \
  4534. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  4535. /* Delay after an RCC peripheral clock enabling */ \
  4536. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  4537. UNUSED(tmpreg); \
  4538. } while(0U)
  4539. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  4540. __IO uint32_t tmpreg = 0x00U; \
  4541. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  4542. /* Delay after an RCC peripheral clock enabling */ \
  4543. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  4544. UNUSED(tmpreg); \
  4545. } while(0U)
  4546. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  4547. __IO uint32_t tmpreg = 0x00U; \
  4548. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  4549. /* Delay after an RCC peripheral clock enabling */ \
  4550. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  4551. UNUSED(tmpreg); \
  4552. } while(0U)
  4553. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  4554. __IO uint32_t tmpreg = 0x00U; \
  4555. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  4556. /* Delay after an RCC peripheral clock enabling */ \
  4557. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  4558. UNUSED(tmpreg); \
  4559. } while(0U)
  4560. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  4561. __IO uint32_t tmpreg = 0x00U; \
  4562. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  4563. /* Delay after an RCC peripheral clock enabling */ \
  4564. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  4565. UNUSED(tmpreg); \
  4566. } while(0U)
  4567. #if defined(STM32F413xx) || defined(STM32F423xx)
  4568. #define __HAL_RCC_LPTIM1_CLK_ENABLE() do { \
  4569. __IO uint32_t tmpreg = 0x00U; \
  4570. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_LPTIM1EN);\
  4571. /* Delay after an RCC peripheral clock enabling */ \
  4572. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_LPTIM1EN);\
  4573. UNUSED(tmpreg); \
  4574. } while(0U)
  4575. #endif /* STM32F413xx || STM32F423xx */
  4576. #define __HAL_RCC_RTCAPB_CLK_ENABLE() do { \
  4577. __IO uint32_t tmpreg = 0x00U; \
  4578. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_RTCAPBEN);\
  4579. /* Delay after an RCC peripheral clock enabling */ \
  4580. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_RTCAPBEN);\
  4581. UNUSED(tmpreg); \
  4582. } while(0U)
  4583. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  4584. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  4585. __IO uint32_t tmpreg = 0x00U; \
  4586. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  4587. /* Delay after an RCC peripheral clock enabling */ \
  4588. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  4589. UNUSED(tmpreg); \
  4590. } while(0U)
  4591. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  4592. #if defined(STM32F413xx) || defined(STM32F423xx)
  4593. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  4594. __IO uint32_t tmpreg = 0x00U; \
  4595. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  4596. /* Delay after an RCC peripheral clock enabling */ \
  4597. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  4598. UNUSED(tmpreg); \
  4599. } while(0U)
  4600. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  4601. __IO uint32_t tmpreg = 0x00U; \
  4602. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  4603. /* Delay after an RCC peripheral clock enabling */ \
  4604. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  4605. UNUSED(tmpreg); \
  4606. } while(0U)
  4607. #endif /* STM32F413xx || STM32F423xx */
  4608. #define __HAL_RCC_FMPI2C1_CLK_ENABLE() do { \
  4609. __IO uint32_t tmpreg = 0x00U; \
  4610. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  4611. /* Delay after an RCC peripheral clock enabling */ \
  4612. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  4613. UNUSED(tmpreg); \
  4614. } while(0U)
  4615. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  4616. __IO uint32_t tmpreg = 0x00U; \
  4617. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  4618. /* Delay after an RCC peripheral clock enabling */ \
  4619. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  4620. UNUSED(tmpreg); \
  4621. } while(0U)
  4622. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  4623. __IO uint32_t tmpreg = 0x00U; \
  4624. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  4625. /* Delay after an RCC peripheral clock enabling */ \
  4626. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  4627. UNUSED(tmpreg); \
  4628. } while(0U)
  4629. #if defined(STM32F413xx) || defined(STM32F423xx)
  4630. #define __HAL_RCC_CAN3_CLK_ENABLE() do { \
  4631. __IO uint32_t tmpreg = 0x00U; \
  4632. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN3EN);\
  4633. /* Delay after an RCC peripheral clock enabling */ \
  4634. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN3EN);\
  4635. UNUSED(tmpreg); \
  4636. } while(0U)
  4637. #endif /* STM32F413xx || STM32F423xx */
  4638. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  4639. __IO uint32_t tmpreg = 0x00U; \
  4640. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  4641. /* Delay after an RCC peripheral clock enabling */ \
  4642. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  4643. UNUSED(tmpreg); \
  4644. } while(0U)
  4645. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  4646. __IO uint32_t tmpreg = 0x00U; \
  4647. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  4648. /* Delay after an RCC peripheral clock enabling */ \
  4649. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  4650. UNUSED(tmpreg); \
  4651. } while(0U)
  4652. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  4653. __IO uint32_t tmpreg = 0x00U; \
  4654. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  4655. /* Delay after an RCC peripheral clock enabling */ \
  4656. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  4657. UNUSED(tmpreg); \
  4658. } while(0U)
  4659. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  4660. __IO uint32_t tmpreg = 0x00U; \
  4661. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  4662. /* Delay after an RCC peripheral clock enabling */ \
  4663. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  4664. UNUSED(tmpreg); \
  4665. } while(0U)
  4666. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  4667. __IO uint32_t tmpreg = 0x00U; \
  4668. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  4669. /* Delay after an RCC peripheral clock enabling */ \
  4670. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  4671. UNUSED(tmpreg); \
  4672. } while(0U)
  4673. #if defined(STM32F413xx) || defined(STM32F423xx)
  4674. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  4675. __IO uint32_t tmpreg = 0x00U; \
  4676. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  4677. /* Delay after an RCC peripheral clock enabling */ \
  4678. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  4679. UNUSED(tmpreg); \
  4680. } while(0U)
  4681. #define __HAL_RCC_UART7_CLK_ENABLE() do { \
  4682. __IO uint32_t tmpreg = 0x00U; \
  4683. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART7EN);\
  4684. /* Delay after an RCC peripheral clock enabling */ \
  4685. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART7EN);\
  4686. UNUSED(tmpreg); \
  4687. } while(0U)
  4688. #define __HAL_RCC_UART8_CLK_ENABLE() do { \
  4689. __IO uint32_t tmpreg = 0x00U; \
  4690. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART8EN);\
  4691. /* Delay after an RCC peripheral clock enabling */ \
  4692. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART8EN);\
  4693. UNUSED(tmpreg); \
  4694. } while(0U)
  4695. #endif /* STM32F413xx || STM32F423xx */
  4696. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  4697. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  4698. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  4699. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  4700. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  4701. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  4702. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  4703. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  4704. #if defined(STM32F413xx) || defined(STM32F423xx)
  4705. #define __HAL_RCC_LPTIM1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_LPTIM1EN))
  4706. #endif /* STM32F413xx || STM32F423xx */
  4707. #define __HAL_RCC_RTCAPB_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_RTCAPBEN))
  4708. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  4709. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  4710. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  4711. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  4712. #if defined(STM32F413xx) || defined(STM32F423xx)
  4713. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  4714. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  4715. #endif /* STM32F413xx || STM32F423xx */
  4716. #define __HAL_RCC_I2C3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C3EN))
  4717. #define __HAL_RCC_FMPI2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_FMPI2C1EN))
  4718. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  4719. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  4720. #if defined(STM32F413xx) || defined(STM32F423xx)
  4721. #define __HAL_RCC_CAN3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN3EN))
  4722. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  4723. #define __HAL_RCC_UART7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART7EN))
  4724. #define __HAL_RCC_UART8_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART8EN))
  4725. #endif /* STM32F413xx || STM32F423xx */
  4726. /**
  4727. * @}
  4728. */
  4729. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  4730. * @brief Get the enable or disable status of the APB1 peripheral clock.
  4731. * @note After reset, the peripheral clock (used for registers read/write access)
  4732. * is disabled and the application software has to enable this clock before
  4733. * using it.
  4734. * @{
  4735. */
  4736. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  4737. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
  4738. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  4739. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  4740. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  4741. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) != RESET)
  4742. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) != RESET)
  4743. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) != RESET)
  4744. #if defined(STM32F413xx) || defined(STM32F423xx)
  4745. #define __HAL_RCC_LPTIM1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_LPTIM1EN)) != RESET)
  4746. #endif /* STM32F413xx || STM32F423xx */
  4747. #define __HAL_RCC_RTCAPB_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_RTCAPBEN)) != RESET)
  4748. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  4749. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  4750. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
  4751. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx | STM32F423xx */
  4752. #if defined(STM32F413xx) || defined(STM32F423xx)
  4753. #define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) != RESET)
  4754. #define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) != RESET)
  4755. #endif /* STM32F413xx || STM32F423xx */
  4756. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) != RESET)
  4757. #define __HAL_RCC_FMPI2C1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_FMPI2C1EN)) != RESET)
  4758. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN))!= RESET)
  4759. #define __HAL_RCC_CAN2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) != RESET)
  4760. #if defined(STM32F413xx) || defined(STM32F423xx)
  4761. #define __HAL_RCC_CAN3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN3EN)) != RESET)
  4762. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  4763. #define __HAL_RCC_UART7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART7EN)) != RESET)
  4764. #define __HAL_RCC_UART8_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART8EN)) != RESET)
  4765. #endif /* STM32F413xx || STM32F423xx */
  4766. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  4767. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
  4768. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  4769. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  4770. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  4771. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) == RESET)
  4772. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) == RESET)
  4773. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) == RESET)
  4774. #if defined(STM32F413xx) || defined(STM32F423xx)
  4775. #define __HAL_RCC_LPTIM1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_LPTIM1EN)) == RESET)
  4776. #endif /* STM32F413xx || STM32F423xx */
  4777. #define __HAL_RCC_RTCAPB_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_RTCAPBEN)) == RESET)
  4778. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  4779. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  4780. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
  4781. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx | STM32F423xx */
  4782. #if defined(STM32F413xx) || defined(STM32F423xx)
  4783. #define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) == RESET)
  4784. #define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) == RESET)
  4785. #endif /* STM32F413xx || STM32F423xx */
  4786. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C3EN)) == RESET)
  4787. #define __HAL_RCC_FMPI2C1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_FMPI2C1EN)) == RESET)
  4788. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) == RESET)
  4789. #define __HAL_RCC_CAN2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) == RESET)
  4790. #if defined(STM32F413xx) || defined(STM32F423xx)
  4791. #define __HAL_RCC_CAN3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN3EN)) == RESET)
  4792. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  4793. #define __HAL_RCC_UART7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART7EN)) == RESET)
  4794. #define __HAL_RCC_UART8_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART8EN)) == RESET)
  4795. #endif /* STM32F413xx || STM32F423xx */
  4796. /**
  4797. * @}
  4798. */
  4799. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  4800. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  4801. * @note After reset, the peripheral clock (used for registers read/write access)
  4802. * is disabled and the application software has to enable this clock before
  4803. * using it.
  4804. * @{
  4805. */
  4806. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  4807. __IO uint32_t tmpreg = 0x00U; \
  4808. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  4809. /* Delay after an RCC peripheral clock enabling */ \
  4810. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  4811. UNUSED(tmpreg); \
  4812. } while(0U)
  4813. #if defined(STM32F413xx) || defined(STM32F423xx)
  4814. #define __HAL_RCC_UART9_CLK_ENABLE() do { \
  4815. __IO uint32_t tmpreg = 0x00U; \
  4816. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_UART9EN);\
  4817. /* Delay after an RCC peripheral clock enabling */ \
  4818. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_UART9EN);\
  4819. UNUSED(tmpreg); \
  4820. } while(0U)
  4821. #define __HAL_RCC_UART10_CLK_ENABLE() do { \
  4822. __IO uint32_t tmpreg = 0x00U; \
  4823. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_UART10EN);\
  4824. /* Delay after an RCC peripheral clock enabling */ \
  4825. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_UART10EN);\
  4826. UNUSED(tmpreg); \
  4827. } while(0U)
  4828. #endif /* STM32F413xx || STM32F423xx */
  4829. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  4830. __IO uint32_t tmpreg = 0x00U; \
  4831. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  4832. /* Delay after an RCC peripheral clock enabling */ \
  4833. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  4834. UNUSED(tmpreg); \
  4835. } while(0U)
  4836. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  4837. __IO uint32_t tmpreg = 0x00U; \
  4838. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  4839. /* Delay after an RCC peripheral clock enabling */ \
  4840. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN);\
  4841. UNUSED(tmpreg); \
  4842. } while(0U)
  4843. #define __HAL_RCC_EXTIT_CLK_ENABLE() do { \
  4844. __IO uint32_t tmpreg = 0x00U; \
  4845. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_EXTITEN);\
  4846. /* Delay after an RCC peripheral clock enabling */ \
  4847. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_EXTITEN);\
  4848. UNUSED(tmpreg); \
  4849. } while(0U)
  4850. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  4851. __IO uint32_t tmpreg = 0x00U; \
  4852. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  4853. /* Delay after an RCC peripheral clock enabling */ \
  4854. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  4855. UNUSED(tmpreg); \
  4856. } while(0U)
  4857. #define __HAL_RCC_SPI5_CLK_ENABLE() do { \
  4858. __IO uint32_t tmpreg = 0x00U; \
  4859. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  4860. /* Delay after an RCC peripheral clock enabling */ \
  4861. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  4862. UNUSED(tmpreg); \
  4863. } while(0U)
  4864. #if defined(STM32F413xx) || defined(STM32F423xx)
  4865. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  4866. __IO uint32_t tmpreg = 0x00U; \
  4867. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  4868. /* Delay after an RCC peripheral clock enabling */ \
  4869. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  4870. UNUSED(tmpreg); \
  4871. } while(0U)
  4872. #endif /* STM32F413xx || STM32F423xx */
  4873. #define __HAL_RCC_DFSDM1_CLK_ENABLE() do { \
  4874. __IO uint32_t tmpreg = 0x00U; \
  4875. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM1EN);\
  4876. /* Delay after an RCC peripheral clock enabling */ \
  4877. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM1EN);\
  4878. UNUSED(tmpreg); \
  4879. } while(0U)
  4880. #if defined(STM32F413xx) || defined(STM32F423xx)
  4881. #define __HAL_RCC_DFSDM2_CLK_ENABLE() do { \
  4882. __IO uint32_t tmpreg = 0x00U; \
  4883. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM2EN);\
  4884. /* Delay after an RCC peripheral clock enabling */ \
  4885. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM2EN);\
  4886. UNUSED(tmpreg); \
  4887. } while(0U)
  4888. #endif /* STM32F413xx || STM32F423xx */
  4889. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  4890. #if defined(STM32F413xx) || defined(STM32F423xx)
  4891. #define __HAL_RCC_UART9_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_UART9EN))
  4892. #define __HAL_RCC_UART10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_UART10EN))
  4893. #endif /* STM32F413xx || STM32F423xx */
  4894. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SDIOEN))
  4895. #define __HAL_RCC_SPI4_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI4EN))
  4896. #define __HAL_RCC_EXTIT_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_EXTITEN))
  4897. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  4898. #define __HAL_RCC_SPI5_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI5EN))
  4899. #if defined(STM32F413xx) || defined(STM32F423xx)
  4900. #define __HAL_RCC_SAI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SAI1EN))
  4901. #endif /* STM32F413xx || STM32F423xx */
  4902. #define __HAL_RCC_DFSDM1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_DFSDM1EN))
  4903. #if defined(STM32F413xx) || defined(STM32F423xx)
  4904. #define __HAL_RCC_DFSDM2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_DFSDM2EN))
  4905. #endif /* STM32F413xx || STM32F423xx */
  4906. /**
  4907. * @}
  4908. */
  4909. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  4910. * @brief Get the enable or disable status of the APB2 peripheral clock.
  4911. * @note After reset, the peripheral clock (used for registers read/write access)
  4912. * is disabled and the application software has to enable this clock before
  4913. * using it.
  4914. * @{
  4915. */
  4916. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) != RESET)
  4917. #if defined(STM32F413xx) || defined(STM32F423xx)
  4918. #define __HAL_RCC_UART9_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_UART9EN)) != RESET)
  4919. #define __HAL_RCC_UART10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_UART10EN)) != RESET)
  4920. #endif /* STM32F413xx || STM32F423xx */
  4921. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) != RESET)
  4922. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) != RESET)
  4923. #define __HAL_RCC_EXTIT_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_EXTITEN)) != RESET)
  4924. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) != RESET)
  4925. #define __HAL_RCC_SPI5_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) != RESET)
  4926. #if defined(STM32F413xx) || defined(STM32F423xx)
  4927. #define __HAL_RCC_SAI1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI1EN)) != RESET)
  4928. #endif /* STM32F413xx || STM32F423xx */
  4929. #define __HAL_RCC_DFSDM1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_DFSDM1EN)) != RESET)
  4930. #if defined(STM32F413xx) || defined(STM32F423xx)
  4931. #define __HAL_RCC_DFSDM2_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_DFSDM2EN)) != RESET)
  4932. #endif /* STM32F413xx || STM32F423xx */
  4933. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) == RESET)
  4934. #if defined(STM32F413xx) || defined(STM32F423xx)
  4935. #define __HAL_RCC_UART9_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_UART9EN)) == RESET)
  4936. #define __HAL_RCC_UART10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_UART10EN)) == RESET)
  4937. #endif /* STM32F413xx || STM32F423xx */
  4938. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SDIOEN)) == RESET)
  4939. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI4EN)) == RESET)
  4940. #define __HAL_RCC_EXTIT_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_EXTITEN)) == RESET)
  4941. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) == RESET)
  4942. #define __HAL_RCC_SPI5_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI5EN)) == RESET)
  4943. #if defined(STM32F413xx) || defined(STM32F423xx)
  4944. #define __HAL_RCC_SAI1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SAI1EN)) == RESET)
  4945. #endif /* STM32F413xx || STM32F423xx */
  4946. #define __HAL_RCC_DFSDM1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_DFSDM1EN)) == RESET)
  4947. #if defined(STM32F413xx) || defined(STM32F423xx)
  4948. #define __HAL_RCC_DFSDM2_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_DFSDM2EN)) == RESET)
  4949. #endif /* STM32F413xx || STM32F423xx */
  4950. /**
  4951. * @}
  4952. */
  4953. /** @defgroup RCCEx_AHB1_Force_Release_Reset AHB1 Force Release Reset
  4954. * @brief Force or release AHB1 peripheral reset.
  4955. * @{
  4956. */
  4957. #if defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4958. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIODRST))
  4959. #endif /* STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4960. #if defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4961. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOERST))
  4962. #endif /* STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4963. #if defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4964. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  4965. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  4966. #endif /* STM32F412Zx || STM32F413xx || STM32F423xx */
  4967. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  4968. #if defined(STM32F412Rx) || defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4969. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST))
  4970. #endif /* STM32F412Rx || STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4971. #if defined(STM32F412Vx) || defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4972. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOERST))
  4973. #endif /* STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  4974. #if defined(STM32F412Zx) || defined(STM32F413xx) || defined(STM32F423xx)
  4975. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  4976. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  4977. #endif /* STM32F412Zx || STM32F413xx || STM32F423xx */
  4978. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  4979. /**
  4980. * @}
  4981. */
  4982. /** @defgroup RCCEx_AHB2_Force_Release_Reset AHB2 Force Release Reset
  4983. * @brief Force or release AHB2 peripheral reset.
  4984. * @{
  4985. */
  4986. #define __HAL_RCC_AHB2_FORCE_RESET() (RCC->AHB2RSTR = 0xFFFFFFFFU)
  4987. #define __HAL_RCC_AHB2_RELEASE_RESET() (RCC->AHB2RSTR = 0x00U)
  4988. #if defined(STM32F423xx)
  4989. #define __HAL_RCC_AES_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_AESRST))
  4990. #define __HAL_RCC_AES_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_AESRST))
  4991. #endif /* STM32F423xx */
  4992. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_OTGFSRST))
  4993. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_OTGFSRST))
  4994. #define __HAL_RCC_RNG_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_RNGRST))
  4995. #define __HAL_RCC_RNG_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_RNGRST))
  4996. /**
  4997. * @}
  4998. */
  4999. /** @defgroup RCCEx_AHB3_Force_Release_Reset AHB3 Force Release Reset
  5000. * @brief Force or release AHB3 peripheral reset.
  5001. * @{
  5002. */
  5003. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  5004. #define __HAL_RCC_AHB3_FORCE_RESET() (RCC->AHB3RSTR = 0xFFFFFFFFU)
  5005. #define __HAL_RCC_AHB3_RELEASE_RESET() (RCC->AHB3RSTR = 0x00U)
  5006. #define __HAL_RCC_FSMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FSMCRST))
  5007. #define __HAL_RCC_QSPI_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_QSPIRST))
  5008. #define __HAL_RCC_FSMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FSMCRST))
  5009. #define __HAL_RCC_QSPI_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_QSPIRST))
  5010. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  5011. #if defined(STM32F412Cx)
  5012. #define __HAL_RCC_AHB3_FORCE_RESET()
  5013. #define __HAL_RCC_AHB3_RELEASE_RESET()
  5014. #define __HAL_RCC_FSMC_FORCE_RESET()
  5015. #define __HAL_RCC_QSPI_FORCE_RESET()
  5016. #define __HAL_RCC_FSMC_RELEASE_RESET()
  5017. #define __HAL_RCC_QSPI_RELEASE_RESET()
  5018. #endif /* STM32F412Cx */
  5019. /**
  5020. * @}
  5021. */
  5022. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  5023. * @brief Force or release APB1 peripheral reset.
  5024. * @{
  5025. */
  5026. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  5027. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  5028. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  5029. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  5030. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  5031. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  5032. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  5033. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  5034. #if defined(STM32F413xx) || defined(STM32F423xx)
  5035. #define __HAL_RCC_LPTIM1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_LPTIM1RST))
  5036. #endif /* STM32F413xx || STM32F423xx */
  5037. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  5038. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  5039. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  5040. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  5041. #if defined(STM32F413xx) || defined(STM32F423xx)
  5042. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  5043. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  5044. #endif /* STM32F413xx || STM32F423xx */
  5045. #define __HAL_RCC_I2C3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C3RST))
  5046. #define __HAL_RCC_FMPI2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_FMPI2C1RST))
  5047. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  5048. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  5049. #if defined(STM32F413xx) || defined(STM32F423xx)
  5050. #define __HAL_RCC_CAN3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN3RST))
  5051. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  5052. #define __HAL_RCC_UART7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART7RST))
  5053. #define __HAL_RCC_UART8_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART8RST))
  5054. #endif /* STM32F413xx || STM32F423xx */
  5055. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  5056. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  5057. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  5058. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  5059. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  5060. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  5061. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  5062. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  5063. #if defined(STM32F413xx) || defined(STM32F423xx)
  5064. #define __HAL_RCC_LPTIM1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_LPTIM1RST))
  5065. #endif /* STM32F413xx || STM32F423xx */
  5066. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  5067. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  5068. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  5069. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  5070. #if defined(STM32F413xx) || defined(STM32F423xx)
  5071. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  5072. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  5073. #endif /* STM32F413xx || STM32F423xx */
  5074. #define __HAL_RCC_I2C3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C3RST))
  5075. #define __HAL_RCC_FMPI2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_FMPI2C1RST))
  5076. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  5077. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  5078. #if defined(STM32F413xx) || defined(STM32F423xx)
  5079. #define __HAL_RCC_CAN3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN3RST))
  5080. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  5081. #define __HAL_RCC_UART7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART7RST))
  5082. #define __HAL_RCC_UART8_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART8RST))
  5083. #endif /* STM32F413xx || STM32F423xx */
  5084. /**
  5085. * @}
  5086. */
  5087. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  5088. * @brief Force or release APB2 peripheral reset.
  5089. * @{
  5090. */
  5091. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  5092. #if defined(STM32F413xx) || defined(STM32F423xx)
  5093. #define __HAL_RCC_UART9_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_UART9RST))
  5094. #define __HAL_RCC_UART10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_UART10RST))
  5095. #endif /* STM32F413xx || STM32F423xx */
  5096. #define __HAL_RCC_SDIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SDIORST))
  5097. #define __HAL_RCC_SPI4_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI4RST))
  5098. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  5099. #define __HAL_RCC_SPI5_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI5RST))
  5100. #if defined(STM32F413xx) || defined(STM32F423xx)
  5101. #define __HAL_RCC_SAI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SAI1RST))
  5102. #endif /* STM32F413xx || STM32F423xx */
  5103. #define __HAL_RCC_DFSDM1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_DFSDM1RST))
  5104. #if defined(STM32F413xx) || defined(STM32F423xx)
  5105. #define __HAL_RCC_DFSDM2_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_DFSDM2RST))
  5106. #endif /* STM32F413xx || STM32F423xx */
  5107. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  5108. #if defined(STM32F413xx) || defined(STM32F423xx)
  5109. #define __HAL_RCC_UART9_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_UART9RST))
  5110. #define __HAL_RCC_UART10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_UART10RST))
  5111. #endif /* STM32F413xx || STM32F423xx */
  5112. #define __HAL_RCC_SDIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SDIORST))
  5113. #define __HAL_RCC_SPI4_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI4RST))
  5114. #define __HAL_RCC_TIM10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  5115. #define __HAL_RCC_SPI5_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI5RST))
  5116. #if defined(STM32F413xx) || defined(STM32F423xx)
  5117. #define __HAL_RCC_SAI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SAI1RST))
  5118. #endif /* STM32F413xx || STM32F423xx */
  5119. #define __HAL_RCC_DFSDM1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_DFSDM1RST))
  5120. #if defined(STM32F413xx) || defined(STM32F423xx)
  5121. #define __HAL_RCC_DFSDM2_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_DFSDM2RST))
  5122. #endif /* STM32F413xx || STM32F423xx */
  5123. /**
  5124. * @}
  5125. */
  5126. /** @defgroup RCCEx_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  5127. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  5128. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  5129. * power consumption.
  5130. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  5131. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  5132. * @{
  5133. */
  5134. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIODLPEN))
  5135. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOELPEN))
  5136. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  5137. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  5138. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  5139. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  5140. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  5141. #if defined(STM32F413xx) || defined(STM32F423xx)
  5142. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  5143. #endif /* STM32F413xx || STM32F423xx */
  5144. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIODLPEN))
  5145. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOELPEN))
  5146. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  5147. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  5148. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  5149. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  5150. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  5151. #if defined(STM32F413xx) || defined(STM32F423xx)
  5152. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  5153. #endif /* STM32F413xx || STM32F423xx */
  5154. /**
  5155. * @}
  5156. */
  5157. /** @defgroup RCCEx_AHB2_LowPower_Enable_Disable AHB2 Peripheral Low Power Enable Disable
  5158. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  5159. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  5160. * power consumption.
  5161. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  5162. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  5163. * @{
  5164. */
  5165. #if defined(STM32F423xx)
  5166. #define __HAL_RCC_AES_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_AESLPEN))
  5167. #define __HAL_RCC_AES_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_AESLPEN))
  5168. #endif /* STM32F423xx */
  5169. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_OTGFSLPEN))
  5170. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_OTGFSLPEN))
  5171. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_RNGLPEN))
  5172. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_RNGLPEN))
  5173. /**
  5174. * @}
  5175. */
  5176. /** @defgroup RCCEx_AHB3_LowPower_Enable_Disable AHB3 Peripheral Low Power Enable Disable
  5177. * @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  5178. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  5179. * power consumption.
  5180. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  5181. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  5182. * @{
  5183. */
  5184. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  5185. #define __HAL_RCC_FSMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FSMCLPEN))
  5186. #define __HAL_RCC_QSPI_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_QSPILPEN))
  5187. #define __HAL_RCC_FSMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FSMCLPEN))
  5188. #define __HAL_RCC_QSPI_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_QSPILPEN))
  5189. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  5190. /**
  5191. * @}
  5192. */
  5193. /** @defgroup RCCEx_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  5194. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  5195. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  5196. * power consumption.
  5197. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  5198. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  5199. * @{
  5200. */
  5201. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  5202. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  5203. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  5204. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  5205. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  5206. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  5207. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  5208. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  5209. #if defined(STM32F413xx) || defined(STM32F423xx)
  5210. #define __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_LPTIM1LPEN))
  5211. #endif /* STM32F413xx || STM32F423xx */
  5212. #define __HAL_RCC_RTCAPB_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_RTCAPBLPEN))
  5213. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
  5214. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  5215. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  5216. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  5217. #if defined(STM32F413xx) || defined(STM32F423xx)
  5218. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  5219. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  5220. #endif /* STM32F413xx || STM32F423xx */
  5221. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C3LPEN))
  5222. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_FMPI2C1LPEN))
  5223. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  5224. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  5225. #if defined(STM32F413xx) || defined(STM32F423xx)
  5226. #define __HAL_RCC_CAN3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN3LPEN))
  5227. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  5228. #define __HAL_RCC_UART7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART7LPEN))
  5229. #define __HAL_RCC_UART8_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART8LPEN))
  5230. #endif /* STM32F413xx || STM32F423xx */
  5231. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  5232. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  5233. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  5234. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  5235. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  5236. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  5237. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  5238. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  5239. #if defined(STM32F413xx) || defined(STM32F423xx)
  5240. #define __HAL_RCC_LPTIM1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_LPTIM1LPEN))
  5241. #endif /* STM32F413xx || STM32F423xx */
  5242. #define __HAL_RCC_RTCAPB_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_RTCAPBLPEN))
  5243. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
  5244. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  5245. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  5246. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  5247. #if defined(STM32F413xx) || defined(STM32F423xx)
  5248. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  5249. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  5250. #endif /* STM32F413xx || STM32F423xx */
  5251. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C3LPEN))
  5252. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_DISABLE()(RCC->APB1LPENR &= ~(RCC_APB1LPENR_FMPI2C1LPEN))
  5253. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  5254. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  5255. #if defined(STM32F413xx) || defined(STM32F423xx)
  5256. #define __HAL_RCC_CAN3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN3LPEN))
  5257. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  5258. #define __HAL_RCC_UART7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART7LPEN))
  5259. #define __HAL_RCC_UART8_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART8LPEN))
  5260. #endif /* STM32F413xx || STM32F423xx */
  5261. /**
  5262. * @}
  5263. */
  5264. /** @defgroup RCCEx_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  5265. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  5266. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  5267. * power consumption.
  5268. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  5269. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  5270. * @{
  5271. */
  5272. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  5273. #if defined(STM32F413xx) || defined(STM32F423xx)
  5274. #define __HAL_RCC_UART9_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_UART9LPEN))
  5275. #define __HAL_RCC_UART10_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_UART10LPEN))
  5276. #endif /* STM32F413xx || STM32F423xx */
  5277. #define __HAL_RCC_SDIO_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SDIOLPEN))
  5278. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI4LPEN))
  5279. #define __HAL_RCC_EXTIT_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_EXTITLPEN))
  5280. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  5281. #define __HAL_RCC_SPI5_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI5LPEN))
  5282. #if defined(STM32F413xx) || defined(STM32F423xx)
  5283. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SAI1LPEN))
  5284. #endif /* STM32F413xx || STM32F423xx */
  5285. #define __HAL_RCC_DFSDM1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_DFSDM1LPEN))
  5286. #if defined(STM32F413xx) || defined(STM32F423xx)
  5287. #define __HAL_RCC_DFSDM2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_DFSDM2LPEN))
  5288. #endif /* STM32F413xx || STM32F423xx */
  5289. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  5290. #if defined(STM32F413xx) || defined(STM32F423xx)
  5291. #define __HAL_RCC_UART9_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_UART9LPEN))
  5292. #define __HAL_RCC_UART10_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_UART10LPEN))
  5293. #endif /* STM32F413xx || STM32F423xx */
  5294. #define __HAL_RCC_SDIO_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SDIOLPEN))
  5295. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI4LPEN))
  5296. #define __HAL_RCC_EXTIT_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_EXTITLPEN))
  5297. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  5298. #define __HAL_RCC_SPI5_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI5LPEN))
  5299. #if defined(STM32F413xx) || defined(STM32F423xx)
  5300. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SAI1LPEN))
  5301. #endif /* STM32F413xx || STM32F423xx */
  5302. #define __HAL_RCC_DFSDM1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_DFSDM1LPEN))
  5303. #if defined(STM32F413xx) || defined(STM32F423xx)
  5304. #define __HAL_RCC_DFSDM2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_DFSDM2LPEN))
  5305. #endif /* STM32F413xx || STM32F423xx */
  5306. /**
  5307. * @}
  5308. */
  5309. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  5310. /*----------------------------------------------------------------------------*/
  5311. /*------------------------------- PLL Configuration --------------------------*/
  5312. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) ||\
  5313. defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  5314. defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  5315. /** @brief Macro to configure the main PLL clock source, multiplication and division factors.
  5316. * @note This function must be used only when the main PLL is disabled.
  5317. * @param __RCC_PLLSource__ specifies the PLL entry clock source.
  5318. * This parameter can be one of the following values:
  5319. * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
  5320. * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
  5321. * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.
  5322. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  5323. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  5324. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  5325. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  5326. * of 2 MHz to limit PLL jitter.
  5327. * @param __PLLN__ specifies the multiplication factor for PLL VCO output clock
  5328. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5329. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  5330. * output frequency is between 100 and 432 MHz.
  5331. *
  5332. * @param __PLLP__ specifies the division factor for main system clock (SYSCLK)
  5333. * This parameter must be a number in the range {2, 4, 6, or 8}.
  5334. *
  5335. * @param __PLLQ__ specifies the division factor for OTG FS, SDIO and RNG clocks
  5336. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5337. * @note If the USB OTG FS is used in your application, you have to set the
  5338. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  5339. * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work
  5340. * correctly.
  5341. *
  5342. * @param __PLLR__ PLL division factor for I2S, SAI, SYSTEM, SPDIFRX clocks.
  5343. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5344. * @note This parameter is only available in STM32F446xx/STM32F469xx/STM32F479xx/
  5345. STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/STM32F413xx/STM32F423xx devices.
  5346. *
  5347. */
  5348. #define __HAL_RCC_PLL_CONFIG(__RCC_PLLSource__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__,__PLLR__) \
  5349. (RCC->PLLCFGR = ((__RCC_PLLSource__) | (__PLLM__) | \
  5350. ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  5351. ((((__PLLP__) >> 1U) -1U) << RCC_PLLCFGR_PLLP_Pos) | \
  5352. ((__PLLQ__) << RCC_PLLCFGR_PLLQ_Pos) | \
  5353. ((__PLLR__) << RCC_PLLCFGR_PLLR_Pos)))
  5354. #else
  5355. /** @brief Macro to configure the main PLL clock source, multiplication and division factors.
  5356. * @note This function must be used only when the main PLL is disabled.
  5357. * @param __RCC_PLLSource__ specifies the PLL entry clock source.
  5358. * This parameter can be one of the following values:
  5359. * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
  5360. * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
  5361. * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.
  5362. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  5363. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  5364. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  5365. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  5366. * of 2 MHz to limit PLL jitter.
  5367. * @param __PLLN__ specifies the multiplication factor for PLL VCO output clock
  5368. * This parameter must be a number between Min_Data = 50 and Max_Data = 432
  5369. * Except for STM32F411xE devices where Min_Data = 192.
  5370. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  5371. * output frequency is between 100 and 432 MHz, Except for STM32F411xE devices
  5372. * where frequency is between 192 and 432 MHz.
  5373. * @param __PLLP__ specifies the division factor for main system clock (SYSCLK)
  5374. * This parameter must be a number in the range {2, 4, 6, or 8}.
  5375. *
  5376. * @param __PLLQ__ specifies the division factor for OTG FS, SDIO and RNG clocks
  5377. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5378. * @note If the USB OTG FS is used in your application, you have to set the
  5379. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  5380. * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work
  5381. * correctly.
  5382. *
  5383. */
  5384. #define __HAL_RCC_PLL_CONFIG(__RCC_PLLSource__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__) \
  5385. (RCC->PLLCFGR = (0x20000000U | (__RCC_PLLSource__) | (__PLLM__)| \
  5386. ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  5387. ((((__PLLP__) >> 1U) -1U) << RCC_PLLCFGR_PLLP_Pos) | \
  5388. ((__PLLQ__) << RCC_PLLCFGR_PLLQ_Pos)))
  5389. #endif /* STM32F410xx || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  5390. /*----------------------------------------------------------------------------*/
  5391. /*----------------------------PLLI2S Configuration ---------------------------*/
  5392. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  5393. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  5394. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
  5395. defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  5396. defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  5397. /** @brief Macros to enable or disable the PLLI2S.
  5398. * @note The PLLI2S is disabled by hardware when entering STOP and STANDBY modes.
  5399. */
  5400. #define __HAL_RCC_PLLI2S_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLI2SON_BB = ENABLE)
  5401. #define __HAL_RCC_PLLI2S_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLI2SON_BB = DISABLE)
  5402. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  5403. STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx ||
  5404. STM32F412Rx || STM32F412Cx */
  5405. #if defined(STM32F446xx)
  5406. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  5407. * @note This macro must be used only when the PLLI2S is disabled.
  5408. * @note PLLI2S clock source is common with the main PLL (configured in
  5409. * HAL_RCC_ClockConfig() API).
  5410. * @param __PLLI2SM__ specifies the division factor for PLLI2S VCO input clock
  5411. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  5412. * @note You have to set the PLLI2SM parameter correctly to ensure that the VCO input
  5413. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  5414. * of 1 MHz to limit PLLI2S jitter.
  5415. *
  5416. * @param __PLLI2SN__ specifies the multiplication factor for PLLI2S VCO output clock
  5417. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5418. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  5419. * output frequency is between Min_Data = 100 and Max_Data = 432 MHz.
  5420. *
  5421. * @param __PLLI2SP__ specifies division factor for SPDIFRX Clock.
  5422. * This parameter must be a number in the range {2, 4, 6, or 8}.
  5423. * @note the PLLI2SP parameter is only available with STM32F446xx Devices
  5424. *
  5425. * @param __PLLI2SR__ specifies the division factor for I2S clock
  5426. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5427. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  5428. * on the I2S clock frequency.
  5429. *
  5430. * @param __PLLI2SQ__ specifies the division factor for SAI clock
  5431. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5432. */
  5433. #define __HAL_RCC_PLLI2S_CONFIG(__PLLI2SM__, __PLLI2SN__, __PLLI2SP__, __PLLI2SQ__, __PLLI2SR__) \
  5434. (RCC->PLLI2SCFGR = ((__PLLI2SM__) |\
  5435. ((__PLLI2SN__) << RCC_PLLI2SCFGR_PLLI2SN_Pos) |\
  5436. ((((__PLLI2SP__) >> 1U) -1U) << RCC_PLLI2SCFGR_PLLI2SP_Pos) |\
  5437. ((__PLLI2SQ__) << RCC_PLLI2SCFGR_PLLI2SQ_Pos) |\
  5438. ((__PLLI2SR__) << RCC_PLLI2SCFGR_PLLI2SR_Pos)))
  5439. #elif defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
  5440. defined(STM32F413xx) || defined(STM32F423xx)
  5441. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  5442. * @note This macro must be used only when the PLLI2S is disabled.
  5443. * @note PLLI2S clock source is common with the main PLL (configured in
  5444. * HAL_RCC_ClockConfig() API).
  5445. * @param __PLLI2SM__ specifies the division factor for PLLI2S VCO input clock
  5446. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  5447. * @note You have to set the PLLI2SM parameter correctly to ensure that the VCO input
  5448. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  5449. * of 1 MHz to limit PLLI2S jitter.
  5450. *
  5451. * @param __PLLI2SN__ specifies the multiplication factor for PLLI2S VCO output clock
  5452. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5453. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  5454. * output frequency is between Min_Data = 100 and Max_Data = 432 MHz.
  5455. *
  5456. * @param __PLLI2SR__ specifies the division factor for I2S clock
  5457. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5458. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  5459. * on the I2S clock frequency.
  5460. *
  5461. * @param __PLLI2SQ__ specifies the division factor for SAI clock
  5462. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5463. */
  5464. #define __HAL_RCC_PLLI2S_CONFIG(__PLLI2SM__, __PLLI2SN__, __PLLI2SQ__, __PLLI2SR__) \
  5465. (RCC->PLLI2SCFGR = ((__PLLI2SM__) |\
  5466. ((__PLLI2SN__) << RCC_PLLI2SCFGR_PLLI2SN_Pos) |\
  5467. ((__PLLI2SQ__) << RCC_PLLI2SCFGR_PLLI2SQ_Pos) |\
  5468. ((__PLLI2SR__) << RCC_PLLI2SCFGR_PLLI2SR_Pos)))
  5469. #else
  5470. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  5471. * @note This macro must be used only when the PLLI2S is disabled.
  5472. * @note PLLI2S clock source is common with the main PLL (configured in
  5473. * HAL_RCC_ClockConfig() API).
  5474. * @param __PLLI2SN__ specifies the multiplication factor for PLLI2S VCO output clock
  5475. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5476. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  5477. * output frequency is between Min_Data = 100 and Max_Data = 432 MHz.
  5478. *
  5479. * @param __PLLI2SR__ specifies the division factor for I2S clock
  5480. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5481. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  5482. * on the I2S clock frequency.
  5483. *
  5484. */
  5485. #define __HAL_RCC_PLLI2S_CONFIG(__PLLI2SN__, __PLLI2SR__) \
  5486. (RCC->PLLI2SCFGR = (((__PLLI2SN__) << RCC_PLLI2SCFGR_PLLI2SN_Pos) |\
  5487. ((__PLLI2SR__) << RCC_PLLI2SCFGR_PLLI2SR_Pos)))
  5488. #endif /* STM32F446xx */
  5489. #if defined(STM32F411xE)
  5490. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  5491. * @note This macro must be used only when the PLLI2S is disabled.
  5492. * @note This macro must be used only when the PLLI2S is disabled.
  5493. * @note PLLI2S clock source is common with the main PLL (configured in
  5494. * HAL_RCC_ClockConfig() API).
  5495. * @param __PLLI2SM__ specifies the division factor for PLLI2S VCO input clock
  5496. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  5497. * @note The PLLI2SM parameter is only used with STM32F411xE/STM32F410xx Devices
  5498. * @note You have to set the PLLI2SM parameter correctly to ensure that the VCO input
  5499. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  5500. * of 2 MHz to limit PLLI2S jitter.
  5501. * @param __PLLI2SN__ specifies the multiplication factor for PLLI2S VCO output clock
  5502. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  5503. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  5504. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  5505. * @param __PLLI2SR__ specifies the division factor for I2S clock
  5506. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5507. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  5508. * on the I2S clock frequency.
  5509. */
  5510. #define __HAL_RCC_PLLI2S_I2SCLK_CONFIG(__PLLI2SM__, __PLLI2SN__, __PLLI2SR__) (RCC->PLLI2SCFGR = ((__PLLI2SM__) |\
  5511. ((__PLLI2SN__) << RCC_PLLI2SCFGR_PLLI2SN_Pos) |\
  5512. ((__PLLI2SR__) << RCC_PLLI2SCFGR_PLLI2SR_Pos)))
  5513. #endif /* STM32F411xE */
  5514. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  5515. /** @brief Macro used by the SAI HAL driver to configure the PLLI2S clock multiplication and division factors.
  5516. * @note This macro must be used only when the PLLI2S is disabled.
  5517. * @note PLLI2S clock source is common with the main PLL (configured in
  5518. * HAL_RCC_ClockConfig() API)
  5519. * @param __PLLI2SN__ specifies the multiplication factor for PLLI2S VCO output clock.
  5520. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5521. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  5522. * output frequency is between Min_Data = 100 and Max_Data = 432 MHz.
  5523. * @param __PLLI2SQ__ specifies the division factor for SAI1 clock.
  5524. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5525. * @note the PLLI2SQ parameter is only available with STM32F427xx/437xx/429xx/439xx/469xx/479xx
  5526. * Devices and can be configured using the __HAL_RCC_PLLI2S_PLLSAICLK_CONFIG() macro
  5527. * @param __PLLI2SR__ specifies the division factor for I2S clock
  5528. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5529. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  5530. * on the I2S clock frequency.
  5531. */
  5532. #define __HAL_RCC_PLLI2S_SAICLK_CONFIG(__PLLI2SN__, __PLLI2SQ__, __PLLI2SR__) (RCC->PLLI2SCFGR = ((__PLLI2SN__) << 6U) |\
  5533. ((__PLLI2SQ__) << 24U) |\
  5534. ((__PLLI2SR__) << 28U))
  5535. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  5536. /*----------------------------------------------------------------------------*/
  5537. /*------------------------------ PLLSAI Configuration ------------------------*/
  5538. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  5539. /** @brief Macros to Enable or Disable the PLLISAI.
  5540. * @note The PLLSAI is only available with STM32F429x/439x Devices.
  5541. * @note The PLLSAI is disabled by hardware when entering STOP and STANDBY modes.
  5542. */
  5543. #define __HAL_RCC_PLLSAI_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLSAION_BB = ENABLE)
  5544. #define __HAL_RCC_PLLSAI_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLSAION_BB = DISABLE)
  5545. #if defined(STM32F446xx)
  5546. /** @brief Macro to configure the PLLSAI clock multiplication and division factors.
  5547. *
  5548. * @param __PLLSAIM__ specifies the division factor for PLLSAI VCO input clock
  5549. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  5550. * @note You have to set the PLLSAIM parameter correctly to ensure that the VCO input
  5551. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  5552. * of 1 MHz to limit PLLI2S jitter.
  5553. * @note The PLLSAIM parameter is only used with STM32F446xx Devices
  5554. *
  5555. * @param __PLLSAIN__ specifies the multiplication factor for PLLSAI VCO output clock.
  5556. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5557. * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
  5558. * output frequency is between Min_Data = 100 and Max_Data = 432 MHz.
  5559. *
  5560. * @param __PLLSAIP__ specifies division factor for OTG FS, SDIO and RNG clocks.
  5561. * This parameter must be a number in the range {2, 4, 6, or 8}.
  5562. * @note the PLLSAIP parameter is only available with STM32F446xx Devices
  5563. *
  5564. * @param __PLLSAIQ__ specifies the division factor for SAI clock
  5565. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5566. *
  5567. * @param __PLLSAIR__ specifies the division factor for LTDC clock
  5568. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5569. * @note the PLLI2SR parameter is only available with STM32F427/437/429/439xx Devices
  5570. */
  5571. #define __HAL_RCC_PLLSAI_CONFIG(__PLLSAIM__, __PLLSAIN__, __PLLSAIP__, __PLLSAIQ__, __PLLSAIR__) \
  5572. (RCC->PLLSAICFGR = ((__PLLSAIM__) | \
  5573. ((__PLLSAIN__) << RCC_PLLSAICFGR_PLLSAIN_Pos) | \
  5574. ((((__PLLSAIP__) >> 1U) -1U) << RCC_PLLSAICFGR_PLLSAIP_Pos) | \
  5575. ((__PLLSAIQ__) << RCC_PLLSAICFGR_PLLSAIQ_Pos)))
  5576. #endif /* STM32F446xx */
  5577. #if defined(STM32F469xx) || defined(STM32F479xx)
  5578. /** @brief Macro to configure the PLLSAI clock multiplication and division factors.
  5579. *
  5580. * @param __PLLSAIN__ specifies the multiplication factor for PLLSAI VCO output clock.
  5581. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5582. * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
  5583. * output frequency is between Min_Data = 100 and Max_Data = 432 MHz.
  5584. *
  5585. * @param __PLLSAIP__ specifies division factor for SDIO and CLK48 clocks.
  5586. * This parameter must be a number in the range {2, 4, 6, or 8}.
  5587. *
  5588. * @param __PLLSAIQ__ specifies the division factor for SAI clock
  5589. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5590. *
  5591. * @param __PLLSAIR__ specifies the division factor for LTDC clock
  5592. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5593. */
  5594. #define __HAL_RCC_PLLSAI_CONFIG(__PLLSAIN__, __PLLSAIP__, __PLLSAIQ__, __PLLSAIR__) \
  5595. (RCC->PLLSAICFGR = (((__PLLSAIN__) << RCC_PLLSAICFGR_PLLSAIN_Pos) |\
  5596. ((((__PLLSAIP__) >> 1U) -1U) << RCC_PLLSAICFGR_PLLSAIP_Pos) |\
  5597. ((__PLLSAIQ__) << RCC_PLLSAICFGR_PLLSAIQ_Pos) |\
  5598. ((__PLLSAIR__) << RCC_PLLSAICFGR_PLLSAIR_Pos)))
  5599. #endif /* STM32F469xx || STM32F479xx */
  5600. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  5601. /** @brief Macro to configure the PLLSAI clock multiplication and division factors.
  5602. *
  5603. * @param __PLLSAIN__ specifies the multiplication factor for PLLSAI VCO output clock.
  5604. * This parameter must be a number between Min_Data = 50 and Max_Data = 432.
  5605. * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
  5606. * output frequency is between Min_Data = 100 and Max_Data = 432 MHz.
  5607. *
  5608. * @param __PLLSAIQ__ specifies the division factor for SAI clock
  5609. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  5610. *
  5611. * @param __PLLSAIR__ specifies the division factor for LTDC clock
  5612. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  5613. * @note the PLLI2SR parameter is only available with STM32F427/437/429/439xx Devices
  5614. */
  5615. #define __HAL_RCC_PLLSAI_CONFIG(__PLLSAIN__, __PLLSAIQ__, __PLLSAIR__) \
  5616. (RCC->PLLSAICFGR = (((__PLLSAIN__) << RCC_PLLSAICFGR_PLLSAIN_Pos) | \
  5617. ((__PLLSAIQ__) << RCC_PLLSAICFGR_PLLSAIQ_Pos) | \
  5618. ((__PLLSAIR__) << RCC_PLLSAICFGR_PLLSAIR_Pos)))
  5619. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  5620. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  5621. /*----------------------------------------------------------------------------*/
  5622. /*------------------- PLLSAI/PLLI2S Dividers Configuration -------------------*/
  5623. #if defined(STM32F413xx) || defined(STM32F423xx)
  5624. /** @brief Macro to configure the SAI clock Divider coming from PLLI2S.
  5625. * @note This function must be called before enabling the PLLI2S.
  5626. * @param __PLLI2SDivR__ specifies the PLLI2S division factor for SAI1 clock.
  5627. * This parameter must be a number between 1 and 32.
  5628. * SAI1 clock frequency = f(PLLI2SR) / __PLLI2SDivR__
  5629. */
  5630. #define __HAL_RCC_PLLI2S_PLLSAICLKDIVR_CONFIG(__PLLI2SDivR__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLI2SDIVR, (__PLLI2SDivR__)-1U))
  5631. /** @brief Macro to configure the SAI clock Divider coming from PLL.
  5632. * @param __PLLDivR__ specifies the PLL division factor for SAI1 clock.
  5633. * This parameter must be a number between 1 and 32.
  5634. * SAI1 clock frequency = f(PLLR) / __PLLDivR__
  5635. */
  5636. #define __HAL_RCC_PLL_PLLSAICLKDIVR_CONFIG(__PLLDivR__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLDIVR, ((__PLLDivR__)-1U)<<8U))
  5637. #endif /* STM32F413xx || STM32F423xx */
  5638. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) ||\
  5639. defined(STM32F469xx) || defined(STM32F479xx)
  5640. /** @brief Macro to configure the SAI clock Divider coming from PLLI2S.
  5641. * @note This function must be called before enabling the PLLI2S.
  5642. * @param __PLLI2SDivQ__ specifies the PLLI2S division factor for SAI1 clock.
  5643. * This parameter must be a number between 1 and 32.
  5644. * SAI1 clock frequency = f(PLLI2SQ) / __PLLI2SDivQ__
  5645. */
  5646. #define __HAL_RCC_PLLI2S_PLLSAICLKDIVQ_CONFIG(__PLLI2SDivQ__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLI2SDIVQ, (__PLLI2SDivQ__)-1U))
  5647. /** @brief Macro to configure the SAI clock Divider coming from PLLSAI.
  5648. * @note This function must be called before enabling the PLLSAI.
  5649. * @param __PLLSAIDivQ__ specifies the PLLSAI division factor for SAI1 clock .
  5650. * This parameter must be a number between Min_Data = 1 and Max_Data = 32.
  5651. * SAI1 clock frequency = f(PLLSAIQ) / __PLLSAIDivQ__
  5652. */
  5653. #define __HAL_RCC_PLLSAI_PLLSAICLKDIVQ_CONFIG(__PLLSAIDivQ__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVQ, ((__PLLSAIDivQ__)-1U)<<8U))
  5654. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  5655. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  5656. /** @brief Macro to configure the LTDC clock Divider coming from PLLSAI.
  5657. *
  5658. * @note The LTDC peripheral is only available with STM32F427/437/429/439/469/479xx Devices.
  5659. * @note This function must be called before enabling the PLLSAI.
  5660. * @param __PLLSAIDivR__ specifies the PLLSAI division factor for LTDC clock .
  5661. * This parameter must be a number between Min_Data = 2 and Max_Data = 16.
  5662. * LTDC clock frequency = f(PLLSAIR) / __PLLSAIDivR__
  5663. */
  5664. #define __HAL_RCC_PLLSAI_PLLSAICLKDIVR_CONFIG(__PLLSAIDivR__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVR, (__PLLSAIDivR__)))
  5665. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  5666. /*----------------------------------------------------------------------------*/
  5667. /*------------------------- Peripheral Clock selection -----------------------*/
  5668. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  5669. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  5670. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) ||\
  5671. defined(STM32F479xx)
  5672. /** @brief Macro to configure the I2S clock source (I2SCLK).
  5673. * @note This function must be called before enabling the I2S APB clock.
  5674. * @param __SOURCE__ specifies the I2S clock source.
  5675. * This parameter can be one of the following values:
  5676. * @arg RCC_I2SCLKSOURCE_PLLI2S: PLLI2S clock used as I2S clock source.
  5677. * @arg RCC_I2SCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin
  5678. * used as I2S clock source.
  5679. */
  5680. #define __HAL_RCC_I2S_CONFIG(__SOURCE__) (*(__IO uint32_t *) RCC_CFGR_I2SSRC_BB = (__SOURCE__))
  5681. /** @brief Macro to get the I2S clock source (I2SCLK).
  5682. * @retval The clock source can be one of the following values:
  5683. * @arg @ref RCC_I2SCLKSOURCE_PLLI2S: PLLI2S clock used as I2S clock source.
  5684. * @arg @ref RCC_I2SCLKSOURCE_EXT External clock mapped on the I2S_CKIN pin
  5685. * used as I2S clock source
  5686. */
  5687. #define __HAL_RCC_GET_I2S_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_I2SSRC)))
  5688. #endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx */
  5689. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
  5690. /** @brief Macro to configure SAI1BlockA clock source selection.
  5691. * @note The SAI peripheral is only available with STM32F427/437/429/439/469/479xx Devices.
  5692. * @note This function must be called before enabling PLLSAI, PLLI2S and
  5693. * the SAI clock.
  5694. * @param __SOURCE__ specifies the SAI Block A clock source.
  5695. * This parameter can be one of the following values:
  5696. * @arg RCC_SAIACLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used
  5697. * as SAI1 Block A clock.
  5698. * @arg RCC_SAIACLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used
  5699. * as SAI1 Block A clock.
  5700. * @arg RCC_SAIACLKSOURCE_Ext: External clock mapped on the I2S_CKIN pin
  5701. * used as SAI1 Block A clock.
  5702. */
  5703. #define __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1ASRC, (__SOURCE__)))
  5704. /** @brief Macro to configure SAI1BlockB clock source selection.
  5705. * @note The SAI peripheral is only available with STM32F427/437/429/439/469/479xx Devices.
  5706. * @note This function must be called before enabling PLLSAI, PLLI2S and
  5707. * the SAI clock.
  5708. * @param __SOURCE__ specifies the SAI Block B clock source.
  5709. * This parameter can be one of the following values:
  5710. * @arg RCC_SAIBCLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used
  5711. * as SAI1 Block B clock.
  5712. * @arg RCC_SAIBCLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used
  5713. * as SAI1 Block B clock.
  5714. * @arg RCC_SAIBCLKSOURCE_Ext: External clock mapped on the I2S_CKIN pin
  5715. * used as SAI1 Block B clock.
  5716. */
  5717. #define __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1BSRC, (__SOURCE__)))
  5718. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  5719. #if defined(STM32F446xx)
  5720. /** @brief Macro to configure SAI1 clock source selection.
  5721. * @note This configuration is only available with STM32F446xx Devices.
  5722. * @note This function must be called before enabling PLL, PLLSAI, PLLI2S and
  5723. * the SAI clock.
  5724. * @param __SOURCE__ specifies the SAI1 clock source.
  5725. * This parameter can be one of the following values:
  5726. * @arg RCC_SAI1CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI1 clock.
  5727. * @arg RCC_SAI1CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI1 clock.
  5728. * @arg RCC_SAI1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  5729. * @arg RCC_SAI1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  5730. */
  5731. #define __HAL_RCC_SAI1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1SRC, (__SOURCE__)))
  5732. /** @brief Macro to Get SAI1 clock source selection.
  5733. * @note This configuration is only available with STM32F446xx Devices.
  5734. * @retval The clock source can be one of the following values:
  5735. * @arg RCC_SAI1CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI1 clock.
  5736. * @arg RCC_SAI1CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI1 clock.
  5737. * @arg RCC_SAI1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  5738. * @arg RCC_SAI1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  5739. */
  5740. #define __HAL_RCC_GET_SAI1_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SAI1SRC))
  5741. /** @brief Macro to configure SAI2 clock source selection.
  5742. * @note This configuration is only available with STM32F446xx Devices.
  5743. * @note This function must be called before enabling PLL, PLLSAI, PLLI2S and
  5744. * the SAI clock.
  5745. * @param __SOURCE__ specifies the SAI2 clock source.
  5746. * This parameter can be one of the following values:
  5747. * @arg RCC_SAI2CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI2 clock.
  5748. * @arg RCC_SAI2CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI2 clock.
  5749. * @arg RCC_SAI2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI2 clock.
  5750. * @arg RCC_SAI2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL Source clock used as SAI2 clock.
  5751. */
  5752. #define __HAL_RCC_SAI2_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI2SRC, (__SOURCE__)))
  5753. /** @brief Macro to Get SAI2 clock source selection.
  5754. * @note This configuration is only available with STM32F446xx Devices.
  5755. * @retval The clock source can be one of the following values:
  5756. * @arg RCC_SAI2CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI2 clock.
  5757. * @arg RCC_SAI2CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI2 clock.
  5758. * @arg RCC_SAI2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI2 clock.
  5759. * @arg RCC_SAI2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL Source clock used as SAI2 clock.
  5760. */
  5761. #define __HAL_RCC_GET_SAI2_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SAI2SRC))
  5762. /** @brief Macro to configure I2S APB1 clock source selection.
  5763. * @note This function must be called before enabling PLL, PLLI2S and the I2S clock.
  5764. * @param __SOURCE__ specifies the I2S APB1 clock source.
  5765. * This parameter can be one of the following values:
  5766. * @arg RCC_I2SAPB1CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  5767. * @arg RCC_I2SAPB1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as I2S APB1 clock.
  5768. * @arg RCC_I2SAPB1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as I2S APB1 clock.
  5769. * @arg RCC_I2SAPB1CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  5770. */
  5771. #define __HAL_RCC_I2S_APB1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_I2S1SRC, (__SOURCE__)))
  5772. /** @brief Macro to Get I2S APB1 clock source selection.
  5773. * @retval The clock source can be one of the following values:
  5774. * @arg RCC_I2SAPB1CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  5775. * @arg RCC_I2SAPB1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as I2S APB1 clock.
  5776. * @arg RCC_I2SAPB1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as I2S APB1 clock.
  5777. * @arg RCC_I2SAPB1CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  5778. */
  5779. #define __HAL_RCC_GET_I2S_APB1_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_I2S1SRC))
  5780. /** @brief Macro to configure I2S APB2 clock source selection.
  5781. * @note This function must be called before enabling PLL, PLLI2S and the I2S clock.
  5782. * @param __SOURCE__ specifies the SAI Block A clock source.
  5783. * This parameter can be one of the following values:
  5784. * @arg RCC_I2SAPB2CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  5785. * @arg RCC_I2SAPB2CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as I2S APB2 clock.
  5786. * @arg RCC_I2SAPB2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as I2S APB2 clock.
  5787. * @arg RCC_I2SAPB2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  5788. */
  5789. #define __HAL_RCC_I2S_APB2_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_I2S2SRC, (__SOURCE__)))
  5790. /** @brief Macro to Get I2S APB2 clock source selection.
  5791. * @retval The clock source can be one of the following values:
  5792. * @arg RCC_I2SAPB2CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  5793. * @arg RCC_I2SAPB2CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as I2S APB2 clock.
  5794. * @arg RCC_I2SAPB2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as I2S APB2 clock.
  5795. * @arg RCC_I2SAPB2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  5796. */
  5797. #define __HAL_RCC_GET_I2S_APB2_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_I2S2SRC))
  5798. /** @brief Macro to configure the CEC clock.
  5799. * @param __SOURCE__ specifies the CEC clock source.
  5800. * This parameter can be one of the following values:
  5801. * @arg RCC_CECCLKSOURCE_HSI: HSI selected as CEC clock
  5802. * @arg RCC_CECCLKSOURCE_LSE: LSE selected as CEC clock
  5803. */
  5804. #define __HAL_RCC_CEC_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CECSEL, (uint32_t)(__SOURCE__)))
  5805. /** @brief Macro to Get the CEC clock.
  5806. * @retval The clock source can be one of the following values:
  5807. * @arg RCC_CECCLKSOURCE_HSI488: HSI selected as CEC clock
  5808. * @arg RCC_CECCLKSOURCE_LSE: LSE selected as CEC clock
  5809. */
  5810. #define __HAL_RCC_GET_CEC_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CECSEL))
  5811. /** @brief Macro to configure the FMPI2C1 clock.
  5812. * @param __SOURCE__ specifies the FMPI2C1 clock source.
  5813. * This parameter can be one of the following values:
  5814. * @arg RCC_FMPI2C1CLKSOURCE_PCLK1: PCLK1 selected as FMPI2C1 clock
  5815. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as FMPI2C1 clock
  5816. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as FMPI2C1 clock
  5817. */
  5818. #define __HAL_RCC_FMPI2C1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL, (uint32_t)(__SOURCE__)))
  5819. /** @brief Macro to Get the FMPI2C1 clock.
  5820. * @retval The clock source can be one of the following values:
  5821. * @arg RCC_FMPI2C1CLKSOURCE_PCLK1: PCLK1 selected as FMPI2C1 clock
  5822. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as FMPI2C1 clock
  5823. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as FMPI2C1 clock
  5824. */
  5825. #define __HAL_RCC_GET_FMPI2C1_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL))
  5826. /** @brief Macro to configure the CLK48 clock.
  5827. * @param __SOURCE__ specifies the CLK48 clock source.
  5828. * This parameter can be one of the following values:
  5829. * @arg RCC_CLK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CLK48 clock.
  5830. * @arg RCC_CLK48CLKSOURCE_PLLSAIP: PLLSAI VCO Output divided by PLLSAIP used as CLK48 clock.
  5831. */
  5832. #define __HAL_RCC_CLK48_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL, (uint32_t)(__SOURCE__)))
  5833. /** @brief Macro to Get the CLK48 clock.
  5834. * @retval The clock source can be one of the following values:
  5835. * @arg RCC_CLK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CLK48 clock.
  5836. * @arg RCC_CLK48CLKSOURCE_PLLSAIP: PLLSAI VCO Output divided by PLLSAIP used as CLK48 clock.
  5837. */
  5838. #define __HAL_RCC_GET_CLK48_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL))
  5839. /** @brief Macro to configure the SDIO clock.
  5840. * @param __SOURCE__ specifies the SDIO clock source.
  5841. * This parameter can be one of the following values:
  5842. * @arg RCC_SDIOCLKSOURCE_CLK48: CLK48 output used as SDIO clock.
  5843. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  5844. */
  5845. #define __HAL_RCC_SDIO_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL, (uint32_t)(__SOURCE__)))
  5846. /** @brief Macro to Get the SDIO clock.
  5847. * @retval The clock source can be one of the following values:
  5848. * @arg RCC_SDIOCLKSOURCE_CLK48: CLK48 output used as SDIO clock.
  5849. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  5850. */
  5851. #define __HAL_RCC_GET_SDIO_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL))
  5852. /** @brief Macro to configure the SPDIFRX clock.
  5853. * @param __SOURCE__ specifies the SPDIFRX clock source.
  5854. * This parameter can be one of the following values:
  5855. * @arg RCC_SPDIFRXCLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SPDIFRX clock.
  5856. * @arg RCC_SPDIFRXCLKSOURCE_PLLI2SP: PLLI2S VCO Output divided by PLLI2SP used as SPDIFRX clock.
  5857. */
  5858. #define __HAL_RCC_SPDIFRX_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SPDIFRXSEL, (uint32_t)(__SOURCE__)))
  5859. /** @brief Macro to Get the SPDIFRX clock.
  5860. * @retval The clock source can be one of the following values:
  5861. * @arg RCC_SPDIFRXCLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SPDIFRX clock.
  5862. * @arg RCC_SPDIFRXCLKSOURCE_PLLI2SP: PLLI2S VCO Output divided by PLLI2SP used as SPDIFRX clock.
  5863. */
  5864. #define __HAL_RCC_GET_SPDIFRX_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SPDIFRXSEL))
  5865. #endif /* STM32F446xx */
  5866. #if defined(STM32F469xx) || defined(STM32F479xx)
  5867. /** @brief Macro to configure the CLK48 clock.
  5868. * @param __SOURCE__ specifies the CLK48 clock source.
  5869. * This parameter can be one of the following values:
  5870. * @arg RCC_CLK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CLK48 clock.
  5871. * @arg RCC_CLK48CLKSOURCE_PLLSAIP: PLLSAI VCO Output divided by PLLSAIP used as CLK48 clock.
  5872. */
  5873. #define __HAL_RCC_CLK48_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CK48MSEL, (uint32_t)(__SOURCE__)))
  5874. /** @brief Macro to Get the CLK48 clock.
  5875. * @retval The clock source can be one of the following values:
  5876. * @arg RCC_CLK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CLK48 clock.
  5877. * @arg RCC_CLK48CLKSOURCE_PLLSAIP: PLLSAI VCO Output divided by PLLSAIP used as CLK48 clock.
  5878. */
  5879. #define __HAL_RCC_GET_CLK48_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_CK48MSEL))
  5880. /** @brief Macro to configure the SDIO clock.
  5881. * @param __SOURCE__ specifies the SDIO clock source.
  5882. * This parameter can be one of the following values:
  5883. * @arg RCC_SDIOCLKSOURCE_CLK48: CLK48 output used as SDIO clock.
  5884. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  5885. */
  5886. #define __HAL_RCC_SDIO_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SDIOSEL, (uint32_t)(__SOURCE__)))
  5887. /** @brief Macro to Get the SDIO clock.
  5888. * @retval The clock source can be one of the following values:
  5889. * @arg RCC_SDIOCLKSOURCE_CLK48: CLK48 output used as SDIO clock.
  5890. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  5891. */
  5892. #define __HAL_RCC_GET_SDIO_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SDIOSEL))
  5893. /** @brief Macro to configure the DSI clock.
  5894. * @param __SOURCE__ specifies the DSI clock source.
  5895. * This parameter can be one of the following values:
  5896. * @arg RCC_DSICLKSOURCE_PLLR: PLLR output used as DSI clock.
  5897. * @arg RCC_DSICLKSOURCE_DSIPHY: DSI-PHY output used as DSI clock.
  5898. */
  5899. #define __HAL_RCC_DSI_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_DSISEL, (uint32_t)(__SOURCE__)))
  5900. /** @brief Macro to Get the DSI clock.
  5901. * @retval The clock source can be one of the following values:
  5902. * @arg RCC_DSICLKSOURCE_PLLR: PLLR output used as DSI clock.
  5903. * @arg RCC_DSICLKSOURCE_DSIPHY: DSI-PHY output used as DSI clock.
  5904. */
  5905. #define __HAL_RCC_GET_DSI_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_DSISEL))
  5906. #endif /* STM32F469xx || STM32F479xx */
  5907. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
  5908. defined(STM32F413xx) || defined(STM32F423xx)
  5909. /** @brief Macro to configure the DFSDM1 clock.
  5910. * @param __DFSDM1_CLKSOURCE__ specifies the DFSDM1 clock source.
  5911. * This parameter can be one of the following values:
  5912. * @arg RCC_DFSDM1CLKSOURCE_PCLK2: PCLK2 clock used as kernel clock.
  5913. * @arg RCC_DFSDM1CLKSOURCE_SYSCLK: System clock used as kernal clock.
  5914. * @retval None
  5915. */
  5916. #define __HAL_RCC_DFSDM1_CONFIG(__DFSDM1_CLKSOURCE__) MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM1SEL, (__DFSDM1_CLKSOURCE__))
  5917. /** @brief Macro to get the DFSDM1 clock source.
  5918. * @retval The clock source can be one of the following values:
  5919. * @arg RCC_DFSDM1CLKSOURCE_PCLK2: PCLK2 clock used as kernel clock.
  5920. * @arg RCC_DFSDM1CLKSOURCE_SYSCLK: System clock used as kernal clock.
  5921. */
  5922. #define __HAL_RCC_GET_DFSDM1_SOURCE() ((uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM1SEL)))
  5923. /** @brief Macro to configure DFSDM1 Audio clock source selection.
  5924. * @note This configuration is only available with STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/
  5925. STM32F413xx/STM32F423xx Devices.
  5926. * @param __SOURCE__ specifies the DFSDM1 Audio clock source.
  5927. * This parameter can be one of the following values:
  5928. * @arg RCC_DFSDM1AUDIOCLKSOURCE_I2S1: CK_I2S_PCLK1 selected as audio clock
  5929. * @arg RCC_DFSDM1AUDIOCLKSOURCE_I2S2: CK_I2S_PCLK2 selected as audio clock
  5930. */
  5931. #define __HAL_RCC_DFSDM1AUDIO_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM1ASEL, (__SOURCE__)))
  5932. /** @brief Macro to Get DFSDM1 Audio clock source selection.
  5933. * @note This configuration is only available with STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/
  5934. STM32F413xx/STM32F423xx Devices.
  5935. * @retval The clock source can be one of the following values:
  5936. * @arg RCC_DFSDM1AUDIOCLKSOURCE_I2S1: CK_I2S_PCLK1 selected as audio clock
  5937. * @arg RCC_DFSDM1AUDIOCLKSOURCE_I2S2: CK_I2S_PCLK2 selected as audio clock
  5938. */
  5939. #define __HAL_RCC_GET_DFSDM1AUDIO_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM1ASEL))
  5940. #if defined(STM32F413xx) || defined(STM32F423xx)
  5941. /** @brief Macro to configure the DFSDM2 clock.
  5942. * @param __DFSDM2_CLKSOURCE__ specifies the DFSDM1 clock source.
  5943. * This parameter can be one of the following values:
  5944. * @arg RCC_DFSDM2CLKSOURCE_PCLK2: PCLK2 clock used as kernel clock.
  5945. * @arg RCC_DFSDM2CLKSOURCE_SYSCLK: System clock used as kernal clock.
  5946. * @retval None
  5947. */
  5948. #define __HAL_RCC_DFSDM2_CONFIG(__DFSDM2_CLKSOURCE__) MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM1SEL, (__DFSDM2_CLKSOURCE__))
  5949. /** @brief Macro to get the DFSDM2 clock source.
  5950. * @retval The clock source can be one of the following values:
  5951. * @arg RCC_DFSDM2CLKSOURCE_PCLK2: PCLK2 clock used as kernel clock.
  5952. * @arg RCC_DFSDM2CLKSOURCE_SYSCLK: System clock used as kernal clock.
  5953. */
  5954. #define __HAL_RCC_GET_DFSDM2_SOURCE() ((uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM1SEL)))
  5955. /** @brief Macro to configure DFSDM1 Audio clock source selection.
  5956. * @note This configuration is only available with STM32F413xx/STM32F423xx Devices.
  5957. * @param __SOURCE__ specifies the DFSDM2 Audio clock source.
  5958. * This parameter can be one of the following values:
  5959. * @arg RCC_DFSDM2AUDIOCLKSOURCE_I2S1: CK_I2S_PCLK1 selected as audio clock
  5960. * @arg RCC_DFSDM2AUDIOCLKSOURCE_I2S2: CK_I2S_PCLK2 selected as audio clock
  5961. */
  5962. #define __HAL_RCC_DFSDM2AUDIO_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM2ASEL, (__SOURCE__)))
  5963. /** @brief Macro to Get DFSDM2 Audio clock source selection.
  5964. * @note This configuration is only available with STM32F413xx/STM32F423xx Devices.
  5965. * @retval The clock source can be one of the following values:
  5966. * @arg RCC_DFSDM2AUDIOCLKSOURCE_I2S1: CK_I2S_PCLK1 selected as audio clock
  5967. * @arg RCC_DFSDM2AUDIOCLKSOURCE_I2S2: CK_I2S_PCLK2 selected as audio clock
  5968. */
  5969. #define __HAL_RCC_GET_DFSDM2AUDIO_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM2ASEL))
  5970. /** @brief Macro to configure SAI1BlockA clock source selection.
  5971. * @note The SAI peripheral is only available with STM32F413xx/STM32F423xx Devices.
  5972. * @note This function must be called before enabling PLLSAI, PLLI2S and
  5973. * the SAI clock.
  5974. * @param __SOURCE__ specifies the SAI Block A clock source.
  5975. * This parameter can be one of the following values:
  5976. * @arg RCC_SAIACLKSOURCE_PLLI2SR: PLLI2S_R clock divided (R2) used as SAI1 Block A clock.
  5977. * @arg RCC_SAIACLKSOURCE_EXT: External clock mapped on the I2S_CKIN pinused as SAI1 Block A clock.
  5978. * @arg RCC_SAIACLKSOURCE_PLLR: PLL_R clock divided (R1) used as SAI1 Block A clock.
  5979. * @arg RCC_SAIACLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  5980. */
  5981. #define __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1ASRC, (__SOURCE__)))
  5982. /** @brief Macro to Get SAI1 BlockA clock source selection.
  5983. * @note This configuration is only available with STM32F413xx/STM32F423xx Devices.
  5984. * @retval The clock source can be one of the following values:
  5985. * @arg RCC_SAIACLKSOURCE_PLLI2SR: PLLI2S_R clock divided (R2) used as SAI1 Block A clock.
  5986. * @arg RCC_SAIACLKSOURCE_EXT: External clock mapped on the I2S_CKIN pinused as SAI1 Block A clock.
  5987. * @arg RCC_SAIACLKSOURCE_PLLR: PLL_R clock divided (R1) used as SAI1 Block A clock.
  5988. * @arg RCC_SAIACLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  5989. */
  5990. #define __HAL_RCC_GET_SAI_BLOCKA_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SAI1ASRC))
  5991. /** @brief Macro to configure SAI1 BlockB clock source selection.
  5992. * @note The SAI peripheral is only available with STM32F413xx/STM32F423xx Devices.
  5993. * @note This function must be called before enabling PLLSAI, PLLI2S and
  5994. * the SAI clock.
  5995. * @param __SOURCE__ specifies the SAI Block B clock source.
  5996. * This parameter can be one of the following values:
  5997. * @arg RCC_SAIBCLKSOURCE_PLLI2SR: PLLI2S_R clock divided (R2) used as SAI1 Block A clock.
  5998. * @arg RCC_SAIBCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 Block A clock.
  5999. * @arg RCC_SAIBCLKSOURCE_PLLR: PLL_R clock divided (R1) used as SAI1 Block A clock.
  6000. * @arg RCC_SAIBCLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  6001. */
  6002. #define __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1BSRC, (__SOURCE__)))
  6003. /** @brief Macro to Get SAI1 BlockB clock source selection.
  6004. * @note This configuration is only available with STM32F413xx/STM32F423xx Devices.
  6005. * @retval The clock source can be one of the following values:
  6006. * @arg RCC_SAIBCLKSOURCE_PLLI2SR: PLLI2S_R clock divided (R2) used as SAI1 Block A clock.
  6007. * @arg RCC_SAIBCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 Block A clock.
  6008. * @arg RCC_SAIBCLKSOURCE_PLLR: PLL_R clock divided (R1) used as SAI1 Block A clock.
  6009. * @arg RCC_SAIBCLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  6010. */
  6011. #define __HAL_RCC_GET_SAI_BLOCKB_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SAI1BSRC))
  6012. /** @brief Macro to configure the LPTIM1 clock.
  6013. * @param __SOURCE__ specifies the LPTIM1 clock source.
  6014. * This parameter can be one of the following values:
  6015. * @arg RCC_LPTIM1CLKSOURCE_PCLK1: PCLK selected as LPTIM1 clock
  6016. * @arg RCC_LPTIM1CLKSOURCE_HSI: HSI clock selected as LPTIM1 clock
  6017. * @arg RCC_LPTIM1CLKSOURCE_LSI: LSI selected as LPTIM1 clock
  6018. * @arg RCC_LPTIM1CLKSOURCE_LSE: LSE selected as LPTIM1 clock
  6019. */
  6020. #define __HAL_RCC_LPTIM1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_LPTIM1SEL, (uint32_t)(__SOURCE__)))
  6021. /** @brief Macro to Get the LPTIM1 clock.
  6022. * @retval The clock source can be one of the following values:
  6023. * @arg RCC_LPTIM1CLKSOURCE_PCLK1: PCLK selected as LPTIM1 clock
  6024. * @arg RCC_LPTIM1CLKSOURCE_HSI: HSI clock selected as LPTIM1 clock
  6025. * @arg RCC_LPTIM1CLKSOURCE_LSI: LSI selected as LPTIM1 clock
  6026. * @arg RCC_LPTIM1CLKSOURCE_LSE: LSE selected as LPTIM1 clock
  6027. */
  6028. #define __HAL_RCC_GET_LPTIM1_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_LPTIM1SEL))
  6029. #endif /* STM32F413xx || STM32F423xx */
  6030. /** @brief Macro to configure I2S APB1 clock source selection.
  6031. * @param __SOURCE__ specifies the I2S APB1 clock source.
  6032. * This parameter can be one of the following values:
  6033. * @arg RCC_I2SAPB1CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR.
  6034. * @arg RCC_I2SAPB1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin.
  6035. * @arg RCC_I2SAPB1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR.
  6036. * @arg RCC_I2SAPB1CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  6037. */
  6038. #define __HAL_RCC_I2S_APB1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_I2S1SRC, (__SOURCE__)))
  6039. /** @brief Macro to Get I2S APB1 clock source selection.
  6040. * @retval The clock source can be one of the following values:
  6041. * @arg RCC_I2SAPB1CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR.
  6042. * @arg RCC_I2SAPB1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin.
  6043. * @arg RCC_I2SAPB1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR.
  6044. * @arg RCC_I2SAPB1CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  6045. */
  6046. #define __HAL_RCC_GET_I2S_APB1_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_I2S1SRC))
  6047. /** @brief Macro to configure I2S APB2 clock source selection.
  6048. * @param __SOURCE__ specifies the I2S APB2 clock source.
  6049. * This parameter can be one of the following values:
  6050. * @arg RCC_I2SAPB2CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR.
  6051. * @arg RCC_I2SAPB2CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin.
  6052. * @arg RCC_I2SAPB2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR.
  6053. * @arg RCC_I2SAPB2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  6054. */
  6055. #define __HAL_RCC_I2S_APB2_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_I2S2SRC, (__SOURCE__)))
  6056. /** @brief Macro to Get I2S APB2 clock source selection.
  6057. * @retval The clock source can be one of the following values:
  6058. * @arg RCC_I2SAPB2CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR.
  6059. * @arg RCC_I2SAPB2CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin.
  6060. * @arg RCC_I2SAPB2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR.
  6061. * @arg RCC_I2SAPB2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  6062. */
  6063. #define __HAL_RCC_GET_I2S_APB2_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_I2S2SRC))
  6064. /** @brief Macro to configure the PLL I2S clock source (PLLI2SCLK).
  6065. * @note This macro must be called before enabling the I2S APB clock.
  6066. * @param __SOURCE__ specifies the I2S clock source.
  6067. * This parameter can be one of the following values:
  6068. * @arg RCC_PLLI2SCLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  6069. * @arg RCC_PLLI2SCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin
  6070. * used as I2S clock source.
  6071. */
  6072. #define __HAL_RCC_PLL_I2S_CONFIG(__SOURCE__) (*(__IO uint32_t *) RCC_PLLI2SCFGR_PLLI2SSRC_BB = (__SOURCE__))
  6073. /** @brief Macro to configure the FMPI2C1 clock.
  6074. * @param __SOURCE__ specifies the FMPI2C1 clock source.
  6075. * This parameter can be one of the following values:
  6076. * @arg RCC_FMPI2C1CLKSOURCE_PCLK1: PCLK1 selected as FMPI2C1 clock
  6077. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as FMPI2C1 clock
  6078. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as FMPI2C1 clock
  6079. */
  6080. #define __HAL_RCC_FMPI2C1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL, (uint32_t)(__SOURCE__)))
  6081. /** @brief Macro to Get the FMPI2C1 clock.
  6082. * @retval The clock source can be one of the following values:
  6083. * @arg RCC_FMPI2C1CLKSOURCE_PCLK1: PCLK1 selected as FMPI2C1 clock
  6084. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as FMPI2C1 clock
  6085. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as FMPI2C1 clock
  6086. */
  6087. #define __HAL_RCC_GET_FMPI2C1_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL))
  6088. /** @brief Macro to configure the CLK48 clock.
  6089. * @param __SOURCE__ specifies the CLK48 clock source.
  6090. * This parameter can be one of the following values:
  6091. * @arg RCC_CLK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CLK48 clock.
  6092. * @arg RCC_CLK48CLKSOURCE_PLLI2SQ: PLLI2S VCO Output divided by PLLI2SQ used as CLK48 clock.
  6093. */
  6094. #define __HAL_RCC_CLK48_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL, (uint32_t)(__SOURCE__)))
  6095. /** @brief Macro to Get the CLK48 clock.
  6096. * @retval The clock source can be one of the following values:
  6097. * @arg RCC_CLK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CLK48 clock.
  6098. * @arg RCC_CLK48CLKSOURCE_PLLI2SQ: PLLI2S VCO Output divided by PLLI2SQ used as CLK48 clock
  6099. */
  6100. #define __HAL_RCC_GET_CLK48_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL))
  6101. /** @brief Macro to configure the SDIO clock.
  6102. * @param __SOURCE__ specifies the SDIO clock source.
  6103. * This parameter can be one of the following values:
  6104. * @arg RCC_SDIOCLKSOURCE_CLK48: CLK48 output used as SDIO clock.
  6105. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  6106. */
  6107. #define __HAL_RCC_SDIO_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL, (uint32_t)(__SOURCE__)))
  6108. /** @brief Macro to Get the SDIO clock.
  6109. * @retval The clock source can be one of the following values:
  6110. * @arg RCC_SDIOCLKSOURCE_CLK48: CLK48 output used as SDIO clock.
  6111. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  6112. */
  6113. #define __HAL_RCC_GET_SDIO_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL))
  6114. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  6115. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  6116. /** @brief Macro to configure I2S clock source selection.
  6117. * @param __SOURCE__ specifies the I2S clock source.
  6118. * This parameter can be one of the following values:
  6119. * @arg RCC_I2SAPBCLKSOURCE_PLLR: PLL VCO output clock divided by PLLR.
  6120. * @arg RCC_I2SAPBCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin.
  6121. * @arg RCC_I2SAPBCLKSOURCE_PLLSRC: HSI/HSE depends on PLLSRC.
  6122. */
  6123. #define __HAL_RCC_I2S_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_I2SSRC, (__SOURCE__)))
  6124. /** @brief Macro to Get I2S clock source selection.
  6125. * @retval The clock source can be one of the following values:
  6126. * @arg RCC_I2SAPBCLKSOURCE_PLLR: PLL VCO output clock divided by PLLR.
  6127. * @arg RCC_I2SAPBCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin.
  6128. * @arg RCC_I2SAPBCLKSOURCE_PLLSRC: HSI/HSE depends on PLLSRC.
  6129. */
  6130. #define __HAL_RCC_GET_I2S_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_I2SSRC))
  6131. /** @brief Macro to configure the FMPI2C1 clock.
  6132. * @param __SOURCE__ specifies the FMPI2C1 clock source.
  6133. * This parameter can be one of the following values:
  6134. * @arg RCC_FMPI2C1CLKSOURCE_PCLK1: PCLK1 selected as FMPI2C1 clock
  6135. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as FMPI2C1 clock
  6136. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as FMPI2C1 clock
  6137. */
  6138. #define __HAL_RCC_FMPI2C1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL, (uint32_t)(__SOURCE__)))
  6139. /** @brief Macro to Get the FMPI2C1 clock.
  6140. * @retval The clock source can be one of the following values:
  6141. * @arg RCC_FMPI2C1CLKSOURCE_PCLK1: PCLK1 selected as FMPI2C1 clock
  6142. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as FMPI2C1 clock
  6143. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as FMPI2C1 clock
  6144. */
  6145. #define __HAL_RCC_GET_FMPI2C1_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL))
  6146. /** @brief Macro to configure the LPTIM1 clock.
  6147. * @param __SOURCE__ specifies the LPTIM1 clock source.
  6148. * This parameter can be one of the following values:
  6149. * @arg RCC_LPTIM1CLKSOURCE_PCLK1: PCLK1 selected as LPTIM1 clock
  6150. * @arg RCC_LPTIM1CLKSOURCE_HSI: HSI clock selected as LPTIM1 clock
  6151. * @arg RCC_LPTIM1CLKSOURCE_LSI: LSI selected as LPTIM1 clock
  6152. * @arg RCC_LPTIM1CLKSOURCE_LSE: LSE selected as LPTIM1 clock
  6153. */
  6154. #define __HAL_RCC_LPTIM1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_LPTIM1SEL, (uint32_t)(__SOURCE__)))
  6155. /** @brief Macro to Get the LPTIM1 clock.
  6156. * @retval The clock source can be one of the following values:
  6157. * @arg RCC_LPTIM1CLKSOURCE_PCLK1: PCLK1 selected as LPTIM1 clock
  6158. * @arg RCC_LPTIM1CLKSOURCE_HSI: HSI clock selected as LPTIM1 clock
  6159. * @arg RCC_LPTIM1CLKSOURCE_LSI: LSI selected as LPTIM1 clock
  6160. * @arg RCC_LPTIM1CLKSOURCE_LSE: LSE selected as LPTIM1 clock
  6161. */
  6162. #define __HAL_RCC_GET_LPTIM1_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_LPTIM1SEL))
  6163. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  6164. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  6165. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
  6166. defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  6167. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  6168. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  6169. /** @brief Macro to configure the Timers clocks prescalers
  6170. * @note This feature is only available with STM32F429x/439x Devices.
  6171. * @param __PRESC__ specifies the Timers clocks prescalers selection
  6172. * This parameter can be one of the following values:
  6173. * @arg RCC_TIMPRES_DESACTIVATED: The Timers kernels clocks prescaler is
  6174. * equal to HPRE if PPREx is corresponding to division by 1 or 2,
  6175. * else it is equal to [(HPRE * PPREx) / 2] if PPREx is corresponding to
  6176. * division by 4 or more.
  6177. * @arg RCC_TIMPRES_ACTIVATED: The Timers kernels clocks prescaler is
  6178. * equal to HPRE if PPREx is corresponding to division by 1, 2 or 4,
  6179. * else it is equal to [(HPRE * PPREx) / 4] if PPREx is corresponding
  6180. * to division by 8 or more.
  6181. */
  6182. #define __HAL_RCC_TIMCLKPRESCALER(__PRESC__) (*(__IO uint32_t *) RCC_DCKCFGR_TIMPRE_BB = (__PRESC__))
  6183. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx) || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE ||\
  6184. STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx ||\
  6185. STM32F423xx */
  6186. /*----------------------------------------------------------------------------*/
  6187. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  6188. /** @brief Enable PLLSAI_RDY interrupt.
  6189. */
  6190. #define __HAL_RCC_PLLSAI_ENABLE_IT() (RCC->CIR |= (RCC_CIR_PLLSAIRDYIE))
  6191. /** @brief Disable PLLSAI_RDY interrupt.
  6192. */
  6193. #define __HAL_RCC_PLLSAI_DISABLE_IT() (RCC->CIR &= ~(RCC_CIR_PLLSAIRDYIE))
  6194. /** @brief Clear the PLLSAI RDY interrupt pending bits.
  6195. */
  6196. #define __HAL_RCC_PLLSAI_CLEAR_IT() (RCC->CIR |= (RCC_CIR_PLLSAIRDYF))
  6197. /** @brief Check the PLLSAI RDY interrupt has occurred or not.
  6198. * @retval The new state (TRUE or FALSE).
  6199. */
  6200. #define __HAL_RCC_PLLSAI_GET_IT() ((RCC->CIR & (RCC_CIR_PLLSAIRDYIE)) == (RCC_CIR_PLLSAIRDYIE))
  6201. /** @brief Check PLLSAI RDY flag is set or not.
  6202. * @retval The new state (TRUE or FALSE).
  6203. */
  6204. #define __HAL_RCC_PLLSAI_GET_FLAG() ((RCC->CR & (RCC_CR_PLLSAIRDY)) == (RCC_CR_PLLSAIRDY))
  6205. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  6206. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  6207. /** @brief Macros to enable or disable the RCC MCO1 feature.
  6208. */
  6209. #define __HAL_RCC_MCO1_ENABLE() (*(__IO uint32_t *) RCC_CFGR_MCO1EN_BB = ENABLE)
  6210. #define __HAL_RCC_MCO1_DISABLE() (*(__IO uint32_t *) RCC_CFGR_MCO1EN_BB = DISABLE)
  6211. /** @brief Macros to enable or disable the RCC MCO2 feature.
  6212. */
  6213. #define __HAL_RCC_MCO2_ENABLE() (*(__IO uint32_t *) RCC_CFGR_MCO2EN_BB = ENABLE)
  6214. #define __HAL_RCC_MCO2_DISABLE() (*(__IO uint32_t *) RCC_CFGR_MCO2EN_BB = DISABLE)
  6215. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  6216. /**
  6217. * @}
  6218. */
  6219. /* Exported functions --------------------------------------------------------*/
  6220. /** @addtogroup RCCEx_Exported_Functions
  6221. * @{
  6222. */
  6223. /** @addtogroup RCCEx_Exported_Functions_Group1
  6224. * @{
  6225. */
  6226. HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  6227. void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  6228. uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk);
  6229. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) ||\
  6230. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) ||\
  6231. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
  6232. defined(STM32F423xx)
  6233. void HAL_RCCEx_SelectLSEMode(uint8_t Mode);
  6234. #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  6235. #if defined(RCC_PLLI2S_SUPPORT)
  6236. HAL_StatusTypeDef HAL_RCCEx_EnablePLLI2S(RCC_PLLI2SInitTypeDef *PLLI2SInit);
  6237. HAL_StatusTypeDef HAL_RCCEx_DisablePLLI2S(void);
  6238. #endif /* RCC_PLLI2S_SUPPORT */
  6239. #if defined(RCC_PLLSAI_SUPPORT)
  6240. HAL_StatusTypeDef HAL_RCCEx_EnablePLLSAI(RCC_PLLSAIInitTypeDef *PLLSAIInit);
  6241. HAL_StatusTypeDef HAL_RCCEx_DisablePLLSAI(void);
  6242. #endif /* RCC_PLLSAI_SUPPORT */
  6243. /**
  6244. * @}
  6245. */
  6246. /**
  6247. * @}
  6248. */
  6249. /* Private types -------------------------------------------------------------*/
  6250. /* Private variables ---------------------------------------------------------*/
  6251. /* Private constants ---------------------------------------------------------*/
  6252. /** @defgroup RCCEx_Private_Constants RCCEx Private Constants
  6253. * @{
  6254. */
  6255. /** @defgroup RCCEx_BitAddress_AliasRegion RCC BitAddress AliasRegion
  6256. * @brief RCC registers bit address in the alias region
  6257. * @{
  6258. */
  6259. /* --- CR Register ---*/
  6260. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  6261. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  6262. /* Alias word address of PLLSAION bit */
  6263. #define RCC_PLLSAION_BIT_NUMBER 0x1CU
  6264. #define RCC_CR_PLLSAION_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_PLLSAION_BIT_NUMBER * 4U))
  6265. #define PLLSAI_TIMEOUT_VALUE 2U /* Timeout value fixed to 2 ms */
  6266. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  6267. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  6268. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  6269. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
  6270. defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  6271. defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  6272. /* Alias word address of PLLI2SON bit */
  6273. #define RCC_PLLI2SON_BIT_NUMBER 0x1AU
  6274. #define RCC_CR_PLLI2SON_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_PLLI2SON_BIT_NUMBER * 4U))
  6275. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  6276. STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx ||
  6277. STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  6278. /* --- DCKCFGR Register ---*/
  6279. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  6280. defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F401xC) ||\
  6281. defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
  6282. defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
  6283. defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  6284. /* Alias word address of TIMPRE bit */
  6285. #define RCC_DCKCFGR_OFFSET (RCC_OFFSET + 0x8CU)
  6286. #define RCC_TIMPRE_BIT_NUMBER 0x18U
  6287. #define RCC_DCKCFGR_TIMPRE_BB (PERIPH_BB_BASE + (RCC_DCKCFGR_OFFSET * 32U) + (RCC_TIMPRE_BIT_NUMBER * 4U))
  6288. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F410xx || STM32F401xC ||\
  6289. STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
  6290. STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  6291. /* --- CFGR Register ---*/
  6292. #define RCC_CFGR_OFFSET (RCC_OFFSET + 0x08U)
  6293. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  6294. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  6295. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
  6296. defined(STM32F469xx) || defined(STM32F479xx)
  6297. /* Alias word address of I2SSRC bit */
  6298. #define RCC_I2SSRC_BIT_NUMBER 0x17U
  6299. #define RCC_CFGR_I2SSRC_BB (PERIPH_BB_BASE + (RCC_CFGR_OFFSET * 32U) + (RCC_I2SSRC_BIT_NUMBER * 4U))
  6300. #define PLLI2S_TIMEOUT_VALUE 2U /* Timeout value fixed to 2 ms */
  6301. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  6302. STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx */
  6303. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
  6304. defined(STM32F413xx) || defined(STM32F423xx)
  6305. /* --- PLLI2SCFGR Register ---*/
  6306. #define RCC_PLLI2SCFGR_OFFSET (RCC_OFFSET + 0x84U)
  6307. /* Alias word address of PLLI2SSRC bit */
  6308. #define RCC_PLLI2SSRC_BIT_NUMBER 0x16U
  6309. #define RCC_PLLI2SCFGR_PLLI2SSRC_BB (PERIPH_BB_BASE + (RCC_PLLI2SCFGR_OFFSET * 32U) + (RCC_PLLI2SSRC_BIT_NUMBER * 4U))
  6310. #define PLLI2S_TIMEOUT_VALUE 2U /* Timeout value fixed to 2 ms */
  6311. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx | STM32F423xx */
  6312. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  6313. /* Alias word address of MCO1EN bit */
  6314. #define RCC_MCO1EN_BIT_NUMBER 0x8U
  6315. #define RCC_CFGR_MCO1EN_BB (PERIPH_BB_BASE + (RCC_CFGR_OFFSET * 32U) + (RCC_MCO1EN_BIT_NUMBER * 4U))
  6316. /* Alias word address of MCO2EN bit */
  6317. #define RCC_MCO2EN_BIT_NUMBER 0x9U
  6318. #define RCC_CFGR_MCO2EN_BB (PERIPH_BB_BASE + (RCC_CFGR_OFFSET * 32U) + (RCC_MCO2EN_BIT_NUMBER * 4U))
  6319. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  6320. #define PLL_TIMEOUT_VALUE 2U /* 2 ms */
  6321. /**
  6322. * @}
  6323. */
  6324. /**
  6325. * @}
  6326. */
  6327. /* Private macros ------------------------------------------------------------*/
  6328. /** @defgroup RCCEx_Private_Macros RCCEx Private Macros
  6329. * @{
  6330. */
  6331. /** @defgroup RCCEx_IS_RCC_Definitions RCC Private macros to check input parameters
  6332. * @{
  6333. */
  6334. #if defined(STM32F411xE)
  6335. #define IS_RCC_PLLN_VALUE(VALUE) ((192U <= (VALUE)) && ((VALUE) <= 432U))
  6336. #define IS_RCC_PLLI2SN_VALUE(VALUE) ((192U <= (VALUE)) && ((VALUE) <= 432U))
  6337. #else /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||
  6338. STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F410Tx || STM32F410Cx ||
  6339. STM32F410Rx || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Cx || STM32F412Rx ||
  6340. STM32F412Vx || STM32F412Zx || STM32F413xx || STM32F423xx */
  6341. #define IS_RCC_PLLN_VALUE(VALUE) ((50U <= (VALUE)) && ((VALUE) <= 432U))
  6342. #define IS_RCC_PLLI2SN_VALUE(VALUE) ((50U <= (VALUE)) && ((VALUE) <= 432U))
  6343. #endif /* STM32F411xE */
  6344. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
  6345. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x0000007FU))
  6346. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  6347. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)
  6348. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x00000007U))
  6349. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  6350. #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  6351. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x0000000FU))
  6352. #endif /* STM32F401xC || STM32F401xE || STM32F411xE */
  6353. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  6354. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x0000001FU))
  6355. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  6356. #if defined(STM32F446xx)
  6357. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x00000FFFU))
  6358. #endif /* STM32F446xx */
  6359. #if defined(STM32F469xx) || defined(STM32F479xx)
  6360. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x000001FFU))
  6361. #endif /* STM32F469xx || STM32F479xx */
  6362. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
  6363. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x000003FFU))
  6364. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
  6365. #if defined(STM32F413xx) || defined(STM32F423xx)
  6366. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1U <= (SELECTION)) && ((SELECTION) <= 0x00007FFFU))
  6367. #endif /* STM32F413xx || STM32F423xx */
  6368. #define IS_RCC_PLLI2SR_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 7U))
  6369. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  6370. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
  6371. #define IS_RCC_PLLI2SQ_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 15U))
  6372. #define IS_RCC_PLLSAIN_VALUE(VALUE) ((50U <= (VALUE)) && ((VALUE) <= 432U))
  6373. #define IS_RCC_PLLSAIQ_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 15U))
  6374. #define IS_RCC_PLLSAIR_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 7U))
  6375. #define IS_RCC_PLLSAI_DIVQ_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 32U))
  6376. #define IS_RCC_PLLI2S_DIVQ_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 32U))
  6377. #define IS_RCC_PLLSAI_DIVR_VALUE(VALUE) (((VALUE) == RCC_PLLSAIDIVR_2) ||\
  6378. ((VALUE) == RCC_PLLSAIDIVR_4) ||\
  6379. ((VALUE) == RCC_PLLSAIDIVR_8) ||\
  6380. ((VALUE) == RCC_PLLSAIDIVR_16))
  6381. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
  6382. #if defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  6383. defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
  6384. #define IS_RCC_PLLI2SM_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 63U))
  6385. #define IS_RCC_LSE_MODE(MODE) (((MODE) == RCC_LSE_LOWPOWER_MODE) ||\
  6386. ((MODE) == RCC_LSE_HIGHDRIVE_MODE))
  6387. #endif /* STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  6388. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  6389. #define IS_RCC_PLLR_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 7U))
  6390. #define IS_RCC_LSE_MODE(MODE) (((MODE) == RCC_LSE_LOWPOWER_MODE) ||\
  6391. ((MODE) == RCC_LSE_HIGHDRIVE_MODE))
  6392. #define IS_RCC_FMPI2C1CLKSOURCE(SOURCE) (((SOURCE) == RCC_FMPI2C1CLKSOURCE_PCLK1) ||\
  6393. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_SYSCLK) ||\
  6394. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_HSI))
  6395. #define IS_RCC_LPTIM1CLKSOURCE(SOURCE) (((SOURCE) == RCC_LPTIM1CLKSOURCE_PCLK1) ||\
  6396. ((SOURCE) == RCC_LPTIM1CLKSOURCE_HSI) ||\
  6397. ((SOURCE) == RCC_LPTIM1CLKSOURCE_LSI) ||\
  6398. ((SOURCE) == RCC_LPTIM1CLKSOURCE_LSE))
  6399. #define IS_RCC_I2SAPBCLKSOURCE(SOURCE) (((SOURCE) == RCC_I2SAPBCLKSOURCE_PLLR) ||\
  6400. ((SOURCE) == RCC_I2SAPBCLKSOURCE_EXT) ||\
  6401. ((SOURCE) == RCC_I2SAPBCLKSOURCE_PLLSRC))
  6402. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  6403. #if defined(STM32F446xx)
  6404. #define IS_RCC_PLLR_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 7U))
  6405. #define IS_RCC_PLLI2SP_VALUE(VALUE) (((VALUE) == RCC_PLLI2SP_DIV2) ||\
  6406. ((VALUE) == RCC_PLLI2SP_DIV4) ||\
  6407. ((VALUE) == RCC_PLLI2SP_DIV6) ||\
  6408. ((VALUE) == RCC_PLLI2SP_DIV8))
  6409. #define IS_RCC_PLLSAIM_VALUE(VALUE) ((VALUE) <= 63U)
  6410. #define IS_RCC_PLLSAIP_VALUE(VALUE) (((VALUE) == RCC_PLLSAIP_DIV2) ||\
  6411. ((VALUE) == RCC_PLLSAIP_DIV4) ||\
  6412. ((VALUE) == RCC_PLLSAIP_DIV6) ||\
  6413. ((VALUE) == RCC_PLLSAIP_DIV8))
  6414. #define IS_RCC_SAI1CLKSOURCE(SOURCE) (((SOURCE) == RCC_SAI1CLKSOURCE_PLLSAI) ||\
  6415. ((SOURCE) == RCC_SAI1CLKSOURCE_PLLI2S) ||\
  6416. ((SOURCE) == RCC_SAI1CLKSOURCE_PLLR) ||\
  6417. ((SOURCE) == RCC_SAI1CLKSOURCE_EXT))
  6418. #define IS_RCC_SAI2CLKSOURCE(SOURCE) (((SOURCE) == RCC_SAI2CLKSOURCE_PLLSAI) ||\
  6419. ((SOURCE) == RCC_SAI2CLKSOURCE_PLLI2S) ||\
  6420. ((SOURCE) == RCC_SAI2CLKSOURCE_PLLR) ||\
  6421. ((SOURCE) == RCC_SAI2CLKSOURCE_PLLSRC))
  6422. #define IS_RCC_I2SAPB1CLKSOURCE(SOURCE) (((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLI2S) ||\
  6423. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_EXT) ||\
  6424. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLR) ||\
  6425. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLSRC))
  6426. #define IS_RCC_I2SAPB2CLKSOURCE(SOURCE) (((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLI2S) ||\
  6427. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_EXT) ||\
  6428. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLR) ||\
  6429. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLSRC))
  6430. #define IS_RCC_FMPI2C1CLKSOURCE(SOURCE) (((SOURCE) == RCC_FMPI2C1CLKSOURCE_PCLK1) ||\
  6431. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_SYSCLK) ||\
  6432. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_HSI))
  6433. #define IS_RCC_CECCLKSOURCE(SOURCE) (((SOURCE) == RCC_CECCLKSOURCE_HSI) ||\
  6434. ((SOURCE) == RCC_CECCLKSOURCE_LSE))
  6435. #define IS_RCC_CLK48CLKSOURCE(SOURCE) (((SOURCE) == RCC_CLK48CLKSOURCE_PLLQ) ||\
  6436. ((SOURCE) == RCC_CLK48CLKSOURCE_PLLSAIP))
  6437. #define IS_RCC_SDIOCLKSOURCE(SOURCE) (((SOURCE) == RCC_SDIOCLKSOURCE_CLK48) ||\
  6438. ((SOURCE) == RCC_SDIOCLKSOURCE_SYSCLK))
  6439. #define IS_RCC_SPDIFRXCLKSOURCE(SOURCE) (((SOURCE) == RCC_SPDIFRXCLKSOURCE_PLLR) ||\
  6440. ((SOURCE) == RCC_SPDIFRXCLKSOURCE_PLLI2SP))
  6441. #endif /* STM32F446xx */
  6442. #if defined(STM32F469xx) || defined(STM32F479xx)
  6443. #define IS_RCC_PLLR_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 7U))
  6444. #define IS_RCC_PLLSAIP_VALUE(VALUE) (((VALUE) == RCC_PLLSAIP_DIV2) ||\
  6445. ((VALUE) == RCC_PLLSAIP_DIV4) ||\
  6446. ((VALUE) == RCC_PLLSAIP_DIV6) ||\
  6447. ((VALUE) == RCC_PLLSAIP_DIV8))
  6448. #define IS_RCC_CLK48CLKSOURCE(SOURCE) (((SOURCE) == RCC_CLK48CLKSOURCE_PLLQ) ||\
  6449. ((SOURCE) == RCC_CLK48CLKSOURCE_PLLSAIP))
  6450. #define IS_RCC_SDIOCLKSOURCE(SOURCE) (((SOURCE) == RCC_SDIOCLKSOURCE_CLK48) ||\
  6451. ((SOURCE) == RCC_SDIOCLKSOURCE_SYSCLK))
  6452. #define IS_RCC_DSIBYTELANECLKSOURCE(SOURCE) (((SOURCE) == RCC_DSICLKSOURCE_PLLR) ||\
  6453. ((SOURCE) == RCC_DSICLKSOURCE_DSIPHY))
  6454. #define IS_RCC_LSE_MODE(MODE) (((MODE) == RCC_LSE_LOWPOWER_MODE) ||\
  6455. ((MODE) == RCC_LSE_HIGHDRIVE_MODE))
  6456. #endif /* STM32F469xx || STM32F479xx */
  6457. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
  6458. defined(STM32F413xx) || defined(STM32F423xx)
  6459. #define IS_RCC_PLLI2SQ_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 15U))
  6460. #define IS_RCC_PLLR_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 7U))
  6461. #define IS_RCC_PLLI2SCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLI2SCLKSOURCE_PLLSRC) || \
  6462. ((__SOURCE__) == RCC_PLLI2SCLKSOURCE_EXT))
  6463. #define IS_RCC_I2SAPB1CLKSOURCE(SOURCE) (((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLI2S) ||\
  6464. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_EXT) ||\
  6465. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLR) ||\
  6466. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLSRC))
  6467. #define IS_RCC_I2SAPB2CLKSOURCE(SOURCE) (((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLI2S) ||\
  6468. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_EXT) ||\
  6469. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLR) ||\
  6470. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLSRC))
  6471. #define IS_RCC_FMPI2C1CLKSOURCE(SOURCE) (((SOURCE) == RCC_FMPI2C1CLKSOURCE_PCLK1) ||\
  6472. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_SYSCLK) ||\
  6473. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_HSI))
  6474. #define IS_RCC_CLK48CLKSOURCE(SOURCE) (((SOURCE) == RCC_CLK48CLKSOURCE_PLLQ) ||\
  6475. ((SOURCE) == RCC_CLK48CLKSOURCE_PLLI2SQ))
  6476. #define IS_RCC_SDIOCLKSOURCE(SOURCE) (((SOURCE) == RCC_SDIOCLKSOURCE_CLK48) ||\
  6477. ((SOURCE) == RCC_SDIOCLKSOURCE_SYSCLK))
  6478. #define IS_RCC_DFSDM1CLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_DFSDM1CLKSOURCE_PCLK2) || \
  6479. ((__SOURCE__) == RCC_DFSDM1CLKSOURCE_SYSCLK))
  6480. #define IS_RCC_DFSDM1AUDIOCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_DFSDM1AUDIOCLKSOURCE_I2S1) || \
  6481. ((__SOURCE__) == RCC_DFSDM1AUDIOCLKSOURCE_I2S2))
  6482. #if defined(STM32F413xx) || defined(STM32F423xx)
  6483. #define IS_RCC_DFSDM2CLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_DFSDM2CLKSOURCE_PCLK2) || \
  6484. ((__SOURCE__) == RCC_DFSDM2CLKSOURCE_SYSCLK))
  6485. #define IS_RCC_DFSDM2AUDIOCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_DFSDM2AUDIOCLKSOURCE_I2S1) || \
  6486. ((__SOURCE__) == RCC_DFSDM2AUDIOCLKSOURCE_I2S2))
  6487. #define IS_RCC_LPTIM1CLKSOURCE(SOURCE) (((SOURCE) == RCC_LPTIM1CLKSOURCE_PCLK1) ||\
  6488. ((SOURCE) == RCC_LPTIM1CLKSOURCE_HSI) ||\
  6489. ((SOURCE) == RCC_LPTIM1CLKSOURCE_LSI) ||\
  6490. ((SOURCE) == RCC_LPTIM1CLKSOURCE_LSE))
  6491. #define IS_RCC_SAIACLKSOURCE(SOURCE) (((SOURCE) == RCC_SAIACLKSOURCE_PLLI2SR) ||\
  6492. ((SOURCE) == RCC_SAIACLKSOURCE_EXT) ||\
  6493. ((SOURCE) == RCC_SAIACLKSOURCE_PLLR) ||\
  6494. ((SOURCE) == RCC_SAIACLKSOURCE_PLLSRC))
  6495. #define IS_RCC_SAIBCLKSOURCE(SOURCE) (((SOURCE) == RCC_SAIBCLKSOURCE_PLLI2SR) ||\
  6496. ((SOURCE) == RCC_SAIBCLKSOURCE_EXT) ||\
  6497. ((SOURCE) == RCC_SAIBCLKSOURCE_PLLR) ||\
  6498. ((SOURCE) == RCC_SAIBCLKSOURCE_PLLSRC))
  6499. #define IS_RCC_PLL_DIVR_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 32U))
  6500. #define IS_RCC_PLLI2S_DIVR_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 32U))
  6501. #endif /* STM32F413xx || STM32F423xx */
  6502. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  6503. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  6504. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  6505. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
  6506. defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
  6507. defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  6508. #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2SOURCE_SYSCLK) || ((SOURCE) == RCC_MCO2SOURCE_PLLI2SCLK)|| \
  6509. ((SOURCE) == RCC_MCO2SOURCE_HSE) || ((SOURCE) == RCC_MCO2SOURCE_PLLCLK))
  6510. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  6511. STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || \
  6512. STM32F412Rx */
  6513. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  6514. #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2SOURCE_SYSCLK) || ((SOURCE) == RCC_MCO2SOURCE_I2SCLK)|| \
  6515. ((SOURCE) == RCC_MCO2SOURCE_HSE) || ((SOURCE) == RCC_MCO2SOURCE_PLLCLK))
  6516. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  6517. /**
  6518. * @}
  6519. */
  6520. /**
  6521. * @}
  6522. */
  6523. /**
  6524. * @}
  6525. */
  6526. /**
  6527. * @}
  6528. */
  6529. #ifdef __cplusplus
  6530. }
  6531. #endif
  6532. #endif /* __STM32F4xx_HAL_RCC_EX_H */
  6533. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/