stm32g0xx_hal_rcc.h 177 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169
  1. /**
  2. ******************************************************************************
  3. * @file stm32g0xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2018 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file in
  13. * the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. ******************************************************************************
  16. */
  17. /* Define to prevent recursive inclusion -------------------------------------*/
  18. #ifndef STM32G0xx_HAL_RCC_H
  19. #define STM32G0xx_HAL_RCC_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32g0xx_hal_def.h"
  25. #include "stm32g0xx_ll_rcc.h"
  26. /** @addtogroup STM32G0xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup RCC
  30. * @{
  31. */
  32. /* Private constants ---------------------------------------------------------*/
  33. /** @addtogroup RCC_Private_Constants
  34. * @{
  35. */
  36. /* Defines used for Flags */
  37. #define CR_REG_INDEX 1U
  38. #define BDCR_REG_INDEX 2U
  39. #define CSR_REG_INDEX 3U
  40. #if defined(RCC_HSI48_SUPPORT)
  41. #define CRRCR_REG_INDEX 4U
  42. #endif /* RCC_HSI48_SUPPORT */
  43. #define RCC_FLAG_MASK 0x1FU
  44. /* Define used for IS_RCC_CLOCKTYPE() */
  45. #define RCC_CLOCKTYPE_ALL (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1) /*!< All clocktype to configure */
  46. /**
  47. * @}
  48. */
  49. /* Private macros ------------------------------------------------------------*/
  50. /** @addtogroup RCC_Private_Macros
  51. * @{
  52. */
  53. #if defined(RCC_HSI48_SUPPORT)
  54. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) \
  55. (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  56. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  57. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  58. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI48) == RCC_OSCILLATORTYPE_HSI48) || \
  59. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  60. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
  61. #else
  62. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) \
  63. (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  64. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  65. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  66. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  67. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
  68. #endif /* RCC_HSI48_SUPPORT */
  69. #define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
  70. ((__HSE__) == RCC_HSE_BYPASS))
  71. #define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
  72. ((__LSE__) == RCC_LSE_BYPASS))
  73. #define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
  74. #if defined(RCC_HSI48_SUPPORT)
  75. #define IS_RCC_HSI48(__HSI48__) (((__HSI48__) == RCC_HSI48_OFF) || ((__HSI48__) == RCC_HSI48_ON))
  76. #endif /* RCC_HSI48_SUPPORT */
  77. #define IS_RCC_HSI_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= (uint32_t)127U)
  78. #define IS_RCC_HSIDIV(__DIV__) (((__DIV__) == RCC_HSI_DIV1) || ((__DIV__) == RCC_HSI_DIV2) || \
  79. ((__DIV__) == RCC_HSI_DIV4) || ((__DIV__) == RCC_HSI_DIV8) || \
  80. ((__DIV__) == RCC_HSI_DIV16) || ((__DIV__) == RCC_HSI_DIV32)|| \
  81. ((__DIV__) == RCC_HSI_DIV64) || ((__DIV__) == RCC_HSI_DIV128))
  82. #define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
  83. #define IS_RCC_PLL(__PLL__) (((__PLL__) == RCC_PLL_NONE) ||((__PLL__) == RCC_PLL_OFF) || \
  84. ((__PLL__) == RCC_PLL_ON))
  85. #define IS_RCC_PLLSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLSOURCE_NONE) || \
  86. ((__SOURCE__) == RCC_PLLSOURCE_HSI) || \
  87. ((__SOURCE__) == RCC_PLLSOURCE_HSE))
  88. #define IS_RCC_PLLM_VALUE(__VALUE__) (((__VALUE__) == RCC_PLLM_DIV1) || ((__VALUE__) == RCC_PLLM_DIV2) || \
  89. ((__VALUE__) == RCC_PLLM_DIV3) || ((__VALUE__) == RCC_PLLM_DIV4) || \
  90. ((__VALUE__) == RCC_PLLM_DIV5) || ((__VALUE__) == RCC_PLLM_DIV6) || \
  91. ((__VALUE__) == RCC_PLLM_DIV7) || ((__VALUE__) == RCC_PLLM_DIV8))
  92. #define IS_RCC_PLLN_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 86U))
  93. #define IS_RCC_PLLP_VALUE(__VALUE__) ((RCC_PLLP_DIV2 <= (__VALUE__)) && ((__VALUE__) <= RCC_PLLP_DIV32))
  94. #if defined(RCC_PLLQ_SUPPORT)
  95. #define IS_RCC_PLLQ_VALUE(__VALUE__) ((RCC_PLLQ_DIV2 <= (__VALUE__)) && ((__VALUE__) <= RCC_PLLQ_DIV8))
  96. #endif /* RCC_PLLQ_SUPPORT */
  97. #define IS_RCC_PLLR_VALUE(__VALUE__) ((RCC_PLLR_DIV2 <= (__VALUE__)) && ((__VALUE__) <= RCC_PLLR_DIV8))
  98. #define IS_RCC_CLOCKTYPE(__CLK__) ((((__CLK__)\
  99. & RCC_CLOCKTYPE_ALL) != 0x00UL) && (((__CLK__) & ~RCC_CLOCKTYPE_ALL) == 0x00UL))
  100. #define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
  101. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
  102. ((__SOURCE__) == RCC_SYSCLKSOURCE_LSE) || \
  103. ((__SOURCE__) == RCC_SYSCLKSOURCE_LSI) || \
  104. ((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
  105. #define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
  106. ((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
  107. ((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
  108. ((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
  109. ((__HCLK__) == RCC_SYSCLK_DIV512))
  110. #define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
  111. ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
  112. ((__PCLK__) == RCC_HCLK_DIV16))
  113. #define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_NONE) || \
  114. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
  115. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
  116. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV32))
  117. #if defined(RCC_MCO2_SUPPORT)
  118. #define IS_RCC_MCO(__MCOX__) ( ((__MCOX__) == RCC_MCO_PA8) || \
  119. ((__MCOX__) == RCC_MCO_PA9) || \
  120. ((__MCOX__) == RCC_MCO_PD10) || \
  121. ((__MCOX__) == RCC_MCO_PF2) || \
  122. ((__MCOX__) == RCC_MCO_PA10) || \
  123. ((__MCOX__) == RCC_MCO_PA15) || \
  124. ((__MCOX__) == RCC_MCO_PB2) || \
  125. ((__MCOX__) == RCC_MCO_PD7))
  126. #else
  127. #define IS_RCC_MCO(__MCOX__) ( ((__MCOX__) == RCC_MCO_PA8) || \
  128. ((__MCOX__) == RCC_MCO_PA9) || \
  129. ((__MCOX__) == RCC_MCO_PD10) || \
  130. ((__MCOX__) == RCC_MCO_PF2))
  131. #endif /* RCC_MCO2_SUPPORT */
  132. #if defined(STM32G0C1xx) || defined(STM32G0B1xx)
  133. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
  134. ((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
  135. ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
  136. ((__SOURCE__) == RCC_MCO1SOURCE_HSI48) || \
  137. ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
  138. ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
  139. ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
  140. ((__SOURCE__) == RCC_MCO1SOURCE_LSE) || \
  141. ((__SOURCE__) == RCC_MCO1SOURCE_PLLPCLK) || \
  142. ((__SOURCE__) == RCC_MCO1SOURCE_PLLQCLK) || \
  143. ((__SOURCE__) == RCC_MCO1SOURCE_RTCCLK) || \
  144. ((__SOURCE__) == RCC_MCO1SOURCE_RTC_WKUP))
  145. #elif defined(STM32G0B0xx)
  146. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
  147. ((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
  148. ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
  149. ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
  150. ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
  151. ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
  152. ((__SOURCE__) == RCC_MCO1SOURCE_LSE) || \
  153. ((__SOURCE__) == RCC_MCO1SOURCE_PLLPCLK) || \
  154. ((__SOURCE__) == RCC_MCO1SOURCE_PLLQCLK) || \
  155. ((__SOURCE__) == RCC_MCO1SOURCE_RTCCLK) || \
  156. ((__SOURCE__) == RCC_MCO1SOURCE_RTC_WKUP))
  157. #else
  158. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
  159. ((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
  160. ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
  161. ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
  162. ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
  163. ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
  164. ((__SOURCE__) == RCC_MCO1SOURCE_LSE))
  165. #endif /* STM32G0C1xx || STM32G0B1xx */
  166. #if defined(STM32G0C1xx) || defined(STM32G0B1xx) || defined(STM32G0B0xx)
  167. #define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1) || ((__DIV__) == RCC_MCODIV_2) || \
  168. ((__DIV__) == RCC_MCODIV_4) || ((__DIV__) == RCC_MCODIV_8) || \
  169. ((__DIV__) == RCC_MCODIV_16) || ((__DIV__) == RCC_MCODIV_32) || \
  170. ((__DIV__) == RCC_MCODIV_64) || ((__DIV__) == RCC_MCODIV_128) || \
  171. ((__DIV__) == RCC_MCODIV_256)|| ((__DIV__) == RCC_MCODIV_512) || \
  172. ((__DIV__) == RCC_MCODIV_1024))
  173. #else
  174. #define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1) || ((__DIV__) == RCC_MCODIV_2) || \
  175. ((__DIV__) == RCC_MCODIV_4) || ((__DIV__) == RCC_MCODIV_8) || \
  176. ((__DIV__) == RCC_MCODIV_16) || ((__DIV__) == RCC_MCODIV_32) || \
  177. ((__DIV__) == RCC_MCODIV_64) || ((__DIV__) == RCC_MCODIV_128))
  178. #endif /* STM32G0C1xx || STM32G0B1xx || STM32G0B0xx */
  179. #if defined(RCC_MCO2_SUPPORT)
  180. #if defined(RCC_HSI48_SUPPORT)
  181. #define IS_RCC_MCO2SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO2SOURCE_NOCLOCK) || \
  182. ((__SOURCE__) == RCC_MCO2SOURCE_SYSCLK) || \
  183. ((__SOURCE__) == RCC_MCO2SOURCE_HSI48) || \
  184. ((__SOURCE__) == RCC_MCO2SOURCE_HSI) || \
  185. ((__SOURCE__) == RCC_MCO2SOURCE_HSE) || \
  186. ((__SOURCE__) == RCC_MCO2SOURCE_PLLCLK) || \
  187. ((__SOURCE__) == RCC_MCO2SOURCE_LSI) || \
  188. ((__SOURCE__) == RCC_MCO2SOURCE_LSE) || \
  189. ((__SOURCE__) == RCC_MCO2SOURCE_PLLPCLK) || \
  190. ((__SOURCE__) == RCC_MCO2SOURCE_PLLQCLK) || \
  191. ((__SOURCE__) == RCC_MCO2SOURCE_RTCCLK) || \
  192. ((__SOURCE__) == RCC_MCO2SOURCE_RTC_WKUP))
  193. #else
  194. #define IS_RCC_MCO2SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO2SOURCE_NOCLOCK) || \
  195. ((__SOURCE__) == RCC_MCO2SOURCE_SYSCLK) || \
  196. ((__SOURCE__) == RCC_MCO2SOURCE_HSI) || \
  197. ((__SOURCE__) == RCC_MCO2SOURCE_HSE) || \
  198. ((__SOURCE__) == RCC_MCO2SOURCE_PLLCLK) || \
  199. ((__SOURCE__) == RCC_MCO2SOURCE_LSI) || \
  200. ((__SOURCE__) == RCC_MCO2SOURCE_LSE) || \
  201. ((__SOURCE__) == RCC_MCO2SOURCE_PLLPCLK) || \
  202. ((__SOURCE__) == RCC_MCO2SOURCE_PLLQCLK) || \
  203. ((__SOURCE__) == RCC_MCO2SOURCE_RTCCLK) || \
  204. ((__SOURCE__) == RCC_MCO2SOURCE_RTC_WKUP))
  205. #endif /* RCC_HSI48_SUPPORT */
  206. #define IS_RCC_MCO2DIV(__DIV__) (((__DIV__) == RCC_MCO2DIV_1) || ((__DIV__) == RCC_MCO2DIV_2) || \
  207. ((__DIV__) == RCC_MCO2DIV_4) || ((__DIV__) == RCC_MCO2DIV_8) || \
  208. ((__DIV__) == RCC_MCO2DIV_16) || ((__DIV__) == RCC_MCO2DIV_32) || \
  209. ((__DIV__) == RCC_MCO2DIV_64) || ((__DIV__) == RCC_MCO2DIV_128)|| \
  210. ((__DIV__) == RCC_MCO2DIV_256)|| ((__DIV__) == RCC_MCO2DIV_512)|| \
  211. ((__DIV__) == RCC_MCO2DIV_1024))
  212. #endif /* RCC_MCO2_SUPPORT */
  213. #define IS_RCC_LSE_DRIVE(__DRIVE__) (((__DRIVE__) == RCC_LSEDRIVE_LOW) || \
  214. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMLOW) || \
  215. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMHIGH) || \
  216. ((__DRIVE__) == RCC_LSEDRIVE_HIGH))
  217. /**
  218. * @}
  219. */
  220. /* Exported types ------------------------------------------------------------*/
  221. /** @defgroup RCC_Exported_Types RCC Exported Types
  222. * @{
  223. */
  224. /**
  225. * @brief RCC PLL configuration structure definition
  226. */
  227. typedef struct
  228. {
  229. uint32_t PLLState; /*!< The new state of the PLL.
  230. This parameter can be a value of @ref RCC_PLL_Config */
  231. uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
  232. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  233. uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock.
  234. This parameter must be a value of @ref RCC_PLLM_Clock_Divider */
  235. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock.
  236. This parameter must be a number between Min_Data = 8 and Max_Data = 86 */
  237. uint32_t PLLP; /*!< PLLP: PLL Division factor.
  238. User have to set the PLLQ parameter correctly to not exceed max frequency 64MHZ.
  239. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  240. #if defined(RCC_PLLQ_SUPPORT)
  241. uint32_t PLLQ; /*!< PLLQ: PLL Division factor.
  242. User have to set the PLLQ parameter correctly to not exceed max frequency 64MHZ.
  243. This parameter must be a value of @ref RCC_PLLQ_Clock_Divider */
  244. #endif /* RCC_PLLQ_SUPPORT */
  245. uint32_t PLLR; /*!< PLLR: PLL Division for the main system clock.
  246. User have to set the PLLR parameter correctly to not exceed max frequency 64MHZ.
  247. This parameter must be a value of @ref RCC_PLLR_Clock_Divider */
  248. } RCC_PLLInitTypeDef;
  249. /**
  250. * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
  251. */
  252. typedef struct
  253. {
  254. uint32_t OscillatorType; /*!< The oscillators to be configured.
  255. This parameter can be a value of @ref RCC_Oscillator_Type */
  256. uint32_t HSEState; /*!< The new state of the HSE.
  257. This parameter can be a value of @ref RCC_HSE_Config */
  258. uint32_t LSEState; /*!< The new state of the LSE.
  259. This parameter can be a value of @ref RCC_LSE_Config */
  260. uint32_t HSIState; /*!< The new state of the HSI.
  261. This parameter can be a value of @ref RCC_HSI_Config */
  262. uint32_t HSIDiv; /*!< The division factor of the HSI16.
  263. This parameter can be a value of @ref RCC_HSI_Div */
  264. uint32_t HSICalibrationValue; /*!< The calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  265. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
  266. uint32_t LSIState; /*!< The new state of the LSI.
  267. This parameter can be a value of @ref RCC_LSI_Config */
  268. #if defined(RCC_HSI48_SUPPORT)
  269. uint32_t HSI48State; /*!< The new state of the HSI48 (only applicable to STM32G0C1xx/STM32G0B1xx/STM32G0B0xx devices).
  270. This parameter can be a value of @ref RCC_HSI48_Config */
  271. #endif /* RCC_HSI48_SUPPORT */
  272. RCC_PLLInitTypeDef PLL; /*!< Main PLL structure parameters */
  273. } RCC_OscInitTypeDef;
  274. /**
  275. * @brief RCC System, AHB and APB buses clock configuration structure definition
  276. */
  277. typedef struct
  278. {
  279. uint32_t ClockType; /*!< The clock to be configured.
  280. This parameter can be a combination of @ref RCC_System_Clock_Type */
  281. uint32_t SYSCLKSource; /*!< The clock source used as system clock (SYSCLK).
  282. This parameter can be a value of @ref RCC_System_Clock_Source */
  283. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  284. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  285. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  286. This parameter can be a value of @ref RCC_APB1_Clock_Source */
  287. } RCC_ClkInitTypeDef;
  288. /**
  289. * @}
  290. */
  291. /* Exported constants --------------------------------------------------------*/
  292. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  293. * @{
  294. */
  295. /** @defgroup RCC_Timeout_Value Timeout Values
  296. * @{
  297. */
  298. #define RCC_DBP_TIMEOUT_VALUE 2U /* 2 ms (minimum Tick + 1) */
  299. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT /* LSE timeout in ms */
  300. /**
  301. * @}
  302. */
  303. /** @defgroup RCC_Oscillator_Type Oscillator Type
  304. * @{
  305. */
  306. #define RCC_OSCILLATORTYPE_NONE 0x00000000U /*!< Oscillator configuration unchanged */
  307. #define RCC_OSCILLATORTYPE_HSE 0x00000001U /*!< HSE to configure */
  308. #define RCC_OSCILLATORTYPE_HSI 0x00000002U /*!< HSI to configure */
  309. #define RCC_OSCILLATORTYPE_LSE 0x00000004U /*!< LSE to configure */
  310. #define RCC_OSCILLATORTYPE_LSI 0x00000008U /*!< LSI to configure */
  311. #if defined(RCC_HSI48_SUPPORT)
  312. #define RCC_OSCILLATORTYPE_HSI48 0x00000020U /*!< HSI48 to configure */
  313. #endif /* RCC_HSI48_SUPPORT */
  314. /**
  315. * @}
  316. */
  317. /** @defgroup RCC_HSE_Config HSE Config
  318. * @{
  319. */
  320. #define RCC_HSE_OFF 0x00000000U /*!< HSE clock deactivation */
  321. #define RCC_HSE_ON RCC_CR_HSEON /*!< HSE clock activation */
  322. #define RCC_HSE_BYPASS (RCC_CR_HSEBYP | RCC_CR_HSEON) /*!< External clock source for HSE clock */
  323. /**
  324. * @}
  325. */
  326. /** @defgroup RCC_LSE_Config LSE Config
  327. * @{
  328. */
  329. #define RCC_LSE_OFF 0x00000000U /*!< LSE clock deactivation */
  330. #define RCC_LSE_ON RCC_BDCR_LSEON /*!< LSE clock activation */
  331. #define RCC_LSE_BYPASS (RCC_BDCR_LSEBYP | RCC_BDCR_LSEON) /*!< External clock source for LSE clock */
  332. /**
  333. * @}
  334. */
  335. /** @defgroup RCC_HSI_Config HSI Config
  336. * @{
  337. */
  338. #define RCC_HSI_OFF 0x00000000U /*!< HSI clock deactivation */
  339. #define RCC_HSI_ON RCC_CR_HSION /*!< HSI clock activation */
  340. #define RCC_HSICALIBRATION_DEFAULT 64U /*!< Default HSI calibration trimming value */
  341. /**
  342. * @}
  343. */
  344. /** @defgroup RCC_HSI_Div HSI Div
  345. * @{
  346. */
  347. #define RCC_HSI_DIV1 0x00000000U /*!< HSI clock is not divided */
  348. #define RCC_HSI_DIV2 RCC_CR_HSIDIV_0 /*!< HSI clock is divided by 2 */
  349. #define RCC_HSI_DIV4 RCC_CR_HSIDIV_1 /*!< HSI clock is divided by 4 */
  350. #define RCC_HSI_DIV8 (RCC_CR_HSIDIV_1|RCC_CR_HSIDIV_0) /*!< HSI clock is divided by 8 */
  351. #define RCC_HSI_DIV16 RCC_CR_HSIDIV_2 /*!< HSI clock is divided by 16 */
  352. #define RCC_HSI_DIV32 (RCC_CR_HSIDIV_2|RCC_CR_HSIDIV_0) /*!< HSI clock is divided by 32 */
  353. #define RCC_HSI_DIV64 (RCC_CR_HSIDIV_2|RCC_CR_HSIDIV_1) /*!< HSI clock is divided by 64 */
  354. #define RCC_HSI_DIV128 (RCC_CR_HSIDIV_2|RCC_CR_HSIDIV_1|RCC_CR_HSIDIV_0) /*!< HSI clock is divided by 128 */
  355. /**
  356. * @}
  357. */
  358. /** @defgroup RCC_LSI_Config LSI Config
  359. * @{
  360. */
  361. #define RCC_LSI_OFF 0x00000000U /*!< LSI clock deactivation */
  362. #define RCC_LSI_ON RCC_CSR_LSION /*!< LSI clock activation */
  363. /**
  364. * @}
  365. */
  366. #if defined(RCC_HSI48_SUPPORT)
  367. /** @defgroup RCC_HSI48_Config HSI48 Config
  368. * @{
  369. */
  370. #define RCC_HSI48_OFF 0x00000000U /*!< HSI48 clock deactivation */
  371. #define RCC_HSI48_ON RCC_CR_HSI48ON /*!< HSI48 clock activation */
  372. /**
  373. * @}
  374. */
  375. #endif /* RCC_HSI48_SUPPORT */
  376. /** @defgroup RCC_PLL_Config PLL Config
  377. * @{
  378. */
  379. #define RCC_PLL_NONE 0x00000000U /*!< PLL configuration unchanged */
  380. #define RCC_PLL_OFF 0x00000001U /*!< PLL deactivation */
  381. #define RCC_PLL_ON 0x00000002U /*!< PLL activation */
  382. /**
  383. * @}
  384. */
  385. /** @defgroup RCC_PLLM_Clock_Divider PLLM Clock Divider
  386. * @{
  387. */
  388. #define RCC_PLLM_DIV1 0x00000000U /*!< PLLM division factor = 8 */
  389. #define RCC_PLLM_DIV2 RCC_PLLCFGR_PLLM_0 /*!< PLLM division factor = 2 */
  390. #define RCC_PLLM_DIV3 RCC_PLLCFGR_PLLM_1 /*!< PLLM division factor = 3 */
  391. #define RCC_PLLM_DIV4 (RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLLM division factor = 4 */
  392. #define RCC_PLLM_DIV5 RCC_PLLCFGR_PLLM_2 /*!< PLLM division factor = 5 */
  393. #define RCC_PLLM_DIV6 (RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLLM division factor = 6 */
  394. #define RCC_PLLM_DIV7 (RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLLM division factor = 7 */
  395. #define RCC_PLLM_DIV8 (RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1| RCC_PLLCFGR_PLLM_0) /*!< PLLM division factor = 8 */
  396. /**
  397. * @}
  398. */
  399. /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
  400. * @{
  401. */
  402. #define RCC_PLLP_DIV2 RCC_PLLCFGR_PLLP_0 /*!< PLLP division factor = 2 */
  403. #define RCC_PLLP_DIV3 RCC_PLLCFGR_PLLP_1 /*!< PLLP division factor = 3 */
  404. #define RCC_PLLP_DIV4 (RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 4 */
  405. #define RCC_PLLP_DIV5 RCC_PLLCFGR_PLLP_2 /*!< PLLP division factor = 5 */
  406. #define RCC_PLLP_DIV6 (RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 6 */
  407. #define RCC_PLLP_DIV7 (RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1) /*!< PLLP division factor = 7 */
  408. #define RCC_PLLP_DIV8 (RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 8 */
  409. #define RCC_PLLP_DIV9 RCC_PLLCFGR_PLLP_3 /*!< PLLP division factor = 9 */
  410. #define RCC_PLLP_DIV10 (RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 10 */
  411. #define RCC_PLLP_DIV11 (RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_1) /*!< PLLP division factor = 11 */
  412. #define RCC_PLLP_DIV12 (RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 12 */
  413. #define RCC_PLLP_DIV13 (RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2) /*!< PLLP division factor = 13 */
  414. #define RCC_PLLP_DIV14 (RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 14 */
  415. #define RCC_PLLP_DIV15 (RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1) /*!< PLLP division factor = 15 */
  416. #define RCC_PLLP_DIV16 (RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 16 */
  417. #define RCC_PLLP_DIV17 RCC_PLLCFGR_PLLP_4 /*!< PLLP division factor = 17 */
  418. #define RCC_PLLP_DIV18 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 18 */
  419. #define RCC_PLLP_DIV19 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_1) /*!< PLLP division factor = 19 */
  420. #define RCC_PLLP_DIV20 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 20 */
  421. #define RCC_PLLP_DIV21 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_2) /*!< PLLP division factor = 21 */
  422. #define RCC_PLLP_DIV22 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 22 */
  423. #define RCC_PLLP_DIV23 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1) /*!< PLLP division factor = 23 */
  424. #define RCC_PLLP_DIV24 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 24 */
  425. #define RCC_PLLP_DIV25 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3) /*!< PLLP division factor = 25 */
  426. #define RCC_PLLP_DIV26 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 26 */
  427. #define RCC_PLLP_DIV27 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_1) /*!< PLLP division factor = 27 */
  428. #define RCC_PLLP_DIV28 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 28 */
  429. #define RCC_PLLP_DIV29 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2) /*!< PLLP division factor = 29 */
  430. #define RCC_PLLP_DIV30 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 30 */
  431. #define RCC_PLLP_DIV31 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1) /*!< PLLP division factor = 31 */
  432. #define RCC_PLLP_DIV32 (RCC_PLLCFGR_PLLP_4 | RCC_PLLCFGR_PLLP_3 | RCC_PLLCFGR_PLLP_2 | RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< PLLP division factor = 32 */
  433. /**
  434. * @}
  435. */
  436. #if defined(RCC_PLLQ_SUPPORT)
  437. /** @defgroup RCC_PLLQ_Clock_Divider PLLQ Clock Divider
  438. * @{
  439. */
  440. #define RCC_PLLQ_DIV2 RCC_PLLCFGR_PLLQ_0 /*!< PLLQ division factor = 2 */
  441. #define RCC_PLLQ_DIV3 RCC_PLLCFGR_PLLQ_1 /*!< PLLQ division factor = 3 */
  442. #define RCC_PLLQ_DIV4 (RCC_PLLCFGR_PLLQ_1 | RCC_PLLCFGR_PLLQ_0) /*!< PLLQ division factor = 4 */
  443. #define RCC_PLLQ_DIV5 RCC_PLLCFGR_PLLQ_2 /*!< PLLQ division factor = 5 */
  444. #define RCC_PLLQ_DIV6 (RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLQ_0) /*!< PLLQ division factor = 6 */
  445. #define RCC_PLLQ_DIV7 (RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLQ_1) /*!< PLLQ division factor = 7 */
  446. #define RCC_PLLQ_DIV8 (RCC_PLLCFGR_PLLQ_2 |RCC_PLLCFGR_PLLQ_1 | RCC_PLLCFGR_PLLQ_0) /*!< PLLQ division factor = 8 */
  447. /** * @}
  448. */
  449. #endif /* RCC_PLLQ_SUPPORT */
  450. /** @defgroup RCC_PLLR_Clock_Divider PLLR Clock Divider
  451. * @{
  452. */
  453. #define RCC_PLLR_DIV2 RCC_PLLCFGR_PLLR_0 /*!< PLLR division factor = 2 */
  454. #define RCC_PLLR_DIV3 RCC_PLLCFGR_PLLR_1 /*!< PLLR division factor = 3 */
  455. #define RCC_PLLR_DIV4 (RCC_PLLCFGR_PLLR_1 | RCC_PLLCFGR_PLLR_0) /*!< PLLR division factor = 4 */
  456. #define RCC_PLLR_DIV5 RCC_PLLCFGR_PLLR_2 /*!< PLLR division factor = 5 */
  457. #define RCC_PLLR_DIV6 (RCC_PLLCFGR_PLLR_2 | RCC_PLLCFGR_PLLR_0) /*!< PLLR division factor = 6 */
  458. #define RCC_PLLR_DIV7 (RCC_PLLCFGR_PLLR_2 | RCC_PLLCFGR_PLLR_1) /*!< PLLR division factor = 7 */
  459. #define RCC_PLLR_DIV8 (RCC_PLLCFGR_PLLR_2 | RCC_PLLCFGR_PLLR_1 | RCC_PLLCFGR_PLLR_0) /*!< PLLR division factor = 8 */
  460. /** * @}
  461. */
  462. /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
  463. * @{
  464. */
  465. #define RCC_PLLSOURCE_NONE 0x00000000U /*!< No clock selected as PLL entry clock source */
  466. #define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI /*!< HSI clock selected as PLL entry clock source */
  467. #define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */
  468. /**
  469. * @}
  470. */
  471. /** @defgroup RCC_PLL_Clock_Output PLL Clock Output
  472. * @{
  473. */
  474. #define RCC_PLLPCLK RCC_PLLCFGR_PLLPEN /*!< PLLPCLK selection from main PLL */
  475. #if defined(RCC_PLLQ_SUPPORT)
  476. #define RCC_PLLQCLK RCC_PLLCFGR_PLLQEN /*!< PLLQCLK selection from main PLL */
  477. #endif /* RCC_PLLQ_SUPPORT */
  478. #define RCC_PLLRCLK RCC_PLLCFGR_PLLREN /*!< PLLRCLK selection from main PLL */
  479. /**
  480. * @}
  481. */
  482. /** @defgroup RCC_System_Clock_Type System Clock Type
  483. * @{
  484. */
  485. #define RCC_CLOCKTYPE_SYSCLK 0x00000001U /*!< SYSCLK to configure */
  486. #define RCC_CLOCKTYPE_HCLK 0x00000002U /*!< HCLK to configure */
  487. #define RCC_CLOCKTYPE_PCLK1 0x00000004U /*!< PCLK1 to configure */
  488. /**
  489. * @}
  490. */
  491. /** @defgroup RCC_System_Clock_Source System Clock Source
  492. * @{
  493. */
  494. #define RCC_SYSCLKSOURCE_HSI 0x00000000U /*!< HSI selection as system clock */
  495. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_0 /*!< HSE selection as system clock */
  496. #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_1 /*!< PLL selection as system clock */
  497. #define RCC_SYSCLKSOURCE_LSI (RCC_CFGR_SW_1 | RCC_CFGR_SW_0) /*!< LSI selection as system clock */
  498. #define RCC_SYSCLKSOURCE_LSE RCC_CFGR_SW_2 /*!< LSE selection as system clock */
  499. /**
  500. * @}
  501. */
  502. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  503. * @{
  504. */
  505. #define RCC_SYSCLKSOURCE_STATUS_HSI 0x00000000U /*!< HSI used as system clock */
  506. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_0 /*!< HSE used as system clock */
  507. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_1 /*!< PLL used as system clock */
  508. #define RCC_SYSCLKSOURCE_STATUS_LSI (RCC_CFGR_SWS_1 | RCC_CFGR_SWS_0) /*!< LSI used as system clock */
  509. #define RCC_SYSCLKSOURCE_STATUS_LSE RCC_CFGR_SWS_2 /*!< LSE used as system clock */
  510. /**
  511. * @}
  512. */
  513. /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
  514. * @{
  515. */
  516. #define RCC_SYSCLK_DIV1 0x00000000U /*!< SYSCLK not divided */
  517. #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_3 /*!< SYSCLK divided by 2 */
  518. #define RCC_SYSCLK_DIV4 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 4 */
  519. #define RCC_SYSCLK_DIV8 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_1) /*!< SYSCLK divided by 8 */
  520. #define RCC_SYSCLK_DIV16 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_1 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 16 */
  521. #define RCC_SYSCLK_DIV64 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2) /*!< SYSCLK divided by 64 */
  522. #define RCC_SYSCLK_DIV128 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 128 */
  523. #define RCC_SYSCLK_DIV256 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_1) /*!< SYSCLK divided by 256 */
  524. #define RCC_SYSCLK_DIV512 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_1 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 512 */
  525. /**
  526. * @}
  527. */
  528. /** @defgroup RCC_APB1_Clock_Source APB Clock Source
  529. * @{
  530. */
  531. #define RCC_HCLK_DIV1 0x00000000U /*!< HCLK not divided */
  532. #define RCC_HCLK_DIV2 RCC_CFGR_PPRE_2 /*!< HCLK divided by 2 */
  533. #define RCC_HCLK_DIV4 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_0) /*!< HCLK divided by 4 */
  534. #define RCC_HCLK_DIV8 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_1) /*!< HCLK divided by 8 */
  535. #define RCC_HCLK_DIV16 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_1 | RCC_CFGR_PPRE_0) /*!< HCLK divided by 16 */
  536. /**
  537. * @}
  538. */
  539. /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
  540. * @{
  541. */
  542. #define RCC_RTCCLKSOURCE_NONE 0x00000000U /*!< No clock configured for RTC */
  543. #define RCC_RTCCLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
  544. #define RCC_RTCCLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
  545. #define RCC_RTCCLKSOURCE_HSE_DIV32 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 32 used as RTC clock */
  546. /**
  547. * @}
  548. */
  549. /** @defgroup RCC_MCO_Index MCO Index
  550. * @{
  551. */
  552. /* 32 28 20 16 0
  553. --------------------------------
  554. | MCO | GPIO | GPIO | GPIO |
  555. | Index | AF | Port | Pin |
  556. -------------------------------*/
  557. #define RCC_MCO_GPIOPORT_POS 16U
  558. #define RCC_MCO_GPIOPORT_MASK (0xFUL << RCC_MCO_GPIOPORT_POS)
  559. #define RCC_MCO_GPIOAF_POS 20U
  560. #define RCC_MCO_GPIOAF_MASK (0xFFUL << RCC_MCO_GPIOAF_POS)
  561. #define RCC_MCO_INDEX_POS 28U
  562. #define RCC_MCO_INDEX_MASK (0x1UL << RCC_MCO_INDEX_POS)
  563. #define RCC_MCO1_INDEX (0x0UL << RCC_MCO_INDEX_POS) /*!< MCO1 index */
  564. #define RCC_MCO_PA8 (RCC_MCO1_INDEX | (GPIO_AF0_MCO << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOA) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_8)
  565. #define RCC_MCO_PA9 (RCC_MCO1_INDEX | (GPIO_AF0_MCO << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOA) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_9)
  566. #define RCC_MCO_PD10 (RCC_MCO1_INDEX | (GPIO_AF0_MCO << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOD) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_10) /* Not defined for all stm32g0xx family lines */
  567. #define RCC_MCO_PF2 (RCC_MCO1_INDEX | (GPIO_AF0_MCO << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOF) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_2) /* Not defined for all stm32g0xx family lines */
  568. #define RCC_MCO1 RCC_MCO_PA8
  569. #if defined(RCC_MCO2_SUPPORT)
  570. #define RCC_MCO2_INDEX (0x1u << RCC_MCO_INDEX_POS) /*!< MCO2 index */
  571. #define RCC_MCO_PA10 (RCC_MCO2_INDEX | (GPIO_AF3_MCO2 << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOA) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_10)
  572. #define RCC_MCO_PA15 (RCC_MCO2_INDEX | (GPIO_AF3_MCO2 << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOA) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_15)
  573. #define RCC_MCO_PB2 (RCC_MCO2_INDEX | (GPIO_AF3_MCO2 << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOB) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_2)
  574. #define RCC_MCO_PD7 (RCC_MCO2_INDEX | (GPIO_AF3_MCO2 << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOD) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_7)
  575. #define RCC_MCO2 RCC_MCO_PA10
  576. #endif /* RCC_MCO2_SUPPORT */
  577. #define RCC_MCO RCC_MCO1 /*!< MCO1 to be compliant with other families with 2 MCOs*/
  578. /**
  579. * @}
  580. */
  581. /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
  582. * @{
  583. */
  584. #define RCC_MCO1SOURCE_NOCLOCK 0x00000000U /*!< MCO1 output disabled, no clock on MCO1 */
  585. #define RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCOSEL_0 /*!< SYSCLK selection as MCO1 source */
  586. #if defined(RCC_HSI48_SUPPORT)
  587. #define RCC_MCO1SOURCE_HSI48 RCC_CFGR_MCOSEL_1 /*!< HSI48 selection as MCO1 source */
  588. #endif /* RCC_HSI48_SUPPORT */
  589. #define RCC_MCO1SOURCE_HSI (RCC_CFGR_MCOSEL_0| RCC_CFGR_MCOSEL_1) /*!< HSI selection as MCO1 source */
  590. #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCOSEL_2 /*!< HSE selection as MCO1 source */
  591. #define RCC_MCO1SOURCE_PLLCLK (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_2) /*!< PLLCLK selection as MCO1 source */
  592. #define RCC_MCO1SOURCE_LSI (RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSI selection as MCO1 source */
  593. #define RCC_MCO1SOURCE_LSE (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSE selection as MCO1 source */
  594. #if defined(RCC_CFGR_MCOSEL_3)
  595. #define RCC_MCO1SOURCE_PLLPCLK RCC_CFGR_MCOSEL_3 /*!< PLLPCLK selection as MCO1 source */
  596. #define RCC_MCO1SOURCE_PLLQCLK (RCC_CFGR_MCOSEL_3|RCC_CFGR_MCOSEL_0) /*!< PLLQCLK selection as MCO1 source */
  597. #define RCC_MCO1SOURCE_RTCCLK (RCC_CFGR_MCOSEL_3|RCC_CFGR_MCOSEL_1) /*!< RTCCLK selection as MCO1 source */
  598. #define RCC_MCO1SOURCE_RTC_WKUP (RCC_CFGR_MCOSEL_3|RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_0) /*!< RTC_Wakeup selection as MCO1 source */
  599. #endif /* RCC_CFGR_MCOSEL_3 */
  600. /**
  601. * @}
  602. */
  603. /** @defgroup RCC_MCO1_Clock_Prescaler MCO1 Clock Prescaler
  604. * @{
  605. */
  606. #define RCC_MCODIV_1 0x00000000U /*!< MCO not divided */
  607. #define RCC_MCODIV_2 RCC_CFGR_MCOPRE_0 /*!< MCO divided by 2 */
  608. #define RCC_MCODIV_4 RCC_CFGR_MCOPRE_1 /*!< MCO divided by 4 */
  609. #define RCC_MCODIV_8 (RCC_CFGR_MCOPRE_1 | RCC_CFGR_MCOPRE_0) /*!< MCO divided by 8 */
  610. #define RCC_MCODIV_16 RCC_CFGR_MCOPRE_2 /*!< MCO divided by 16 */
  611. #define RCC_MCODIV_32 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_0) /*!< MCO divided by 32 */
  612. #define RCC_MCODIV_64 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_1) /*!< MCO divided by 64 */
  613. #define RCC_MCODIV_128 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_1 | RCC_CFGR_MCOPRE_0) /*!< MCO divided by 128 */
  614. #if defined(RCC_CFGR_MCOPRE_3)
  615. #define RCC_MCODIV_256 RCC_CFGR_MCOPRE_3 /*!< MCO divided by 256 */
  616. #define RCC_MCODIV_512 (RCC_CFGR_MCOPRE_3 | RCC_CFGR_MCOPRE_0) /*!< MCO divided by 512 */
  617. #define RCC_MCODIV_1024 (RCC_CFGR_MCOPRE_3 | RCC_CFGR_MCOPRE_1) /*!< MCO divided by 1024 */
  618. #endif /* RCC_CFGR_MCOSEL_3 */
  619. /**
  620. * @}
  621. */
  622. #if defined(RCC_MCO2_SUPPORT)
  623. /** @defgroup RCC_MCO2_Clock_Source MCO2 Clock Source
  624. * @{
  625. */
  626. #define RCC_MCO2SOURCE_NOCLOCK 0x00000000U /*!< MCO2 output disabled, no clock on MCO2 */
  627. #define RCC_MCO2SOURCE_SYSCLK RCC_CFGR_MCO2SEL_0 /*!< SYSCLK selection as MCO2 source */
  628. #if defined(RCC_HSI48_SUPPORT)
  629. #define RCC_MCO2SOURCE_HSI48 RCC_CFGR_MCO2SEL_1 /*!< HSI48 selection as MCO2 source */
  630. #endif /* RCC_HSI48_SUPPORT */
  631. #define RCC_MCO2SOURCE_HSI (RCC_CFGR_MCO2SEL_1| RCC_CFGR_MCO2SEL_0) /*!< HSI selection as MCO2 source */
  632. #define RCC_MCO2SOURCE_HSE RCC_CFGR_MCO2SEL_2 /*!< HSE selection as MCO2 source */
  633. #define RCC_MCO2SOURCE_PLLCLK (RCC_CFGR_MCO2SEL_2|RCC_CFGR_MCO2SEL_0) /*!< PLLCLK selection as MCO2 source */
  634. #define RCC_MCO2SOURCE_LSI (RCC_CFGR_MCO2SEL_2|RCC_CFGR_MCO2SEL_1) /*!< LSI selection as MCO2 source */
  635. #define RCC_MCO2SOURCE_LSE (RCC_CFGR_MCO2SEL_2|RCC_CFGR_MCO2SEL_1|RCC_CFGR_MCO2SEL_0) /*!< LSE selection as MCO2 source */
  636. #define RCC_MCO2SOURCE_PLLPCLK RCC_CFGR_MCO2SEL_3 /*!< PLLPCLK selection as MCO2 source */
  637. #define RCC_MCO2SOURCE_PLLQCLK (RCC_CFGR_MCO2SEL_3|RCC_CFGR_MCO2SEL_0) /*!< PLLQCLK selection as MCO2 source */
  638. #define RCC_MCO2SOURCE_RTCCLK (RCC_CFGR_MCO2SEL_3|RCC_CFGR_MCO2SEL_1) /*!< RTCCLK selection as MCO2 source */
  639. #define RCC_MCO2SOURCE_RTC_WKUP (RCC_CFGR_MCO2SEL_3|RCC_CFGR_MCO2SEL_1|RCC_CFGR_MCO2SEL_0) /*!< RTC_Wakeup selection as MCO2 source */
  640. /**
  641. * @}
  642. */
  643. /** @defgroup RCC_MCO2_Clock_Prescaler MCO2 Clock Prescaler
  644. * @{
  645. */
  646. #define RCC_MCO2DIV_1 0x00000000U /*!< MCO2 not divided */
  647. #define RCC_MCO2DIV_2 RCC_CFGR_MCO2PRE_0 /*!< MCO2 divided by 2 */
  648. #define RCC_MCO2DIV_4 RCC_CFGR_MCO2PRE_1 /*!< MCO2 divided by 4 */
  649. #define RCC_MCO2DIV_8 (RCC_CFGR_MCO2PRE_1 | RCC_CFGR_MCO2PRE_0) /*!< MCO2 divided by 8 */
  650. #define RCC_MCO2DIV_16 RCC_CFGR_MCO2PRE_2 /*!< MCO2 divided by 16 */
  651. #define RCC_MCO2DIV_32 (RCC_CFGR_MCO2PRE_2 | RCC_CFGR_MCO2PRE_0) /*!< MCO2 divided by 32 */
  652. #define RCC_MCO2DIV_64 (RCC_CFGR_MCO2PRE_2 | RCC_CFGR_MCO2PRE_1) /*!< MCO2 divided by 64 */
  653. #define RCC_MCO2DIV_128 (RCC_CFGR_MCO2PRE_2 | RCC_CFGR_MCO2PRE_1 | RCC_CFGR_MCO2PRE_0) /*!< MCO2 divided by 128 */
  654. #define RCC_MCO2DIV_256 RCC_CFGR_MCO2PRE_3 /*!< MCO2 divided by 256 */
  655. #define RCC_MCO2DIV_512 (RCC_CFGR_MCO2PRE_3 | RCC_CFGR_MCO2PRE_0) /*!< MCO2 divided by 512 */
  656. #define RCC_MCO2DIV_1024 (RCC_CFGR_MCO2PRE_3 | RCC_CFGR_MCO2PRE_1) /*!< MCO2 divided by 1024 */
  657. /**
  658. * @}
  659. */
  660. #endif /* RCC_MCO2_SUPPORT */
  661. /** @defgroup RCC_Interrupt Interrupts
  662. * @{
  663. */
  664. #define RCC_IT_LSIRDY RCC_CIFR_LSIRDYF /*!< LSI Ready Interrupt flag */
  665. #define RCC_IT_LSERDY RCC_CIFR_LSERDYF /*!< LSE Ready Interrupt flag */
  666. #define RCC_IT_HSIRDY RCC_CIFR_HSIRDYF /*!< HSI Ready Interrupt flag */
  667. #define RCC_IT_HSERDY RCC_CIFR_HSERDYF /*!< HSE Ready Interrupt flag */
  668. #define RCC_IT_PLLRDY RCC_CIFR_PLLRDYF /*!< PLL Ready Interrupt flag */
  669. #define RCC_IT_CSS RCC_CIFR_CSSF /*!< HSE Clock Security System Interrupt flag */
  670. #define RCC_IT_LSECSS RCC_CIFR_LSECSSF /*!< LSE Clock Security System Interrupt flag */
  671. #if defined(RCC_HSI48_SUPPORT)
  672. #define RCC_IT_HSI48RDY RCC_CIFR_HSI48RDYF /*!< HSI48 Ready Interrupt flag */
  673. #endif /* RCC_HSI48_SUPPORT */
  674. /**
  675. * @}
  676. */
  677. /** @defgroup RCC_Flag Flags
  678. * Elements values convention: XXXYYYYYb
  679. * - YYYYY : Flag position in the register
  680. * - XXX : Register index
  681. * - 001: CR register
  682. * - 010: BDCR register
  683. * - 011: CSR register
  684. * @{
  685. */
  686. /* Flags in the CR register */
  687. #define RCC_FLAG_HSIRDY ((CR_REG_INDEX << 5U) | RCC_CR_HSIRDY_Pos) /*!< HSI Ready flag */
  688. #define RCC_FLAG_HSERDY ((CR_REG_INDEX << 5U) | RCC_CR_HSERDY_Pos) /*!< HSE Ready flag */
  689. #define RCC_FLAG_PLLRDY ((CR_REG_INDEX << 5U) | RCC_CR_PLLRDY_Pos) /*!< PLL Ready flag */
  690. #if defined(RCC_HSI48_SUPPORT)
  691. /* Flags in the CR register */
  692. #define RCC_FLAG_HSI48RDY ((CR_REG_INDEX << 5U) | RCC_CR_HSI48RDY_Pos) /*!< HSI48 Ready flag */
  693. #endif /* RCC_HSI48_SUPPORT */
  694. /* Flags in the BDCR register */
  695. #define RCC_FLAG_LSERDY ((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSERDY_Pos) /*!< LSE Ready flag */
  696. #define RCC_FLAG_LSECSSD ((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSECSSD_Pos) /*!< LSE Clock Security System Interrupt flag */
  697. /* Flags in the CSR register */
  698. #define RCC_FLAG_LSIRDY ((CSR_REG_INDEX << 5U) | RCC_CSR_LSIRDY_Pos) /*!< LSI Ready flag */
  699. #define RCC_FLAG_OBLRST ((CSR_REG_INDEX << 5U) | RCC_CSR_OBLRSTF_Pos) /*!< Option Byte Loader reset flag */
  700. #define RCC_FLAG_PINRST ((CSR_REG_INDEX << 5U) | RCC_CSR_PINRSTF_Pos) /*!< PIN reset flag */
  701. #define RCC_FLAG_PWRRST ((CSR_REG_INDEX << 5U) | RCC_CSR_PWRRSTF_Pos) /*!< BOR or POR/PDR reset flag */
  702. #define RCC_FLAG_SFTRST ((CSR_REG_INDEX << 5U) | RCC_CSR_SFTRSTF_Pos) /*!< Software Reset flag */
  703. #define RCC_FLAG_IWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_IWDGRSTF_Pos) /*!< Independent Watchdog reset flag */
  704. #define RCC_FLAG_WWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_WWDGRSTF_Pos) /*!< Window watchdog reset flag */
  705. #define RCC_FLAG_LPWRRST ((CSR_REG_INDEX << 5U) | RCC_CSR_LPWRRSTF_Pos) /*!< Low-Power reset flag */
  706. /**
  707. * @}
  708. */
  709. /** @defgroup RCC_LSEDrive_Config LSE Drive Configuration
  710. * @{
  711. */
  712. #define RCC_LSEDRIVE_LOW 0x00000000U /*!< LSE low drive capability */
  713. #define RCC_LSEDRIVE_MEDIUMLOW RCC_BDCR_LSEDRV_0 /*!< LSE medium low drive capability */
  714. #define RCC_LSEDRIVE_MEDIUMHIGH RCC_BDCR_LSEDRV_1 /*!< LSE medium high drive capability */
  715. #define RCC_LSEDRIVE_HIGH RCC_BDCR_LSEDRV /*!< LSE high drive capability */
  716. /**
  717. * @}
  718. */
  719. /** @defgroup RCC_Reset_Flag Reset Flag
  720. * @{
  721. */
  722. #define RCC_RESET_FLAG_OBL RCC_CSR_OBLRSTF /*!< Option Byte Loader reset flag */
  723. #define RCC_RESET_FLAG_PIN RCC_CSR_PINRSTF /*!< PIN reset flag */
  724. #define RCC_RESET_FLAG_PWR RCC_CSR_PWRRSTF /*!< BOR or POR/PDR reset flag */
  725. #define RCC_RESET_FLAG_SW RCC_CSR_SFTRSTF /*!< Software Reset flag */
  726. #define RCC_RESET_FLAG_IWDG RCC_CSR_IWDGRSTF /*!< Independent Watchdog reset flag */
  727. #define RCC_RESET_FLAG_WWDG RCC_CSR_WWDGRSTF /*!< Window watchdog reset flag */
  728. #define RCC_RESET_FLAG_LPWR RCC_CSR_LPWRRSTF /*!< Low power reset flag */
  729. #define RCC_RESET_FLAG_ALL (RCC_RESET_FLAG_OBL | RCC_RESET_FLAG_PIN | RCC_RESET_FLAG_PWR | \
  730. RCC_RESET_FLAG_SW | RCC_RESET_FLAG_IWDG | RCC_RESET_FLAG_WWDG | \
  731. RCC_RESET_FLAG_LPWR)
  732. /**
  733. * @}
  734. */
  735. /**
  736. * @}
  737. */
  738. /* Exported macros -----------------------------------------------------------*/
  739. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  740. * @{
  741. */
  742. /** @defgroup RCC_AHB_Peripheral_Clock_Enable_Disable AHB Peripheral Clock Enable Disable
  743. * @brief Enable or disable the AHB peripheral clock.
  744. * @note After reset, the peripheral clock (used for registers read/write access)
  745. * is disabled and the application software has to enable this clock before
  746. * using it.
  747. * @{
  748. */
  749. #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
  750. __IO uint32_t tmpreg; \
  751. SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN); \
  752. /* Delay after an RCC peripheral clock enabling */ \
  753. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN); \
  754. UNUSED(tmpreg); \
  755. } while(0U)
  756. #if defined(DMA2)
  757. #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
  758. __IO uint32_t tmpreg; \
  759. SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN); \
  760. /* Delay after an RCC peripheral clock enabling */ \
  761. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN); \
  762. UNUSED(tmpreg); \
  763. } while(0U)
  764. #endif /* DMA2 */
  765. #define __HAL_RCC_FLASH_CLK_ENABLE() do { \
  766. __IO uint32_t tmpreg; \
  767. SET_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN); \
  768. /* Delay after an RCC peripheral clock enabling */ \
  769. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN); \
  770. UNUSED(tmpreg); \
  771. } while(0U)
  772. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  773. __IO uint32_t tmpreg; \
  774. SET_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN); \
  775. /* Delay after an RCC peripheral clock enabling */ \
  776. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN); \
  777. UNUSED(tmpreg); \
  778. } while(0U)
  779. #if defined(RNG)
  780. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  781. __IO uint32_t tmpreg; \
  782. SET_BIT(RCC->AHBENR, RCC_AHBENR_RNGEN); \
  783. /* Delay after an RCC peripheral clock enabling */ \
  784. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_RNGEN); \
  785. UNUSED(tmpreg); \
  786. } while(0U)
  787. #endif /* RNG */
  788. #if defined(AES)
  789. #define __HAL_RCC_AES_CLK_ENABLE() do { \
  790. __IO uint32_t tmpreg; \
  791. SET_BIT(RCC->AHBENR, RCC_AHBENR_AESEN); \
  792. /* Delay after an RCC peripheral clock enabling */ \
  793. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_AESEN); \
  794. UNUSED(tmpreg); \
  795. } while(0U)
  796. #endif /* AES */
  797. #define __HAL_RCC_DMA1_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN)
  798. #if defined(DMA2)
  799. #define __HAL_RCC_DMA2_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN)
  800. #endif /* DMA2 */
  801. #define __HAL_RCC_FLASH_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN)
  802. #define __HAL_RCC_CRC_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN)
  803. #if defined(RNG)
  804. #define __HAL_RCC_RNG_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_RNGEN)
  805. #endif /* RNG */
  806. #if defined(AES)
  807. #define __HAL_RCC_AES_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_AESEN)
  808. #endif /* AES */
  809. /**
  810. * @}
  811. */
  812. /** @defgroup RCC_IOPORT_Clock_Enable_Disable IOPORT Clock Enable Disable
  813. * @brief Enable or disable the IO Ports clock.
  814. * @note After reset, the IO ports clock (used for registers read/write access)
  815. * is disabled and the application software has to enable this clock before
  816. * using it.
  817. * @{
  818. */
  819. #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
  820. __IO uint32_t tmpreg; \
  821. SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN); \
  822. /* Delay after an RCC peripheral clock enabling */ \
  823. tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN); \
  824. UNUSED(tmpreg); \
  825. } while(0U)
  826. #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
  827. __IO uint32_t tmpreg; \
  828. SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN); \
  829. /* Delay after an RCC peripheral clock enabling */ \
  830. tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN); \
  831. UNUSED(tmpreg); \
  832. } while(0U)
  833. #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
  834. __IO uint32_t tmpreg; \
  835. SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOCEN); \
  836. /* Delay after an RCC peripheral clock enabling */ \
  837. tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOCEN); \
  838. UNUSED(tmpreg); \
  839. } while(0U)
  840. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  841. __IO uint32_t tmpreg; \
  842. SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIODEN); \
  843. /* Delay after an RCC peripheral clock enabling */ \
  844. tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIODEN); \
  845. UNUSED(tmpreg); \
  846. } while(0U)
  847. #if defined(GPIOE)
  848. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  849. __IO uint32_t tmpreg; \
  850. SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOEEN); \
  851. /* Delay after an RCC peripheral clock enabling */ \
  852. tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOEEN); \
  853. UNUSED(tmpreg); \
  854. } while(0U)
  855. #endif /* GPIOE */
  856. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  857. __IO uint32_t tmpreg; \
  858. SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN); \
  859. /* Delay after an RCC peripheral clock enabling */ \
  860. tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN); \
  861. UNUSED(tmpreg); \
  862. } while(0U)
  863. #define __HAL_RCC_GPIOA_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN)
  864. #define __HAL_RCC_GPIOB_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN)
  865. #define __HAL_RCC_GPIOC_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOCEN)
  866. #define __HAL_RCC_GPIOD_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIODEN)
  867. #if defined(GPIOE)
  868. #define __HAL_RCC_GPIOE_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOEEN)
  869. #endif /* GPIOE */
  870. #define __HAL_RCC_GPIOF_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN)
  871. /**
  872. * @}
  873. */
  874. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  875. * @brief Enable or disable the APB1 peripheral clock.
  876. * @note After reset, the peripheral clock (used for registers read/write access)
  877. * is disabled and the application software has to enable this clock before
  878. * using it.
  879. * @{
  880. */
  881. #if defined(TIM2)
  882. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  883. __IO uint32_t tmpreg; \
  884. SET_BIT(RCC->APBENR1, RCC_APBENR1_TIM2EN); \
  885. /* Delay after an RCC peripheral clock enabling */ \
  886. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM2EN); \
  887. UNUSED(tmpreg); \
  888. } while(0U)
  889. #endif /* TIM2 */
  890. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  891. __IO uint32_t tmpreg; \
  892. SET_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN); \
  893. /* Delay after an RCC peripheral clock enabling */ \
  894. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN); \
  895. UNUSED(tmpreg); \
  896. } while(0U)
  897. #if defined(TIM4)
  898. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  899. __IO uint32_t tmpreg; \
  900. SET_BIT(RCC->APBENR1, RCC_APBENR1_TIM4EN); \
  901. /* Delay after an RCC peripheral clock enabling */ \
  902. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM4EN); \
  903. UNUSED(tmpreg); \
  904. } while(0U)
  905. #endif /* TIM4 */
  906. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  907. __IO uint32_t tmpreg; \
  908. SET_BIT(RCC->APBENR1, RCC_APBENR1_TIM6EN); \
  909. /* Delay after an RCC peripheral clock enabling */ \
  910. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM6EN); \
  911. UNUSED(tmpreg); \
  912. } while(0U)
  913. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  914. __IO uint32_t tmpreg; \
  915. SET_BIT(RCC->APBENR1, RCC_APBENR1_TIM7EN); \
  916. /* Delay after an RCC peripheral clock enabling */ \
  917. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM7EN); \
  918. UNUSED(tmpreg); \
  919. } while(0U)
  920. #if defined(CRS)
  921. #define __HAL_RCC_CRS_CLK_ENABLE() do { \
  922. __IO uint32_t tmpreg; \
  923. SET_BIT(RCC->APBENR1, RCC_APBENR1_CRSEN); \
  924. /* Delay after an RCC peripheral clock enabling */ \
  925. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_CRSEN); \
  926. UNUSED(tmpreg); \
  927. } while(0)
  928. #endif /* CRS */
  929. #define __HAL_RCC_RTCAPB_CLK_ENABLE() do { \
  930. __IO uint32_t tmpreg; \
  931. SET_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN); \
  932. /* Delay after an RCC peripheral clock enabling */ \
  933. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN); \
  934. UNUSED(tmpreg); \
  935. } while(0U)
  936. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  937. __IO uint32_t tmpreg; \
  938. SET_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN); \
  939. /* Delay after an RCC peripheral clock enabling */ \
  940. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN); \
  941. UNUSED(tmpreg); \
  942. } while(0U)
  943. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  944. __IO uint32_t tmpreg; \
  945. SET_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN); \
  946. /* Delay after an RCC peripheral clock enabling */ \
  947. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN); \
  948. UNUSED(tmpreg); \
  949. } while(0U)
  950. #if defined(SPI3)
  951. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  952. __IO uint32_t tmpreg; \
  953. SET_BIT(RCC->APBENR1, RCC_APBENR1_SPI3EN); \
  954. /* Delay after an RCC peripheral clock enabling */ \
  955. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI3EN); \
  956. UNUSED(tmpreg); \
  957. } while(0U)
  958. #endif /* SPI3 */
  959. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  960. __IO uint32_t tmpreg; \
  961. SET_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN); \
  962. /* Delay after an RCC peripheral clock enabling */ \
  963. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN); \
  964. UNUSED(tmpreg); \
  965. } while(0U)
  966. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  967. __IO uint32_t tmpreg; \
  968. SET_BIT(RCC->APBENR1, RCC_APBENR1_USART3EN); \
  969. /* Delay after an RCC peripheral clock enabling */ \
  970. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_USART3EN); \
  971. UNUSED(tmpreg); \
  972. } while(0U)
  973. #define __HAL_RCC_USART4_CLK_ENABLE() do { \
  974. __IO uint32_t tmpreg; \
  975. SET_BIT(RCC->APBENR1, RCC_APBENR1_USART4EN); \
  976. /* Delay after an RCC peripheral clock enabling */ \
  977. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_USART4EN); \
  978. UNUSED(tmpreg); \
  979. } while(0U)
  980. #if defined(USART5)
  981. #define __HAL_RCC_USART5_CLK_ENABLE() do { \
  982. __IO uint32_t tmpreg; \
  983. SET_BIT(RCC->APBENR1, RCC_APBENR1_USART5EN); \
  984. /* Delay after an RCC peripheral clock enabling */ \
  985. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_USART5EN); \
  986. UNUSED(tmpreg); \
  987. } while(0U)
  988. #endif /* USART5 */
  989. #if defined(USART6)
  990. #define __HAL_RCC_USART6_CLK_ENABLE() do { \
  991. __IO uint32_t tmpreg; \
  992. SET_BIT(RCC->APBENR1, RCC_APBENR1_USART6EN); \
  993. /* Delay after an RCC peripheral clock enabling */ \
  994. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_USART6EN); \
  995. UNUSED(tmpreg); \
  996. } while(0U)
  997. #endif /* USART6 */
  998. #if defined(LPUART1)
  999. #define __HAL_RCC_LPUART1_CLK_ENABLE() do { \
  1000. __IO uint32_t tmpreg; \
  1001. SET_BIT(RCC->APBENR1, RCC_APBENR1_LPUART1EN); \
  1002. /* Delay after an RCC peripheral clock enabling */ \
  1003. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_LPUART1EN); \
  1004. UNUSED(tmpreg); \
  1005. } while(0U)
  1006. #endif /* LPUART1 */
  1007. #if defined(LPUART2)
  1008. #define __HAL_RCC_LPUART2_CLK_ENABLE() do { \
  1009. __IO uint32_t tmpreg; \
  1010. SET_BIT(RCC->APBENR1, RCC_APBENR1_LPUART2EN); \
  1011. /* Delay after an RCC peripheral clock enabling */ \
  1012. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_LPUART2EN); \
  1013. UNUSED(tmpreg); \
  1014. } while(0U)
  1015. #endif /* LPUART2 */
  1016. #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
  1017. __IO uint32_t tmpreg; \
  1018. SET_BIT(RCC->APBENR1, RCC_APBENR1_I2C1EN); \
  1019. /* Delay after an RCC peripheral clock enabling */ \
  1020. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C1EN); \
  1021. UNUSED(tmpreg); \
  1022. } while(0U)
  1023. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  1024. __IO uint32_t tmpreg; \
  1025. SET_BIT(RCC->APBENR1, RCC_APBENR1_I2C2EN); \
  1026. /* Delay after an RCC peripheral clock enabling */ \
  1027. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C2EN); \
  1028. UNUSED(tmpreg); \
  1029. } while(0U)
  1030. #if defined(I2C3)
  1031. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  1032. __IO uint32_t tmpreg; \
  1033. SET_BIT(RCC->APBENR1, RCC_APBENR1_I2C3EN); \
  1034. /* Delay after an RCC peripheral clock enabling */ \
  1035. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C3EN); \
  1036. UNUSED(tmpreg); \
  1037. } while(0U)
  1038. #endif /* I2C3 */
  1039. #if defined(CEC)
  1040. #define __HAL_RCC_CEC_CLK_ENABLE() do { \
  1041. __IO uint32_t tmpreg; \
  1042. SET_BIT(RCC->APBENR1, RCC_APBENR1_CECEN); \
  1043. /* Delay after an RCC peripheral clock enabling */ \
  1044. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_CECEN); \
  1045. UNUSED(tmpreg); \
  1046. } while(0U)
  1047. #endif /* CEC */
  1048. #if defined(UCPD1)
  1049. #define __HAL_RCC_UCPD1_CLK_ENABLE() do { \
  1050. __IO uint32_t tmpreg; \
  1051. SET_BIT(RCC->APBENR1, RCC_APBENR1_UCPD1EN); \
  1052. /* Delay after an RCC peripheral clock enabling */ \
  1053. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_UCPD1EN); \
  1054. UNUSED(tmpreg); \
  1055. } while(0U)
  1056. #endif /* UCPD1 */
  1057. #if defined(UCPD2)
  1058. #define __HAL_RCC_UCPD2_CLK_ENABLE() do { \
  1059. __IO uint32_t tmpreg; \
  1060. SET_BIT(RCC->APBENR1, RCC_APBENR1_UCPD2EN); \
  1061. /* Delay after an RCC peripheral clock enabling */ \
  1062. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_UCPD2EN); \
  1063. UNUSED(tmpreg); \
  1064. } while(0U)
  1065. #endif /* UCPD2 */
  1066. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1067. #define __HAL_RCC_USB_CLK_ENABLE() do { \
  1068. __IO uint32_t tmpreg; \
  1069. SET_BIT(RCC->APBENR1, RCC_APBENR1_USBEN); \
  1070. /* Delay after an RCC peripheral clock enabling */ \
  1071. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_USBEN); \
  1072. UNUSED(tmpreg); \
  1073. } while(0U)
  1074. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1075. #if defined(FDCAN1) || defined(FDCAN2)
  1076. #define __HAL_RCC_FDCAN_CLK_ENABLE() do { \
  1077. __IO uint32_t tmpreg; \
  1078. SET_BIT(RCC->APBENR1, RCC_APBENR1_FDCANEN); \
  1079. /* Delay after an RCC peripheral clock enabling */ \
  1080. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_FDCANEN); \
  1081. UNUSED(tmpreg); \
  1082. } while(0)
  1083. #endif /* FDCAN1 || FDCAN2 */
  1084. #define __HAL_RCC_DBGMCU_CLK_ENABLE() do { \
  1085. __IO uint32_t tmpreg; \
  1086. SET_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN); \
  1087. /* Delay after an RCC peripheral clock enabling */ \
  1088. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN); \
  1089. UNUSED(tmpreg); \
  1090. } while(0U)
  1091. #define __HAL_RCC_PWR_CLK_ENABLE() do { \
  1092. __IO uint32_t tmpreg; \
  1093. SET_BIT(RCC->APBENR1, RCC_APBENR1_PWREN); \
  1094. /* Delay after an RCC peripheral clock enabling */ \
  1095. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_PWREN); \
  1096. UNUSED(tmpreg); \
  1097. } while(0U)
  1098. #if defined(DAC1)
  1099. #define __HAL_RCC_DAC1_CLK_ENABLE() do { \
  1100. __IO uint32_t tmpreg; \
  1101. SET_BIT(RCC->APBENR1, RCC_APBENR1_DAC1EN); \
  1102. /* Delay after an RCC peripheral clock enabling */ \
  1103. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_DAC1EN); \
  1104. UNUSED(tmpreg); \
  1105. } while(0U)
  1106. #endif /* DAC1 */
  1107. #if defined(LPTIM2)
  1108. #define __HAL_RCC_LPTIM2_CLK_ENABLE() do { \
  1109. __IO uint32_t tmpreg; \
  1110. SET_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM2EN); \
  1111. /* Delay after an RCC peripheral clock enabling */ \
  1112. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM2EN); \
  1113. UNUSED(tmpreg); \
  1114. } while(0U)
  1115. #endif /* LPTIM2 */
  1116. #if defined(LPTIM1)
  1117. #define __HAL_RCC_LPTIM1_CLK_ENABLE() do { \
  1118. __IO uint32_t tmpreg; \
  1119. SET_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM1EN); \
  1120. /* Delay after an RCC peripheral clock enabling */ \
  1121. tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM1EN); \
  1122. UNUSED(tmpreg); \
  1123. } while(0U)
  1124. #endif /* LPTIM1 */
  1125. /**
  1126. * @}
  1127. */
  1128. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  1129. * @brief Enable or disable the APB2 peripheral clock.
  1130. * @note After reset, the peripheral clock (used for registers read/write access)
  1131. * is disabled and the application software has to enable this clock before
  1132. * using it.
  1133. * @{
  1134. */
  1135. #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
  1136. __IO uint32_t tmpreg; \
  1137. SET_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN); \
  1138. /* Delay after an RCC peripheral clock enabling */ \
  1139. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN); \
  1140. UNUSED(tmpreg); \
  1141. } while(0U)
  1142. #define __HAL_RCC_TIM1_CLK_ENABLE() do { \
  1143. __IO uint32_t tmpreg; \
  1144. SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN); \
  1145. /* Delay after an RCC peripheral clock enabling */ \
  1146. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN); \
  1147. UNUSED(tmpreg); \
  1148. } while(0U)
  1149. #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
  1150. __IO uint32_t tmpreg; \
  1151. SET_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN); \
  1152. /* Delay after an RCC peripheral clock enabling */ \
  1153. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN); \
  1154. UNUSED(tmpreg); \
  1155. } while(0U)
  1156. #define __HAL_RCC_USART1_CLK_ENABLE() do { \
  1157. __IO uint32_t tmpreg; \
  1158. SET_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN); \
  1159. /* Delay after an RCC peripheral clock enabling */ \
  1160. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN); \
  1161. UNUSED(tmpreg); \
  1162. } while(0U)
  1163. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  1164. __IO uint32_t tmpreg; \
  1165. SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN); \
  1166. /* Delay after an RCC peripheral clock enabling */ \
  1167. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN); \
  1168. UNUSED(tmpreg); \
  1169. } while(0U)
  1170. #if defined(TIM15)
  1171. #define __HAL_RCC_TIM15_CLK_ENABLE() do { \
  1172. __IO uint32_t tmpreg; \
  1173. SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM15EN); \
  1174. /* Delay after an RCC peripheral clock enabling */ \
  1175. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM15EN); \
  1176. UNUSED(tmpreg); \
  1177. } while(0U)
  1178. #endif /* TIM15 */
  1179. #define __HAL_RCC_TIM16_CLK_ENABLE() do { \
  1180. __IO uint32_t tmpreg; \
  1181. SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN); \
  1182. /* Delay after an RCC peripheral clock enabling */ \
  1183. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN); \
  1184. UNUSED(tmpreg); \
  1185. } while(0U)
  1186. #define __HAL_RCC_TIM17_CLK_ENABLE() do { \
  1187. __IO uint32_t tmpreg; \
  1188. SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN); \
  1189. /* Delay after an RCC peripheral clock enabling */ \
  1190. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN); \
  1191. UNUSED(tmpreg); \
  1192. } while(0U)
  1193. #define __HAL_RCC_ADC_CLK_ENABLE() do { \
  1194. __IO uint32_t tmpreg; \
  1195. SET_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN); \
  1196. /* Delay after an RCC peripheral clock enabling */ \
  1197. tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN); \
  1198. UNUSED(tmpreg); \
  1199. } while(0U)
  1200. #if defined(TIM2)
  1201. #define __HAL_RCC_TIM2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_TIM2EN)
  1202. #endif /* TIM2 */
  1203. #define __HAL_RCC_TIM3_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN)
  1204. #if defined(TIM4)
  1205. #define __HAL_RCC_TIM4_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_TIM4EN)
  1206. #endif /* TIM4 */
  1207. #if defined(TIM6)
  1208. #define __HAL_RCC_TIM6_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_TIM6EN)
  1209. #endif /* TIM6 */
  1210. #if defined(TIM7)
  1211. #define __HAL_RCC_TIM7_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_TIM7EN)
  1212. #endif /* TIM7 */
  1213. #if defined(CRS)
  1214. #define __HAL_RCC_CRS_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_CRSEN);
  1215. #endif /* CRS */
  1216. #define __HAL_RCC_RTCAPB_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN)
  1217. #define __HAL_RCC_SPI2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN)
  1218. #if defined(SPI3)
  1219. #define __HAL_RCC_SPI3_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_SPI3EN)
  1220. #endif /* SPI3 */
  1221. #define __HAL_RCC_USART2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN)
  1222. #if defined(USART3)
  1223. #define __HAL_RCC_USART3_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_USART3EN)
  1224. #endif /* USART3 */
  1225. #if defined(USART4)
  1226. #define __HAL_RCC_USART4_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_USART4EN)
  1227. #endif /* USART4 */
  1228. #if defined(USART5)
  1229. #define __HAL_RCC_USART5_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_USART5EN)
  1230. #endif /* USART5 */
  1231. #if defined(USART6)
  1232. #define __HAL_RCC_USART6_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_USART6EN)
  1233. #endif /* USART6 */
  1234. #if defined(LPUART1)
  1235. #define __HAL_RCC_LPUART1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_LPUART1EN)
  1236. #endif /* LPUART1 */
  1237. #if defined(LPUART2)
  1238. #define __HAL_RCC_LPUART2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_LPUART2EN)
  1239. #endif /* LPUART2 */
  1240. #define __HAL_RCC_I2C1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_I2C1EN)
  1241. #define __HAL_RCC_I2C2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_I2C2EN)
  1242. #if defined(I2C3)
  1243. #define __HAL_RCC_I2C3_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_I2C3EN)
  1244. #endif /* I2C3 */
  1245. #if defined(CEC)
  1246. #define __HAL_RCC_CEC_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_CECEN)
  1247. #endif /* CEC */
  1248. #if defined(UCPD1)
  1249. #define __HAL_RCC_UCPD1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_UCPD1EN)
  1250. #endif /* UCPD1 */
  1251. #if defined(UCPD2)
  1252. #define __HAL_RCC_UCPD2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_UCPD2EN)
  1253. #endif /* UCPD2 */
  1254. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1255. #define __HAL_RCC_USB_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_USBEN)
  1256. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1257. #if defined(FDCAN1) || defined(FDCAN2)
  1258. #define __HAL_RCC_FDCAN_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_FDCANEN)
  1259. #endif /* FDCAN1 || FDCAN2 */
  1260. #define __HAL_RCC_DBGMCU_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN)
  1261. #define __HAL_RCC_PWR_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_PWREN)
  1262. #if defined(DAC1)
  1263. #define __HAL_RCC_DAC1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_DAC1EN)
  1264. #endif /* DAC1 */
  1265. #if defined(LPTIM1)
  1266. #define __HAL_RCC_LPTIM1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM1EN)
  1267. #endif /* LPTIM1 */
  1268. #if defined(LPTIM2)
  1269. #define __HAL_RCC_LPTIM2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM2EN)
  1270. #endif /* LPTIM2 */
  1271. #define __HAL_RCC_SYSCFG_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN)
  1272. #define __HAL_RCC_TIM1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN)
  1273. #define __HAL_RCC_SPI1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN)
  1274. #define __HAL_RCC_USART1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN)
  1275. #define __HAL_RCC_TIM14_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN)
  1276. #if defined(TIM15)
  1277. #define __HAL_RCC_TIM15_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM15EN)
  1278. #endif /* TIM15 */
  1279. #define __HAL_RCC_TIM16_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN)
  1280. #define __HAL_RCC_TIM17_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN)
  1281. #define __HAL_RCC_ADC_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN)
  1282. /**
  1283. * @}
  1284. */
  1285. /** @defgroup RCC_AHB_Peripheral_Clock_Enabled_Disabled_Status AHB Peripheral Clock Enabled or Disabled Status
  1286. * @brief Check whether the AHB peripheral clock is enabled or not.
  1287. * @note After reset, the peripheral clock (used for registers read/write access)
  1288. * is disabled and the application software has to enable this clock before
  1289. * using it.
  1290. * @{
  1291. */
  1292. #define __HAL_RCC_DMA1_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN) != RESET)
  1293. #if defined(DMA2)
  1294. #define __HAL_RCC_DMA2_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN) != RESET)
  1295. #endif /* DMA2 */
  1296. #define __HAL_RCC_FLASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN) != RESET)
  1297. #define __HAL_RCC_CRC_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN) != RESET)
  1298. #if defined(RNG)
  1299. #define __HAL_RCC_RNG_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_RNGEN) != RESET)
  1300. #endif /* RNG */
  1301. #if defined(AES)
  1302. #define __HAL_RCC_AES_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_AESEN) != RESET)
  1303. #endif /* AES */
  1304. #define __HAL_RCC_DMA1_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN) == RESET)
  1305. #if defined(DMA2)
  1306. #define __HAL_RCC_DMA2_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN) == RESET)
  1307. #endif /* DMA2 */
  1308. #define __HAL_RCC_FLASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN) == RESET)
  1309. #define __HAL_RCC_CRC_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN) == RESET)
  1310. #if defined(RNG)
  1311. #define __HAL_RCC_RNG_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_RNGEN) == RESET)
  1312. #endif /* RNG */
  1313. #if defined(AES)
  1314. #define __HAL_RCC_AES_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_AESEN) == RESET)
  1315. #endif /* AES */
  1316. /**
  1317. * @}
  1318. */
  1319. /** @defgroup RCC_IOPORT_Clock_Enabled_Disabled_Status IOPORT Clock Enabled or Disabled Status
  1320. * @brief Check whether the IO Port clock is enabled or not.
  1321. * @note After reset, the peripheral clock (used for registers read/write access)
  1322. * is disabled and the application software has to enable this clock before
  1323. * using it.
  1324. * @{
  1325. */
  1326. #define __HAL_RCC_GPIOA_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN) != RESET)
  1327. #define __HAL_RCC_GPIOB_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN) != RESET)
  1328. #define __HAL_RCC_GPIOC_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOCEN) != RESET)
  1329. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIODEN) != RESET)
  1330. #if defined(GPIOE)
  1331. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOEEN) != RESET)
  1332. #endif /* GPIOE */
  1333. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN) != RESET)
  1334. #define __HAL_RCC_GPIOA_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN) == RESET)
  1335. #define __HAL_RCC_GPIOB_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN) == RESET)
  1336. #define __HAL_RCC_GPIOC_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOCEN) == RESET)
  1337. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIODEN) == RESET)
  1338. #if defined(GPIOE)
  1339. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOEEN) == RESET)
  1340. #endif /* GPIOE */
  1341. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN) == RESET)
  1342. /**
  1343. * @}
  1344. */
  1345. /** @defgroup RCC_APB1_Clock_Enabled_Disabled_Status APB1 Peripheral Clock Enabled or Disabled Status
  1346. * @brief Check whether the APB1 peripheral clock is enabled or not.
  1347. * @note After reset, the peripheral clock (used for registers read/write access)
  1348. * is disabled and the application software has to enable this clock before
  1349. * using it.
  1350. * @{
  1351. */
  1352. #if defined(TIM2)
  1353. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM2EN) != 0U)
  1354. #endif /* TIM2 */
  1355. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN) != 0U)
  1356. #if defined(TIM4)
  1357. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM4EN) != 0U)
  1358. #endif /* TIM4 */
  1359. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM6EN) != 0U)
  1360. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM7EN) != 0U)
  1361. #if defined(CRS)
  1362. #define __HAL_RCC_CRS_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_CRSEN) != 0U)
  1363. #endif /* CRS */
  1364. #define __HAL_RCC_RTCAPB_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN) != 0U)
  1365. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN) != 0U)
  1366. #if defined(FDCAN1) || defined(FDCAN2)
  1367. #define __HAL_RCC_FDCAN_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_FDCANEN) != 0U)
  1368. #endif /* FDCAN1 || FDCAN2 */
  1369. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1370. #define __HAL_RCC_USB_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USBEN) != 0U)
  1371. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1372. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN) != 0U)
  1373. #if defined(SPI3)
  1374. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI3EN) != 0U)
  1375. #endif /* SPI3 */
  1376. #define __HAL_RCC_USART2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN) != 0U)
  1377. #define __HAL_RCC_USART3_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART3EN) != 0U)
  1378. #define __HAL_RCC_USART4_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART4EN) != 0U)
  1379. #if defined(USART5)
  1380. #define __HAL_RCC_USART5_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART5EN) != 0U)
  1381. #endif /* USART5 */
  1382. #if defined(USART6)
  1383. #define __HAL_RCC_USART6_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART6EN) != 0U)
  1384. #endif /* USART6 */
  1385. #if defined(LPUART1)
  1386. #define __HAL_RCC_LPUART1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPUART1EN)!= 0U)
  1387. #endif /* LPUART1 */
  1388. #if defined(LPUART2)
  1389. #define __HAL_RCC_LPUART2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPUART2EN)!= 0U)
  1390. #endif /* LPUART2 */
  1391. #define __HAL_RCC_I2C1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C1EN) != 0U)
  1392. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C2EN) != 0U)
  1393. #if defined(I2C3)
  1394. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C3EN) != 0U)
  1395. #endif /* I2C3 */
  1396. #if defined(CEC)
  1397. #define __HAL_RCC_CEC_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_CECEN) != 0U)
  1398. #endif /* CEC */
  1399. #if defined(UCPD1)
  1400. #define __HAL_RCC_UCPD1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_UCPD1EN) != 0U)
  1401. #endif /* UCPD1 */
  1402. #if defined(UCPD2)
  1403. #define __HAL_RCC_UCPD2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_UCPD2EN) != 0U)
  1404. #endif /* UCPD2 */
  1405. #define __HAL_RCC_DBGMCU_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN) != 0U)
  1406. #define __HAL_RCC_PWR_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_PWREN) != 0U)
  1407. #if defined(DAC1)
  1408. #define __HAL_RCC_DAC1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_DAC1EN) != 0U)
  1409. #endif /* DAC1 */
  1410. #if defined(LPTIM2)
  1411. #define __HAL_RCC_LPTIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM2EN) != 0U)
  1412. #endif /* LPTIM2 */
  1413. #if defined(LPTIM1)
  1414. #define __HAL_RCC_LPTIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM1EN) != 0U)
  1415. #endif /* LPTIM1 */
  1416. #if defined(TIM2)
  1417. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM2EN) == 0U)
  1418. #endif /* TIM2 */
  1419. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN) == 0U)
  1420. #if defined(TIM4)
  1421. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM4EN) == 0U)
  1422. #endif /* TIM4 */
  1423. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM6EN) == 0U)
  1424. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM7EN) == 0U)
  1425. #if defined(CRS)
  1426. #define __HAL_RCC_CRS_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_CRSEN) == 0U)
  1427. #endif /* CRS */
  1428. #define __HAL_RCC_RTCAPB_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN) == 0U)
  1429. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN) == 0U)
  1430. #if defined(FDCAN1) || defined(FDCAN2)
  1431. #define __HAL_RCC_FDCAN_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_FDCANEN) == 0U)
  1432. #endif /* FDCAN1 || FDCAN2 */
  1433. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1434. #define __HAL_RCC_USB_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USBEN) == 0U)
  1435. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1436. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN) == 0U)
  1437. #if defined(SPI3)
  1438. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI3EN) == 0U)
  1439. #endif /* SPI3 */
  1440. #define __HAL_RCC_USART2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN) == 0U)
  1441. #define __HAL_RCC_USART3_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART3EN) == 0U)
  1442. #define __HAL_RCC_USART4_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART4EN) == 0U)
  1443. #if defined(USART5)
  1444. #define __HAL_RCC_USART5_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART5EN) == 0U)
  1445. #endif /* USART5 */
  1446. #if defined(USART6)
  1447. #define __HAL_RCC_USART6_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART6EN) == 0U)
  1448. #endif /* USART6 */
  1449. #if defined(LPUART1)
  1450. #define __HAL_RCC_LPUART1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPUART1EN)== 0U)
  1451. #endif /* LPUART1 */
  1452. #if defined(LPUART2)
  1453. #define __HAL_RCC_LPUART2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPUART2EN)== 0U)
  1454. #endif /* LPUART2 */
  1455. #define __HAL_RCC_I2C1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C1EN) == 0U)
  1456. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C2EN) == 0U)
  1457. #if defined(I2C3)
  1458. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2C3EN) == 0U)
  1459. #endif /* I2C3 */
  1460. #if defined(CEC)
  1461. #define __HAL_RCC_CEC_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_CECEN) == 0U)
  1462. #endif /* CEC */
  1463. #if defined(UCPD1)
  1464. #define __HAL_RCC_UCPD1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_UCPD1EN) == 0U)
  1465. #endif /* UCPD1 */
  1466. #if defined(UCPD2)
  1467. #define __HAL_RCC_UCPD2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_UCPD2EN) == 0U)
  1468. #endif /* UCPD2 */
  1469. #define __HAL_RCC_DBGMCU_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN) == 0U)
  1470. #define __HAL_RCC_PWR_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_PWREN) == 0U)
  1471. #if defined(DAC1)
  1472. #define __HAL_RCC_DAC1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_DAC1EN) == 0U)
  1473. #endif /* DAC1 */
  1474. #if defined(LPTIM2)
  1475. #define __HAL_RCC_LPTIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM2EN) == 0U)
  1476. #endif /* LPTIM2 */
  1477. #if defined(LPTIM1)
  1478. #define __HAL_RCC_LPTIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIM1EN) == 0U)
  1479. #endif /* LPTIM1 */
  1480. /**
  1481. * @}
  1482. */
  1483. /** @defgroup RCC_APB2_Clock_Enabled_Disabled_Status APB2 Peripheral Clock Enabled or Disabled Status
  1484. * @brief Check whether the APB2 peripheral clock is enabled or not.
  1485. * @note After reset, the peripheral clock (used for registers read/write access)
  1486. * is disabled and the application software has to enable this clock before
  1487. * using it.
  1488. * @{
  1489. */
  1490. #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN) != 0U)
  1491. #define __HAL_RCC_TIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN) != 0U)
  1492. #define __HAL_RCC_SPI1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN) != 0U)
  1493. #define __HAL_RCC_USART1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN) != 0U)
  1494. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN) != 0U)
  1495. #if defined(TIM15)
  1496. #define __HAL_RCC_TIM15_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM15EN) != 0U)
  1497. #endif /* TIM15 */
  1498. #define __HAL_RCC_TIM16_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN) != 0U)
  1499. #define __HAL_RCC_TIM17_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN) != 0U)
  1500. #define __HAL_RCC_ADC_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN) != 0U)
  1501. #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN) == 0U)
  1502. #define __HAL_RCC_TIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN) == 0U)
  1503. #define __HAL_RCC_SPI1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN) == 0U)
  1504. #define __HAL_RCC_USART1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN) == 0U)
  1505. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN) == 0U)
  1506. #if defined(TIM15)
  1507. #define __HAL_RCC_TIM15_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM15EN) == 0U)
  1508. #endif /* TIM15 */
  1509. #define __HAL_RCC_TIM16_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN) == 0U)
  1510. #define __HAL_RCC_TIM17_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN) == 0U)
  1511. #define __HAL_RCC_ADC_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN) == 0U)
  1512. /**
  1513. * @}
  1514. */
  1515. /** @defgroup RCC_AHB_Force_Release_Reset AHB Peripheral Force Release Reset
  1516. * @brief Force or release AHB1 peripheral reset.
  1517. * @{
  1518. */
  1519. #define __HAL_RCC_AHB_FORCE_RESET() WRITE_REG(RCC->AHBRSTR, 0xFFFFFFFFU)
  1520. #define __HAL_RCC_DMA1_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_DMA1RST)
  1521. #if defined(DMA2)
  1522. #define __HAL_RCC_DMA2_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_DMA2RST)
  1523. #endif /* DMA2 */
  1524. #define __HAL_RCC_FLASH_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_FLASHRST)
  1525. #define __HAL_RCC_CRC_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_CRCRST)
  1526. #if defined(RNG)
  1527. #define __HAL_RCC_RNG_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_RNGRST)
  1528. #endif /* RNG */
  1529. #if defined(AES)
  1530. #define __HAL_RCC_AES_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_AESRST)
  1531. #endif /* AES */
  1532. #define __HAL_RCC_AHB_RELEASE_RESET() WRITE_REG(RCC->AHBRSTR, 0x00000000U)
  1533. #define __HAL_RCC_DMA1_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_DMA1RST)
  1534. #if defined(DMA2)
  1535. #define __HAL_RCC_DMA2_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_DMA2RST)
  1536. #endif /* DMA2 */
  1537. #define __HAL_RCC_FLASH_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_FLASHRST)
  1538. #define __HAL_RCC_CRC_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_CRCRST)
  1539. #if defined(RNG)
  1540. #define __HAL_RCC_RNG_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_RNGRST)
  1541. #endif /* RNG */
  1542. #if defined(AES)
  1543. #define __HAL_RCC_AES_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_AESRST)
  1544. #endif /* AES */
  1545. /**
  1546. * @}
  1547. */
  1548. /** @defgroup RCC_IOPORT_Force_Release_Reset IOPORT Force Release Reset
  1549. * @brief Force or release IO Port reset.
  1550. * @{
  1551. */
  1552. #define __HAL_RCC_IOP_FORCE_RESET() WRITE_REG(RCC->IOPRSTR, 0xFFFFFFFFU)
  1553. #define __HAL_RCC_GPIOA_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOARST)
  1554. #define __HAL_RCC_GPIOB_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOBRST)
  1555. #define __HAL_RCC_GPIOC_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOCRST)
  1556. #define __HAL_RCC_GPIOD_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIODRST)
  1557. #if defined(GPIOE)
  1558. #define __HAL_RCC_GPIOE_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOERST)
  1559. #endif /* GPIOE */
  1560. #define __HAL_RCC_GPIOF_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOFRST)
  1561. #define __HAL_RCC_IOP_RELEASE_RESET() WRITE_REG(RCC->IOPRSTR, 0x00000000U)
  1562. #define __HAL_RCC_GPIOA_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOARST)
  1563. #define __HAL_RCC_GPIOB_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOBRST)
  1564. #define __HAL_RCC_GPIOC_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOCRST)
  1565. #define __HAL_RCC_GPIOD_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIODRST)
  1566. #if defined(GPIOE)
  1567. #define __HAL_RCC_GPIOE_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOERST)
  1568. #endif /* GPIOE */
  1569. #define __HAL_RCC_GPIOF_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOFRST)
  1570. /**
  1571. * @}
  1572. */
  1573. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Peripheral Force Release Reset
  1574. * @brief Force or release APB1 peripheral reset.
  1575. * @{
  1576. */
  1577. #define __HAL_RCC_APB1_FORCE_RESET() WRITE_REG(RCC->APBRSTR1, 0xFFFFFFFFU)
  1578. #if defined(TIM2)
  1579. #define __HAL_RCC_TIM2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM2RST)
  1580. #endif /* TIM2 */
  1581. #define __HAL_RCC_TIM3_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM3RST)
  1582. #if defined(TIM4)
  1583. #define __HAL_RCC_TIM4_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM4RST)
  1584. #endif /* TIM4 */
  1585. #define __HAL_RCC_TIM6_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM6RST)
  1586. #define __HAL_RCC_TIM7_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM7RST)
  1587. #if defined(CRS)
  1588. #define __HAL_RCC_CRS_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_CRSRST)
  1589. #endif /* CRS */
  1590. #define __HAL_RCC_SPI2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_SPI2RST)
  1591. #if defined(SPI3)
  1592. #define __HAL_RCC_SPI3_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_SPI3RST)
  1593. #endif /* SPI3 */
  1594. #define __HAL_RCC_USART2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART2RST)
  1595. #define __HAL_RCC_USART3_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART3RST)
  1596. #define __HAL_RCC_USART4_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART4RST)
  1597. #if defined(USART5)
  1598. #define __HAL_RCC_USART5_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART5RST)
  1599. #endif /* USART5 */
  1600. #if defined(USART6)
  1601. #define __HAL_RCC_USART6_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART6RST)
  1602. #endif /* USART6 */
  1603. #if defined(LPUART1)
  1604. #define __HAL_RCC_LPUART1_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPUART1RST)
  1605. #endif /* LPUART1 */
  1606. #if defined(LPUART2)
  1607. #define __HAL_RCC_LPUART2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPUART2RST)
  1608. #endif /* LPUART2 */
  1609. #define __HAL_RCC_I2C1_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2C1RST)
  1610. #define __HAL_RCC_I2C2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2C2RST)
  1611. #if defined(I2C3)
  1612. #define __HAL_RCC_I2C3_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2C3RST)
  1613. #endif /* I2C3 */
  1614. #if defined(CEC)
  1615. #define __HAL_RCC_CEC_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_CECRST)
  1616. #endif /* CEC */
  1617. #if defined(UCPD1)
  1618. #define __HAL_RCC_UCPD1_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_UCPD1RST)
  1619. #endif /* UCPD1 */
  1620. #if defined(UCPD2)
  1621. #define __HAL_RCC_UCPD2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_UCPD2RST)
  1622. #endif /* UCPD2 */
  1623. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1624. #define __HAL_RCC_USB_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USBRST)
  1625. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1626. #if defined(FDCAN1) || defined(FDCAN2)
  1627. #define __HAL_RCC_FDCAN_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_FDCANRST)
  1628. #endif /* FDCAN1 || FDCAN2 */
  1629. #define __HAL_RCC_DBGMCU_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_DBGRST)
  1630. #define __HAL_RCC_PWR_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_PWRRST)
  1631. #if defined(DAC1)
  1632. #define __HAL_RCC_DAC1_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_DAC1RST)
  1633. #endif /* DAC1 */
  1634. #if defined(LPTIM2)
  1635. #define __HAL_RCC_LPTIM2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPTIM2RST)
  1636. #endif /* LPTIM2 */
  1637. #if defined(LPTIM1)
  1638. #define __HAL_RCC_LPTIM1_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPTIM1RST)
  1639. #endif /* LPTIM1 */
  1640. #define __HAL_RCC_APB1_RELEASE_RESET() WRITE_REG(RCC->APBRSTR1, 0x00000000U)
  1641. #if defined(TIM2)
  1642. #define __HAL_RCC_TIM2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM2RST)
  1643. #endif /* TIM2 */
  1644. #define __HAL_RCC_TIM3_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM3RST)
  1645. #if defined(TIM4)
  1646. #define __HAL_RCC_TIM4_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM4RST)
  1647. #endif /* TIM4 */
  1648. #define __HAL_RCC_TIM6_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM6RST)
  1649. #define __HAL_RCC_TIM7_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM7RST)
  1650. #if defined(CRS)
  1651. #define __HAL_RCC_CRS_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_CRSRST)
  1652. #endif /* CRS */
  1653. #define __HAL_RCC_SPI2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_SPI2RST)
  1654. #if defined(SPI3)
  1655. #define __HAL_RCC_SPI3_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_SPI3RST)
  1656. #endif /* SPI3 */
  1657. #define __HAL_RCC_USART2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART2RST)
  1658. #define __HAL_RCC_USART3_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART3RST)
  1659. #define __HAL_RCC_USART4_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART4RST)
  1660. #if defined(USART5)
  1661. #define __HAL_RCC_USART5_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART5RST)
  1662. #endif /* USART5 */
  1663. #if defined(USART6)
  1664. #define __HAL_RCC_USART6_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART6RST)
  1665. #endif /* USART6 */
  1666. #if defined(LPUART1)
  1667. #define __HAL_RCC_LPUART1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPUART1RST)
  1668. #endif /* LPUART1 */
  1669. #if defined(LPUART2)
  1670. #define __HAL_RCC_LPUART2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPUART2RST)
  1671. #endif /* LPUART2 */
  1672. #define __HAL_RCC_I2C1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2C1RST)
  1673. #define __HAL_RCC_I2C2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2C2RST)
  1674. #if defined(I2C3)
  1675. #define __HAL_RCC_I2C3_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2C3RST)
  1676. #endif /* I2C3 */
  1677. #if defined(CEC)
  1678. #define __HAL_RCC_CEC_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_CECRST)
  1679. #endif /* CEC */
  1680. #if defined(UCPD1)
  1681. #define __HAL_RCC_UCPD1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_UCPD1RST)
  1682. #endif /* UCPD1 */
  1683. #if defined(UCPD2)
  1684. #define __HAL_RCC_UCPD2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_UCPD2RST)
  1685. #endif /* UCPD2 */
  1686. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1687. #define __HAL_RCC_USB_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USBRST)
  1688. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1689. #if defined(FDCAN1) || defined(FDCAN2)
  1690. #define __HAL_RCC_FDCAN_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_FDCANRST)
  1691. #endif /* FDCAN1 || FDCAN2 */
  1692. #define __HAL_RCC_DBGMCU_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_DBGRST)
  1693. #define __HAL_RCC_PWR_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_PWRRST)
  1694. #if defined(DAC1)
  1695. #define __HAL_RCC_DAC1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_DAC1RST)
  1696. #endif /* DAC1 */
  1697. #if defined(LPTIM2)
  1698. #define __HAL_RCC_LPTIM2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPTIM2RST)
  1699. #endif /* LPTIM2 */
  1700. #if defined(LPTIM1)
  1701. #define __HAL_RCC_LPTIM1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPTIM1RST)
  1702. #endif /* LPTIM1 */
  1703. /**
  1704. * @}
  1705. */
  1706. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Peripheral Force Release Reset
  1707. * @brief Force or release APB2 peripheral reset.
  1708. * @{
  1709. */
  1710. #define __HAL_RCC_APB2_FORCE_RESET() WRITE_REG(RCC->APBRSTR2, 0xFFFFFFFFU)
  1711. #define __HAL_RCC_SYSCFG_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SYSCFGRST)
  1712. #define __HAL_RCC_TIM1_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM1RST)
  1713. #define __HAL_RCC_SPI1_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SPI1RST)
  1714. #define __HAL_RCC_USART1_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_USART1RST)
  1715. #define __HAL_RCC_TIM14_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM14RST)
  1716. #if defined(TIM15)
  1717. #define __HAL_RCC_TIM15_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM15RST)
  1718. #endif /* TIM15 */
  1719. #define __HAL_RCC_TIM16_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM16RST)
  1720. #define __HAL_RCC_TIM17_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM17RST)
  1721. #define __HAL_RCC_ADC_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_ADCRST)
  1722. #define __HAL_RCC_APB2_RELEASE_RESET() WRITE_REG(RCC->APBRSTR2, 0x00U)
  1723. #define __HAL_RCC_SYSCFG_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SYSCFGRST)
  1724. #define __HAL_RCC_TIM1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM1RST)
  1725. #define __HAL_RCC_SPI1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SPI1RST)
  1726. #define __HAL_RCC_USART1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_USART1RST)
  1727. #define __HAL_RCC_TIM14_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM14RST)
  1728. #if defined(TIM15)
  1729. #define __HAL_RCC_TIM15_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM15RST)
  1730. #endif /* TIM15 */
  1731. #define __HAL_RCC_TIM16_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM16RST)
  1732. #define __HAL_RCC_TIM17_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM17RST)
  1733. #define __HAL_RCC_ADC_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_ADCRST)
  1734. /**
  1735. * @}
  1736. */
  1737. /** @defgroup RCC_AHB_Clock_Sleep_Enable_Disable AHB Peripherals Clock Sleep Enable Disable
  1738. * @brief Enable or disable the AHB peripherals clock during Low Power (Sleep) mode.
  1739. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1740. * power consumption.
  1741. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1742. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1743. * @{
  1744. */
  1745. #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA1SMEN)
  1746. #if defined(DMA2)
  1747. #define __HAL_RCC_DMA2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA2SMEN)
  1748. #endif /* DMA2 */
  1749. #define __HAL_RCC_FLASH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHBSMENR, RCC_AHBSMENR_FLASHSMEN)
  1750. #define __HAL_RCC_SRAM_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHBSMENR, RCC_AHBSMENR_SRAMSMEN)
  1751. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHBSMENR, RCC_AHBSMENR_CRCSMEN)
  1752. #if defined(RNG)
  1753. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHBSMENR, RCC_AHBSMENR_RNGSMEN)
  1754. #endif /* RNG */
  1755. #if defined(AES)
  1756. #define __HAL_RCC_AES_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHBSMENR, RCC_AHBSMENR_AESSMEN)
  1757. #endif /* AES */
  1758. #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA1SMEN)
  1759. #if defined(DMA2)
  1760. #define __HAL_RCC_DMA2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA2SMEN)
  1761. #endif /* DMA2 */
  1762. #define __HAL_RCC_FLASH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHBSMENR, RCC_AHBSMENR_FLASHSMEN)
  1763. #define __HAL_RCC_SRAM_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHBSMENR, RCC_AHBSMENR_SRAMSMEN)
  1764. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHBSMENR, RCC_AHBSMENR_CRCSMEN)
  1765. #if defined(RNG)
  1766. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHBSMENR, RCC_AHBSMENR_RNGSMEN)
  1767. #endif /* RNG */
  1768. #if defined(AES)
  1769. #define __HAL_RCC_AES_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHBSMENR, RCC_AHBSMENR_AESSMEN)
  1770. #endif /* AES */
  1771. /**
  1772. * @}
  1773. */
  1774. /** @defgroup RCC_IOPORT_Clock_Sleep_Enable_Disable IOPORT Clock Sleep Enable Disable
  1775. * @brief Enable or disable the IOPORT clock during Low Power (Sleep) mode.
  1776. * @note IOPORT clock gating in SLEEP mode can be used to further reduce
  1777. * power consumption.
  1778. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1779. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1780. * @{
  1781. */
  1782. #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() SET_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOASMEN)
  1783. #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() SET_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOBSMEN)
  1784. #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() SET_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOCSMEN)
  1785. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() SET_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIODSMEN)
  1786. #if defined(GPIOE)
  1787. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() SET_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOESMEN)
  1788. #endif /* GPIOE */
  1789. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() SET_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOFSMEN)
  1790. #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOASMEN)
  1791. #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOBSMEN)
  1792. #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOCSMEN)
  1793. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIODSMEN)
  1794. #if defined(GPIOE)
  1795. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOESMEN)
  1796. #endif /* GPIOE */
  1797. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOFSMEN)
  1798. /**
  1799. * @}
  1800. */
  1801. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable APB1 Peripheral Clock Sleep Enable Disable
  1802. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  1803. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1804. * power consumption.
  1805. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1806. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1807. * @{
  1808. */
  1809. #if defined(TIM2)
  1810. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM2SMEN)
  1811. #endif /* TIM2 */
  1812. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM3SMEN)
  1813. #if defined(TIM4)
  1814. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM4SMEN)
  1815. #endif /* TIM4 */
  1816. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM6SMEN)
  1817. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM7SMEN)
  1818. #if defined(CRS)
  1819. #define __HAL_RCC_CRS_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CRSSMEN)
  1820. #endif /* CRS */
  1821. #define __HAL_RCC_RTCAPB_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_RTCAPBSMEN)
  1822. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_WWDGSMEN)
  1823. #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI2SMEN)
  1824. #if defined(SPI3)
  1825. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI3SMEN)
  1826. #endif /* SPI3 */
  1827. #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART2SMEN)
  1828. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART3SMEN)
  1829. #define __HAL_RCC_USART4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART4SMEN)
  1830. #if defined(USART5)
  1831. #define __HAL_RCC_USART5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART5SMEN)
  1832. #endif /* USART5 */
  1833. #if defined(USART6)
  1834. #define __HAL_RCC_USART6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART6SMEN)
  1835. #endif /* USART6 */
  1836. #if defined(LPUART1)
  1837. #define __HAL_RCC_LPUART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART1SMEN)
  1838. #endif /* LPUART1 */
  1839. #if defined(LPUART2)
  1840. #define __HAL_RCC_LPUART2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART2SMEN)
  1841. #endif /* LPUART2 */
  1842. #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C1SMEN)
  1843. #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C2SMEN)
  1844. #if defined(I2C3)
  1845. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C3SMEN)
  1846. #endif /* I2C3 */
  1847. #if defined(CEC)
  1848. #define __HAL_RCC_CEC_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CECSMEN)
  1849. #endif /* CEC */
  1850. #if defined(UCPD1)
  1851. #define __HAL_RCC_UCPD1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD1SMEN)
  1852. #endif /* UCPD1 */
  1853. #if defined(UCPD2)
  1854. #define __HAL_RCC_UCPD2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD2SMEN)
  1855. #endif /* UCPD2 */
  1856. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1857. #define __HAL_RCC_USB_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USBSMEN)
  1858. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1859. #if defined(FDCAN1) || defined(FDCAN2)
  1860. #define __HAL_RCC_FDCAN_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_FDCANSMEN)
  1861. #endif /* FDCAN1 || FDCAN2 */
  1862. #define __HAL_RCC_DBGMCU_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DBGSMEN)
  1863. #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_PWRSMEN)
  1864. #if defined(DAC1)
  1865. #define __HAL_RCC_DAC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DAC1SMEN)
  1866. #endif /* DAC1 */
  1867. #if defined(LPTIM2)
  1868. #define __HAL_RCC_LPTIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM2SMEN)
  1869. #endif /* LPTIM2 */
  1870. #if defined(LPTIM1)
  1871. #define __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM1SMEN)
  1872. #endif /* LPTIM1 */
  1873. #if defined(TIM2)
  1874. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM2SMEN)
  1875. #endif /* TIM2 */
  1876. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM3SMEN)
  1877. #if defined(TIM4)
  1878. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM4SMEN)
  1879. #endif /* TIM4 */
  1880. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM6SMEN)
  1881. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM7SMEN)
  1882. #if defined(CRS)
  1883. #define __HAL_RCC_CRS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CRSSMEN)
  1884. #endif /* CRS */
  1885. #define __HAL_RCC_RTCAPB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_RTCAPBSMEN)
  1886. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_WWDGSMEN)
  1887. #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI2SMEN)
  1888. #if defined(SPI3)
  1889. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI3SMEN)
  1890. #endif /* TIM2 */
  1891. #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART2SMEN)
  1892. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART3SMEN)
  1893. #define __HAL_RCC_USART4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART4SMEN)
  1894. #if defined(USART5)
  1895. #define __HAL_RCC_USART5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART5SMEN)
  1896. #endif /* USART5 */
  1897. #if defined(USART6)
  1898. #define __HAL_RCC_USART6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART6SMEN)
  1899. #endif /* USART6 */
  1900. #if defined(LPUART1)
  1901. #define __HAL_RCC_LPUART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART1SMEN)
  1902. #endif /* LPUART1 */
  1903. #if defined(LPUART2)
  1904. #define __HAL_RCC_LPUART2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART2SMEN)
  1905. #endif /* LPUART2 */
  1906. #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C1SMEN)
  1907. #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C2SMEN)
  1908. #if defined(I2C3)
  1909. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C3SMEN)
  1910. #endif /* I2C3 */
  1911. #if defined(CEC)
  1912. #define __HAL_RCC_CEC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CECSMEN)
  1913. #endif /* CEC */
  1914. #if defined(UCPD1)
  1915. #define __HAL_RCC_UCPD1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD1SMEN)
  1916. #endif /* UCPD1 */
  1917. #if defined(UCPD2)
  1918. #define __HAL_RCC_UCPD2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD2SMEN)
  1919. #endif /* UCPD2 */
  1920. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  1921. #define __HAL_RCC_USB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USBSMEN)
  1922. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  1923. #if defined(FDCAN1) || defined(FDCAN2)
  1924. #define __HAL_RCC_FDCAN_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_FDCANSMEN)
  1925. #endif /* FDCAN1) || FDCAN2 */
  1926. #define __HAL_RCC_DBGMCU_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DBGSMEN)
  1927. #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_PWRSMEN)
  1928. #if defined(DAC1)
  1929. #define __HAL_RCC_DAC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DAC1SMEN)
  1930. #endif /* DAC1 */
  1931. #if defined(LPTIM2)
  1932. #define __HAL_RCC_LPTIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM2SMEN)
  1933. #endif /* LPTIM2 */
  1934. #if defined(LPTIM1)
  1935. #define __HAL_RCC_LPTIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM1SMEN)
  1936. #endif /* LPTIM1 */
  1937. /**
  1938. * @}
  1939. */
  1940. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable APB2 Peripheral Clock Sleep Enable Disable
  1941. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1942. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1943. * power consumption.
  1944. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1945. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1946. * @{
  1947. */
  1948. #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SYSCFGSMEN)
  1949. #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM1SMEN)
  1950. #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SPI1SMEN)
  1951. #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_USART1SMEN)
  1952. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM14SMEN)
  1953. #if defined(TIM15)
  1954. #define __HAL_RCC_TIM15_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM15SMEN)
  1955. #endif /* TIM15 */
  1956. #define __HAL_RCC_TIM16_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM16SMEN)
  1957. #define __HAL_RCC_TIM17_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM17SMEN)
  1958. #define __HAL_RCC_ADC_CLK_SLEEP_ENABLE() SET_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_ADCSMEN)
  1959. #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SYSCFGSMEN)
  1960. #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM1SMEN)
  1961. #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SPI1SMEN)
  1962. #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_USART1SMEN)
  1963. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM14SMEN)
  1964. #if defined(TIM15)
  1965. #define __HAL_RCC_TIM15_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM15SMEN)
  1966. #endif /* TIM15 */
  1967. #define __HAL_RCC_TIM16_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM16SMEN)
  1968. #define __HAL_RCC_TIM17_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM17SMEN)
  1969. #define __HAL_RCC_ADC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_ADCSMEN)
  1970. /**
  1971. * @}
  1972. */
  1973. /** @defgroup RCC_AHB_Clock_Sleep_Enabled_Disabled_Status AHB Peripheral Clock Sleep Enabled or Disabled Status
  1974. * @brief Check whether the AHB peripheral clock during Low Power (Sleep) mode is enabled or not.
  1975. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1976. * power consumption.
  1977. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1978. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1979. * @{
  1980. */
  1981. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA1SMEN) != RESET)
  1982. #if defined(DMA2)
  1983. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA2SMEN) != RESET)
  1984. #endif /* DMA2 */
  1985. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_FLASHSMEN)!= RESET)
  1986. #define __HAL_RCC_SRAM_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_SRAMSMEN) != RESET)
  1987. #define __HAL_RCC_CRC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_CRCSMEN) != RESET)
  1988. #if defined(RNG)
  1989. #define __HAL_RCC_RNG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_RNGSMEN) != RESET)
  1990. #endif /* RNG */
  1991. #if defined(AES)
  1992. #define __HAL_RCC_AES_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_AESSMEN) != RESET)
  1993. #endif /* AES */
  1994. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA1SMEN) == RESET)
  1995. #if defined(DMA2)
  1996. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_DMA2SMEN) == RESET)
  1997. #endif /* DMA2 */
  1998. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_FLASHSMEN) == RESET)
  1999. #define __HAL_RCC_SRAM_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_SRAMSMEN) == RESET)
  2000. #define __HAL_RCC_CRC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_CRCSMEN) == RESET)
  2001. #if defined(RNG)
  2002. #define __HAL_RCC_RNG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_RNGSMEN) == RESET)
  2003. #endif /* RNG */
  2004. #if defined(AES)
  2005. #define __HAL_RCC_AES_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHBSMENR, RCC_AHBSMENR_AESSMEN) == RESET)
  2006. #endif /* AES */
  2007. /**
  2008. * @}
  2009. */
  2010. /** @defgroup RCC_IOPORT_Clock_Sleep_Enabled_Disabled_Status IOPORT Clock Sleep Enabled or Disabled Status
  2011. * @brief Check whether the IOPORT clock during Low Power (Sleep) mode is enabled or not.
  2012. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2013. * power consumption.
  2014. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2015. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2016. * @{
  2017. */
  2018. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOASMEN)!= RESET)
  2019. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOBSMEN)!= RESET)
  2020. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOCSMEN)!= RESET)
  2021. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIODSMEN)!= RESET)
  2022. #if defined(GPIOE)
  2023. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOESMEN)!= RESET)
  2024. #endif /* GPIOE */
  2025. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOFSMEN)!= RESET)
  2026. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOASMEN) == RESET)
  2027. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOBSMEN) == RESET)
  2028. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOCSMEN) == RESET)
  2029. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIODSMEN) == RESET)
  2030. #if defined(GPIOE)
  2031. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOESMEN) == RESET)
  2032. #endif /* GPIOE */
  2033. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->IOPSMENR, RCC_IOPSMENR_GPIOFSMEN) == RESET)
  2034. /**
  2035. * @}
  2036. */
  2037. /** @defgroup RCC_APB1_Clock_Sleep_Enabled_Disabled_Status APB1 Peripheral Clock Sleep Enabled or Disabled Status
  2038. * @brief Check whether the APB1 peripheral clock during Low Power (Sleep) mode is enabled or not.
  2039. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2040. * power consumption.
  2041. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2042. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2043. * @{
  2044. */
  2045. #if defined(TIM2)
  2046. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM2SMEN) != RESET)
  2047. #endif /* TIM2 */
  2048. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM3SMEN) != RESET)
  2049. #if defined(TIM4)
  2050. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM4SMEN) != RESET)
  2051. #endif /* TIM4 */
  2052. #if defined(TIM6)
  2053. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM6SMEN) != RESET)
  2054. #endif /* TIM6 */
  2055. #if defined(TIM7)
  2056. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM7SMEN) != RESET)
  2057. #endif /* TIM7 */
  2058. #if defined(CRS)
  2059. #define __HAL_RCC_CRS_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CRSSMEN) != RESET)
  2060. #endif /* CRS */
  2061. #define __HAL_RCC_RTCAPB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_RTCAPBSMEN) != RESET)
  2062. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_WWDGSMEN) != RESET)
  2063. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI2SMEN) != RESET)
  2064. #if defined(SPI3)
  2065. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI3SMEN) != RESET)
  2066. #endif /* SPI3 */
  2067. #define __HAL_RCC_USART2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART2SMEN) != RESET)
  2068. #if defined(USART3)
  2069. #define __HAL_RCC_USART3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART3SMEN) != RESET)
  2070. #endif /* USART3 */
  2071. #if defined(USART4)
  2072. #define __HAL_RCC_USART4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART4SMEN) != RESET)
  2073. #endif /* USART4 */
  2074. #if defined(USART5)
  2075. #define __HAL_RCC_USART5_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART5SMEN) != RESET)
  2076. #endif /* USART5 */
  2077. #if defined(USART6)
  2078. #define __HAL_RCC_USART6_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART6SMEN) != RESET)
  2079. #endif /* USART6 */
  2080. #if defined(LPUART1)
  2081. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART1SMEN)!= RESET)
  2082. #endif /* LPUART1 */
  2083. #if defined(LPUART2)
  2084. #define __HAL_RCC_LPUART2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART2SMEN)!= RESET)
  2085. #endif /* LPUART2 */
  2086. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C1SMEN) != RESET)
  2087. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C2SMEN) != RESET)
  2088. #if defined(I2C3)
  2089. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C3SMEN) != RESET)
  2090. #endif /* I2C3 */
  2091. #if defined(CEC)
  2092. #define __HAL_RCC_CEC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CECSMEN) != RESET)
  2093. #endif /* CEC */
  2094. #if defined(UCPD1)
  2095. #define __HAL_RCC_UCPD1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD1SMEN) != RESET)
  2096. #endif /* UCPD1 */
  2097. #if defined(UCPD2)
  2098. #define __HAL_RCC_UCPD2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD2SMEN) != RESET)
  2099. #endif /* UCPD2 */
  2100. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  2101. #define __HAL_RCC_USB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USBSMEN) != RESET)
  2102. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  2103. #if defined(FDCAN1) || defined(FDCAN2)
  2104. #define __HAL_RCC_FDCAN_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_FDCANSMEN) != RESET)
  2105. #endif /* FDCAN1 || FDCAN2 */
  2106. #define __HAL_RCC_DBGMCU_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DBGSMEN) != RESET)
  2107. #define __HAL_RCC_PWR_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_PWRSMEN) != RESET)
  2108. #if defined(DAC1)
  2109. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DAC1SMEN) != RESET)
  2110. #endif /* DAC1 */
  2111. #if defined(LPTIM2)
  2112. #define __HAL_RCC_LPTIM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM2SMEN) != RESET)
  2113. #endif /* LPTIM2 */
  2114. #if defined(LPTIM1)
  2115. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM1SMEN) != RESET)
  2116. #endif /* LPTIM1 */
  2117. #if defined(TIM2)
  2118. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM2SMEN) == RESET)
  2119. #endif /* TIM2 */
  2120. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM3SMEN) == RESET)
  2121. #if defined(TIM4)
  2122. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM4SMEN) == RESET)
  2123. #endif /* TIM4 */
  2124. #if defined(TIM6)
  2125. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM6SMEN) == RESET)
  2126. #endif /* TIM6 */
  2127. #if defined(TIM7)
  2128. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_TIM7SMEN) == RESET)
  2129. #endif /* TIM7 */
  2130. #if defined(CRS)
  2131. #define __HAL_RCC_CRS_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CRSSMEN) == RESET)
  2132. #endif /* CRS */
  2133. #define __HAL_RCC_RTCAPB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_RTCAPBSMEN) == RESET)
  2134. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_WWDGSMEN) == RESET)
  2135. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI2SMEN) == RESET)
  2136. #if defined(SPI3)
  2137. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_SPI3SMEN) == RESET)
  2138. #endif /* SPI3 */
  2139. #define __HAL_RCC_USART2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART2SMEN) == RESET)
  2140. #if defined(USART3)
  2141. #define __HAL_RCC_USART3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART3SMEN) == RESET)
  2142. #endif /* USART3 */
  2143. #if defined(USART4)
  2144. #define __HAL_RCC_USART4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART4SMEN) == RESET)
  2145. #endif /* USART4 */
  2146. #if defined(USART5)
  2147. #define __HAL_RCC_USART5_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART5SMEN) == RESET)
  2148. #endif /* USART5 */
  2149. #if defined(USART6)
  2150. #define __HAL_RCC_USART6_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USART6SMEN) == RESET)
  2151. #endif /* USART6 */
  2152. #if defined(LPUART1)
  2153. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART1SMEN)== RESET)
  2154. #endif /* LPUART1 */
  2155. #if defined(LPUART2)
  2156. #define __HAL_RCC_LPUART2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPUART2SMEN)== RESET)
  2157. #endif /* LPUART2 */
  2158. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C1SMEN) == RESET)
  2159. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C2SMEN) == RESET)
  2160. #if defined(I2C3)
  2161. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_I2C3SMEN) == RESET)
  2162. #endif /* I2C3 */
  2163. #if defined(CEC)
  2164. #define __HAL_RCC_CEC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_CECSMEN) == RESET)
  2165. #endif /* CEC */
  2166. #if defined(UCPD1)
  2167. #define __HAL_RCC_UCPD1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD1SMEN) == RESET)
  2168. #endif /* UCPD1 */
  2169. #if defined(UCPD2)
  2170. #define __HAL_RCC_UCPD2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_UCPD2SMEN) == RESET)
  2171. #endif /* UCPD2 */
  2172. #if defined(STM32G0B0xx) || defined(STM32G0B1xx) || defined (STM32G0C1xx)
  2173. #define __HAL_RCC_USB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_USBSMEN) == RESET)
  2174. #endif /* STM32G0B0xx || STM32G0B1xx || STM32G0C1xx */
  2175. #if defined(FDCAN1) || defined(FDCAN2)
  2176. #define __HAL_RCC_FDCAN_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_FDCANSMEN) == RESET)
  2177. #endif /* FDCAN1 || FDCAN2 */
  2178. #define __HAL_RCC_DBGMCU_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DBGSMEN) == RESET)
  2179. #define __HAL_RCC_PWR_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_PWRSMEN) == RESET)
  2180. #if defined(DAC1)
  2181. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_DAC1SMEN) == RESET)
  2182. #endif /* DAC1 */
  2183. #if defined(LPTIM2)
  2184. #define __HAL_RCC_LPTIM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM2SMEN) == RESET)
  2185. #endif /* LPTIM2 */
  2186. #if defined(LPTIM1)
  2187. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR1, RCC_APBSMENR1_LPTIM1SMEN) == RESET)
  2188. #endif /* LPTIM1 */
  2189. /**
  2190. * @}
  2191. */
  2192. /** @defgroup RCC_APB2_Clock_Sleep_Enabled_Disabled_Status APB2 Peripheral Clock Sleep Enabled or Disabled Status
  2193. * @brief Check whether the APB2 peripheral clock during Low Power (Sleep) mode is enabled or not.
  2194. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2195. * power consumption.
  2196. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2197. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2198. * @{
  2199. */
  2200. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SYSCFGSMEN) != RESET)
  2201. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM1SMEN) != RESET)
  2202. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SPI1SMEN) != RESET)
  2203. #define __HAL_RCC_USART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_USART1SMEN) != RESET)
  2204. #define __HAL_RCC_TIM14_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM14SMEN) != RESET)
  2205. #if defined(TIM15)
  2206. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM15SMEN) != RESET)
  2207. #endif /* TIM15 */
  2208. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM16SMEN) != RESET)
  2209. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM17SMEN) != RESET)
  2210. #define __HAL_RCC_ADC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_ADCSMEN) != RESET)
  2211. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SYSCFGSMEN) == RESET)
  2212. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM1SMEN) == RESET)
  2213. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_SPI1SMEN) == RESET)
  2214. #define __HAL_RCC_USART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_USART1SMEN) == RESET)
  2215. #define __HAL_RCC_TIM14_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM14SMEN) == RESET)
  2216. #if defined(TIM15)
  2217. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM15SMEN) == RESET)
  2218. #endif /* TIM15 */
  2219. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM16SMEN) == RESET)
  2220. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_TIM17SMEN) == RESET)
  2221. #define __HAL_RCC_ADC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APBSMENR2 , RCC_APBSMENR2_ADCSMEN) == RESET)
  2222. /**
  2223. * @}
  2224. */
  2225. /** @defgroup RCC_Backup_Domain_Reset RCC Backup Domain Reset
  2226. * @{
  2227. */
  2228. /** @brief Macros to force or release the Backup domain reset.
  2229. * @note This function resets the RTC peripheral (including the backup registers)
  2230. * and the RTC clock source selection in RCC_CSR register.
  2231. * @note The BKPSRAM is not affected by this reset.
  2232. * @retval None
  2233. */
  2234. #define __HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  2235. #define __HAL_RCC_BACKUPRESET_RELEASE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  2236. /**
  2237. * @}
  2238. */
  2239. /** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
  2240. * @{
  2241. */
  2242. /** @brief Macros to enable or disable the RTC clock.
  2243. * @note As the RTC is in the Backup domain and write access is denied to
  2244. * this domain after reset, you have to enable write access using
  2245. * HAL_PWR_EnableBkUpAccess() function before to configure the RTC
  2246. * (to be done once after reset).
  2247. * @note These macros must be used after the RTC clock source was selected.
  2248. * @retval None
  2249. */
  2250. #define __HAL_RCC_RTC_ENABLE() SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  2251. #define __HAL_RCC_RTC_DISABLE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  2252. /**
  2253. * @}
  2254. */
  2255. /** @defgroup RCC_Clock_Configuration RCC Clock Configuration
  2256. * @{
  2257. */
  2258. /** @brief Macros to enable the Internal High Speed oscillator (HSI).
  2259. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  2260. * It is used (enabled by hardware) as system clock source after startup
  2261. * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
  2262. * of the HSE used directly or indirectly as system clock (if the Clock
  2263. * Security System CSS is enabled).
  2264. * @note After enabling the HSI, the application software should wait on HSIRDY
  2265. * flag to be set indicating that HSI clock is stable and can be used as
  2266. * system clock source.
  2267. * This parameter can be: ENABLE or DISABLE.
  2268. * @retval None
  2269. */
  2270. #define __HAL_RCC_HSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSION)
  2271. /** @brief Macros to disable the Internal High Speed oscillator (HSI).
  2272. * @note HSI can not be stopped if it is used as system clock source. In this case,
  2273. * you have to select another source of the system clock then stop the HSI.
  2274. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  2275. * clock cycles.
  2276. * @retval None
  2277. */
  2278. #define __HAL_RCC_HSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSION)
  2279. /** @brief Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
  2280. * @note The calibration is used to compensate for the variations in voltage
  2281. * and temperature that influence the frequency of the internal HSI RC.
  2282. * @param __HSICALIBRATIONVALUE__ specifies the calibration trimming value
  2283. * (default is RCC_HSICALIBRATION_DEFAULT).
  2284. * This parameter must be a number between 0 and 127.
  2285. * @retval None
  2286. */
  2287. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICALIBRATIONVALUE__) \
  2288. MODIFY_REG(RCC->ICSCR, RCC_ICSCR_HSITRIM, (uint32_t)(__HSICALIBRATIONVALUE__) << RCC_ICSCR_HSITRIM_Pos)
  2289. /**
  2290. * @brief Macros to enable or disable the force of the Internal High Speed oscillator (HSI)
  2291. * in STOP mode to be quickly available as kernel clock for USARTs and I2Cs.
  2292. * @note Keeping the HSI ON in STOP mode allows to avoid slowing down the communication
  2293. * speed because of the HSI startup time.
  2294. * @note The enable of this function has not effect on the HSION bit.
  2295. * This parameter can be: ENABLE or DISABLE.
  2296. * @retval None
  2297. */
  2298. #define __HAL_RCC_HSISTOP_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIKERON)
  2299. #define __HAL_RCC_HSISTOP_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIKERON)
  2300. /** @brief Macro to configure the HSISYS clock.
  2301. * @param __HSIDIV__ specifies the HSI16 division factor.
  2302. * This parameter can be one of the following values:
  2303. * @arg @ref RCC_HSI_DIV1 HSI clock source is divided by 1
  2304. * @arg @ref RCC_HSI_DIV2 HSI clock source is divided by 2
  2305. * @arg @ref RCC_HSI_DIV4 HSI clock source is divided by 4
  2306. * @arg @ref RCC_HSI_DIV8 HSI clock source is divided by 8
  2307. * @arg @ref RCC_HSI_DIV16 HSI clock source is divided by 16
  2308. * @arg @ref RCC_HSI_DIV32 HSI clock source is divided by 32
  2309. * @arg @ref RCC_HSI_DIV64 HSI clock source is divided by 64
  2310. * @arg @ref RCC_HSI_DIV128 HSI clock source is divided by 128
  2311. */
  2312. #define __HAL_RCC_HSI_CONFIG(__HSIDIV__) \
  2313. MODIFY_REG(RCC->CR, RCC_CR_HSIDIV, (__HSIDIV__))
  2314. /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
  2315. * @note After enabling the LSI, the application software should wait on
  2316. * LSIRDY flag to be set indicating that LSI clock is stable and can
  2317. * be used to clock the IWDG and/or the RTC.
  2318. * @note LSI can not be disabled if the IWDG is running.
  2319. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  2320. * clock cycles.
  2321. * @retval None
  2322. */
  2323. #define __HAL_RCC_LSI_ENABLE() SET_BIT(RCC->CSR, RCC_CSR_LSION)
  2324. #define __HAL_RCC_LSI_DISABLE() CLEAR_BIT(RCC->CSR, RCC_CSR_LSION)
  2325. /**
  2326. * @brief Macro to configure the External High Speed oscillator (HSE).
  2327. * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
  2328. * supported by this macro. User should request a transition to HSE Off
  2329. * first and then HSE On or HSE Bypass.
  2330. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  2331. * software should wait on HSERDY flag to be set indicating that HSE clock
  2332. * is stable and can be used to clock the PLL and/or system clock.
  2333. * @note HSE state can not be changed if it is used directly or through the
  2334. * PLL as system clock. In this case, you have to select another source
  2335. * of the system clock then change the HSE state (ex. disable it).
  2336. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  2337. * @note This function reset the CSSON bit, so if the clock security system(CSS)
  2338. * was previously enabled you have to enable it again after calling this
  2339. * function.
  2340. * @param __STATE__ specifies the new state of the HSE.
  2341. * This parameter can be one of the following values:
  2342. * @arg @ref RCC_HSE_OFF Turn OFF the HSE oscillator, HSERDY flag goes low after
  2343. * 6 HSE oscillator clock cycles.
  2344. * @arg @ref RCC_HSE_ON Turn ON the HSE oscillator.
  2345. * @arg @ref RCC_HSE_BYPASS HSE oscillator bypassed with external clock.
  2346. * @retval None
  2347. */
  2348. #define __HAL_RCC_HSE_CONFIG(__STATE__) do { \
  2349. if((__STATE__) == RCC_HSE_ON) \
  2350. { \
  2351. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  2352. } \
  2353. else if((__STATE__) == RCC_HSE_BYPASS) \
  2354. { \
  2355. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  2356. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  2357. } \
  2358. else \
  2359. { \
  2360. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  2361. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  2362. } \
  2363. } while(0U)
  2364. /**
  2365. * @brief Macro to configure the External Low Speed oscillator (LSE).
  2366. * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
  2367. * supported by this macro. User should request a transition to LSE Off
  2368. * first and then LSE On or LSE Bypass.
  2369. * @note As the LSE is in the Backup domain and write access is denied to
  2370. * this domain after reset, you have to enable write access using
  2371. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  2372. * (to be done once after reset).
  2373. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  2374. * software should wait on LSERDY flag to be set indicating that LSE clock
  2375. * is stable and can be used to clock the RTC.
  2376. * @param __STATE__ specifies the new state of the LSE.
  2377. * This parameter can be one of the following values:
  2378. * @arg @ref RCC_LSE_OFF Turn OFF the LSE oscillator, LSERDY flag goes low after
  2379. * 6 LSE oscillator clock cycles.
  2380. * @arg @ref RCC_LSE_ON Turn ON the LSE oscillator.
  2381. * @arg @ref RCC_LSE_BYPASS LSE oscillator bypassed with external clock.
  2382. * @retval None
  2383. */
  2384. #define __HAL_RCC_LSE_CONFIG(__STATE__) do { \
  2385. if((__STATE__) == RCC_LSE_ON) \
  2386. { \
  2387. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  2388. } \
  2389. else if((__STATE__) == RCC_LSE_BYPASS) \
  2390. { \
  2391. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  2392. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  2393. } \
  2394. else \
  2395. { \
  2396. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  2397. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  2398. } \
  2399. } while(0U)
  2400. #if defined(RCC_HSI48_SUPPORT)
  2401. /** @brief Macros to enable or disable the Internal High Speed 48MHz oscillator (HSI48).
  2402. * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes.
  2403. * @note After enabling the HSI48, the application software should wait on HSI48RDY
  2404. * flag to be set indicating that HSI48 clock is stable.
  2405. * This parameter can be: ENABLE or DISABLE.
  2406. * @retval None
  2407. */
  2408. #define __HAL_RCC_HSI48_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSI48ON)
  2409. #define __HAL_RCC_HSI48_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSI48ON)
  2410. #endif /* RCC_HSI48_SUPPORT */
  2411. /**
  2412. * @}
  2413. */
  2414. /** @addtogroup RCC_RTC_Clock_Configuration
  2415. * @{
  2416. */
  2417. /** @brief Macros to configure the RTC clock (RTCCLK).
  2418. * @note As the RTC clock configuration bits are in the Backup domain and write
  2419. * access is denied to this domain after reset, you have to enable write
  2420. * access using the Power Backup Access macro before to configure
  2421. * the RTC clock source (to be done once after reset).
  2422. * @note Once the RTC clock is configured it cannot be changed unless the
  2423. * Backup domain is reset using __HAL_RCC_BACKUPRESET_FORCE() macro, or by
  2424. * a Power On Reset (POR).
  2425. *
  2426. * @param __RTC_CLKSOURCE__ specifies the RTC clock source.
  2427. * This parameter can be one of the following values:
  2428. * @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
  2429. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  2430. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  2431. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  2432. *
  2433. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  2434. * work in STOP and STANDBY modes, and can be used as wakeup source.
  2435. * However, when the HSE clock is used as RTC clock source, the RTC
  2436. * cannot be used in STOP and STANDBY modes.
  2437. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  2438. * RTC clock source).
  2439. * @retval None
  2440. */
  2441. #define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) \
  2442. MODIFY_REG( RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
  2443. /** @brief Macro to get the RTC clock source.
  2444. * @retval The returned value can be one of the following:
  2445. * @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
  2446. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  2447. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  2448. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  2449. */
  2450. #define __HAL_RCC_GET_RTC_SOURCE() ((uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL)))
  2451. /** @brief Macros to enable or disable the main PLL.
  2452. * @note After enabling the main PLL, the application software should wait on
  2453. * PLLRDY flag to be set indicating that PLL clock is stable and can
  2454. * be used as system clock source.
  2455. * @note The main PLL can not be disabled if it is used as system clock source
  2456. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  2457. * @retval None
  2458. */
  2459. /**
  2460. * @}
  2461. */
  2462. /** @addtogroup RCC_Clock_Configuration
  2463. * @{
  2464. */
  2465. #define __HAL_RCC_PLL_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLON)
  2466. #define __HAL_RCC_PLL_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLON)
  2467. /** @brief Macro to configure the PLL clock source.
  2468. * @note This function must be used only when the main PLL is disabled.
  2469. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  2470. * This parameter can be one of the following values:
  2471. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  2472. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  2473. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  2474. * @retval None
  2475. *
  2476. */
  2477. #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) \
  2478. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
  2479. /** @brief Macro to configure the PLL multiplication factor.
  2480. * @note This function must be used only when the main PLL is disabled.
  2481. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  2482. * This parameter must be a value of RCC_PLLM_Clock_Divider.
  2483. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  2484. * frequency ranges from 4 to 16 MHz. It is recommended to select a frequency
  2485. * of 16 MHz to limit PLL jitter.
  2486. * @retval None
  2487. *
  2488. */
  2489. #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) \
  2490. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, (__PLLM__))
  2491. /**
  2492. * @brief Macro to configure the main PLL clock source, multiplication and division factors.
  2493. * @note This function must be used only when the main PLL is disabled.
  2494. *
  2495. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  2496. * This parameter can be one of the following values:
  2497. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  2498. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  2499. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  2500. *
  2501. * @param __PLLM__ specifies the division factor for PLL VCO input clock.
  2502. * This parameter must be a value of RCC_PLLM_Clock_Divider.
  2503. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  2504. * frequency ranges from 4 to 16 MHz. It is recommended to select a frequency
  2505. * of 16 MHz to limit PLL jitter.
  2506. *
  2507. * @param __PLLN__ specifies the multiplication factor for PLL VCO output clock.
  2508. * This parameter must be a number between 8 and 86.
  2509. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  2510. * output frequency is between 64 and 344 MHz.
  2511. *
  2512. * @param __PLLP__ specifies the division factor for ADC clock.
  2513. * This parameter must be a value of @ref RCC_PLLP_Clock_Divider.
  2514. *
  2515. * @param __PLLQ__ specifies the division factor for RBG & HS Timers clocks.(1)
  2516. * This parameter must be a value of @ref RCC_PLLQ_Clock_Divider
  2517. * @note (1)__PLLQ__ parameter availability depends on devices
  2518. * @note If the USB FS is used in your application, you have to set the
  2519. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  2520. * the RNG needs a frequency lower than or equal to 48 MHz to work
  2521. * correctly.
  2522. *
  2523. * @param __PLLR__ specifies the division factor for the main system clock.
  2524. * This parameter must be a value of RCC_PLLR_Clock_Divider
  2525. * @note You have to set the PLL parameters correctly to not exceed 64MHZ.
  2526. * @retval None
  2527. */
  2528. #if defined(RCC_PLLQ_SUPPORT)
  2529. #define __HAL_RCC_PLL_CONFIG(__PLLSOURCE__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__,__PLLR__ ) \
  2530. MODIFY_REG(RCC->PLLCFGR, \
  2531. (RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | \
  2532. RCC_PLLCFGR_PLLP | RCC_PLLCFGR_PLLQ | RCC_PLLCFGR_PLLR), \
  2533. ((uint32_t) (__PLLSOURCE__) | \
  2534. (uint32_t) (__PLLM__) | \
  2535. (uint32_t) ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  2536. (uint32_t) (__PLLP__) | \
  2537. (uint32_t) (__PLLQ__) | \
  2538. (uint32_t) (__PLLR__)))
  2539. #else
  2540. #define __HAL_RCC_PLL_CONFIG(__PLLSOURCE__, __PLLM__, __PLLN__, __PLLP__, __PLLR__ ) \
  2541. MODIFY_REG(RCC->PLLCFGR, \
  2542. (RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | \
  2543. RCC_PLLCFGR_PLLP | RCC_PLLCFGR_PLLR), \
  2544. ((uint32_t) (__PLLSOURCE__) | \
  2545. (uint32_t) (__PLLM__) | \
  2546. (uint32_t) ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  2547. (uint32_t) (__PLLP__) | \
  2548. (uint32_t) (__PLLR__)))
  2549. #endif /* RCC_PLLQ_SUPPORT */
  2550. /** @brief Macro to get the oscillator used as PLL clock source.
  2551. * @retval The oscillator used as PLL clock source. The returned value can be one
  2552. * of the following:
  2553. * @arg @ref RCC_PLLSOURCE_NONE No oscillator is used as PLL clock source.
  2554. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator is used as PLL clock source.
  2555. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator is used as PLL clock source.
  2556. */
  2557. #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC))
  2558. /**
  2559. * @brief Enable each clock output (RCC_PLLRCLK, RCC_PLLQCLK(*), RCC_PLLPCLK)
  2560. * @note Enabling clock outputs RCC_PLLPCLK and RCC_PLLQCLK(*) can be done at anytime
  2561. * without the need to stop the PLL in order to save power. But RCC_PLLRCLK cannot
  2562. * be stopped if used as System Clock.
  2563. * @note (*) RCC_PLLQCLK availability depends on devices
  2564. * @param __PLLCLOCKOUT__ specifies the PLL clock to be output.
  2565. * This parameter can be one or a combination of the following values:
  2566. * @arg @ref RCC_PLLPCLK This clock is used to generate the clock for the ADC.
  2567. * @if defined(STM32G081xx)
  2568. * @arg @ref RCC_PLLQCLK This Clock is used to generate the clock for the High Speed Timers,
  2569. * and the random analog generator (<=48 MHz).
  2570. * @endif
  2571. * @arg @ref RCC_PLLRCLK This Clock is used to generate the high speed system clock (up to 64MHz)
  2572. * @retval None
  2573. */
  2574. #define __HAL_RCC_PLLCLKOUT_ENABLE(__PLLCLOCKOUT__) SET_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2575. /**
  2576. * @brief Disable each clock output (RCC_PLLRCLK, RCC_PLLQCLK(*), RCC_PLLPCLK)
  2577. * @note Disabling clock outputs RCC_PLLPCLK and RCC_PLLQCLK(*) can be done at anytime
  2578. * without the need to stop the PLL in order to save power. But RCC_PLLRCLK cannot
  2579. * be stopped if used as System Clock.
  2580. * @note (*) RCC_PLLQCLK availability depends on devices
  2581. * @param __PLLCLOCKOUT__ specifies the PLL clock to be output.
  2582. * This parameter can be one or a combination of the following values:
  2583. * @arg @ref RCC_PLLPCLK This clock may be used to generate the clock for the ADC, I2S1.
  2584. * @if defined(STM32G081xx)
  2585. * @arg @ref RCC_PLLQCLK This Clock may be used to generate the clock for the High Speed Timers,
  2586. * and RNG (<=48 MHz).
  2587. * @endif
  2588. * @arg @ref RCC_PLLRCLK This Clock is used to generate the high speed system clock (up to 64MHz)
  2589. * @retval None
  2590. */
  2591. #define __HAL_RCC_PLLCLKOUT_DISABLE(__PLLCLOCKOUT__) CLEAR_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2592. /**
  2593. * @brief Get clock output enable status (RCC_PLLRCLK, RCC_PLLQCLK(*), RCC_PLLPCLK)
  2594. * @param __PLLCLOCKOUT__ specifies the output PLL clock to be checked.
  2595. * This parameter can be one of the following values:
  2596. * @arg RCC_PLLPCLK This clock may be used to generate the clock for ADC, I2S1.
  2597. * @if defined(STM32G081xx)
  2598. * @arg RCC_PLLQCLK This Clock may be used to generate the clock for the HS Timers,
  2599. * the RNG (<=48 MHz).
  2600. * @endif
  2601. * @arg @ref RCC_PLLRCLK This Clock is used to generate the high speed system clock (up to 64MHz)
  2602. * @retval SET / RESET
  2603. * @note (*) RCC_PLLQCLK availability depends on devices
  2604. */
  2605. #define __HAL_RCC_GET_PLLCLKOUT_CONFIG(__PLLCLOCKOUT__) READ_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2606. /**
  2607. * @brief Macro to configure the system clock source.
  2608. * @param __SYSCLKSOURCE__ specifies the system clock source.
  2609. * This parameter can be one of the following values:
  2610. * @arg @ref RCC_SYSCLKSOURCE_HSI HSI oscillator is used as system clock source.
  2611. * @arg @ref RCC_SYSCLKSOURCE_HSE HSE oscillator is used as system clock source.
  2612. * @arg @ref RCC_SYSCLKSOURCE_PLLCLK PLL output is used as system clock source.
  2613. * @arg @ref RCC_SYSCLKSOURCE_LSI LSI oscillator is used as system clock source.
  2614. * @arg @ref RCC_SYSCLKSOURCE_LSE LSE oscillator is used as system clock source.
  2615. * @retval None
  2616. */
  2617. #define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
  2618. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__SYSCLKSOURCE__))
  2619. /** @brief Macro to get the clock source used as system clock.
  2620. * @retval The clock source used as system clock. The returned value can be one
  2621. * of the following:
  2622. * @arg @ref RCC_SYSCLKSOURCE_STATUS_HSI HSI used as system clock.
  2623. * @arg @ref RCC_SYSCLKSOURCE_STATUS_HSE HSE used as system clock.
  2624. * @arg @ref RCC_SYSCLKSOURCE_STATUS_PLLCLK PLL used as system clock.
  2625. * @arg @ref RCC_SYSCLKSOURCE_STATUS_LSI LSI used as system clock source.
  2626. * @arg @ref RCC_SYSCLKSOURCE_STATUS_LSE LSE used as system clock source.
  2627. */
  2628. #define __HAL_RCC_GET_SYSCLK_SOURCE() (RCC->CFGR & RCC_CFGR_SWS)
  2629. /**
  2630. * @brief Macro to configure the External Low Speed oscillator (LSE) drive capability.
  2631. * @note As the LSE is in the Backup domain and write access is denied to
  2632. * this domain after reset, you have to enable write access using
  2633. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  2634. * (to be done once after reset).
  2635. * @param __LSEDRIVE__ specifies the new state of the LSE drive capability.
  2636. * This parameter can be one of the following values:
  2637. * @arg @ref RCC_LSEDRIVE_LOW LSE oscillator low drive capability.
  2638. * @arg @ref RCC_LSEDRIVE_MEDIUMLOW LSE oscillator medium low drive capability.
  2639. * @arg @ref RCC_LSEDRIVE_MEDIUMHIGH LSE oscillator medium high drive capability.
  2640. * @arg @ref RCC_LSEDRIVE_HIGH LSE oscillator high drive capability.
  2641. * @retval None
  2642. */
  2643. #define __HAL_RCC_LSEDRIVE_CONFIG(__LSEDRIVE__) \
  2644. MODIFY_REG(RCC->BDCR, RCC_BDCR_LSEDRV, (uint32_t)(__LSEDRIVE__))
  2645. /** @brief Macro to configure the Microcontroller output clock.
  2646. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  2647. * This parameter can be one of the following values:
  2648. * @arg @ref RCC_MCO1SOURCE_NOCLOCK MCO output disabled
  2649. * @arg @ref RCC_MCO1SOURCE_SYSCLK System clock selected as MCO source
  2650. * @arg @ref RCC_MCO1SOURCE_HSI HSI clock selected as MCO source
  2651. * @arg @ref RCC_MCO1SOURCE_HSE HSE clock selected as MCO source
  2652. * @arg @ref RCC_MCO1SOURCE_PLLCLK Main PLL clock selected as MCO source
  2653. * @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO source
  2654. * @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO source
  2655. * @arg @ref RCC_MCO1SOURCE_PLLPCLK PLLP output clock selected as MCO source
  2656. * @arg @ref RCC_MCO1SOURCE_PLLQCLK PLLQ output clock selected as MCO source
  2657. * @arg @ref RCC_MCO1SOURCE_RTCCLK RTC clock selected as MCO source
  2658. * @arg @ref RCC_MCO1SOURCE_RTC_WKUP RTC_WKUP clock selected as MCO source
  2659. @if STM32G0C1xx
  2660. * @arg @ref RCC_MCO1SOURCE_HSI48 HSI48 clock selected as MCO source for devices with HSI48
  2661. @endif
  2662. * @param __MCODIV__ specifies the MCO clock prescaler.
  2663. * This parameter can be one of the following values:
  2664. * @arg @ref RCC_MCODIV_1 MCO clock source is divided by 1
  2665. * @arg @ref RCC_MCODIV_2 MCO clock source is divided by 2
  2666. * @arg @ref RCC_MCODIV_4 MCO clock source is divided by 4
  2667. * @arg @ref RCC_MCODIV_8 MCO clock source is divided by 8
  2668. * @arg @ref RCC_MCODIV_16 MCO clock source is divided by 16
  2669. * @arg @ref RCC_MCODIV_32 MCO clock source is divided by 32
  2670. * @arg @ref RCC_MCODIV_64 MCO clock source is divided by 64
  2671. * @arg @ref RCC_MCODIV_128 MCO clock source is divided by 128
  2672. @if STM32G0C1xx
  2673. * @arg @ref RCC_MCODIV_256 MCO clock source is divided by 256
  2674. * @arg @ref RCC_MCODIV_512 MCO clock source is divided by 512
  2675. * @arg @ref RCC_MCODIV_1024 MCO clock source is divided by 1024
  2676. @endif
  2677. */
  2678. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  2679. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  2680. #if defined(RCC_MCO2_SUPPORT)
  2681. /** @brief Macro to configure the Microcontroller output clock 2.
  2682. * @param __MCOCLKSOURCE__ specifies the MCO2 clock source.
  2683. * This parameter can be one of the following values:
  2684. * @arg @ref RCC_MCO2SOURCE_NOCLOCK MCO2 output disabled
  2685. * @arg @ref RCC_MCO2SOURCE_SYSCLK System clock selected as MCO source
  2686. * @arg @ref RCC_MCO2SOURCE_HSI HSI clock selected as MCO2 source
  2687. * @arg @ref RCC_MCO2SOURCE_HSE HSE clock selected as MCO2 source
  2688. * @arg @ref RCC_MCO2SOURCE_PLLCLK Main PLL clock selected as MCO2 source
  2689. * @arg @ref RCC_MCO2SOURCE_LSI LSI clock selected as MCO2 source
  2690. * @arg @ref RCC_MCO2SOURCE_LSE LSE clock selected as MCO2 source
  2691. * @arg @ref RCC_MCO2SOURCE_PLLPCLK PLLP output clock selected as MCO2 source
  2692. * @arg @ref RCC_MCO2SOURCE_PLLQCLK PLLQ output clock selected as MCO2 source
  2693. * @arg @ref RCC_MCO2SOURCE_RTCCLK RTC clock selected as MCO2 source
  2694. * @arg @ref RCC_MCO2SOURCE_RTC_WKUP RTC_WKUP clock selected as MCO2 source
  2695. @if STM32G0C1xx
  2696. * @arg @ref RCC_MCO2SOURCE_HSI48 HSI48 clock selected as MCO2 source for devices with HSI48
  2697. @endif
  2698. * @param __MCODIV__ specifies the MCO clock prescaler.
  2699. * This parameter can be one of the following values:
  2700. * @arg @ref RCC_MCO2DIV_1 MCO2 clock source is divided by 1
  2701. * @arg @ref RCC_MCO2DIV_2 MCO2 clock source is divided by 2
  2702. * @arg @ref RCC_MCO2DIV_4 MCO2 clock source is divided by 4
  2703. * @arg @ref RCC_MCO2DIV_8 MCO2 clock source is divided by 8
  2704. * @arg @ref RCC_MCO2DIV_16 MCO2 clock source is divided by 16
  2705. * @arg @ref RCC_MCO2DIV_32 MCO2 clock source is divided by 32
  2706. * @arg @ref RCC_MCO2DIV_64 MCO2 clock source is divided by 64
  2707. * @arg @ref RCC_MCO2DIV_128 MCO2 clock source is divided by 128
  2708. * @arg @ref RCC_MCO2DIV_256 MCO2 clock source is divided by 256
  2709. * @arg @ref RCC_MCO2DIV_512 MCO2 clock source is divided by 512
  2710. * @arg @ref RCC_MCO2DIV_1024 MCO2 clock source is divided by 1024
  2711. */
  2712. #define __HAL_RCC_MCO2_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  2713. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO2SEL | RCC_CFGR_MCO2PRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  2714. #endif /* RCC_MCO2_SUPPORT */
  2715. /**
  2716. * @}
  2717. */
  2718. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  2719. * @brief macros to manage the specified RCC Flags and interrupts.
  2720. * @{
  2721. */
  2722. /** @brief Enable RCC interrupt.
  2723. * @param __INTERRUPT__ specifies the RCC interrupt sources to be enabled.
  2724. * This parameter can be any combination of the following values:
  2725. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2726. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2727. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2728. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2729. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2730. @if STM32G0C1xx
  2731. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2732. @endif
  2733. * @retval None
  2734. */
  2735. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) SET_BIT(RCC->CIER, (__INTERRUPT__))
  2736. /** @brief Disable RCC interrupt.
  2737. * @param __INTERRUPT__ specifies the RCC interrupt sources to be disabled.
  2738. * This parameter can be any combination of the following values:
  2739. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2740. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2741. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2742. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2743. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2744. @if STM32G0C1xx
  2745. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2746. @endif
  2747. * @retval None
  2748. */
  2749. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(RCC->CIER, (__INTERRUPT__))
  2750. /** @brief Clear RCC interrupt pending bits.
  2751. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  2752. * This parameter can be any combination of the following values:
  2753. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2754. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2755. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2756. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2757. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2758. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  2759. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2760. @if STM32G0C1xx
  2761. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2762. @endif
  2763. * @retval None
  2764. */
  2765. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (RCC->CICR = (__INTERRUPT__))
  2766. /** @brief Check whether the RCC interrupt has occurred or not.
  2767. * @param __INTERRUPT__ specifies the RCC interrupt source to check.
  2768. * This parameter can be one of the following values:
  2769. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2770. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2771. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2772. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2773. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2774. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  2775. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2776. @if STM32G0C1xx
  2777. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2778. @endif
  2779. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  2780. */
  2781. #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIFR & (__INTERRUPT__)) == (__INTERRUPT__))
  2782. /** @brief Set RMVF bit to clear the reset flags.
  2783. * The reset flags are: RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_PWRRST,
  2784. * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
  2785. * @retval None
  2786. */
  2787. #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
  2788. /** @brief Check whether the selected RCC flag is set or not.
  2789. * @param __FLAG__ specifies the flag to check.
  2790. * This parameter can be one of the following values:
  2791. * @arg @ref RCC_FLAG_HSIRDY HSI oscillator clock ready
  2792. * @arg @ref RCC_FLAG_HSERDY HSE oscillator clock ready
  2793. * @arg @ref RCC_FLAG_PLLRDY Main PLL clock ready
  2794. * @arg @ref RCC_FLAG_LSERDY LSE oscillator clock ready
  2795. * @arg @ref RCC_FLAG_LSECSSD Clock security system failure on LSE oscillator detection
  2796. * @arg @ref RCC_FLAG_LSIRDY LSI oscillator clock ready
  2797. @if STM32G0C1xx
  2798. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2799. @endif
  2800. * @arg @ref RCC_FLAG_PWRRST BOR or POR/PDR reset
  2801. * @arg @ref RCC_FLAG_OBLRST OBLRST reset
  2802. * @arg @ref RCC_FLAG_PINRST Pin reset
  2803. * @arg @ref RCC_FLAG_SFTRST Software reset
  2804. * @arg @ref RCC_FLAG_IWDGRST Independent Watchdog reset
  2805. * @arg @ref RCC_FLAG_WWDGRST Window Watchdog reset
  2806. * @arg @ref RCC_FLAG_LPWRRST Low Power reset
  2807. * @retval The new state of __FLAG__ (TRUE or FALSE).
  2808. */
  2809. #if defined(RCC_HSI48_SUPPORT)
  2810. #define __HAL_RCC_GET_FLAG(__FLAG__) \
  2811. (((((((__FLAG__) >> 5U) == CR_REG_INDEX) ? RCC->CR : \
  2812. ((((__FLAG__) >> 5U) == CRRCR_REG_INDEX) ? RCC->CRRCR : \
  2813. ((((__FLAG__) >> 5U) == BDCR_REG_INDEX) ? RCC->BDCR : \
  2814. ((((__FLAG__) >> 5U) == CSR_REG_INDEX) ? RCC->CSR : RCC->CIFR)))) & \
  2815. (1U << ((__FLAG__) & RCC_FLAG_MASK))) != RESET) ? 1U : 0U)
  2816. #else
  2817. #define __HAL_RCC_GET_FLAG(__FLAG__) \
  2818. (((((((__FLAG__) >> 5U) == CR_REG_INDEX) ? RCC->CR : \
  2819. ((((__FLAG__) >> 5U) == BDCR_REG_INDEX) ? RCC->BDCR : \
  2820. ((((__FLAG__) >> 5U) == CSR_REG_INDEX) ? RCC->CSR : RCC->CIFR))) & \
  2821. (1U << ((__FLAG__) & RCC_FLAG_MASK))) != RESET) ? 1U : 0U)
  2822. #endif /* RCC_HSI48_SUPPORT */
  2823. /**
  2824. * @}
  2825. */
  2826. /**
  2827. * @}
  2828. */
  2829. /* Include RCC HAL Extended module */
  2830. #include "stm32g0xx_hal_rcc_ex.h"
  2831. /* Exported functions --------------------------------------------------------*/
  2832. /** @addtogroup RCC_Exported_Functions
  2833. * @{
  2834. */
  2835. /** @addtogroup RCC_Exported_Functions_Group1
  2836. * @{
  2837. */
  2838. /* Initialization and de-initialization functions ******************************/
  2839. HAL_StatusTypeDef HAL_RCC_DeInit(void);
  2840. HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  2841. HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
  2842. /**
  2843. * @}
  2844. */
  2845. /** @addtogroup RCC_Exported_Functions_Group2
  2846. * @{
  2847. */
  2848. /* Peripheral Control functions ************************************************/
  2849. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  2850. void HAL_RCC_EnableCSS(void);
  2851. void HAL_RCC_EnableLSECSS(void);
  2852. void HAL_RCC_DisableLSECSS(void);
  2853. uint32_t HAL_RCC_GetSysClockFreq(void);
  2854. uint32_t HAL_RCC_GetHCLKFreq(void);
  2855. uint32_t HAL_RCC_GetPCLK1Freq(void);
  2856. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  2857. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
  2858. uint32_t HAL_RCC_GetResetSource(void);
  2859. /* LSE & HSE CSS NMI IRQ handler */
  2860. void HAL_RCC_NMI_IRQHandler(void);
  2861. /* User Callbacks in non blocking mode (IT mode) */
  2862. void HAL_RCC_CSSCallback(void);
  2863. void HAL_RCC_LSECSSCallback(void);
  2864. /**
  2865. * @}
  2866. */
  2867. /**
  2868. * @}
  2869. */
  2870. /**
  2871. * @}
  2872. */
  2873. /**
  2874. * @}
  2875. */
  2876. #ifdef __cplusplus
  2877. }
  2878. #endif
  2879. #endif /* STM32G0xx_HAL_RCC_H */