stm32f2xx_hal_rcc.h 116 KB

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