stm32f2xx_hal_rcc.h 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F2xx_HAL_RCC_H
  21. #define __STM32F2xx_HAL_RCC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f2xx_hal_def.h"
  27. /** @addtogroup STM32F2xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup RCC
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup RCC_Exported_Types RCC Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief RCC PLL configuration structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t PLLState; /*!< The new state of the PLL.
  43. This parameter can be a value of @ref RCC_PLL_Config */
  44. uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
  45. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  46. uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock.
  47. This parameter must be a number between Min_Data = 0 and Max_Data = 63 */
  48. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock.
  49. This parameter must be a number between Min_Data = 192 and Max_Data = 432 */
  50. uint32_t PLLP; /*!< PLLP: Division factor for main system clock (SYSCLK).
  51. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  52. uint32_t PLLQ; /*!< PLLQ: Division factor for OTG FS, SDIO and RNG clocks.
  53. This parameter must be a number between Min_Data = 2 and Max_Data = 15 */
  54. }RCC_PLLInitTypeDef;
  55. /**
  56. * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t OscillatorType; /*!< The oscillators to be configured.
  61. This parameter can be a value of @ref RCC_Oscillator_Type */
  62. uint32_t HSEState; /*!< The new state of the HSE.
  63. This parameter can be a value of @ref RCC_HSE_Config */
  64. uint32_t LSEState; /*!< The new state of the LSE.
  65. This parameter can be a value of @ref RCC_LSE_Config */
  66. uint32_t HSIState; /*!< The new state of the HSI.
  67. This parameter can be a value of @ref RCC_HSI_Config */
  68. uint32_t HSICalibrationValue; /*!< The HSI calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  69. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
  70. uint32_t LSIState; /*!< The new state of the LSI.
  71. This parameter can be a value of @ref RCC_LSI_Config */
  72. RCC_PLLInitTypeDef PLL; /*!< PLL structure parameters */
  73. }RCC_OscInitTypeDef;
  74. /**
  75. * @brief RCC System, AHB and APB busses clock configuration structure definition
  76. */
  77. typedef struct
  78. {
  79. uint32_t ClockType; /*!< The clock to be configured.
  80. This parameter can be a value of @ref RCC_System_Clock_Type */
  81. uint32_t SYSCLKSource; /*!< The clock source (SYSCLKS) used as system clock.
  82. This parameter can be a value of @ref RCC_System_Clock_Source */
  83. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  84. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  85. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  86. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  87. uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
  88. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  89. }RCC_ClkInitTypeDef;
  90. /**
  91. * @}
  92. */
  93. /* Exported constants --------------------------------------------------------*/
  94. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  95. * @{
  96. */
  97. /** @defgroup RCC_Oscillator_Type Oscillator Type
  98. * @{
  99. */
  100. #define RCC_OSCILLATORTYPE_NONE 0x00000000U
  101. #define RCC_OSCILLATORTYPE_HSE 0x00000001U
  102. #define RCC_OSCILLATORTYPE_HSI 0x00000002U
  103. #define RCC_OSCILLATORTYPE_LSE 0x00000004U
  104. #define RCC_OSCILLATORTYPE_LSI 0x00000008U
  105. /**
  106. * @}
  107. */
  108. /** @defgroup RCC_HSE_Config HSE Config
  109. * @{
  110. */
  111. #define RCC_HSE_OFF ((uint8_t)0x00)
  112. #define RCC_HSE_ON ((uint8_t)0x01)
  113. #define RCC_HSE_BYPASS ((uint8_t)0x05)
  114. /**
  115. * @}
  116. */
  117. /** @defgroup RCC_LSE_Config LSE Config
  118. * @{
  119. */
  120. #define RCC_LSE_OFF ((uint8_t)0x00)
  121. #define RCC_LSE_ON ((uint8_t)0x01)
  122. #define RCC_LSE_BYPASS ((uint8_t)0x05)
  123. /**
  124. * @}
  125. */
  126. /** @defgroup RCC_HSI_Config HSI Config
  127. * @{
  128. */
  129. #define RCC_HSI_OFF ((uint8_t)0x00)
  130. #define RCC_HSI_ON ((uint8_t)0x01)
  131. #define RCC_HSICALIBRATION_DEFAULT 0x10U /* Default HSI calibration trimming value */
  132. /**
  133. * @}
  134. */
  135. /** @defgroup RCC_LSI_Config LSI Config
  136. * @{
  137. */
  138. #define RCC_LSI_OFF ((uint8_t)0x00)
  139. #define RCC_LSI_ON ((uint8_t)0x01)
  140. /**
  141. * @}
  142. */
  143. /** @defgroup RCC_PLL_Config PLL Config
  144. * @{
  145. */
  146. #define RCC_PLL_NONE ((uint8_t)0x00)
  147. #define RCC_PLL_OFF ((uint8_t)0x01)
  148. #define RCC_PLL_ON ((uint8_t)0x02)
  149. /**
  150. * @}
  151. */
  152. /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
  153. * @{
  154. */
  155. #define RCC_PLLP_DIV2 0x00000002U
  156. #define RCC_PLLP_DIV4 0x00000004U
  157. #define RCC_PLLP_DIV6 0x00000006U
  158. #define RCC_PLLP_DIV8 0x00000008U
  159. /**
  160. * @}
  161. */
  162. /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
  163. * @{
  164. */
  165. #define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI
  166. #define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE
  167. /**
  168. * @}
  169. */
  170. /** @defgroup RCC_System_Clock_Type System Clock Type
  171. * @{
  172. */
  173. #define RCC_CLOCKTYPE_SYSCLK 0x00000001U
  174. #define RCC_CLOCKTYPE_HCLK 0x00000002U
  175. #define RCC_CLOCKTYPE_PCLK1 0x00000004U
  176. #define RCC_CLOCKTYPE_PCLK2 0x00000008U
  177. /**
  178. * @}
  179. */
  180. /** @defgroup RCC_System_Clock_Source System Clock Source
  181. * @{
  182. */
  183. #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI
  184. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE
  185. #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL
  186. /**
  187. * @}
  188. */
  189. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  190. * @{
  191. */
  192. #define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  193. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  194. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  195. /**
  196. * @}
  197. */
  198. /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
  199. * @{
  200. */
  201. #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1
  202. #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2
  203. #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4
  204. #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8
  205. #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16
  206. #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64
  207. #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128
  208. #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256
  209. #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512
  210. /**
  211. * @}
  212. */
  213. /** @defgroup RCC_APB1_APB2_Clock_Source APB1/APB2 Clock Source
  214. * @{
  215. */
  216. #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1
  217. #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2
  218. #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4
  219. #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8
  220. #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16
  221. /**
  222. * @}
  223. */
  224. /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
  225. * @{
  226. */
  227. #define RCC_RTCCLKSOURCE_LSE 0x00000100U
  228. #define RCC_RTCCLKSOURCE_LSI 0x00000200U
  229. #define RCC_RTCCLKSOURCE_HSE_DIV2 0x00020300U
  230. #define RCC_RTCCLKSOURCE_HSE_DIV3 0x00030300U
  231. #define RCC_RTCCLKSOURCE_HSE_DIV4 0x00040300U
  232. #define RCC_RTCCLKSOURCE_HSE_DIV5 0x00050300U
  233. #define RCC_RTCCLKSOURCE_HSE_DIV6 0x00060300U
  234. #define RCC_RTCCLKSOURCE_HSE_DIV7 0x00070300U
  235. #define RCC_RTCCLKSOURCE_HSE_DIV8 0x00080300U
  236. #define RCC_RTCCLKSOURCE_HSE_DIV9 0x00090300U
  237. #define RCC_RTCCLKSOURCE_HSE_DIV10 0x000A0300U
  238. #define RCC_RTCCLKSOURCE_HSE_DIV11 0x000B0300U
  239. #define RCC_RTCCLKSOURCE_HSE_DIV12 0x000C0300U
  240. #define RCC_RTCCLKSOURCE_HSE_DIV13 0x000D0300U
  241. #define RCC_RTCCLKSOURCE_HSE_DIV14 0x000E0300U
  242. #define RCC_RTCCLKSOURCE_HSE_DIV15 0x000F0300U
  243. #define RCC_RTCCLKSOURCE_HSE_DIV16 0x00100300U
  244. #define RCC_RTCCLKSOURCE_HSE_DIV17 0x00110300U
  245. #define RCC_RTCCLKSOURCE_HSE_DIV18 0x00120300U
  246. #define RCC_RTCCLKSOURCE_HSE_DIV19 0x00130300U
  247. #define RCC_RTCCLKSOURCE_HSE_DIV20 0x00140300U
  248. #define RCC_RTCCLKSOURCE_HSE_DIV21 0x00150300U
  249. #define RCC_RTCCLKSOURCE_HSE_DIV22 0x00160300U
  250. #define RCC_RTCCLKSOURCE_HSE_DIV23 0x00170300U
  251. #define RCC_RTCCLKSOURCE_HSE_DIV24 0x00180300U
  252. #define RCC_RTCCLKSOURCE_HSE_DIV25 0x00190300U
  253. #define RCC_RTCCLKSOURCE_HSE_DIV26 0x001A0300U
  254. #define RCC_RTCCLKSOURCE_HSE_DIV27 0x001B0300U
  255. #define RCC_RTCCLKSOURCE_HSE_DIV28 0x001C0300U
  256. #define RCC_RTCCLKSOURCE_HSE_DIV29 0x001D0300U
  257. #define RCC_RTCCLKSOURCE_HSE_DIV30 0x001E0300U
  258. #define RCC_RTCCLKSOURCE_HSE_DIV31 0x001F0300U
  259. /**
  260. * @}
  261. */
  262. /** @defgroup RCC_MCO_Index MCO Index
  263. * @{
  264. */
  265. #define RCC_MCO1 0x00000000U
  266. #define RCC_MCO2 0x00000001U
  267. /**
  268. * @}
  269. */
  270. /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
  271. * @{
  272. */
  273. #define RCC_MCO1SOURCE_HSI 0x00000000U
  274. #define RCC_MCO1SOURCE_LSE RCC_CFGR_MCO1_0
  275. #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCO1_1
  276. #define RCC_MCO1SOURCE_PLLCLK RCC_CFGR_MCO1
  277. /**
  278. * @}
  279. */
  280. /** @defgroup RCC_MCO2_Clock_Source MCO2 Clock Source
  281. * @{
  282. */
  283. #define RCC_MCO2SOURCE_SYSCLK 0x00000000U
  284. #define RCC_MCO2SOURCE_PLLI2SCLK RCC_CFGR_MCO2_0
  285. #define RCC_MCO2SOURCE_HSE RCC_CFGR_MCO2_1
  286. #define RCC_MCO2SOURCE_PLLCLK RCC_CFGR_MCO2
  287. /**
  288. * @}
  289. */
  290. /** @defgroup RCC_MCOx_Clock_Prescaler MCOx Clock Prescaler
  291. * @{
  292. */
  293. #define RCC_MCODIV_1 0x00000000U
  294. #define RCC_MCODIV_2 RCC_CFGR_MCO1PRE_2
  295. #define RCC_MCODIV_3 ((uint32_t)RCC_CFGR_MCO1PRE_0 | RCC_CFGR_MCO1PRE_2)
  296. #define RCC_MCODIV_4 ((uint32_t)RCC_CFGR_MCO1PRE_1 | RCC_CFGR_MCO1PRE_2)
  297. #define RCC_MCODIV_5 RCC_CFGR_MCO1PRE
  298. /**
  299. * @}
  300. */
  301. /** @defgroup RCC_Interrupt Interrupts
  302. * @{
  303. */
  304. #define RCC_IT_LSIRDY ((uint8_t)0x01)
  305. #define RCC_IT_LSERDY ((uint8_t)0x02)
  306. #define RCC_IT_HSIRDY ((uint8_t)0x04)
  307. #define RCC_IT_HSERDY ((uint8_t)0x08)
  308. #define RCC_IT_PLLRDY ((uint8_t)0x10)
  309. #define RCC_IT_PLLI2SRDY ((uint8_t)0x20)
  310. #define RCC_IT_CSS ((uint8_t)0x80)
  311. /**
  312. * @}
  313. */
  314. /** @defgroup RCC_Flag Flags
  315. * Elements values convention: 0XXYYYYYb
  316. * - YYYYY : Flag position in the register
  317. * - 0XX : Register index
  318. * - 01: CR register
  319. * - 10: BDCR register
  320. * - 11: CSR register
  321. * @{
  322. */
  323. /* Flags in the CR register */
  324. #define RCC_FLAG_HSIRDY ((uint8_t)0x21)
  325. #define RCC_FLAG_HSERDY ((uint8_t)0x31)
  326. #define RCC_FLAG_PLLRDY ((uint8_t)0x39)
  327. #define RCC_FLAG_PLLI2SRDY ((uint8_t)0x3B)
  328. /* Flags in the BDCR register */
  329. #define RCC_FLAG_LSERDY ((uint8_t)0x41)
  330. /* Flags in the CSR register */
  331. #define RCC_FLAG_LSIRDY ((uint8_t)0x61)
  332. #define RCC_FLAG_BORRST ((uint8_t)0x79)
  333. #define RCC_FLAG_PINRST ((uint8_t)0x7A)
  334. #define RCC_FLAG_PORRST ((uint8_t)0x7B)
  335. #define RCC_FLAG_SFTRST ((uint8_t)0x7C)
  336. #define RCC_FLAG_IWDGRST ((uint8_t)0x7D)
  337. #define RCC_FLAG_WWDGRST ((uint8_t)0x7E)
  338. #define RCC_FLAG_LPWRRST ((uint8_t)0x7F)
  339. /**
  340. * @}
  341. */
  342. /**
  343. * @}
  344. */
  345. /* Exported macro ------------------------------------------------------------*/
  346. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  347. * @{
  348. */
  349. /** @defgroup RCC_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  350. * @brief Enable or disable the AHB1 peripheral clock.
  351. * @note After reset, the peripheral clock (used for registers read/write access)
  352. * is disabled and the application software has to enable this clock before
  353. * using it.
  354. * @{
  355. */
  356. #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
  357. __IO uint32_t tmpreg = 0x00U; \
  358. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOAEN);\
  359. /* Delay after an RCC peripheral clock enabling */ \
  360. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOAEN);\
  361. UNUSED(tmpreg); \
  362. } while(0)
  363. #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
  364. __IO uint32_t tmpreg = 0x00U; \
  365. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOBEN);\
  366. /* Delay after an RCC peripheral clock enabling */ \
  367. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOBEN);\
  368. UNUSED(tmpreg); \
  369. } while(0)
  370. #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
  371. __IO uint32_t tmpreg = 0x00U; \
  372. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);\
  373. /* Delay after an RCC peripheral clock enabling */ \
  374. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);\
  375. UNUSED(tmpreg); \
  376. } while(0)
  377. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  378. __IO uint32_t tmpreg = 0x00U; \
  379. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  380. /* Delay after an RCC peripheral clock enabling */ \
  381. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);\
  382. UNUSED(tmpreg); \
  383. } while(0)
  384. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  385. __IO uint32_t tmpreg = 0x00U; \
  386. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  387. /* Delay after an RCC peripheral clock enabling */ \
  388. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOEEN);\
  389. UNUSED(tmpreg); \
  390. } while(0)
  391. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  392. __IO uint32_t tmpreg = 0x00U; \
  393. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  394. /* Delay after an RCC peripheral clock enabling */ \
  395. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  396. UNUSED(tmpreg); \
  397. } while(0)
  398. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  399. __IO uint32_t tmpreg = 0x00U; \
  400. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  401. /* Delay after an RCC peripheral clock enabling */ \
  402. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  403. UNUSED(tmpreg); \
  404. } while(0)
  405. #define __HAL_RCC_GPIOH_CLK_ENABLE() do { \
  406. __IO uint32_t tmpreg = 0x00U; \
  407. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOHEN);\
  408. /* Delay after an RCC peripheral clock enabling */ \
  409. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOHEN);\
  410. UNUSED(tmpreg); \
  411. } while(0)
  412. #define __HAL_RCC_GPIOI_CLK_ENABLE() do { \
  413. __IO uint32_t tmpreg = 0x00U; \
  414. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  415. /* Delay after an RCC peripheral clock enabling */ \
  416. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  417. UNUSED(tmpreg); \
  418. } while(0)
  419. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  420. __IO uint32_t tmpreg = 0x00U; \
  421. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  422. /* Delay after an RCC peripheral clock enabling */ \
  423. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN);\
  424. UNUSED(tmpreg); \
  425. } while(0)
  426. #define __HAL_RCC_BKPSRAM_CLK_ENABLE() do { \
  427. __IO uint32_t tmpreg = 0x00U; \
  428. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  429. /* Delay after an RCC peripheral clock enabling */ \
  430. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPSRAMEN);\
  431. UNUSED(tmpreg); \
  432. } while(0)
  433. #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
  434. __IO uint32_t tmpreg = 0x00U; \
  435. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
  436. /* Delay after an RCC peripheral clock enabling */ \
  437. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
  438. UNUSED(tmpreg); \
  439. } while(0)
  440. #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
  441. __IO uint32_t tmpreg = 0x00U; \
  442. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN);\
  443. /* Delay after an RCC peripheral clock enabling */ \
  444. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN);\
  445. UNUSED(tmpreg); \
  446. } while(0)
  447. #define __HAL_RCC_USB_OTG_HS_CLK_ENABLE() do { \
  448. __IO uint32_t tmpreg = 0x00U; \
  449. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  450. /* Delay after an RCC peripheral clock enabling */ \
  451. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  452. UNUSED(tmpreg); \
  453. } while(0)
  454. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE() do { \
  455. __IO uint32_t tmpreg = 0x00U; \
  456. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  457. /* Delay after an RCC peripheral clock enabling */ \
  458. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  459. UNUSED(tmpreg); \
  460. } while(0)
  461. #define __HAL_RCC_GPIOA_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOAEN))
  462. #define __HAL_RCC_GPIOB_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOBEN))
  463. #define __HAL_RCC_GPIOC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOCEN))
  464. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIODEN))
  465. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOEEN))
  466. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  467. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  468. #define __HAL_RCC_GPIOH_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOHEN))
  469. #define __HAL_RCC_GPIOI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOIEN))
  470. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_CRCEN))
  471. #define __HAL_RCC_BKPSRAM_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_BKPSRAMEN))
  472. #define __HAL_RCC_DMA1_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA1EN))
  473. #define __HAL_RCC_DMA2_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA2EN))
  474. #define __HAL_RCC_USB_OTG_HS_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSEN))
  475. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSULPIEN))
  476. /**
  477. * @}
  478. */
  479. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  480. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  481. * @note After reset, the peripheral clock (used for registers read/write access)
  482. * is disabled and the application software has to enable this clock before
  483. * using it.
  484. * @{
  485. */
  486. #define __HAL_RCC_GPIOA_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOAEN)) != RESET)
  487. #define __HAL_RCC_GPIOB_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOBEN)) != RESET)
  488. #define __HAL_RCC_GPIOC_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOCEN)) != RESET)
  489. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIODEN)) != RESET)
  490. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOEEN)) != RESET)
  491. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOFEN)) != RESET)
  492. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOGEN)) != RESET)
  493. #define __HAL_RCC_GPIOH_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOHEN)) != RESET)
  494. #define __HAL_RCC_GPIOI_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOIEN)) != RESET)
  495. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_CRCEN)) != RESET)
  496. #define __HAL_RCC_BKPSRAM_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_BKPSRAMEN)) != RESET)
  497. #define __HAL_RCC_DMA1_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA1EN)) != RESET)
  498. #define __HAL_RCC_DMA2_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA2EN)) != RESET)
  499. #define __HAL_RCC_USB_OTG_HS_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_OTGHSEN)) != RESET)
  500. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_ENABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_OTGHSULPIEN)) != RESET)
  501. #define __HAL_RCC_GPIOA_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOAEN)) == RESET)
  502. #define __HAL_RCC_GPIOB_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOBEN)) == RESET)
  503. #define __HAL_RCC_GPIOC_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOCEN)) == RESET)
  504. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIODEN)) == RESET)
  505. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOEEN)) == RESET)
  506. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOFEN)) == RESET)
  507. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOGEN)) == RESET)
  508. #define __HAL_RCC_GPIOH_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOHEN)) == RESET)
  509. #define __HAL_RCC_GPIOI_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOIEN)) == RESET)
  510. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_CRCEN)) == RESET)
  511. #define __HAL_RCC_BKPSRAM_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_BKPSRAMEN)) == RESET)
  512. #define __HAL_RCC_DMA1_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA1EN)) == RESET)
  513. #define __HAL_RCC_DMA2_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA2EN)) == RESET)
  514. #define __HAL_RCC_USB_OTG_HS_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_OTGHSEN)) == RESET)
  515. #define __HAL_RCC_USB_OTG_HS_ULPI_IS_CLK_DISABLED() ((RCC->AHB1ENR &(RCC_AHB1ENR_OTGHSULPIEN)) == RESET)
  516. /**
  517. * @}
  518. */
  519. /** @defgroup RCC_AHB2_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  520. * @brief Enable or disable the AHB2 peripheral clock.
  521. * @note After reset, the peripheral clock (used for registers read/write access)
  522. * is disabled and the application software has to enable this clock before
  523. * using it.
  524. * @{
  525. */
  526. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do {(RCC->AHB2ENR |= (RCC_AHB2ENR_OTGFSEN));\
  527. __HAL_RCC_SYSCFG_CLK_ENABLE();\
  528. }while(0)
  529. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  530. __IO uint32_t tmpreg = 0x00U; \
  531. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  532. /* Delay after an RCC peripheral clock enabling */ \
  533. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);\
  534. UNUSED(tmpreg); \
  535. } while(0)
  536. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_OTGFSEN))
  537. #define __HAL_RCC_RNG_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_RNGEN))
  538. /**
  539. * @}
  540. */
  541. /** @defgroup RCC_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enable Disable Status
  542. * @brief Get the enable or disable status of the AHB2 peripheral clock.
  543. * @note After reset, the peripheral clock (used for registers read/write access)
  544. * is disabled and the application software has to enable this clock before
  545. * using it.
  546. * @{
  547. */
  548. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHB2ENR &(RCC_AHB2ENR_OTGFSEN)) != RESET)
  549. #define __HAL_RCC_RNG_IS_CLK_ENABLED() ((RCC->AHB2ENR &(RCC_AHB2ENR_RNGEN)) != RESET)
  550. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHB2ENR &(RCC_AHB2ENR_OTGFSEN)) == RESET)
  551. #define __HAL_RCC_RNG_IS_CLK_DISABLED() ((RCC->AHB2ENR &(RCC_AHB2ENR_RNGEN)) == RESET)
  552. /**
  553. * @}
  554. */
  555. /** @defgroup RCC_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  556. * @brief Enables or disables the AHB3 peripheral clock.
  557. * @note After reset, the peripheral clock (used for registers read/write access)
  558. * is disabled and the application software has to enable this clock before
  559. * using it.
  560. * @{
  561. */
  562. #define __HAL_RCC_FSMC_CLK_ENABLE() do { \
  563. __IO uint32_t tmpreg = 0x00U; \
  564. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  565. /* Delay after an RCC peripheral clock enabling */ \
  566. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  567. UNUSED(tmpreg); \
  568. } while(0)
  569. #define __HAL_RCC_FSMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FSMCEN))
  570. /**
  571. * @}
  572. */
  573. /** @defgroup RCC_AHB3_Peripheral_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enable Disable Status
  574. * @brief Get the enable or disable status of the AHB3 peripheral clock.
  575. * @note After reset, the peripheral clock (used for registers read/write access)
  576. * is disabled and the application software has to enable this clock before
  577. * using it.
  578. * @{
  579. */
  580. #define __HAL_RCC_FSMC_IS_CLK_ENABLED() ((RCC->AHB3ENR &(RCC_AHB3ENR_FSMCEN))!= RESET)
  581. #define __HAL_RCC_FSMC_IS_CLK_DISABLED() ((RCC->AHB3ENR &(RCC_AHB3ENR_FSMCEN))== RESET)
  582. /**
  583. * @}
  584. */
  585. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  586. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  587. * @note After reset, the peripheral clock (used for registers read/write access)
  588. * is disabled and the application software has to enable this clock before
  589. * using it.
  590. * @{
  591. */
  592. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  593. __IO uint32_t tmpreg = 0x00U; \
  594. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  595. /* Delay after an RCC peripheral clock enabling */ \
  596. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  597. UNUSED(tmpreg); \
  598. } while(0)
  599. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  600. __IO uint32_t tmpreg = 0x00U; \
  601. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  602. /* Delay after an RCC peripheral clock enabling */ \
  603. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  604. UNUSED(tmpreg); \
  605. } while(0)
  606. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  607. __IO uint32_t tmpreg = 0x00U; \
  608. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  609. /* Delay after an RCC peripheral clock enabling */ \
  610. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  611. UNUSED(tmpreg); \
  612. } while(0)
  613. #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
  614. __IO uint32_t tmpreg = 0x00U; \
  615. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
  616. /* Delay after an RCC peripheral clock enabling */ \
  617. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
  618. UNUSED(tmpreg); \
  619. } while(0)
  620. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  621. __IO uint32_t tmpreg = 0x00U; \
  622. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  623. /* Delay after an RCC peripheral clock enabling */ \
  624. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  625. UNUSED(tmpreg); \
  626. } while(0)
  627. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  628. __IO uint32_t tmpreg = 0x00U; \
  629. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  630. /* Delay after an RCC peripheral clock enabling */ \
  631. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  632. UNUSED(tmpreg); \
  633. } while(0)
  634. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  635. __IO uint32_t tmpreg = 0x00U; \
  636. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  637. /* Delay after an RCC peripheral clock enabling */ \
  638. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  639. UNUSED(tmpreg); \
  640. } while(0)
  641. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  642. __IO uint32_t tmpreg = 0x00U; \
  643. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  644. /* Delay after an RCC peripheral clock enabling */ \
  645. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  646. UNUSED(tmpreg); \
  647. } while(0)
  648. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  649. __IO uint32_t tmpreg = 0x00U; \
  650. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  651. /* Delay after an RCC peripheral clock enabling */ \
  652. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  653. UNUSED(tmpreg); \
  654. } while(0)
  655. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  656. __IO uint32_t tmpreg = 0x00U; \
  657. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
  658. /* Delay after an RCC peripheral clock enabling */ \
  659. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
  660. UNUSED(tmpreg); \
  661. } while(0)
  662. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  663. __IO uint32_t tmpreg = 0x00U; \
  664. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  665. /* Delay after an RCC peripheral clock enabling */ \
  666. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  667. UNUSED(tmpreg); \
  668. } while(0)
  669. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  670. __IO uint32_t tmpreg = 0x00U; \
  671. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  672. /* Delay after an RCC peripheral clock enabling */ \
  673. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  674. UNUSED(tmpreg); \
  675. } while(0)
  676. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  677. __IO uint32_t tmpreg = 0x00U; \
  678. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
  679. /* Delay after an RCC peripheral clock enabling */ \
  680. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
  681. UNUSED(tmpreg); \
  682. } while(0)
  683. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  684. __IO uint32_t tmpreg = 0x00U; \
  685. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  686. /* Delay after an RCC peripheral clock enabling */ \
  687. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  688. UNUSED(tmpreg); \
  689. } while(0)
  690. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  691. __IO uint32_t tmpreg = 0x00U; \
  692. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  693. /* Delay after an RCC peripheral clock enabling */ \
  694. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  695. UNUSED(tmpreg); \
  696. } while(0)
  697. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  698. __IO uint32_t tmpreg = 0x00U; \
  699. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  700. /* Delay after an RCC peripheral clock enabling */ \
  701. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  702. UNUSED(tmpreg); \
  703. } while(0)
  704. #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
  705. __IO uint32_t tmpreg = 0x00U; \
  706. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
  707. /* Delay after an RCC peripheral clock enabling */ \
  708. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
  709. UNUSED(tmpreg); \
  710. } while(0)
  711. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  712. __IO uint32_t tmpreg = 0x00U; \
  713. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  714. /* Delay after an RCC peripheral clock enabling */ \
  715. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  716. UNUSED(tmpreg); \
  717. } while(0)
  718. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  719. __IO uint32_t tmpreg = 0x00U; \
  720. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  721. /* Delay after an RCC peripheral clock enabling */ \
  722. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C3EN);\
  723. UNUSED(tmpreg); \
  724. } while(0)
  725. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  726. __IO uint32_t tmpreg = 0x00U; \
  727. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  728. /* Delay after an RCC peripheral clock enabling */ \
  729. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  730. UNUSED(tmpreg); \
  731. } while(0)
  732. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  733. __IO uint32_t tmpreg = 0x00U; \
  734. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  735. /* Delay after an RCC peripheral clock enabling */ \
  736. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  737. UNUSED(tmpreg); \
  738. } while(0)
  739. #define __HAL_RCC_PWR_CLK_ENABLE() do { \
  740. __IO uint32_t tmpreg = 0x00U; \
  741. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
  742. /* Delay after an RCC peripheral clock enabling */ \
  743. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
  744. UNUSED(tmpreg); \
  745. } while(0)
  746. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  747. __IO uint32_t tmpreg = 0x00U; \
  748. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  749. /* Delay after an RCC peripheral clock enabling */ \
  750. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  751. UNUSED(tmpreg); \
  752. } while(0)
  753. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  754. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  755. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  756. #define __HAL_RCC_TIM5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM5EN))
  757. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  758. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  759. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  760. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  761. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  762. #define __HAL_RCC_WWDG_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_WWDGEN))
  763. #define __HAL_RCC_SPI2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI2EN))
  764. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  765. #define __HAL_RCC_USART2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART2EN))
  766. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  767. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  768. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  769. #define __HAL_RCC_I2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C1EN))
  770. #define __HAL_RCC_I2C2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN))
  771. #define __HAL_RCC_I2C3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C3EN))
  772. #define __HAL_RCC_PWR_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN))
  773. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  774. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  775. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  776. /**
  777. * @}
  778. */
  779. /** @defgroup RCC_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  780. * @brief Get the enable or disable status of the APB1 peripheral clock.
  781. * @note After reset, the peripheral clock (used for registers read/write access)
  782. * is disabled and the application software has to enable this clock before
  783. * using it.
  784. * @{
  785. */
  786. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM2EN))!= RESET)
  787. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM3EN))!= RESET)
  788. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM4EN))!= RESET)
  789. #define __HAL_RCC_TIM5_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM5EN))!= RESET)
  790. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM6EN))!= RESET)
  791. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM7EN))!= RESET)
  792. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM12EN))!= RESET)
  793. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM13EN))!= RESET)
  794. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM14EN))!= RESET)
  795. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_WWDGEN))!= RESET)
  796. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_SPI2EN))!= RESET)
  797. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_SPI3EN))!= RESET)
  798. #define __HAL_RCC_USART2_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_USART2EN))!= RESET)
  799. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_USART3EN))!= RESET)
  800. #define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_UART4EN))!= RESET)
  801. #define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_UART5EN))!= RESET)
  802. #define __HAL_RCC_I2C1_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_I2C1EN))!= RESET)
  803. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_I2C2EN))!= RESET)
  804. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_I2C3EN))!= RESET)
  805. #define __HAL_RCC_PWR_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_PWREN))!= RESET)
  806. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_CAN1EN))!= RESET)
  807. #define __HAL_RCC_CAN2_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_CAN2EN))!= RESET)
  808. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR &(RCC_APB1ENR_DACEN))!= RESET)
  809. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM2EN))== RESET)
  810. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM3EN))== RESET)
  811. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM4EN))== RESET)
  812. #define __HAL_RCC_TIM5_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM5EN))== RESET)
  813. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM6EN))== RESET)
  814. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM7EN))== RESET)
  815. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM12EN))== RESET)
  816. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM13EN))== RESET)
  817. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_TIM14EN))== RESET)
  818. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_WWDGEN))== RESET)
  819. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_SPI2EN))== RESET)
  820. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_SPI3EN))== RESET)
  821. #define __HAL_RCC_USART2_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_USART2EN))== RESET)
  822. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_USART3EN))== RESET)
  823. #define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_UART4EN))== RESET)
  824. #define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_UART5EN))== RESET)
  825. #define __HAL_RCC_I2C1_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_I2C1EN))== RESET)
  826. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_I2C2EN))== RESET)
  827. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_I2C3EN))== RESET)
  828. #define __HAL_RCC_PWR_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_PWREN))== RESET)
  829. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_CAN1EN))== RESET)
  830. #define __HAL_RCC_CAN2_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_CAN2EN))== RESET)
  831. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR &(RCC_APB1ENR_DACEN))== RESET)
  832. /**
  833. * @}
  834. */
  835. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  836. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  837. * @note After reset, the peripheral clock (used for registers read/write access)
  838. * is disabled and the application software has to enable this clock before
  839. * using it.
  840. * @{
  841. */
  842. #define __HAL_RCC_TIM1_CLK_ENABLE() do { \
  843. __IO uint32_t tmpreg = 0x00U; \
  844. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
  845. /* Delay after an RCC peripheral clock enabling */ \
  846. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
  847. UNUSED(tmpreg); \
  848. } while(0)
  849. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  850. __IO uint32_t tmpreg = 0x00U; \
  851. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  852. /* Delay after an RCC peripheral clock enabling */ \
  853. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  854. UNUSED(tmpreg); \
  855. } while(0)
  856. #define __HAL_RCC_USART1_CLK_ENABLE() do { \
  857. __IO uint32_t tmpreg = 0x00U; \
  858. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
  859. /* Delay after an RCC peripheral clock enabling */ \
  860. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
  861. UNUSED(tmpreg); \
  862. } while(0)
  863. #define __HAL_RCC_USART6_CLK_ENABLE() do { \
  864. __IO uint32_t tmpreg = 0x00U; \
  865. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
  866. /* Delay after an RCC peripheral clock enabling */ \
  867. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
  868. UNUSED(tmpreg); \
  869. } while(0)
  870. #define __HAL_RCC_ADC1_CLK_ENABLE() do { \
  871. __IO uint32_t tmpreg = 0x00U; \
  872. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
  873. /* Delay after an RCC peripheral clock enabling */ \
  874. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
  875. UNUSED(tmpreg); \
  876. } while(0)
  877. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  878. __IO uint32_t tmpreg = 0x00U; \
  879. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  880. /* Delay after an RCC peripheral clock enabling */ \
  881. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  882. UNUSED(tmpreg); \
  883. } while(0)
  884. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  885. __IO uint32_t tmpreg = 0x00U; \
  886. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  887. /* Delay after an RCC peripheral clock enabling */ \
  888. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  889. UNUSED(tmpreg); \
  890. } while(0)
  891. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  892. __IO uint32_t tmpreg = 0x00U; \
  893. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  894. /* Delay after an RCC peripheral clock enabling */ \
  895. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDIOEN);\
  896. UNUSED(tmpreg); \
  897. } while(0)
  898. #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
  899. __IO uint32_t tmpreg = 0x00U; \
  900. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
  901. /* Delay after an RCC peripheral clock enabling */ \
  902. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
  903. UNUSED(tmpreg); \
  904. } while(0)
  905. #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
  906. __IO uint32_t tmpreg = 0x00U; \
  907. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
  908. /* Delay after an RCC peripheral clock enabling */ \
  909. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
  910. UNUSED(tmpreg); \
  911. } while(0)
  912. #define __HAL_RCC_TIM9_CLK_ENABLE() do { \
  913. __IO uint32_t tmpreg = 0x00U; \
  914. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
  915. /* Delay after an RCC peripheral clock enabling */ \
  916. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
  917. UNUSED(tmpreg); \
  918. } while(0)
  919. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  920. __IO uint32_t tmpreg = 0x00U; \
  921. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  922. /* Delay after an RCC peripheral clock enabling */ \
  923. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  924. UNUSED(tmpreg); \
  925. } while(0)
  926. #define __HAL_RCC_TIM11_CLK_ENABLE() do { \
  927. __IO uint32_t tmpreg = 0x00U; \
  928. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
  929. /* Delay after an RCC peripheral clock enabling */ \
  930. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
  931. UNUSED(tmpreg); \
  932. } while(0)
  933. #define __HAL_RCC_TIM1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM1EN))
  934. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  935. #define __HAL_RCC_USART1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
  936. #define __HAL_RCC_USART6_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART6EN))
  937. #define __HAL_RCC_ADC1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC1EN))
  938. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  939. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  940. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SDIOEN))
  941. #define __HAL_RCC_SPI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI1EN))
  942. #define __HAL_RCC_SYSCFG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SYSCFGEN))
  943. #define __HAL_RCC_TIM9_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM9EN))
  944. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  945. #define __HAL_RCC_TIM11_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM11EN))
  946. /**
  947. * @}
  948. */
  949. /** @defgroup RCC_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  950. * @brief Get the enable or disable status of the APB2 peripheral clock.
  951. * @note After reset, the peripheral clock (used for registers read/write access)
  952. * is disabled and the application software has to enable this clock before
  953. * using it.
  954. * @{
  955. */
  956. #define __HAL_RCC_TIM1_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM1EN))!= RESET)
  957. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM8EN))!= RESET)
  958. #define __HAL_RCC_USART1_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_USART1EN))!= RESET)
  959. #define __HAL_RCC_USART6_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_USART6EN))!= RESET)
  960. #define __HAL_RCC_ADC1_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_ADC1EN))!= RESET)
  961. #define __HAL_RCC_ADC2_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_ADC2EN))!= RESET)
  962. #define __HAL_RCC_ADC3_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_ADC3EN))!= RESET)
  963. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_SDIOEN))!= RESET)
  964. #define __HAL_RCC_SPI1_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_SPI1EN))!= RESET)
  965. #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_SYSCFGEN))!= RESET)
  966. #define __HAL_RCC_TIM9_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM9EN))!= RESET)
  967. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM10EN))!= RESET)
  968. #define __HAL_RCC_TIM11_IS_CLK_ENABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM11EN))!= RESET)
  969. #define __HAL_RCC_TIM1_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM1EN))== RESET)
  970. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM8EN))== RESET)
  971. #define __HAL_RCC_USART1_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_USART1EN))== RESET)
  972. #define __HAL_RCC_USART6_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_USART6EN))== RESET)
  973. #define __HAL_RCC_ADC1_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_ADC1EN))== RESET)
  974. #define __HAL_RCC_ADC2_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_ADC2EN))== RESET)
  975. #define __HAL_RCC_ADC3_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_ADC3EN))== RESET)
  976. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_SDIOEN))== RESET)
  977. #define __HAL_RCC_SPI1_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_SPI1EN))== RESET)
  978. #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_SYSCFGEN))== RESET)
  979. #define __HAL_RCC_TIM9_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM9EN))== RESET)
  980. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM10EN))== RESET)
  981. #define __HAL_RCC_TIM11_IS_CLK_DISABLED() ((RCC->APB2ENR &(RCC_APB2ENR_TIM11EN))== RESET)
  982. /**
  983. * @}
  984. */
  985. /** @defgroup RCC_AHB1_Force_Release_Reset AHB1 Force Release Reset
  986. * @brief Force or release AHB1 peripheral reset.
  987. * @{
  988. */
  989. #define __HAL_RCC_AHB1_FORCE_RESET() (RCC->AHB1RSTR = 0xFFFFFFFFU)
  990. #define __HAL_RCC_GPIOA_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOARST))
  991. #define __HAL_RCC_GPIOB_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOBRST))
  992. #define __HAL_RCC_GPIOC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOCRST))
  993. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIODRST))
  994. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOERST))
  995. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  996. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  997. #define __HAL_RCC_GPIOH_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOHRST))
  998. #define __HAL_RCC_GPIOI_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOIRST))
  999. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_CRCRST))
  1000. #define __HAL_RCC_DMA1_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA1RST))
  1001. #define __HAL_RCC_DMA2_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA2RST))
  1002. #define __HAL_RCC_USB_OTG_HS_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHRST))
  1003. #define __HAL_RCC_OTGHSULPI_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHSULPIRST))
  1004. #define __HAL_RCC_AHB1_RELEASE_RESET() (RCC->AHB1RSTR = 0x00U)
  1005. #define __HAL_RCC_GPIOA_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOARST))
  1006. #define __HAL_RCC_GPIOB_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOBRST))
  1007. #define __HAL_RCC_GPIOC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOCRST))
  1008. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST))
  1009. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOERST))
  1010. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  1011. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  1012. #define __HAL_RCC_GPIOH_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOHRST))
  1013. #define __HAL_RCC_GPIOI_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOIRST))
  1014. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_CRCRST))
  1015. #define __HAL_RCC_DMA1_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA1RST))
  1016. #define __HAL_RCC_DMA2_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA2RST))
  1017. #define __HAL_RCC_USB_OTG_HS_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHRST))
  1018. #define __HAL_RCC_OTGHSULPI_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHSULPIRST))
  1019. /**
  1020. * @}
  1021. */
  1022. /** @defgroup RCC_AHB2_Force_Release_Reset AHB2 Force Release Reset
  1023. * @brief Force or release AHB2 peripheral reset.
  1024. * @{
  1025. */
  1026. #define __HAL_RCC_AHB2_FORCE_RESET() (RCC->AHB2RSTR = 0xFFFFFFFFU)
  1027. #define __HAL_RCC_RNG_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_RNGRST))
  1028. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_OTGFSRST))
  1029. #define __HAL_RCC_AHB2_RELEASE_RESET() (RCC->AHB2RSTR = 0x00U)
  1030. #define __HAL_RCC_RNG_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_RNGRST))
  1031. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_OTGFSRST))
  1032. /**
  1033. * @}
  1034. */
  1035. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Force Release Reset
  1036. * @brief Force or release APB1 peripheral reset.
  1037. * @{
  1038. */
  1039. #define __HAL_RCC_APB1_FORCE_RESET() (RCC->APB1RSTR = 0xFFFFFFFFU)
  1040. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  1041. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  1042. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  1043. #define __HAL_RCC_TIM5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM5RST))
  1044. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  1045. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  1046. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  1047. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  1048. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  1049. #define __HAL_RCC_WWDG_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
  1050. #define __HAL_RCC_SPI2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
  1051. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  1052. #define __HAL_RCC_USART2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
  1053. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  1054. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  1055. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  1056. #define __HAL_RCC_I2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
  1057. #define __HAL_RCC_I2C2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
  1058. #define __HAL_RCC_I2C3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C3RST))
  1059. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  1060. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  1061. #define __HAL_RCC_PWR_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
  1062. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  1063. #define __HAL_RCC_APB1_RELEASE_RESET() (RCC->APB1RSTR = 0x00U)
  1064. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  1065. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  1066. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  1067. #define __HAL_RCC_TIM5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM5RST))
  1068. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  1069. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  1070. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  1071. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  1072. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  1073. #define __HAL_RCC_WWDG_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
  1074. #define __HAL_RCC_SPI2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI2RST))
  1075. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  1076. #define __HAL_RCC_USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
  1077. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  1078. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  1079. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  1080. #define __HAL_RCC_I2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C1RST))
  1081. #define __HAL_RCC_I2C2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C2RST))
  1082. #define __HAL_RCC_I2C3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C3RST))
  1083. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  1084. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  1085. #define __HAL_RCC_PWR_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_PWRRST))
  1086. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  1087. /**
  1088. * @}
  1089. */
  1090. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Force Release Reset
  1091. * @brief Force or release APB2 peripheral reset.
  1092. * @{
  1093. */
  1094. #define __HAL_RCC_APB2_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFFU)
  1095. #define __HAL_RCC_TIM1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM1RST))
  1096. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  1097. #define __HAL_RCC_USART1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
  1098. #define __HAL_RCC_USART6_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART6RST))
  1099. #define __HAL_RCC_ADC_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_ADCRST))
  1100. #define __HAL_RCC_SDIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SDIORST))
  1101. #define __HAL_RCC_SPI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
  1102. #define __HAL_RCC_SYSCFG_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SYSCFGRST))
  1103. #define __HAL_RCC_TIM9_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM9RST))
  1104. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  1105. #define __HAL_RCC_TIM11_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM11RST))
  1106. #define __HAL_RCC_APB2_RELEASE_RESET() (RCC->APB2RSTR = 0x00U)
  1107. #define __HAL_RCC_TIM1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM1RST))
  1108. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  1109. #define __HAL_RCC_USART1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART1RST))
  1110. #define __HAL_RCC_USART6_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART6RST))
  1111. #define __HAL_RCC_ADC_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_ADCRST))
  1112. #define __HAL_RCC_SDIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SDIORST))
  1113. #define __HAL_RCC_SPI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI1RST))
  1114. #define __HAL_RCC_SYSCFG_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SYSCFGRST))
  1115. #define __HAL_RCC_TIM9_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM9RST))
  1116. #define __HAL_RCC_TIM10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  1117. #define __HAL_RCC_TIM11_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM11RST))
  1118. /**
  1119. * @}
  1120. */
  1121. /** @defgroup RCC_AHB3_Force_Release_Reset AHB3 Force Release Reset
  1122. * @brief Force or release AHB3 peripheral reset.
  1123. * @{
  1124. */
  1125. #define __HAL_RCC_AHB3_FORCE_RESET() (RCC->AHB3RSTR = 0xFFFFFFFFU)
  1126. #define __HAL_RCC_FSMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FSMCRST))
  1127. #define __HAL_RCC_AHB3_RELEASE_RESET() (RCC->AHB3RSTR = 0x00U)
  1128. #define __HAL_RCC_FSMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FSMCRST))
  1129. /**
  1130. * @}
  1131. */
  1132. /** @defgroup RCC_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
  1133. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  1134. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1135. * power consumption.
  1136. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  1137. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1138. * @{
  1139. */
  1140. #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOALPEN))
  1141. #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOBLPEN))
  1142. #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOCLPEN))
  1143. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIODLPEN))
  1144. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOELPEN))
  1145. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  1146. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  1147. #define __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOHLPEN))
  1148. #define __HAL_RCC_GPIOI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOILPEN))
  1149. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_CRCLPEN))
  1150. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_FLITFLPEN))
  1151. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM1LPEN))
  1152. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  1153. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_BKPSRAMLPEN))
  1154. #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA1LPEN))
  1155. #define __HAL_RCC_DMA2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA2LPEN))
  1156. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSLPEN))
  1157. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSULPILPEN))
  1158. #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOALPEN))
  1159. #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOBLPEN))
  1160. #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOCLPEN))
  1161. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIODLPEN))
  1162. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOELPEN))
  1163. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  1164. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  1165. #define __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOHLPEN))
  1166. #define __HAL_RCC_GPIOI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOILPEN))
  1167. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_CRCLPEN))
  1168. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_FLITFLPEN))
  1169. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM1LPEN))
  1170. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  1171. #define __HAL_RCC_BKPSRAM_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_BKPSRAMLPEN))
  1172. #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA1LPEN))
  1173. #define __HAL_RCC_DMA2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA2LPEN))
  1174. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSLPEN))
  1175. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSULPILPEN))
  1176. /**
  1177. * @}
  1178. */
  1179. /** @defgroup RCC_AHB2_LowPower_Enable_Disable AHB2 Peripheral Low Power Enable Disable
  1180. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  1181. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1182. * power consumption.
  1183. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  1184. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1185. * @{
  1186. */
  1187. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_OTGFSLPEN))
  1188. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_RNGLPEN))
  1189. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_OTGFSLPEN))
  1190. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_RNGLPEN))
  1191. /**
  1192. * @}
  1193. */
  1194. /** @defgroup RCC_AHB3_LowPower_Enable_Disable AHB3 Peripheral Low Power Enable Disable
  1195. * @brief Enables or disables the AHB3 peripheral clock during Low Power (Sleep) mode.
  1196. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1197. * power consumption.
  1198. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1199. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1200. * @{
  1201. */
  1202. #define __HAL_RCC_FSMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FSMCLPEN))
  1203. #define __HAL_RCC_FSMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FSMCLPEN))
  1204. /**
  1205. * @}
  1206. */
  1207. /** @defgroup RCC_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
  1208. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  1209. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1210. * power consumption.
  1211. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  1212. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1213. * @{
  1214. */
  1215. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  1216. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  1217. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  1218. #define __HAL_RCC_TIM5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM5LPEN))
  1219. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  1220. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  1221. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  1222. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  1223. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  1224. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_WWDGLPEN))
  1225. #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI2LPEN))
  1226. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
  1227. #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART2LPEN))
  1228. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  1229. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  1230. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  1231. #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C1LPEN))
  1232. #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C2LPEN))
  1233. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C3LPEN))
  1234. #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_PWRLPEN))
  1235. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  1236. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  1237. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  1238. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  1239. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  1240. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  1241. #define __HAL_RCC_TIM5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM5LPEN))
  1242. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  1243. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  1244. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  1245. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  1246. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  1247. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_WWDGLPEN))
  1248. #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI2LPEN))
  1249. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
  1250. #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART2LPEN))
  1251. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  1252. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  1253. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  1254. #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C1LPEN))
  1255. #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C2LPEN))
  1256. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C3LPEN))
  1257. #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_PWRLPEN))
  1258. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  1259. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  1260. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  1261. /**
  1262. * @}
  1263. */
  1264. /** @defgroup RCC_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
  1265. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1266. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1267. * power consumption.
  1268. * @note After wake-up from SLEEP mode, the peripheral clock is enabled again.
  1269. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1270. * @{
  1271. */
  1272. #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM1LPEN))
  1273. #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_USART1LPEN))
  1274. #define __HAL_RCC_USART6_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_USART6LPEN))
  1275. #define __HAL_RCC_ADC1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC1LPEN))
  1276. #define __HAL_RCC_SDIO_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SDIOLPEN))
  1277. #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI1LPEN))
  1278. #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SYSCFGLPEN))
  1279. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  1280. #define __HAL_RCC_TIM9_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM9LPEN))
  1281. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  1282. #define __HAL_RCC_TIM11_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM11LPEN))
  1283. #define __HAL_RCC_ADC2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC2LPEN))
  1284. #define __HAL_RCC_ADC3_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC3LPEN))
  1285. #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM1LPEN))
  1286. #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_USART1LPEN))
  1287. #define __HAL_RCC_USART6_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_USART6LPEN))
  1288. #define __HAL_RCC_ADC1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC1LPEN))
  1289. #define __HAL_RCC_SDIO_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SDIOLPEN))
  1290. #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI1LPEN))
  1291. #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SYSCFGLPEN))
  1292. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  1293. #define __HAL_RCC_TIM9_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM9LPEN))
  1294. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  1295. #define __HAL_RCC_TIM11_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM11LPEN))
  1296. #define __HAL_RCC_ADC2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC2LPEN))
  1297. #define __HAL_RCC_ADC3_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC3LPEN))
  1298. /**
  1299. * @}
  1300. */
  1301. /** @defgroup RCC_HSI_Configuration HSI Configuration
  1302. * @{
  1303. */
  1304. /** @brief Macros to enable or disable the Internal High Speed oscillator (HSI).
  1305. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  1306. * It is used (enabled by hardware) as system clock source after startup
  1307. * from Reset, wake-up from STOP and STANDBY mode, or in case of failure
  1308. * of the HSE used directly or indirectly as system clock (if the Clock
  1309. * Security System CSS is enabled).
  1310. * @note HSI can not be stopped if it is used as system clock source. In this case,
  1311. * you have to select another source of the system clock then stop the HSI.
  1312. * @note After enabling the HSI, the application software should wait on HSIRDY
  1313. * flag to be set indicating that HSI clock is stable and can be used as
  1314. * system clock source.
  1315. * This parameter can be: ENABLE or DISABLE.
  1316. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  1317. * clock cycles.
  1318. */
  1319. #define __HAL_RCC_HSI_ENABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = ENABLE)
  1320. #define __HAL_RCC_HSI_DISABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = DISABLE)
  1321. /** @brief Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
  1322. * @note The calibration is used to compensate for the variations in voltage
  1323. * and temperature that influence the frequency of the internal HSI RC.
  1324. * @param __HSICalibrationValue__ specifies the calibration trimming value.
  1325. * (default is RCC_HSICALIBRATION_DEFAULT).
  1326. * This parameter must be a number between 0 and 0x1F.
  1327. */
  1328. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICalibrationValue__) (MODIFY_REG(RCC->CR,\
  1329. RCC_CR_HSITRIM, (uint32_t)(__HSICalibrationValue__) << POSITION_VAL(RCC_CR_HSITRIM)))
  1330. /**
  1331. * @}
  1332. */
  1333. /** @defgroup RCC_LSI_Configuration LSI Configuration
  1334. * @{
  1335. */
  1336. /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
  1337. * @note After enabling the LSI, the application software should wait on
  1338. * LSIRDY flag to be set indicating that LSI clock is stable and can
  1339. * be used to clock the IWDG and/or the RTC.
  1340. * @note LSI can not be disabled if the IWDG is running.
  1341. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  1342. * clock cycles.
  1343. */
  1344. #define __HAL_RCC_LSI_ENABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = ENABLE)
  1345. #define __HAL_RCC_LSI_DISABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = DISABLE)
  1346. /**
  1347. * @}
  1348. */
  1349. /** @defgroup RCC_HSE_Configuration HSE Configuration
  1350. * @{
  1351. */
  1352. /**
  1353. * @brief Macro to configure the External High Speed oscillator (HSE).
  1354. * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not supported by this macro.
  1355. * User should request a transition to HSE Off first and then HSE On or HSE Bypass.
  1356. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  1357. * software should wait on HSERDY flag to be set indicating that HSE clock
  1358. * is stable and can be used to clock the PLL and/or system clock.
  1359. * @note HSE state can not be changed if it is used directly or through the
  1360. * PLL as system clock. In this case, you have to select another source
  1361. * of the system clock then change the HSE state (ex. disable it).
  1362. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  1363. * @note This function reset the CSSON bit, so if the clock security system(CSS)
  1364. * was previously enabled you have to enable it again after calling this
  1365. * function.
  1366. * @param __STATE__ specifies the new state of the HSE.
  1367. * This parameter can be one of the following values:
  1368. * @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after
  1369. * 6 HSE oscillator clock cycles.
  1370. * @arg RCC_HSE_ON: turn ON the HSE oscillator.
  1371. * @arg RCC_HSE_BYPASS: HSE oscillator bypassed with external clock.
  1372. */
  1373. #define __HAL_RCC_HSE_CONFIG(__STATE__) (*(__IO uint8_t *) RCC_CR_BYTE2_ADDRESS = (__STATE__))
  1374. /**
  1375. * @}
  1376. */
  1377. /** @defgroup RCC_LSE_Configuration LSE Configuration
  1378. * @{
  1379. */
  1380. /**
  1381. * @brief Macro to configure the External Low Speed oscillator (LSE).
  1382. * @note Transition LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro.
  1383. * User should request a transition to LSE Off first and then LSE On or LSE Bypass.
  1384. * @note As the LSE is in the Backup domain and write access is denied to
  1385. * this domain after reset, you have to enable write access using
  1386. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  1387. * (to be done once after reset).
  1388. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  1389. * software should wait on LSERDY flag to be set indicating that LSE clock
  1390. * is stable and can be used to clock the RTC.
  1391. * @param __STATE__ specifies the new state of the LSE.
  1392. * This parameter can be one of the following values:
  1393. * @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after
  1394. * 6 LSE oscillator clock cycles.
  1395. * @arg RCC_LSE_ON: turn ON the LSE oscillator.
  1396. * @arg RCC_LSE_BYPASS: LSE oscillator bypassed with external clock.
  1397. */
  1398. #define __HAL_RCC_LSE_CONFIG(__STATE__) (*(__IO uint8_t *) RCC_BDCR_BYTE0_ADDRESS = (__STATE__))
  1399. /**
  1400. * @}
  1401. */
  1402. /** @defgroup RCC_Internal_RTC_Clock_Configuration RTC Clock Configuration
  1403. * @{
  1404. */
  1405. /** @brief Macros to enable or disable the RTC clock.
  1406. * @note These macros must be used only after the RTC clock source was selected.
  1407. */
  1408. #define __HAL_RCC_RTC_ENABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = ENABLE)
  1409. #define __HAL_RCC_RTC_DISABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = DISABLE)
  1410. /** @brief Macros to configure the RTC clock (RTCCLK).
  1411. * @note As the RTC clock configuration bits are in the Backup domain and write
  1412. * access is denied to this domain after reset, you have to enable write
  1413. * access using the Power Backup Access macro before to configure
  1414. * the RTC clock source (to be done once after reset).
  1415. * @note Once the RTC clock is configured it can't be changed unless the
  1416. * Backup domain is reset using __HAL_RCC_BackupReset_RELEASE() macro, or by
  1417. * a Power On Reset (POR).
  1418. * @param __RTCCLKSource__ specifies the RTC clock source.
  1419. * This parameter can be one of the following values:
  1420. * @arg RCC_RTCCLKSOURCE_LSE: LSE selected as RTC clock.
  1421. * @arg RCC_RTCCLKSOURCE_LSI: LSI selected as RTC clock.
  1422. * @arg RCC_RTCCLKSOURCE_HSE_DIVx: HSE clock divided by x selected
  1423. * as RTC clock, where x:[2,31]
  1424. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  1425. * work in STOP and STANDBY modes, and can be used as wake-up source.
  1426. * However, when the HSE clock is used as RTC clock source, the RTC
  1427. * cannot be used in STOP and STANDBY modes.
  1428. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  1429. * RTC clock source).
  1430. */
  1431. #define __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__) (((__RTCCLKSource__) & RCC_BDCR_RTCSEL) == RCC_BDCR_RTCSEL) ? \
  1432. MODIFY_REG(RCC->CFGR, RCC_CFGR_RTCPRE, ((__RTCCLKSource__) & 0xFFFFCFFU)) : CLEAR_BIT(RCC->CFGR, RCC_CFGR_RTCPRE)
  1433. #define __HAL_RCC_RTC_CONFIG(__RTCCLKSource__) do { __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__); \
  1434. RCC->BDCR |= ((__RTCCLKSource__) & 0x00000FFFU); \
  1435. } while (0)
  1436. /** @brief Macros to force or release the Backup domain reset.
  1437. * @note This function resets the RTC peripheral (including the backup registers)
  1438. * and the RTC clock source selection in RCC_CSR register.
  1439. * @note The BKPSRAM is not affected by this reset.
  1440. */
  1441. #define __HAL_RCC_BACKUPRESET_FORCE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = ENABLE)
  1442. #define __HAL_RCC_BACKUPRESET_RELEASE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = DISABLE)
  1443. /**
  1444. * @}
  1445. */
  1446. /** @defgroup RCC_PLL_Configuration PLL Configuration
  1447. * @{
  1448. */
  1449. /** @brief Macros to enable or disable the main PLL.
  1450. * @note After enabling the main PLL, the application software should wait on
  1451. * PLLRDY flag to be set indicating that PLL clock is stable and can
  1452. * be used as system clock source.
  1453. * @note The main PLL can not be disabled if it is used as system clock source
  1454. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  1455. */
  1456. #define __HAL_RCC_PLL_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
  1457. #define __HAL_RCC_PLL_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = DISABLE)
  1458. /** @brief Macro to configure the main PLL clock source, multiplication and division factors.
  1459. * @note This function must be used only when the main PLL is disabled.
  1460. * @param __RCC_PLLSource__ specifies the PLL entry clock source.
  1461. * This parameter can be one of the following values:
  1462. * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
  1463. * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
  1464. * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.
  1465. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  1466. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  1467. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  1468. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  1469. * of 2 MHz to limit PLL jitter.
  1470. * @param __PLLN__ specifies the multiplication factor for PLL VCO output clock
  1471. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1472. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  1473. * output frequency is between 192 and 432 MHz.
  1474. *
  1475. * @param __PLLP__ specifies the division factor for main system clock (SYSCLK)
  1476. * This parameter must be a number in the range {2, 4, 6, or 8}.
  1477. *
  1478. * @param __PLLQ__ specifies the division factor for OTG FS, SDIO and RNG clocks
  1479. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  1480. * @note If the USB OTG FS is used in your application, you have to set the
  1481. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  1482. * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work
  1483. * correctly.
  1484. *
  1485. */
  1486. #define __HAL_RCC_PLL_CONFIG(__RCC_PLLSource__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__) \
  1487. (RCC->PLLCFGR = (0x20000000U | (__RCC_PLLSource__) | (__PLLM__)| \
  1488. ((__PLLN__) << POSITION_VAL(RCC_PLLCFGR_PLLN)) | \
  1489. ((((__PLLP__) >> 1U) -1U) << POSITION_VAL(RCC_PLLCFGR_PLLP)) | \
  1490. ((__PLLQ__) << POSITION_VAL(RCC_PLLCFGR_PLLQ))))
  1491. /**
  1492. * @}
  1493. */
  1494. /** @brief Macro to configure the PLL clock source.
  1495. * @note This function must be used only when the main PLL is disabled.
  1496. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  1497. * This parameter can be one of the following values:
  1498. * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
  1499. * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
  1500. *
  1501. */
  1502. #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
  1503. /** @brief Macro to configure the PLL multiplication factor.
  1504. * @note This function must be used only when the main PLL is disabled.
  1505. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  1506. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  1507. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  1508. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  1509. * of 2 MHz to limit PLL jitter.
  1510. *
  1511. */
  1512. #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, (__PLLM__))
  1513. /** @defgroup RCC_PLL_I2S_Configuration PLL I2S Configuration
  1514. * @{
  1515. */
  1516. /** @brief Macros to enable or disable the PLLI2S.
  1517. * @note The PLLI2S is disabled by hardware when entering STOP and STANDBY modes.
  1518. */
  1519. #define __HAL_RCC_PLLI2S_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLI2SON_BB = ENABLE)
  1520. #define __HAL_RCC_PLLI2S_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLI2SON_BB = DISABLE)
  1521. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  1522. * @note This macro must be used only when the PLLI2S is disabled.
  1523. * @note PLLI2S clock source is common with the main PLL (configured in
  1524. * HAL_RCC_ClockConfig() API).
  1525. * @param __PLLI2SN__ specifies the multiplication factor for PLLI2S VCO output clock
  1526. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1527. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  1528. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  1529. * @param __PLLI2SR__ specifies the division factor for I2S clock
  1530. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  1531. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  1532. * on the I2S clock frequency.
  1533. */
  1534. #define __HAL_RCC_PLLI2S_CONFIG(__PLLI2SN__, __PLLI2SR__) (RCC->PLLI2SCFGR = ((__PLLI2SN__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SN)) | ((__PLLI2SR__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SR)))
  1535. /** @brief Macro to configure the I2S clock source (I2SCLK).
  1536. * @note This function must be called before enabling the I2S APB clock.
  1537. * @param __SOURCE__ specifies the I2S clock source.
  1538. * This parameter can be one of the following values:
  1539. * @arg RCC_I2SCLKSOURCE_PLLI2S: PLLI2S clock used as I2S clock source.
  1540. * @arg RCC_I2SCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin
  1541. * used as I2S clock source.
  1542. */
  1543. #define __HAL_RCC_I2S_CONFIG(__SOURCE__) (*(__IO uint32_t *) RCC_CFGR_I2SSRC_BB = (__SOURCE__))
  1544. /**
  1545. * @}
  1546. */
  1547. /** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
  1548. * @{
  1549. */
  1550. /** @brief Macro to configure the MCO1 clock.
  1551. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  1552. * This parameter can be one of the following values:
  1553. * @arg RCC_MCO1SOURCE_HSI: HSI clock selected as MCO1 source
  1554. * @arg RCC_MCO1SOURCE_LSE: LSE clock selected as MCO1 source
  1555. * @arg RCC_MCO1SOURCE_HSE: HSE clock selected as MCO1 source
  1556. * @arg RCC_MCO1SOURCE_PLLCLK: main PLL clock selected as MCO1 source
  1557. * @param __MCODIV__ specifies the MCO clock prescaler.
  1558. * This parameter can be one of the following values:
  1559. * @arg RCC_MCODIV_1: no division applied to MCOx clock
  1560. * @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
  1561. * @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
  1562. * @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
  1563. * @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
  1564. */
  1565. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  1566. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO1 | RCC_CFGR_MCO1PRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  1567. /** @brief Macro to configure the MCO2 clock.
  1568. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  1569. * This parameter can be one of the following values:
  1570. * @arg RCC_MCO2SOURCE_SYSCLK: System clock (SYSCLK) selected as MCO2 source
  1571. * @arg RCC_MCO2SOURCE_PLLI2SCLK: PLLI2S clock selected as MCO2 source
  1572. * @arg RCC_MCO2SOURCE_HSE: HSE clock selected as MCO2 source
  1573. * @arg RCC_MCO2SOURCE_PLLCLK: main PLL clock selected as MCO2 source
  1574. * @param __MCODIV__ specifies the MCO clock prescaler.
  1575. * This parameter can be one of the following values:
  1576. * @arg RCC_MCODIV_1: no division applied to MCOx clock
  1577. * @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
  1578. * @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
  1579. * @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
  1580. * @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
  1581. */
  1582. #define __HAL_RCC_MCO2_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  1583. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO2 | RCC_CFGR_MCO2PRE), ((__MCOCLKSOURCE__) | ((__MCODIV__) << 3U)));
  1584. /**
  1585. * @}
  1586. */
  1587. /** @defgroup RCC_Get_Clock_source Get Clock source
  1588. * @{
  1589. */
  1590. /**
  1591. * @brief Macro to configure the system clock source.
  1592. * @param __RCC_SYSCLKSOURCE__ specifies the system clock source.
  1593. * This parameter can be one of the following values:
  1594. * - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
  1595. * - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
  1596. * - RCC_SYSCLKSOURCE_PLLCLK: PLL output is used as system clock source.
  1597. */
  1598. #define __HAL_RCC_SYSCLK_CONFIG(__RCC_SYSCLKSOURCE__) MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__RCC_SYSCLKSOURCE__))
  1599. /** @brief Macro to get the clock source used as system clock.
  1600. * @retval The clock source used as system clock. The returned value can be one
  1601. * of the following:
  1602. * - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
  1603. * - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
  1604. * - RCC_SYSCLKSOURCE_STATUS_PLLCLK: PLL used as system clock.
  1605. */
  1606. #define __HAL_RCC_GET_SYSCLK_SOURCE() (RCC->CFGR & RCC_CFGR_SWS)
  1607. /** @brief Macro to get the oscillator used as PLL clock source.
  1608. * @retval The oscillator used as PLL clock source. The returned value can be one
  1609. * of the following:
  1610. * - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source.
  1611. * - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source.
  1612. */
  1613. #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC))
  1614. /**
  1615. * @}
  1616. */
  1617. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  1618. * @brief macros to manage the specified RCC Flags and interrupts.
  1619. * @{
  1620. */
  1621. /** @brief Enable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to enable
  1622. * the selected interrupts).
  1623. * @param __INTERRUPT__ specifies the RCC interrupt sources to be enabled.
  1624. * This parameter can be any combination of the following values:
  1625. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  1626. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  1627. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  1628. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  1629. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  1630. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  1631. */
  1632. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS |= (__INTERRUPT__))
  1633. /** @brief Disable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to disable
  1634. * the selected interrupts).
  1635. * @param __INTERRUPT__ specifies the RCC interrupt sources to be disabled.
  1636. * This parameter can be any combination of the following values:
  1637. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  1638. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  1639. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  1640. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  1641. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  1642. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  1643. */
  1644. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS &= (uint8_t)(~(__INTERRUPT__)))
  1645. /** @brief Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CIR[23:16]
  1646. * bits to clear the selected interrupt pending bits.
  1647. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  1648. * This parameter can be any combination of the following values:
  1649. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  1650. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  1651. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  1652. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  1653. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  1654. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  1655. * @arg RCC_IT_CSS: Clock Security System interrupt
  1656. */
  1657. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE2_ADDRESS = (__INTERRUPT__))
  1658. /** @brief Check the RCC's interrupt has occurred or not.
  1659. * @param __INTERRUPT__ specifies the RCC interrupt source to check.
  1660. * This parameter can be one of the following values:
  1661. * @arg RCC_IT_LSIRDY: LSI ready interrupt.
  1662. * @arg RCC_IT_LSERDY: LSE ready interrupt.
  1663. * @arg RCC_IT_HSIRDY: HSI ready interrupt.
  1664. * @arg RCC_IT_HSERDY: HSE ready interrupt.
  1665. * @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
  1666. * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
  1667. * @arg RCC_IT_CSS: Clock Security System interrupt
  1668. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  1669. */
  1670. #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIR & (__INTERRUPT__)) == (__INTERRUPT__))
  1671. /** @brief Set RMVF bit to clear the reset flags: RCC_FLAG_PINRST, RCC_FLAG_PORRST,
  1672. * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
  1673. */
  1674. #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
  1675. /** @brief Check RCC flag is set or not.
  1676. * @param __FLAG__ specifies the flag to check.
  1677. * This parameter can be one of the following values:
  1678. * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready.
  1679. * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready.
  1680. * @arg RCC_FLAG_PLLRDY: Main PLL clock ready.
  1681. * @arg RCC_FLAG_PLLI2SRDY: PLLI2S clock ready.
  1682. * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready.
  1683. * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready.
  1684. * @arg RCC_FLAG_BORRST: POR/PDR or BOR reset.
  1685. * @arg RCC_FLAG_PINRST: Pin reset.
  1686. * @arg RCC_FLAG_PORRST: POR/PDR reset.
  1687. * @arg RCC_FLAG_SFTRST: Software reset.
  1688. * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset.
  1689. * @arg RCC_FLAG_WWDGRST: Window Watchdog reset.
  1690. * @arg RCC_FLAG_LPWRRST: Low Power reset.
  1691. * @retval The new state of __FLAG__ (TRUE or FALSE).
  1692. */
  1693. #define RCC_FLAG_MASK ((uint8_t)0x1FU)
  1694. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U)? RCC->CR :((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR :((((__FLAG__) >> 5U) == 3U)? RCC->CSR :RCC->CIR))) & ((uint32_t)1U << ((__FLAG__) & RCC_FLAG_MASK)))!= 0U)? 1U : 0U)
  1695. #define RCC_GET_PLL_OSCSOURCE() ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> POSITION_VAL(RCC_PLLCFGR_PLLSRC))
  1696. /**
  1697. * @}
  1698. */
  1699. /**
  1700. * @}
  1701. */
  1702. /* Include RCC HAL Extended module */
  1703. #include "stm32f2xx_hal_rcc_ex.h"
  1704. /* Exported functions --------------------------------------------------------*/
  1705. /** @addtogroup RCC_Exported_Functions
  1706. * @{
  1707. */
  1708. /** @addtogroup RCC_Exported_Functions_Group1
  1709. * @{
  1710. */
  1711. /* Initialization and de-initialization functions ******************************/
  1712. HAL_StatusTypeDef HAL_RCC_DeInit(void);
  1713. HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  1714. HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
  1715. /**
  1716. * @}
  1717. */
  1718. /** @addtogroup RCC_Exported_Functions_Group2
  1719. * @{
  1720. */
  1721. /* Peripheral Control functions ************************************************/
  1722. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  1723. void HAL_RCC_EnableCSS(void);
  1724. void HAL_RCC_DisableCSS(void);
  1725. uint32_t HAL_RCC_GetSysClockFreq(void);
  1726. uint32_t HAL_RCC_GetHCLKFreq(void);
  1727. uint32_t HAL_RCC_GetPCLK1Freq(void);
  1728. uint32_t HAL_RCC_GetPCLK2Freq(void);
  1729. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  1730. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
  1731. /* CSS NMI IRQ handler */
  1732. void HAL_RCC_NMI_IRQHandler(void);
  1733. /* User Callbacks in non blocking mode (IT mode) */
  1734. void HAL_RCC_CSSCallback(void);
  1735. /**
  1736. * @}
  1737. */
  1738. /**
  1739. * @}
  1740. */
  1741. /* Private types -------------------------------------------------------------*/
  1742. /* Private variables ---------------------------------------------------------*/
  1743. /* Private constants ---------------------------------------------------------*/
  1744. /** @defgroup RCC_Private_Constants RCC Private Constants
  1745. * @{
  1746. */
  1747. /** @defgroup RCC_BitAddress_AliasRegion RCC BitAddress AliasRegion
  1748. * @brief RCC registers bit address in the alias region
  1749. * @{
  1750. */
  1751. #define RCC_OFFSET (RCC_BASE - PERIPH_BASE)
  1752. /* --- CR Register ---*/
  1753. /* Alias word address of HSION bit */
  1754. #define RCC_CR_OFFSET (RCC_OFFSET + 0x00U)
  1755. #define RCC_HSION_BIT_NUMBER 0x00U
  1756. #define RCC_CR_HSION_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_HSION_BIT_NUMBER * 4U))
  1757. /* Alias word address of CSSON bit */
  1758. #define RCC_CSSON_BIT_NUMBER 0x13U
  1759. #define RCC_CR_CSSON_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_CSSON_BIT_NUMBER * 4U))
  1760. /* Alias word address of PLLON bit */
  1761. #define RCC_PLLON_BIT_NUMBER 0x18U
  1762. #define RCC_CR_PLLON_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_PLLON_BIT_NUMBER * 4U))
  1763. /* Alias word address of PLLI2SON bit */
  1764. #define RCC_PLLI2SON_BIT_NUMBER 0x1AU
  1765. #define RCC_CR_PLLI2SON_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_PLLI2SON_BIT_NUMBER * 4U))
  1766. /* --- CFGR Register ---*/
  1767. /* Alias word address of I2SSRC bit */
  1768. #define RCC_CFGR_OFFSET (RCC_OFFSET + 0x08U)
  1769. #define RCC_I2SSRC_BIT_NUMBER 0x17U
  1770. #define RCC_CFGR_I2SSRC_BB (PERIPH_BB_BASE + (RCC_CFGR_OFFSET * 32U) + (RCC_I2SSRC_BIT_NUMBER * 4U))
  1771. /* --- BDCR Register ---*/
  1772. /* Alias word address of RTCEN bit */
  1773. #define RCC_BDCR_OFFSET (RCC_OFFSET + 0x70U)
  1774. #define RCC_RTCEN_BIT_NUMBER 0x0FU
  1775. #define RCC_BDCR_RTCEN_BB (PERIPH_BB_BASE + (RCC_BDCR_OFFSET * 32U) + (RCC_RTCEN_BIT_NUMBER * 4U))
  1776. /* Alias word address of BDRST bit */
  1777. #define RCC_BDRST_BIT_NUMBER 0x10U
  1778. #define RCC_BDCR_BDRST_BB (PERIPH_BB_BASE + (RCC_BDCR_OFFSET * 32U) + (RCC_BDRST_BIT_NUMBER * 4U))
  1779. /* --- CSR Register ---*/
  1780. /* Alias word address of LSION bit */
  1781. #define RCC_CSR_OFFSET (RCC_OFFSET + 0x74U)
  1782. #define RCC_LSION_BIT_NUMBER 0x00U
  1783. #define RCC_CSR_LSION_BB (PERIPH_BB_BASE + (RCC_CSR_OFFSET * 32U) + (RCC_LSION_BIT_NUMBER * 4U))
  1784. /* CR register byte 3 (Bits[23:16]) base address */
  1785. #define RCC_CR_BYTE2_ADDRESS 0x40023802U
  1786. /* CIR register byte 2 (Bits[15:8]) base address */
  1787. #define RCC_CIR_BYTE1_ADDRESS ((uint32_t)(RCC_BASE + 0x0CU + 0x01U))
  1788. /* CIR register byte 3 (Bits[23:16]) base address */
  1789. #define RCC_CIR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + 0x0CU + 0x02U))
  1790. /* BDCR register base address */
  1791. #define RCC_BDCR_BYTE0_ADDRESS (PERIPH_BASE + RCC_BDCR_OFFSET)
  1792. #define RCC_DBP_TIMEOUT_VALUE 2U
  1793. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
  1794. #define HSE_TIMEOUT_VALUE HSE_STARTUP_TIMEOUT
  1795. #define HSI_TIMEOUT_VALUE 2U /* 2 ms */
  1796. #define LSI_TIMEOUT_VALUE 2U /* 2 ms */
  1797. #define PLLI2S_TIMEOUT_VALUE 2U /* Timeout value fixed to 100 ms */
  1798. /**
  1799. * @}
  1800. */
  1801. /**
  1802. * @}
  1803. */
  1804. /* Private macros ------------------------------------------------------------*/
  1805. /** @defgroup RCC_Private_Macros RCC Private Macros
  1806. * @{
  1807. */
  1808. /** @defgroup RCC_IS_RCC_Definitions RCC Private macros to check input parameters
  1809. * @{
  1810. */
  1811. #define IS_RCC_OSCILLATORTYPE(OSCILLATOR) ((OSCILLATOR) <= 15U)
  1812. #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \
  1813. ((HSE) == RCC_HSE_BYPASS))
  1814. #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
  1815. ((LSE) == RCC_LSE_BYPASS))
  1816. #define IS_RCC_HSI(HSI) (((HSI) == RCC_HSI_OFF) || ((HSI) == RCC_HSI_ON))
  1817. #define IS_RCC_LSI(LSI) (((LSI) == RCC_LSI_OFF) || ((LSI) == RCC_LSI_ON))
  1818. #define IS_RCC_PLL(PLL) (((PLL) == RCC_PLL_NONE) ||((PLL) == RCC_PLL_OFF) || ((PLL) == RCC_PLL_ON))
  1819. #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
  1820. ((SOURCE) == RCC_PLLSOURCE_HSE))
  1821. #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
  1822. ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
  1823. ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK))
  1824. #define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
  1825. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
  1826. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV2) || \
  1827. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV3) || \
  1828. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV4) || \
  1829. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV5) || \
  1830. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV6) || \
  1831. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV7) || \
  1832. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV8) || \
  1833. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV9) || \
  1834. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV10) || \
  1835. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV11) || \
  1836. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV12) || \
  1837. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV13) || \
  1838. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV14) || \
  1839. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV15) || \
  1840. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV16) || \
  1841. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV17) || \
  1842. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV18) || \
  1843. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV19) || \
  1844. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV20) || \
  1845. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV21) || \
  1846. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV22) || \
  1847. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV23) || \
  1848. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV24) || \
  1849. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV25) || \
  1850. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV26) || \
  1851. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV27) || \
  1852. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV28) || \
  1853. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV29) || \
  1854. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV30) || \
  1855. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV31))
  1856. #define IS_RCC_PLLM_VALUE(VALUE) ((VALUE) <= 63U)
  1857. #define IS_RCC_PLLN_VALUE(VALUE) ((192U <= (VALUE)) && ((VALUE) <= 432U))
  1858. #define IS_RCC_PLLP_VALUE(VALUE) (((VALUE) == 2U) || ((VALUE) == 4U) || ((VALUE) == 6U) || ((VALUE) == 8U))
  1859. #define IS_RCC_PLLQ_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 15U))
  1860. #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_DIV1) || ((HCLK) == RCC_SYSCLK_DIV2) || \
  1861. ((HCLK) == RCC_SYSCLK_DIV4) || ((HCLK) == RCC_SYSCLK_DIV8) || \
  1862. ((HCLK) == RCC_SYSCLK_DIV16) || ((HCLK) == RCC_SYSCLK_DIV64) || \
  1863. ((HCLK) == RCC_SYSCLK_DIV128) || ((HCLK) == RCC_SYSCLK_DIV256) || \
  1864. ((HCLK) == RCC_SYSCLK_DIV512))
  1865. #define IS_RCC_CLOCKTYPE(CLK) ((1U <= (CLK)) && ((CLK) <= 15U))
  1866. #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_DIV1) || ((PCLK) == RCC_HCLK_DIV2) || \
  1867. ((PCLK) == RCC_HCLK_DIV4) || ((PCLK) == RCC_HCLK_DIV8) || \
  1868. ((PCLK) == RCC_HCLK_DIV16))
  1869. #define IS_RCC_MCO(MCOx) (((MCOx) == RCC_MCO1) || ((MCOx) == RCC_MCO2))
  1870. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_HSI) || ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
  1871. ((SOURCE) == RCC_MCO1SOURCE_HSE) || ((SOURCE) == RCC_MCO1SOURCE_PLLCLK))
  1872. #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2SOURCE_SYSCLK) || ((SOURCE) == RCC_MCO2SOURCE_PLLI2SCLK)|| \
  1873. ((SOURCE) == RCC_MCO2SOURCE_HSE) || ((SOURCE) == RCC_MCO2SOURCE_PLLCLK))
  1874. #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1) || ((DIV) == RCC_MCODIV_2) || \
  1875. ((DIV) == RCC_MCODIV_3) || ((DIV) == RCC_MCODIV_4) || \
  1876. ((DIV) == RCC_MCODIV_5))
  1877. #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1FU)
  1878. /**
  1879. * @}
  1880. */
  1881. /**
  1882. * @}
  1883. */
  1884. /**
  1885. * @}
  1886. */
  1887. /**
  1888. * @}
  1889. */
  1890. #ifdef __cplusplus
  1891. }
  1892. #endif
  1893. #endif /* __STM32F2xx_HAL_RCC_H */
  1894. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/