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.
 
 
 

7124 lines
419 KiB

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