stm32f7xx_hal_rcc.h 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file in
  13. * the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. ******************************************************************************
  16. */
  17. /* Define to prevent recursive inclusion -------------------------------------*/
  18. #ifndef __STM32F7xx_HAL_RCC_H
  19. #define __STM32F7xx_HAL_RCC_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32f7xx_hal_def.h"
  25. /* Include RCC HAL Extended module */
  26. /* (include on top of file since RCC structures are defined in extended file) */
  27. #include "stm32f7xx_hal_rcc_ex.h"
  28. /** @addtogroup STM32F7xx_HAL_Driver
  29. * @{
  30. */
  31. /** @addtogroup RCC
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup RCC_Exported_Types RCC Exported Types
  36. * @{
  37. */
  38. /**
  39. * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
  40. */
  41. typedef struct
  42. {
  43. uint32_t OscillatorType; /*!< The oscillators to be configured.
  44. This parameter can be a value of @ref RCC_Oscillator_Type */
  45. uint32_t HSEState; /*!< The new state of the HSE.
  46. This parameter can be a value of @ref RCC_HSE_Config */
  47. uint32_t LSEState; /*!< The new state of the LSE.
  48. This parameter can be a value of @ref RCC_LSE_Config */
  49. uint32_t HSIState; /*!< The new state of the HSI.
  50. This parameter can be a value of @ref RCC_HSI_Config */
  51. uint32_t HSICalibrationValue; /*!< The HSI calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  52. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
  53. uint32_t LSIState; /*!< The new state of the LSI.
  54. This parameter can be a value of @ref RCC_LSI_Config */
  55. RCC_PLLInitTypeDef PLL; /*!< PLL structure parameters */
  56. }RCC_OscInitTypeDef;
  57. /**
  58. * @brief RCC System, AHB and APB buses clock configuration structure definition
  59. */
  60. typedef struct
  61. {
  62. uint32_t ClockType; /*!< The clock to be configured.
  63. This parameter can be a value of @ref RCC_System_Clock_Type */
  64. uint32_t SYSCLKSource; /*!< The clock source (SYSCLKS) used as system clock.
  65. This parameter can be a value of @ref RCC_System_Clock_Source */
  66. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  67. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  68. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  69. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  70. uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
  71. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  72. }RCC_ClkInitTypeDef;
  73. /**
  74. * @}
  75. */
  76. /* Exported constants --------------------------------------------------------*/
  77. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  78. * @{
  79. */
  80. /** @defgroup RCC_Oscillator_Type Oscillator Type
  81. * @{
  82. */
  83. #define RCC_OSCILLATORTYPE_NONE ((uint32_t)0x00000000U)
  84. #define RCC_OSCILLATORTYPE_HSE ((uint32_t)0x00000001U)
  85. #define RCC_OSCILLATORTYPE_HSI ((uint32_t)0x00000002U)
  86. #define RCC_OSCILLATORTYPE_LSE ((uint32_t)0x00000004U)
  87. #define RCC_OSCILLATORTYPE_LSI ((uint32_t)0x00000008U)
  88. /**
  89. * @}
  90. */
  91. /** @defgroup RCC_HSE_Config RCC HSE Config
  92. * @{
  93. */
  94. #define RCC_HSE_OFF ((uint32_t)0x00000000U)
  95. #define RCC_HSE_ON RCC_CR_HSEON
  96. #define RCC_HSE_BYPASS ((uint32_t)(RCC_CR_HSEBYP | RCC_CR_HSEON))
  97. /**
  98. * @}
  99. */
  100. /** @defgroup RCC_LSE_Config RCC LSE Config
  101. * @{
  102. */
  103. #define RCC_LSE_OFF ((uint32_t)0x00000000U)
  104. #define RCC_LSE_ON RCC_BDCR_LSEON
  105. #define RCC_LSE_BYPASS ((uint32_t)(RCC_BDCR_LSEBYP | RCC_BDCR_LSEON))
  106. /**
  107. * @}
  108. */
  109. /** @defgroup RCC_HSI_Config RCC HSI Config
  110. * @{
  111. */
  112. #define RCC_HSI_OFF ((uint32_t)0x00000000U)
  113. #define RCC_HSI_ON RCC_CR_HSION
  114. #define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10U) /* Default HSI calibration trimming value */
  115. /**
  116. * @}
  117. */
  118. /** @defgroup RCC_LSI_Config RCC LSI Config
  119. * @{
  120. */
  121. #define RCC_LSI_OFF ((uint32_t)0x00000000U)
  122. #define RCC_LSI_ON RCC_CSR_LSION
  123. /**
  124. * @}
  125. */
  126. /** @defgroup RCC_PLL_Config RCC PLL Config
  127. * @{
  128. */
  129. #define RCC_PLL_NONE ((uint32_t)0x00000000U)
  130. #define RCC_PLL_OFF ((uint32_t)0x00000001U)
  131. #define RCC_PLL_ON ((uint32_t)0x00000002U)
  132. /**
  133. * @}
  134. */
  135. /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
  136. * @{
  137. */
  138. #define RCC_PLLP_DIV2 ((uint32_t)0x00000002U)
  139. #define RCC_PLLP_DIV4 ((uint32_t)0x00000004U)
  140. #define RCC_PLLP_DIV6 ((uint32_t)0x00000006U)
  141. #define RCC_PLLP_DIV8 ((uint32_t)0x00000008U)
  142. /**
  143. * @}
  144. */
  145. /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
  146. * @{
  147. */
  148. #define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI
  149. #define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE
  150. /**
  151. * @}
  152. */
  153. /** @defgroup RCC_System_Clock_Type RCC System Clock Type
  154. * @{
  155. */
  156. #define RCC_CLOCKTYPE_SYSCLK ((uint32_t)0x00000001U)
  157. #define RCC_CLOCKTYPE_HCLK ((uint32_t)0x00000002U)
  158. #define RCC_CLOCKTYPE_PCLK1 ((uint32_t)0x00000004U)
  159. #define RCC_CLOCKTYPE_PCLK2 ((uint32_t)0x00000008U)
  160. /**
  161. * @}
  162. */
  163. /** @defgroup RCC_System_Clock_Source RCC System Clock Source
  164. * @{
  165. */
  166. #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI
  167. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE
  168. #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL
  169. /**
  170. * @}
  171. */
  172. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  173. * @{
  174. */
  175. #define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  176. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  177. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  178. /**
  179. * @}
  180. */
  181. /** @defgroup RCC_AHB_Clock_Source RCC AHB Clock Source
  182. * @{
  183. */
  184. #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1
  185. #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2
  186. #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4
  187. #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8
  188. #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16
  189. #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64
  190. #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128
  191. #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256
  192. #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512
  193. /**
  194. * @}
  195. */
  196. /** @defgroup RCC_APB1_APB2_Clock_Source RCC APB1/APB2 Clock Source
  197. * @{
  198. */
  199. #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1
  200. #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2
  201. #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4
  202. #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8
  203. #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16
  204. /**
  205. * @}
  206. */
  207. /** @defgroup RCC_RTC_Clock_Source RCC RTC Clock Source
  208. * @{
  209. */
  210. #define RCC_RTCCLKSOURCE_NO_CLK ((uint32_t)0x00000000U)
  211. #define RCC_RTCCLKSOURCE_LSE ((uint32_t)0x00000100U)
  212. #define RCC_RTCCLKSOURCE_LSI ((uint32_t)0x00000200U)
  213. #define RCC_RTCCLKSOURCE_HSE_DIVX ((uint32_t)0x00000300U)
  214. #define RCC_RTCCLKSOURCE_HSE_DIV2 ((uint32_t)0x00020300U)
  215. #define RCC_RTCCLKSOURCE_HSE_DIV3 ((uint32_t)0x00030300U)
  216. #define RCC_RTCCLKSOURCE_HSE_DIV4 ((uint32_t)0x00040300U)
  217. #define RCC_RTCCLKSOURCE_HSE_DIV5 ((uint32_t)0x00050300U)
  218. #define RCC_RTCCLKSOURCE_HSE_DIV6 ((uint32_t)0x00060300U)
  219. #define RCC_RTCCLKSOURCE_HSE_DIV7 ((uint32_t)0x00070300U)
  220. #define RCC_RTCCLKSOURCE_HSE_DIV8 ((uint32_t)0x00080300U)
  221. #define RCC_RTCCLKSOURCE_HSE_DIV9 ((uint32_t)0x00090300U)
  222. #define RCC_RTCCLKSOURCE_HSE_DIV10 ((uint32_t)0x000A0300U)
  223. #define RCC_RTCCLKSOURCE_HSE_DIV11 ((uint32_t)0x000B0300U)
  224. #define RCC_RTCCLKSOURCE_HSE_DIV12 ((uint32_t)0x000C0300U)
  225. #define RCC_RTCCLKSOURCE_HSE_DIV13 ((uint32_t)0x000D0300U)
  226. #define RCC_RTCCLKSOURCE_HSE_DIV14 ((uint32_t)0x000E0300U)
  227. #define RCC_RTCCLKSOURCE_HSE_DIV15 ((uint32_t)0x000F0300U)
  228. #define RCC_RTCCLKSOURCE_HSE_DIV16 ((uint32_t)0x00100300U)
  229. #define RCC_RTCCLKSOURCE_HSE_DIV17 ((uint32_t)0x00110300U)
  230. #define RCC_RTCCLKSOURCE_HSE_DIV18 ((uint32_t)0x00120300U)
  231. #define RCC_RTCCLKSOURCE_HSE_DIV19 ((uint32_t)0x00130300U)
  232. #define RCC_RTCCLKSOURCE_HSE_DIV20 ((uint32_t)0x00140300U)
  233. #define RCC_RTCCLKSOURCE_HSE_DIV21 ((uint32_t)0x00150300U)
  234. #define RCC_RTCCLKSOURCE_HSE_DIV22 ((uint32_t)0x00160300U)
  235. #define RCC_RTCCLKSOURCE_HSE_DIV23 ((uint32_t)0x00170300U)
  236. #define RCC_RTCCLKSOURCE_HSE_DIV24 ((uint32_t)0x00180300U)
  237. #define RCC_RTCCLKSOURCE_HSE_DIV25 ((uint32_t)0x00190300U)
  238. #define RCC_RTCCLKSOURCE_HSE_DIV26 ((uint32_t)0x001A0300U)
  239. #define RCC_RTCCLKSOURCE_HSE_DIV27 ((uint32_t)0x001B0300U)
  240. #define RCC_RTCCLKSOURCE_HSE_DIV28 ((uint32_t)0x001C0300U)
  241. #define RCC_RTCCLKSOURCE_HSE_DIV29 ((uint32_t)0x001D0300U)
  242. #define RCC_RTCCLKSOURCE_HSE_DIV30 ((uint32_t)0x001E0300U)
  243. #define RCC_RTCCLKSOURCE_HSE_DIV31 ((uint32_t)0x001F0300U)
  244. /**
  245. * @}
  246. */
  247. /** @defgroup RCC_MCO_Index RCC MCO Index
  248. * @{
  249. */
  250. #define RCC_MCO1 ((uint32_t)0x00000000U)
  251. #define RCC_MCO2 ((uint32_t)0x00000001U)
  252. /**
  253. * @}
  254. */
  255. /** @defgroup RCC_MCO1_Clock_Source RCC MCO1 Clock Source
  256. * @{
  257. */
  258. #define RCC_MCO1SOURCE_HSI ((uint32_t)0x00000000U)
  259. #define RCC_MCO1SOURCE_LSE RCC_CFGR_MCO1_0
  260. #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCO1_1
  261. #define RCC_MCO1SOURCE_PLLCLK RCC_CFGR_MCO1
  262. /**
  263. * @}
  264. */
  265. /** @defgroup RCC_MCO2_Clock_Source RCC MCO2 Clock Source
  266. * @{
  267. */
  268. #define RCC_MCO2SOURCE_SYSCLK ((uint32_t)0x00000000U)
  269. #define RCC_MCO2SOURCE_PLLI2SCLK RCC_CFGR_MCO2_0
  270. #define RCC_MCO2SOURCE_HSE RCC_CFGR_MCO2_1
  271. #define RCC_MCO2SOURCE_PLLCLK RCC_CFGR_MCO2
  272. /**
  273. * @}
  274. */
  275. /** @defgroup RCC_MCOx_Clock_Prescaler RCC MCO1 Clock Prescaler
  276. * @{
  277. */
  278. #define RCC_MCODIV_1 ((uint32_t)0x00000000U)
  279. #define RCC_MCODIV_2 RCC_CFGR_MCO1PRE_2
  280. #define RCC_MCODIV_3 ((uint32_t)RCC_CFGR_MCO1PRE_0 | RCC_CFGR_MCO1PRE_2)
  281. #define RCC_MCODIV_4 ((uint32_t)RCC_CFGR_MCO1PRE_1 | RCC_CFGR_MCO1PRE_2)
  282. #define RCC_MCODIV_5 RCC_CFGR_MCO1PRE
  283. /**
  284. * @}
  285. */
  286. /** @defgroup RCC_Interrupt RCC Interrupt
  287. * @{
  288. */
  289. #define RCC_IT_LSIRDY ((uint8_t)0x01U)
  290. #define RCC_IT_LSERDY ((uint8_t)0x02U)
  291. #define RCC_IT_HSIRDY ((uint8_t)0x04U)
  292. #define RCC_IT_HSERDY ((uint8_t)0x08U)
  293. #define RCC_IT_PLLRDY ((uint8_t)0x10U)
  294. #define RCC_IT_PLLI2SRDY ((uint8_t)0x20U)
  295. #define RCC_IT_PLLSAIRDY ((uint8_t)0x40U)
  296. #define RCC_IT_CSS ((uint8_t)0x80U)
  297. /**
  298. * @}
  299. */
  300. /** @defgroup RCC_Flag RCC Flags
  301. * Elements values convention: 0XXYYYYYb
  302. * - YYYYY : Flag position in the register
  303. * - 0XX : Register index
  304. * - 01: CR register
  305. * - 10: BDCR register
  306. * - 11: CSR register
  307. * @{
  308. */
  309. /* Flags in the CR register */
  310. #define RCC_FLAG_HSIRDY ((uint8_t)0x21U)
  311. #define RCC_FLAG_HSERDY ((uint8_t)0x31U)
  312. #define RCC_FLAG_PLLRDY ((uint8_t)0x39U)
  313. #define RCC_FLAG_PLLI2SRDY ((uint8_t)0x3BU)
  314. #define RCC_FLAG_PLLSAIRDY ((uint8_t)0x3CU)
  315. /* Flags in the BDCR register */
  316. #define RCC_FLAG_LSERDY ((uint8_t)0x41U)
  317. /* Flags in the CSR register */
  318. #define RCC_FLAG_LSIRDY ((uint8_t)0x61U)
  319. #define RCC_FLAG_BORRST ((uint8_t)0x79U)
  320. #define RCC_FLAG_PINRST ((uint8_t)0x7AU)
  321. #define RCC_FLAG_PORRST ((uint8_t)0x7BU)
  322. #define RCC_FLAG_SFTRST ((uint8_t)0x7CU)
  323. #define RCC_FLAG_IWDGRST ((uint8_t)0x7DU)
  324. #define RCC_FLAG_WWDGRST ((uint8_t)0x7EU)
  325. #define RCC_FLAG_LPWRRST ((uint8_t)0x7FU)
  326. /**
  327. * @}
  328. */
  329. /** @defgroup RCC_LSEDrive_Configuration RCC LSE Drive configurations
  330. * @{
  331. */
  332. #define RCC_LSEDRIVE_LOW ((uint32_t)0x00000000U)
  333. #define RCC_LSEDRIVE_MEDIUMLOW RCC_BDCR_LSEDRV_1
  334. #define RCC_LSEDRIVE_MEDIUMHIGH RCC_BDCR_LSEDRV_0
  335. #define RCC_LSEDRIVE_HIGH RCC_BDCR_LSEDRV
  336. /**
  337. * @}
  338. */
  339. /**
  340. * @}
  341. */
  342. /* Exported macro ------------------------------------------------------------*/
  343. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  344. * @{
  345. */
  346. /** @defgroup RCC_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  347. * @brief Enable or disable the AHB1 peripheral clock.
  348. * @note After reset, the peripheral clock (used for registers read/write access)
  349. * is disabled and the application software has to enable this clock before
  350. * using it.
  351. * @{
  352. */
  353. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  354. __IO uint32_t tmpreg; \
  355. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  356. /* Delay after an RCC peripheral clock enabling */ \
  357. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  358. UNUSED(tmpreg); \
  359. } while(0)
  360. #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
  361. __IO uint32_t tmpreg; \
  362. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
  363. /* Delay after an RCC peripheral clock enabling */ \
  364. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
  365. UNUSED(tmpreg); \
  366. } while(0)
  367. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  368. #define __HAL_RCC_DMA1_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA1EN))
  369. /**
  370. * @}
  371. */
  372. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  373. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  374. * @note After reset, the peripheral clock (used for registers read/write access)
  375. * is disabled and the application software has to enable this clock before
  376. * using it.
  377. * @{
  378. */
  379. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  380. __IO uint32_t tmpreg; \
  381. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
  382. /* Delay after an RCC peripheral clock enabling */ \
  383. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
  384. UNUSED(tmpreg); \
  385. } while(0)
  386. #define __HAL_RCC_PWR_CLK_ENABLE() do { \
  387. __IO uint32_t tmpreg; \
  388. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
  389. /* Delay after an RCC peripheral clock enabling */ \
  390. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
  391. UNUSED(tmpreg); \
  392. } while(0)
  393. #define __HAL_RCC_WWDG_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_WWDGEN))
  394. #define __HAL_RCC_PWR_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN))
  395. /**
  396. * @}
  397. */
  398. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  399. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  400. * @note After reset, the peripheral clock (used for registers read/write access)
  401. * is disabled and the application software has to enable this clock before
  402. * using it.
  403. * @{
  404. */
  405. #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
  406. __IO uint32_t tmpreg; \
  407. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
  408. /* Delay after an RCC peripheral clock enabling */ \
  409. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
  410. UNUSED(tmpreg); \
  411. } while(0)
  412. #define __HAL_RCC_SYSCFG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SYSCFGEN))
  413. /**
  414. * @}
  415. */
  416. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  417. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  418. * @note After reset, the peripheral clock (used for registers read/write access)
  419. * is disabled and the application software has to enable this clock before
  420. * using it.
  421. * @{
  422. */
  423. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) != RESET)
  424. #define __HAL_RCC_DMA1_IS_CLK_ENABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_DMA1EN)) != RESET)
  425. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_CRCEN)) == RESET)
  426. #define __HAL_RCC_DMA1_IS_CLK_DISABLED() ((RCC->AHB1ENR & (RCC_AHB1ENR_DMA1EN)) == RESET)
  427. /**
  428. * @}
  429. */
  430. /** @defgroup RCC_APB1_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  431. * @brief Get the enable or disable status of the APB1 peripheral clock.
  432. * @note After reset, the peripheral clock (used for registers read/write access)
  433. * is disabled and the application software has to enable this clock before
  434. * using it.
  435. * @{
  436. */
  437. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) != RESET)
  438. #define __HAL_RCC_PWR_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) != RESET)
  439. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) == RESET)
  440. #define __HAL_RCC_PWR_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) == RESET)
  441. /**
  442. * @}
  443. */
  444. /** @defgroup RCC_APB2_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  445. * @brief EGet the enable or disable status of the APB2 peripheral clock.
  446. * @note After reset, the peripheral clock (used for registers read/write access)
  447. * is disabled and the application software has to enable this clock before
  448. * using it.
  449. * @{
  450. */
  451. #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SYSCFGEN)) != RESET)
  452. #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SYSCFGEN)) == RESET)
  453. /**
  454. * @}
  455. */
  456. /** @defgroup RCC_Peripheral_Clock_Force_Release RCC Peripheral Clock Force Release
  457. * @brief Force or release AHB peripheral reset.
  458. * @{
  459. */
  460. #define __HAL_RCC_AHB1_FORCE_RESET() (RCC->AHB1RSTR = 0xFFFFFFFFU)
  461. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  462. #define __HAL_RCC_DMA1_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA1RST))
  463. #define __HAL_RCC_AHB1_RELEASE_RESET() (RCC->AHB1RSTR = 0x00U)
  464. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  465. #define __HAL_RCC_DMA1_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA1RST))
  466. /**
  467. * @}
  468. */
  469. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Force Release Reset
  470. * @brief Force or release APB1 peripheral reset.
  471. * @{
  472. */
  473. #define __HAL_RCC_APB1_FORCE_RESET() (RCC->APB1RSTR = 0xFFFFFFFFU)
  474. #define __HAL_RCC_WWDG_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
  475. #define __HAL_RCC_PWR_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
  476. #define __HAL_RCC_APB1_RELEASE_RESET() (RCC->APB1RSTR = 0x00U)
  477. #define __HAL_RCC_WWDG_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
  478. #define __HAL_RCC_PWR_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_PWRRST))
  479. /**
  480. * @}
  481. */
  482. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Force Release Reset
  483. * @brief Force or release APB2 peripheral reset.
  484. * @{
  485. */
  486. #define __HAL_RCC_APB2_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFFU)
  487. #define __HAL_RCC_SYSCFG_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SYSCFGRST))
  488. #define __HAL_RCC_APB2_RELEASE_RESET() (RCC->APB2RSTR = 0x00U)
  489. #define __HAL_RCC_SYSCFG_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SYSCFGRST))
  490. /**
  491. * @}
  492. */
  493. /** @defgroup RCC_Peripheral_Clock_Sleep_Enable_Disable RCC Peripheral Clock Sleep Enable Disable
  494. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  495. * power consumption.
  496. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  497. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  498. * @{
  499. */
  500. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  501. #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA1LPEN))
  502. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  503. #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA1LPEN))
  504. /** @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  505. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  506. * power consumption.
  507. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  508. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  509. */
  510. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_WWDGLPEN))
  511. #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_PWRLPEN))
  512. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_WWDGLPEN))
  513. #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_PWRLPEN))
  514. /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  515. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  516. * power consumption.
  517. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  518. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  519. */
  520. #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SYSCFGLPEN))
  521. #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SYSCFGLPEN))
  522. /**
  523. * @}
  524. */
  525. /** @defgroup RCC_AHB1_Clock_Sleep_Enable_Disable_Status AHB1 Peripheral Clock Sleep Enable Disable Status
  526. * @brief Get the enable or disable status of the AHB1 peripheral clock during Low Power (Sleep) mode.
  527. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  528. * power consumption.
  529. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  530. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  531. * @{
  532. */
  533. #define __HAL_RCC_CRC_IS_CLK_SLEEP_ENABLED() ((RCC->AHB1LPENR & (RCC_AHB1LPENR_CRCLPEN)) != RESET)
  534. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_ENABLED() ((RCC->AHB1LPENR & (RCC_AHB1LPENR_DMA1LPEN)) != RESET)
  535. #define __HAL_RCC_CRC_IS_CLK_SLEEP_DISABLED() ((RCC->AHB1LPENR & (RCC_AHB1LPENR_CRCLPEN)) == RESET)
  536. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_DISABLED() ((RCC->AHB1LPENR & (RCC_AHB1LPENR_DMA1LPEN)) == RESET)
  537. /**
  538. * @}
  539. */
  540. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable_Status APB1 Peripheral Clock Sleep Enable Disable Status
  541. * @brief Get the enable or disable status of the APB1 peripheral clock during Low Power (Sleep) mode.
  542. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  543. * power consumption.
  544. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  545. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  546. * @{
  547. */
  548. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_WWDGLPEN)) != RESET)
  549. #define __HAL_RCC_PWR_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_PWRLPEN)) != RESET)
  550. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_WWDGLPEN)) == RESET)
  551. #define __HAL_RCC_PWR_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_PWRLPEN)) == RESET)
  552. /**
  553. * @}
  554. */
  555. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable_Status APB2 Peripheral Clock Sleep Enable Disable Status
  556. * @brief Get the enable or disable status of the APB2 peripheral clock during Low Power (Sleep) mode.
  557. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  558. * power consumption.
  559. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  560. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  561. * @{
  562. */
  563. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_SYSCFGLPEN)) != RESET)
  564. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_SYSCFGLPEN)) == RESET)
  565. /**
  566. * @}
  567. */
  568. /** @defgroup RCC_HSI_Configuration HSI Configuration
  569. * @{
  570. */
  571. /** @brief Macros to enable or disable the Internal High Speed oscillator (HSI).
  572. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  573. * It is used (enabled by hardware) as system clock source after startup
  574. * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
  575. * of the HSE used directly or indirectly as system clock (if the Clock
  576. * Security System CSS is enabled).
  577. * @note HSI can not be stopped if it is used as system clock source. In this case,
  578. * you have to select another source of the system clock then stop the HSI.
  579. * @note After enabling the HSI, the application software should wait on HSIRDY
  580. * flag to be set indicating that HSI clock is stable and can be used as
  581. * system clock source.
  582. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  583. * clock cycles.
  584. */
  585. #define __HAL_RCC_HSI_ENABLE() (RCC->CR |= (RCC_CR_HSION))
  586. #define __HAL_RCC_HSI_DISABLE() (RCC->CR &= ~(RCC_CR_HSION))
  587. /** @brief Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
  588. * @note The calibration is used to compensate for the variations in voltage
  589. * and temperature that influence the frequency of the internal HSI RC.
  590. * @param __HSICALIBRATIONVALUE__ specifies the calibration trimming value.
  591. * (default is RCC_HSICALIBRATION_DEFAULT).
  592. */
  593. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICALIBRATIONVALUE__) (MODIFY_REG(RCC->CR,\
  594. RCC_CR_HSITRIM, (uint32_t)(__HSICALIBRATIONVALUE__) << RCC_CR_HSITRIM_Pos))
  595. /**
  596. * @}
  597. */
  598. /** @defgroup RCC_LSI_Configuration LSI Configuration
  599. * @{
  600. */
  601. /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
  602. * @note After enabling the LSI, the application software should wait on
  603. * LSIRDY flag to be set indicating that LSI clock is stable and can
  604. * be used to clock the IWDG and/or the RTC.
  605. * @note LSI can not be disabled if the IWDG is running.
  606. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  607. * clock cycles.
  608. */
  609. #define __HAL_RCC_LSI_ENABLE() (RCC->CSR |= (RCC_CSR_LSION))
  610. #define __HAL_RCC_LSI_DISABLE() (RCC->CSR &= ~(RCC_CSR_LSION))
  611. /**
  612. * @}
  613. */
  614. /** @defgroup RCC_HSE_Configuration HSE Configuration
  615. * @{
  616. */
  617. /**
  618. * @brief Macro to configure the External High Speed oscillator (HSE).
  619. * @note Transitions HSE Bypass to HSE On and HSE On to HSE Bypass are not
  620. * supported by this macro. User should request a transition to HSE Off
  621. * first and then HSE On or HSE Bypass.
  622. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  623. * software should wait on HSERDY flag to be set indicating that HSE clock
  624. * is stable and can be used to clock the PLL and/or system clock.
  625. * @note HSE state can not be changed if it is used directly or through the
  626. * PLL as system clock. In this case, you have to select another source
  627. * of the system clock then change the HSE state (ex. disable it).
  628. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  629. * @note This function reset the CSSON bit, so if the clock security system(CSS)
  630. * was previously enabled you have to enable it again after calling this
  631. * function.
  632. * @param __STATE__ specifies the new state of the HSE.
  633. * This parameter can be one of the following values:
  634. * @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after
  635. * 6 HSE oscillator clock cycles.
  636. * @arg RCC_HSE_ON: turn ON the HSE oscillator.
  637. * @arg RCC_HSE_BYPASS: HSE oscillator bypassed with external clock.
  638. */
  639. #define __HAL_RCC_HSE_CONFIG(__STATE__) \
  640. do { \
  641. if ((__STATE__) == RCC_HSE_ON) \
  642. { \
  643. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  644. } \
  645. else if ((__STATE__) == RCC_HSE_OFF) \
  646. { \
  647. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  648. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  649. } \
  650. else if ((__STATE__) == RCC_HSE_BYPASS) \
  651. { \
  652. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  653. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  654. } \
  655. else \
  656. { \
  657. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  658. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  659. } \
  660. } while(0)
  661. /**
  662. * @}
  663. */
  664. /** @defgroup RCC_LSE_Configuration LSE Configuration
  665. * @{
  666. */
  667. /**
  668. * @brief Macro to configure the External Low Speed oscillator (LSE).
  669. * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro.
  670. * User should request a transition to LSE Off first and then LSE On or LSE Bypass.
  671. * @note As the LSE is in the Backup domain and write access is denied to
  672. * this domain after reset, you have to enable write access using
  673. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  674. * (to be done once after reset).
  675. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  676. * software should wait on LSERDY flag to be set indicating that LSE clock
  677. * is stable and can be used to clock the RTC.
  678. * @param __STATE__ specifies the new state of the LSE.
  679. * This parameter can be one of the following values:
  680. * @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after
  681. * 6 LSE oscillator clock cycles.
  682. * @arg RCC_LSE_ON: turn ON the LSE oscillator.
  683. * @arg RCC_LSE_BYPASS: LSE oscillator bypassed with external clock.
  684. */
  685. #define __HAL_RCC_LSE_CONFIG(__STATE__) \
  686. do { \
  687. if((__STATE__) == RCC_LSE_ON) \
  688. { \
  689. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  690. } \
  691. else if((__STATE__) == RCC_LSE_OFF) \
  692. { \
  693. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  694. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  695. } \
  696. else if((__STATE__) == RCC_LSE_BYPASS) \
  697. { \
  698. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  699. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  700. } \
  701. else \
  702. { \
  703. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  704. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  705. } \
  706. } while(0)
  707. /**
  708. * @}
  709. */
  710. /** @defgroup RCC_Internal_RTC_Clock_Configuration RTC Clock Configuration
  711. * @{
  712. */
  713. /** @brief Macros to enable or disable the RTC clock.
  714. * @note These macros must be used only after the RTC clock source was selected.
  715. */
  716. #define __HAL_RCC_RTC_ENABLE() (RCC->BDCR |= (RCC_BDCR_RTCEN))
  717. #define __HAL_RCC_RTC_DISABLE() (RCC->BDCR &= ~(RCC_BDCR_RTCEN))
  718. /** @brief Macros to configure the RTC clock (RTCCLK).
  719. * @note As the RTC clock configuration bits are in the Backup domain and write
  720. * access is denied to this domain after reset, you have to enable write
  721. * access using the Power Backup Access macro before to configure
  722. * the RTC clock source (to be done once after reset).
  723. * @note Once the RTC clock is configured it can't be changed unless the
  724. * Backup domain is reset using __HAL_RCC_BackupReset_RELEASE() macro, or by
  725. * a Power On Reset (POR).
  726. * @param __RTCCLKSource__ specifies the RTC clock source.
  727. * This parameter can be one of the following values:
  728. @arg @ref RCC_RTCCLKSOURCE_NO_CLK: No clock selected as RTC clock.
  729. * @arg @ref RCC_RTCCLKSOURCE_LSE: LSE selected as RTC clock.
  730. * @arg @ref RCC_RTCCLKSOURCE_LSI: LSI selected as RTC clock.
  731. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIVX: HSE clock divided by x selected
  732. * as RTC clock, where x:[2,31]
  733. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  734. * work in STOP and STANDBY modes, and can be used as wakeup source.
  735. * However, when the HSE clock is used as RTC clock source, the RTC
  736. * cannot be used in STOP and STANDBY modes.
  737. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  738. * RTC clock source).
  739. */
  740. #define __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__) (((__RTCCLKSource__) & RCC_BDCR_RTCSEL) == RCC_BDCR_RTCSEL) ? \
  741. MODIFY_REG(RCC->CFGR, RCC_CFGR_RTCPRE, ((__RTCCLKSource__) & 0xFFFFCFF)) : CLEAR_BIT(RCC->CFGR, RCC_CFGR_RTCPRE)
  742. #define __HAL_RCC_RTC_CONFIG(__RTCCLKSource__) do { __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__); \
  743. RCC->BDCR |= ((__RTCCLKSource__) & 0x00000FFF); \
  744. } while (0)
  745. /** @brief Macro to get the RTC clock source.
  746. * @retval The clock source can be one of the following values:
  747. * @arg @ref RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock
  748. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock
  749. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
  750. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIVX HSE divided by X selected as RTC clock (X can be retrieved thanks to @ref __HAL_RCC_GET_RTC_HSE_PRESCALER()
  751. */
  752. #define __HAL_RCC_GET_RTC_SOURCE() (READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL))
  753. /**
  754. * @brief Get the RTC and HSE clock divider (RTCPRE).
  755. * @retval Returned value can be one of the following values:
  756. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIVX: HSE clock divided by x selected
  757. * as RTC clock, where x:[2,31]
  758. */
  759. #define __HAL_RCC_GET_RTC_HSE_PRESCALER() (READ_BIT(RCC->CFGR, RCC_CFGR_RTCPRE) | RCC_BDCR_RTCSEL)
  760. /** @brief Macros to force or release the Backup domain reset.
  761. * @note This function resets the RTC peripheral (including the backup registers)
  762. * and the RTC clock source selection in RCC_CSR register.
  763. * @note The BKPSRAM is not affected by this reset.
  764. */
  765. #define __HAL_RCC_BACKUPRESET_FORCE() (RCC->BDCR |= (RCC_BDCR_BDRST))
  766. #define __HAL_RCC_BACKUPRESET_RELEASE() (RCC->BDCR &= ~(RCC_BDCR_BDRST))
  767. /**
  768. * @}
  769. */
  770. /** @defgroup RCC_PLL_Configuration PLL Configuration
  771. * @{
  772. */
  773. /** @brief Macros to enable or disable the main PLL.
  774. * @note After enabling the main PLL, the application software should wait on
  775. * PLLRDY flag to be set indicating that PLL clock is stable and can
  776. * be used as system clock source.
  777. * @note The main PLL can not be disabled if it is used as system clock source
  778. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  779. */
  780. #define __HAL_RCC_PLL_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLON)
  781. #define __HAL_RCC_PLL_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLON)
  782. /** @brief Macro to configure the PLL clock source.
  783. * @note This function must be used only when the main PLL is disabled.
  784. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  785. * This parameter can be one of the following values:
  786. * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
  787. * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
  788. *
  789. */
  790. #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
  791. /** @brief Macro to configure the PLL multiplication factor.
  792. * @note This function must be used only when the main PLL is disabled.
  793. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  794. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  795. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  796. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  797. * of 2 MHz to limit PLL jitter.
  798. *
  799. */
  800. #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, (__PLLM__))
  801. /**
  802. * @}
  803. */
  804. /** @defgroup RCC_PLL_I2S_Configuration PLL I2S Configuration
  805. * @{
  806. */
  807. /** @brief Macro to configure the I2S clock source (I2SCLK).
  808. * @note This function must be called before enabling the I2S APB clock.
  809. * @param __SOURCE__ specifies the I2S clock source.
  810. * This parameter can be one of the following values:
  811. * @arg RCC_I2SCLKSOURCE_PLLI2S: PLLI2S clock used as I2S clock source.
  812. * @arg RCC_I2SCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin
  813. * used as I2S clock source.
  814. */
  815. #define __HAL_RCC_I2S_CONFIG(__SOURCE__) do {RCC->CFGR &= ~(RCC_CFGR_I2SSRC); \
  816. RCC->CFGR |= (__SOURCE__); \
  817. }while(0)
  818. /** @brief Macros to enable or disable the PLLI2S.
  819. * @note The PLLI2S is disabled by hardware when entering STOP and STANDBY modes.
  820. */
  821. #define __HAL_RCC_PLLI2S_ENABLE() (RCC->CR |= (RCC_CR_PLLI2SON))
  822. #define __HAL_RCC_PLLI2S_DISABLE() (RCC->CR &= ~(RCC_CR_PLLI2SON))
  823. /**
  824. * @}
  825. */
  826. /** @defgroup RCC_Get_Clock_source Get Clock source
  827. * @{
  828. */
  829. /**
  830. * @brief Macro to configure the system clock source.
  831. * @param __RCC_SYSCLKSOURCE__ specifies the system clock source.
  832. * This parameter can be one of the following values:
  833. * - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
  834. * - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
  835. * - RCC_SYSCLKSOURCE_PLLCLK: PLL output is used as system clock source.
  836. */
  837. #define __HAL_RCC_SYSCLK_CONFIG(__RCC_SYSCLKSOURCE__) MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__RCC_SYSCLKSOURCE__))
  838. /** @brief Macro to get the clock source used as system clock.
  839. * @retval The clock source used as system clock. The returned value can be one
  840. * of the following:
  841. * - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
  842. * - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
  843. * - RCC_SYSCLKSOURCE_STATUS_PLLCLK: PLL used as system clock.
  844. */
  845. #define __HAL_RCC_GET_SYSCLK_SOURCE() (RCC->CFGR & RCC_CFGR_SWS)
  846. /**
  847. * @brief Macro to configures the External Low Speed oscillator (LSE) drive capability.
  848. * @note As the LSE is in the Backup domain and write access is denied to
  849. * this domain after reset, you have to enable write access using
  850. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  851. * (to be done once after reset).
  852. * @param __RCC_LSEDRIVE__ specifies the new state of the LSE drive capability.
  853. * This parameter can be one of the following values:
  854. * @arg RCC_LSEDRIVE_LOW: LSE oscillator low drive capability.
  855. * @arg RCC_LSEDRIVE_MEDIUMLOW: LSE oscillator medium low drive capability.
  856. * @arg RCC_LSEDRIVE_MEDIUMHIGH: LSE oscillator medium high drive capability.
  857. * @arg RCC_LSEDRIVE_HIGH: LSE oscillator high drive capability.
  858. * @retval None
  859. */
  860. #define __HAL_RCC_LSEDRIVE_CONFIG(__RCC_LSEDRIVE__) \
  861. (MODIFY_REG(RCC->BDCR, RCC_BDCR_LSEDRV, (uint32_t)(__RCC_LSEDRIVE__) ))
  862. /** @brief Macro to get the oscillator used as PLL clock source.
  863. * @retval The oscillator used as PLL clock source. The returned value can be one
  864. * of the following:
  865. * - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source.
  866. * - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source.
  867. */
  868. #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC))
  869. /**
  870. * @}
  871. */
  872. /** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
  873. * @{
  874. */
  875. /** @brief Macro to configure the MCO1 clock.
  876. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  877. * This parameter can be one of the following values:
  878. * @arg RCC_MCO1SOURCE_HSI: HSI clock selected as MCO1 source
  879. * @arg RCC_MCO1SOURCE_LSE: LSE clock selected as MCO1 source
  880. * @arg RCC_MCO1SOURCE_HSE: HSE clock selected as MCO1 source
  881. * @arg RCC_MCO1SOURCE_PLLCLK: main PLL clock selected as MCO1 source
  882. * @param __MCODIV__ specifies the MCO clock prescaler.
  883. * This parameter can be one of the following values:
  884. * @arg RCC_MCODIV_1: no division applied to MCOx clock
  885. * @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
  886. * @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
  887. * @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
  888. * @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
  889. */
  890. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  891. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO1 | RCC_CFGR_MCO1PRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  892. /** @brief Macro to configure the MCO2 clock.
  893. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  894. * This parameter can be one of the following values:
  895. * @arg RCC_MCO2SOURCE_SYSCLK: System clock (SYSCLK) selected as MCO2 source
  896. * @arg RCC_MCO2SOURCE_PLLI2SCLK: PLLI2S clock selected as MCO2 source
  897. * @arg RCC_MCO2SOURCE_HSE: HSE clock selected as MCO2 source
  898. * @arg RCC_MCO2SOURCE_PLLCLK: main PLL clock selected as MCO2 source
  899. * @param __MCODIV__ specifies the MCO clock prescaler.
  900. * This parameter can be one of the following values:
  901. * @arg RCC_MCODIV_1: no division applied to MCOx clock
  902. * @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
  903. * @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
  904. * @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
  905. * @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
  906. */
  907. #define __HAL_RCC_MCO2_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  908. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO2 | RCC_CFGR_MCO2PRE), ((__MCOCLKSOURCE__) | ((__MCODIV__) << 3)));
  909. /**
  910. * @}
  911. */
  912. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  913. * @brief macros to manage the specified RCC Flags and interrupts.
  914. * @{
  915. */
  916. /** @brief Enable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to enable
  917. * the selected interrupts).
  918. * @param __INTERRUPT__ specifies the RCC interrupt sources to be enabled.
  919. * This parameter can be any combination of the following values:
  920. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  921. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  922. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  923. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  924. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  925. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  926. */
  927. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS |= (__INTERRUPT__))
  928. /** @brief Disable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to disable
  929. * the selected interrupts).
  930. * @param __INTERRUPT__ specifies the RCC interrupt sources to be disabled.
  931. * This parameter can be any combination of the following values:
  932. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  933. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  934. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  935. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  936. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  937. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  938. */
  939. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS &= (uint8_t)(~(__INTERRUPT__)))
  940. /** @brief Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CIR[23:16]
  941. * bits to clear the selected interrupt pending bits.
  942. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  943. * This parameter can be any combination of the following values:
  944. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  945. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  946. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  947. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  948. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  949. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  950. * @arg RCC_IT_CSS: Clock Security System interrupt
  951. */
  952. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE2_ADDRESS = (__INTERRUPT__))
  953. /** @brief Check the RCC's interrupt has occurred or not.
  954. * @param __INTERRUPT__ specifies the RCC interrupt source to check.
  955. * This parameter can be one of the following values:
  956. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  957. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  958. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  959. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  960. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  961. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  962. * @arg RCC_IT_CSS: Clock Security System interrupt
  963. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  964. */
  965. #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIR & (__INTERRUPT__)) == (__INTERRUPT__))
  966. /** @brief Set RMVF bit to clear the reset flags: RCC_FLAG_PINRST, RCC_FLAG_PORRST,
  967. * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
  968. */
  969. #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
  970. /** @brief Check RCC flag is set or not.
  971. * @param __FLAG__ specifies the flag to check.
  972. * This parameter can be one of the following values:
  973. * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready.
  974. * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready.
  975. * @arg RCC_FLAG_PLLRDY: Main PLL clock ready.
  976. * @arg RCC_FLAG_PLLI2SRDY: PLLI2S clock ready.
  977. * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready.
  978. * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready.
  979. * @arg RCC_FLAG_BORRST: POR/PDR or BOR reset.
  980. * @arg RCC_FLAG_PINRST: Pin reset.
  981. * @arg RCC_FLAG_PORRST: POR/PDR reset.
  982. * @arg RCC_FLAG_SFTRST: Software reset.
  983. * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset.
  984. * @arg RCC_FLAG_WWDGRST: Window Watchdog reset.
  985. * @arg RCC_FLAG_LPWRRST: Low Power reset.
  986. * @retval The new state of __FLAG__ (TRUE or FALSE).
  987. */
  988. #define RCC_FLAG_MASK ((uint8_t)0x1F)
  989. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5) == 1)? RCC->CR :((((__FLAG__) >> 5) == 2) ? RCC->BDCR :((((__FLAG__) >> 5) == 3)? RCC->CSR :RCC->CIR))) & ((uint32_t)1 << ((__FLAG__) & RCC_FLAG_MASK)))!= 0)? 1 : 0)
  990. /**
  991. * @}
  992. */
  993. /**
  994. * @}
  995. */
  996. /* Include RCC HAL Extension module */
  997. #include "stm32f7xx_hal_rcc_ex.h"
  998. /* Exported functions --------------------------------------------------------*/
  999. /** @addtogroup RCC_Exported_Functions
  1000. * @{
  1001. */
  1002. /** @addtogroup RCC_Exported_Functions_Group1
  1003. * @{
  1004. */
  1005. /* Initialization and de-initialization functions ******************************/
  1006. HAL_StatusTypeDef HAL_RCC_DeInit(void);
  1007. HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  1008. HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
  1009. /**
  1010. * @}
  1011. */
  1012. /** @addtogroup RCC_Exported_Functions_Group2
  1013. * @{
  1014. */
  1015. /* Peripheral Control functions ************************************************/
  1016. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  1017. void HAL_RCC_EnableCSS(void);
  1018. void HAL_RCC_DisableCSS(void);
  1019. uint32_t HAL_RCC_GetSysClockFreq(void);
  1020. uint32_t HAL_RCC_GetHCLKFreq(void);
  1021. uint32_t HAL_RCC_GetPCLK1Freq(void);
  1022. uint32_t HAL_RCC_GetPCLK2Freq(void);
  1023. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  1024. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
  1025. /* CSS NMI IRQ handler */
  1026. void HAL_RCC_NMI_IRQHandler(void);
  1027. /* User Callbacks in non blocking mode (IT mode) */
  1028. void HAL_RCC_CSSCallback(void);
  1029. /**
  1030. * @}
  1031. */
  1032. /**
  1033. * @}
  1034. */
  1035. /* Private types -------------------------------------------------------------*/
  1036. /* Private variables ---------------------------------------------------------*/
  1037. /* Private constants ---------------------------------------------------------*/
  1038. /** @defgroup RCC_Private_Constants RCC Private Constants
  1039. * @{
  1040. */
  1041. #define HSE_TIMEOUT_VALUE HSE_STARTUP_TIMEOUT
  1042. #define HSI_TIMEOUT_VALUE ((uint32_t)2) /* 2 ms */
  1043. #define LSI_TIMEOUT_VALUE ((uint32_t)2) /* 2 ms */
  1044. #define PLL_TIMEOUT_VALUE ((uint32_t)2) /* 2 ms */
  1045. #define CLOCKSWITCH_TIMEOUT_VALUE ((uint32_t)5000) /* 5 s */
  1046. #define PLLI2S_TIMEOUT_VALUE 100U /* Timeout value fixed to 100 ms */
  1047. #define PLLSAI_TIMEOUT_VALUE 100U /* Timeout value fixed to 100 ms */
  1048. /** @defgroup RCC_BitAddress_Alias RCC BitAddress Alias
  1049. * @brief RCC registers bit address alias
  1050. * @{
  1051. */
  1052. /* CIR register byte 2 (Bits[15:8]) base address */
  1053. #define RCC_CIR_BYTE1_ADDRESS ((uint32_t)(RCC_BASE + 0x0C + 0x01))
  1054. /* CIR register byte 3 (Bits[23:16]) base address */
  1055. #define RCC_CIR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + 0x0C + 0x02))
  1056. #define RCC_DBP_TIMEOUT_VALUE ((uint32_t)100)
  1057. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
  1058. /**
  1059. * @}
  1060. */
  1061. /**
  1062. * @}
  1063. */
  1064. /* Private macros ------------------------------------------------------------*/
  1065. /** @addtogroup RCC_Private_Macros RCC Private Macros
  1066. * @{
  1067. */
  1068. /** @defgroup RCC_IS_RCC_Definitions RCC Private macros to check input parameters
  1069. * @{
  1070. */
  1071. #define IS_RCC_OSCILLATORTYPE(OSCILLATOR) ((OSCILLATOR) <= 15)
  1072. #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \
  1073. ((HSE) == RCC_HSE_BYPASS))
  1074. #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
  1075. ((LSE) == RCC_LSE_BYPASS))
  1076. #define IS_RCC_HSI(HSI) (((HSI) == RCC_HSI_OFF) || ((HSI) == RCC_HSI_ON))
  1077. #define IS_RCC_LSI(LSI) (((LSI) == RCC_LSI_OFF) || ((LSI) == RCC_LSI_ON))
  1078. #define IS_RCC_PLL(PLL) (((PLL) == RCC_PLL_NONE) ||((PLL) == RCC_PLL_OFF) || ((PLL) == RCC_PLL_ON))
  1079. #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
  1080. ((SOURCE) == RCC_PLLSOURCE_HSE))
  1081. #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
  1082. ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
  1083. ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK))
  1084. #define IS_RCC_PLLM_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 63))
  1085. #define IS_RCC_PLLN_VALUE(VALUE) ((50 <= (VALUE)) && ((VALUE) <= 432))
  1086. #define IS_RCC_PLLP_VALUE(VALUE) (((VALUE) == RCC_PLLP_DIV2) || ((VALUE) == RCC_PLLP_DIV4) || \
  1087. ((VALUE) == RCC_PLLP_DIV6) || ((VALUE) == RCC_PLLP_DIV8))
  1088. #define IS_RCC_PLLQ_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 15))
  1089. #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_DIV1) || ((HCLK) == RCC_SYSCLK_DIV2) || \
  1090. ((HCLK) == RCC_SYSCLK_DIV4) || ((HCLK) == RCC_SYSCLK_DIV8) || \
  1091. ((HCLK) == RCC_SYSCLK_DIV16) || ((HCLK) == RCC_SYSCLK_DIV64) || \
  1092. ((HCLK) == RCC_SYSCLK_DIV128) || ((HCLK) == RCC_SYSCLK_DIV256) || \
  1093. ((HCLK) == RCC_SYSCLK_DIV512))
  1094. #define IS_RCC_CLOCKTYPE(CLK) ((1 <= (CLK)) && ((CLK) <= 15))
  1095. #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_DIV1) || ((PCLK) == RCC_HCLK_DIV2) || \
  1096. ((PCLK) == RCC_HCLK_DIV4) || ((PCLK) == RCC_HCLK_DIV8) || \
  1097. ((PCLK) == RCC_HCLK_DIV16))
  1098. #define IS_RCC_MCO(MCOX) (((MCOX) == RCC_MCO1) || ((MCOX) == RCC_MCO2))
  1099. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_HSI) || ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
  1100. ((SOURCE) == RCC_MCO1SOURCE_HSE) || ((SOURCE) == RCC_MCO1SOURCE_PLLCLK))
  1101. #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2SOURCE_SYSCLK) || ((SOURCE) == RCC_MCO2SOURCE_PLLI2SCLK)|| \
  1102. ((SOURCE) == RCC_MCO2SOURCE_HSE) || ((SOURCE) == RCC_MCO2SOURCE_PLLCLK))
  1103. #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1) || ((DIV) == RCC_MCODIV_2) || \
  1104. ((DIV) == RCC_MCODIV_3) || ((DIV) == RCC_MCODIV_4) || \
  1105. ((DIV) == RCC_MCODIV_5))
  1106. #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F)
  1107. #define IS_RCC_RTCCLKSOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSOURCE_LSE) || ((SOURCE) == RCC_RTCCLKSOURCE_LSI) || \
  1108. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV2) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV3) || \
  1109. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV4) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV5) || \
  1110. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV6) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV7) || \
  1111. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV8) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV9) || \
  1112. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV10) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV11) || \
  1113. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV12) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV13) || \
  1114. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV14) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV15) || \
  1115. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV16) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV17) || \
  1116. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV18) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV19) || \
  1117. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV20) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV21) || \
  1118. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV22) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV23) || \
  1119. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV24) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV25) || \
  1120. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV26) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV27) || \
  1121. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV28) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV29) || \
  1122. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV30) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV31))
  1123. #define IS_RCC_LSE_DRIVE(DRIVE) (((DRIVE) == RCC_LSEDRIVE_LOW) || \
  1124. ((DRIVE) == RCC_LSEDRIVE_MEDIUMLOW) || \
  1125. ((DRIVE) == RCC_LSEDRIVE_MEDIUMHIGH) || \
  1126. ((DRIVE) == RCC_LSEDRIVE_HIGH))
  1127. /**
  1128. * @}
  1129. */
  1130. /**
  1131. * @}
  1132. */
  1133. /**
  1134. * @}
  1135. */
  1136. /**
  1137. * @}
  1138. */
  1139. #ifdef __cplusplus
  1140. }
  1141. #endif
  1142. #endif /* __STM32F7xx_HAL_RCC_H */