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.
 
 
 

6591 lines
386 KiB

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