Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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