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

7114 lines
417 KiB

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