stm32g4xx_hal_rcc.h 163 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406
  1. /**
  2. ******************************************************************************
  3. * @file stm32g4xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2019 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 STM32G4xx_HAL_RCC_H
  19. #define STM32G4xx_HAL_RCC_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32g4xx_hal_def.h"
  25. /** @addtogroup STM32G4xx_HAL_Driver
  26. * @{
  27. */
  28. /** @addtogroup RCC
  29. * @{
  30. */
  31. /* Exported types ------------------------------------------------------------*/
  32. /** @defgroup RCC_Exported_Types RCC Exported Types
  33. * @{
  34. */
  35. /**
  36. * @brief RCC PLL configuration structure definition
  37. */
  38. typedef struct
  39. {
  40. uint32_t PLLState; /*!< The new state of the PLL.
  41. This parameter can be a value of @ref RCC_PLL_Config */
  42. uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
  43. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  44. uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock.
  45. This parameter must be a value of @ref RCC_PLLM_Clock_Divider */
  46. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock.
  47. This parameter must be a number between Min_Data = 8 and Max_Data = 127 */
  48. uint32_t PLLP; /*!< PLLP: Division factor for ADC clock.
  49. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  50. uint32_t PLLQ; /*!< PLLQ: Division factor for SAI, I2S, USB, FDCAN and QUADSPI clocks.
  51. This parameter must be a value of @ref RCC_PLLQ_Clock_Divider */
  52. uint32_t PLLR; /*!< PLLR: Division for the main system clock.
  53. User have to set the PLLR parameter correctly to not exceed max frequency 170MHZ.
  54. This parameter must be a value of @ref RCC_PLLR_Clock_Divider */
  55. }RCC_PLLInitTypeDef;
  56. /**
  57. * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
  58. */
  59. typedef struct
  60. {
  61. uint32_t OscillatorType; /*!< The oscillators to be configured.
  62. This parameter can be a value of @ref RCC_Oscillator_Type */
  63. uint32_t HSEState; /*!< The new state of the HSE.
  64. This parameter can be a value of @ref RCC_HSE_Config */
  65. uint32_t LSEState; /*!< The new state of the LSE.
  66. This parameter can be a value of @ref RCC_LSE_Config */
  67. uint32_t HSIState; /*!< The new state of the HSI.
  68. This parameter can be a value of @ref RCC_HSI_Config */
  69. uint32_t HSICalibrationValue; /*!< The calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  70. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */
  71. uint32_t LSIState; /*!< The new state of the LSI.
  72. This parameter can be a value of @ref RCC_LSI_Config */
  73. uint32_t HSI48State; /*!< The new state of the HSI48.
  74. This parameter can be a value of @ref RCC_HSI48_Config */
  75. RCC_PLLInitTypeDef PLL; /*!< Main PLL structure parameters */
  76. }RCC_OscInitTypeDef;
  77. /**
  78. * @brief RCC System, AHB and APB busses clock configuration structure definition
  79. */
  80. typedef struct
  81. {
  82. uint32_t ClockType; /*!< The clock to be configured.
  83. This parameter can be a value of @ref RCC_System_Clock_Type */
  84. uint32_t SYSCLKSource; /*!< The clock source used as system clock (SYSCLK).
  85. This parameter can be a value of @ref RCC_System_Clock_Source */
  86. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  87. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  88. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  89. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  90. uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
  91. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  92. }RCC_ClkInitTypeDef;
  93. /**
  94. * @}
  95. */
  96. /* Exported constants --------------------------------------------------------*/
  97. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  98. * @{
  99. */
  100. /** @defgroup RCC_Timeout_Value Timeout Values
  101. * @{
  102. */
  103. #define RCC_DBP_TIMEOUT_VALUE 2U /* 2 ms (minimum Tick + 1) */
  104. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
  105. /**
  106. * @}
  107. */
  108. /** @defgroup RCC_Oscillator_Type Oscillator Type
  109. * @{
  110. */
  111. #define RCC_OSCILLATORTYPE_NONE 0x00000000U /*!< Oscillator configuration unchanged */
  112. #define RCC_OSCILLATORTYPE_HSE 0x00000001U /*!< HSE to configure */
  113. #define RCC_OSCILLATORTYPE_HSI 0x00000002U /*!< HSI to configure */
  114. #define RCC_OSCILLATORTYPE_LSE 0x00000004U /*!< LSE to configure */
  115. #define RCC_OSCILLATORTYPE_LSI 0x00000008U /*!< LSI to configure */
  116. #define RCC_OSCILLATORTYPE_HSI48 0x00000020U /*!< HSI48 to configure */
  117. /**
  118. * @}
  119. */
  120. /** @defgroup RCC_HSE_Config HSE Config
  121. * @{
  122. */
  123. #define RCC_HSE_OFF 0x00000000U /*!< HSE clock deactivation */
  124. #define RCC_HSE_ON RCC_CR_HSEON /*!< HSE clock activation */
  125. #define RCC_HSE_BYPASS (RCC_CR_HSEBYP | RCC_CR_HSEON) /*!< External clock source for HSE clock */
  126. /**
  127. * @}
  128. */
  129. /** @defgroup RCC_LSE_Config LSE Config
  130. * @{
  131. */
  132. #define RCC_LSE_OFF 0x00000000U /*!< LSE clock deactivation */
  133. #define RCC_LSE_ON RCC_BDCR_LSEON /*!< LSE clock activation */
  134. #define RCC_LSE_BYPASS (RCC_BDCR_LSEBYP | RCC_BDCR_LSEON) /*!< External clock source for LSE clock */
  135. /**
  136. * @}
  137. */
  138. /** @defgroup RCC_HSI_Config HSI Config
  139. * @{
  140. */
  141. #define RCC_HSI_OFF 0x00000000U /*!< HSI clock deactivation */
  142. #define RCC_HSI_ON RCC_CR_HSION /*!< HSI clock activation */
  143. #define RCC_HSICALIBRATION_DEFAULT 0x40U /* Default HSI calibration trimming value */
  144. /**
  145. * @}
  146. */
  147. /** @defgroup RCC_LSI_Config LSI Config
  148. * @{
  149. */
  150. #define RCC_LSI_OFF 0x00000000U /*!< LSI clock deactivation */
  151. #define RCC_LSI_ON RCC_CSR_LSION /*!< LSI clock activation */
  152. /**
  153. * @}
  154. */
  155. /** @defgroup RCC_HSI48_Config HSI48 Config
  156. * @{
  157. */
  158. #define RCC_HSI48_OFF 0x00000000U /*!< HSI48 clock deactivation */
  159. #define RCC_HSI48_ON RCC_CRRCR_HSI48ON /*!< HSI48 clock activation */
  160. /**
  161. * @}
  162. */
  163. /** @defgroup RCC_PLL_Config PLL Config
  164. * @{
  165. */
  166. #define RCC_PLL_NONE 0x00000000U /*!< PLL configuration unchanged */
  167. #define RCC_PLL_OFF 0x00000001U /*!< PLL deactivation */
  168. #define RCC_PLL_ON 0x00000002U /*!< PLL activation */
  169. /**
  170. * @}
  171. */
  172. /** @defgroup RCC_PLLM_Clock_Divider PLLM Clock Divider
  173. * @{
  174. */
  175. #define RCC_PLLM_DIV1 0x00000001U /*!< PLLM division factor = 1 */
  176. #define RCC_PLLM_DIV2 0x00000002U /*!< PLLM division factor = 2 */
  177. #define RCC_PLLM_DIV3 0x00000003U /*!< PLLM division factor = 3 */
  178. #define RCC_PLLM_DIV4 0x00000004U /*!< PLLM division factor = 4 */
  179. #define RCC_PLLM_DIV5 0x00000005U /*!< PLLM division factor = 5 */
  180. #define RCC_PLLM_DIV6 0x00000006U /*!< PLLM division factor = 6 */
  181. #define RCC_PLLM_DIV7 0x00000007U /*!< PLLM division factor = 7 */
  182. #define RCC_PLLM_DIV8 0x00000008U /*!< PLLM division factor = 8 */
  183. #define RCC_PLLM_DIV9 0x00000009U /*!< PLLM division factor = 9 */
  184. #define RCC_PLLM_DIV10 0x0000000AU /*!< PLLM division factor = 10 */
  185. #define RCC_PLLM_DIV11 0x0000000BU /*!< PLLM division factor = 11 */
  186. #define RCC_PLLM_DIV12 0x0000000CU /*!< PLLM division factor = 12 */
  187. #define RCC_PLLM_DIV13 0x0000000DU /*!< PLLM division factor = 13 */
  188. #define RCC_PLLM_DIV14 0x0000000EU /*!< PLLM division factor = 14 */
  189. #define RCC_PLLM_DIV15 0x0000000FU /*!< PLLM division factor = 15 */
  190. #define RCC_PLLM_DIV16 0x00000010U /*!< PLLM division factor = 16 */
  191. /**
  192. * @}
  193. */
  194. /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
  195. * @{
  196. */
  197. #define RCC_PLLP_DIV2 0x00000002U /*!< PLLP division factor = 2 */
  198. #define RCC_PLLP_DIV3 0x00000003U /*!< PLLP division factor = 3 */
  199. #define RCC_PLLP_DIV4 0x00000004U /*!< PLLP division factor = 4 */
  200. #define RCC_PLLP_DIV5 0x00000005U /*!< PLLP division factor = 5 */
  201. #define RCC_PLLP_DIV6 0x00000006U /*!< PLLP division factor = 6 */
  202. #define RCC_PLLP_DIV7 0x00000007U /*!< PLLP division factor = 7 */
  203. #define RCC_PLLP_DIV8 0x00000008U /*!< PLLP division factor = 8 */
  204. #define RCC_PLLP_DIV9 0x00000009U /*!< PLLP division factor = 9 */
  205. #define RCC_PLLP_DIV10 0x0000000AU /*!< PLLP division factor = 10 */
  206. #define RCC_PLLP_DIV11 0x0000000BU /*!< PLLP division factor = 11 */
  207. #define RCC_PLLP_DIV12 0x0000000CU /*!< PLLP division factor = 12 */
  208. #define RCC_PLLP_DIV13 0x0000000DU /*!< PLLP division factor = 13 */
  209. #define RCC_PLLP_DIV14 0x0000000EU /*!< PLLP division factor = 14 */
  210. #define RCC_PLLP_DIV15 0x0000000FU /*!< PLLP division factor = 15 */
  211. #define RCC_PLLP_DIV16 0x00000010U /*!< PLLP division factor = 16 */
  212. #define RCC_PLLP_DIV17 0x00000011U /*!< PLLP division factor = 17 */
  213. #define RCC_PLLP_DIV18 0x00000012U /*!< PLLP division factor = 18 */
  214. #define RCC_PLLP_DIV19 0x00000013U /*!< PLLP division factor = 19 */
  215. #define RCC_PLLP_DIV20 0x00000014U /*!< PLLP division factor = 20 */
  216. #define RCC_PLLP_DIV21 0x00000015U /*!< PLLP division factor = 21 */
  217. #define RCC_PLLP_DIV22 0x00000016U /*!< PLLP division factor = 22 */
  218. #define RCC_PLLP_DIV23 0x00000017U /*!< PLLP division factor = 23 */
  219. #define RCC_PLLP_DIV24 0x00000018U /*!< PLLP division factor = 24 */
  220. #define RCC_PLLP_DIV25 0x00000019U /*!< PLLP division factor = 25 */
  221. #define RCC_PLLP_DIV26 0x0000001AU /*!< PLLP division factor = 26 */
  222. #define RCC_PLLP_DIV27 0x0000001BU /*!< PLLP division factor = 27 */
  223. #define RCC_PLLP_DIV28 0x0000001CU /*!< PLLP division factor = 28 */
  224. #define RCC_PLLP_DIV29 0x0000001DU /*!< PLLP division factor = 29 */
  225. #define RCC_PLLP_DIV30 0x0000001EU /*!< PLLP division factor = 30 */
  226. #define RCC_PLLP_DIV31 0x0000001FU /*!< PLLP division factor = 31 */
  227. /**
  228. * @}
  229. */
  230. /** @defgroup RCC_PLLQ_Clock_Divider PLLQ Clock Divider
  231. * @{
  232. */
  233. #define RCC_PLLQ_DIV2 0x00000002U /*!< PLLQ division factor = 2 */
  234. #define RCC_PLLQ_DIV4 0x00000004U /*!< PLLQ division factor = 4 */
  235. #define RCC_PLLQ_DIV6 0x00000006U /*!< PLLQ division factor = 6 */
  236. #define RCC_PLLQ_DIV8 0x00000008U /*!< PLLQ division factor = 8 */
  237. /**
  238. * @}
  239. */
  240. /** @defgroup RCC_PLLR_Clock_Divider PLLR Clock Divider
  241. * @{
  242. */
  243. #define RCC_PLLR_DIV2 0x00000002U /*!< PLLR division factor = 2 */
  244. #define RCC_PLLR_DIV4 0x00000004U /*!< PLLR division factor = 4 */
  245. #define RCC_PLLR_DIV6 0x00000006U /*!< PLLR division factor = 6 */
  246. #define RCC_PLLR_DIV8 0x00000008U /*!< PLLR division factor = 8 */
  247. /**
  248. * @}
  249. */
  250. /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
  251. * @{
  252. */
  253. #define RCC_PLLSOURCE_NONE 0x00000000U /*!< No clock selected as PLL entry clock source */
  254. #define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI /*!< HSI clock selected as PLL entry clock source */
  255. #define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */
  256. /**
  257. * @}
  258. */
  259. /** @defgroup RCC_PLL_Clock_Output PLL Clock Output
  260. * @{
  261. */
  262. #define RCC_PLL_ADCCLK RCC_PLLCFGR_PLLPEN /*!< PLLADCCLK selection from main PLL */
  263. #define RCC_PLL_48M1CLK RCC_PLLCFGR_PLLQEN /*!< PLL48M1CLK selection from main PLL */
  264. #define RCC_PLL_SYSCLK RCC_PLLCFGR_PLLREN /*!< PLLCLK selection from main PLL */
  265. /**
  266. * @}
  267. */
  268. /** @defgroup RCC_System_Clock_Type System Clock Type
  269. * @{
  270. */
  271. #define RCC_CLOCKTYPE_SYSCLK 0x00000001U /*!< SYSCLK to configure */
  272. #define RCC_CLOCKTYPE_HCLK 0x00000002U /*!< HCLK to configure */
  273. #define RCC_CLOCKTYPE_PCLK1 0x00000004U /*!< PCLK1 to configure */
  274. #define RCC_CLOCKTYPE_PCLK2 0x00000008U /*!< PCLK2 to configure */
  275. /**
  276. * @}
  277. */
  278. /** @defgroup RCC_System_Clock_Source System Clock Source
  279. * @{
  280. */
  281. #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI /*!< HSI selection as system clock */
  282. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE /*!< HSE selection as system clock */
  283. #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL /*!< PLL selection as system clock */
  284. /**
  285. * @}
  286. */
  287. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  288. * @{
  289. */
  290. #define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  291. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  292. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  293. /**
  294. * @}
  295. */
  296. /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
  297. * @{
  298. */
  299. #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1 /*!< SYSCLK not divided */
  300. #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2 /*!< SYSCLK divided by 2 */
  301. #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4 /*!< SYSCLK divided by 4 */
  302. #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8 /*!< SYSCLK divided by 8 */
  303. #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16 /*!< SYSCLK divided by 16 */
  304. #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64 /*!< SYSCLK divided by 64 */
  305. #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128 /*!< SYSCLK divided by 128 */
  306. #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256 /*!< SYSCLK divided by 256 */
  307. #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
  308. /**
  309. * @}
  310. */
  311. /** @defgroup RCC_APB1_APB2_Clock_Source APB1 APB2 Clock Source
  312. * @{
  313. */
  314. #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1 /*!< HCLK not divided */
  315. #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2 /*!< HCLK divided by 2 */
  316. #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4 /*!< HCLK divided by 4 */
  317. #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8 /*!< HCLK divided by 8 */
  318. #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16 /*!< HCLK divided by 16 */
  319. /**
  320. * @}
  321. */
  322. /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
  323. * @{
  324. */
  325. #define RCC_RTCCLKSOURCE_NONE 0x00000000U /*!< No clock used as RTC clock */
  326. #define RCC_RTCCLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
  327. #define RCC_RTCCLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
  328. #define RCC_RTCCLKSOURCE_HSE_DIV32 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 32 used as RTC clock */
  329. /**
  330. * @}
  331. */
  332. /** @defgroup RCC_MCO_Index MCO Index
  333. * @{
  334. */
  335. /* 32 28 20 16 0
  336. --------------------------------
  337. | MCO | GPIO | GPIO | GPIO |
  338. | Index | AF | Port | Pin |
  339. -------------------------------*/
  340. #define RCC_MCO_GPIOPORT_POS 16U
  341. #define RCC_MCO_GPIOPORT_MASK (0xFUL << RCC_MCO_GPIOPORT_POS)
  342. #define RCC_MCO_GPIOAF_POS 20U
  343. #define RCC_MCO_GPIOAF_MASK (0xFFUL << RCC_MCO_GPIOAF_POS)
  344. #define RCC_MCO_INDEX_POS 28U
  345. #define RCC_MCO_INDEX_MASK (0x1UL << RCC_MCO_INDEX_POS)
  346. #define RCC_MCO1_INDEX (0x0UL << RCC_MCO_INDEX_POS) /*!< MCO1 index */
  347. #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)
  348. #define RCC_MCO_PG10 (RCC_MCO1_INDEX | (GPIO_AF0_MCO << RCC_MCO_GPIOAF_POS) | (GPIO_GET_INDEX(GPIOG) << RCC_MCO_GPIOPORT_POS) | GPIO_PIN_10)
  349. /* Legacy Defines*/
  350. #define RCC_MCO1 RCC_MCO_PA8
  351. #define RCC_MCO RCC_MCO1 /*!< MCO1 to be compliant with other families with 2 MCOs*/
  352. /**
  353. * @}
  354. */
  355. /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
  356. * @{
  357. */
  358. #define RCC_MCO1SOURCE_NOCLOCK 0x00000000U /*!< MCO1 output disabled, no clock on MCO1 */
  359. #define RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCOSEL_0 /*!< SYSCLK selection as MCO1 source */
  360. #define RCC_MCO1SOURCE_HSI (RCC_CFGR_MCOSEL_0| RCC_CFGR_MCOSEL_1) /*!< HSI selection as MCO1 source */
  361. #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCOSEL_2 /*!< HSE selection as MCO1 source */
  362. #define RCC_MCO1SOURCE_PLLCLK (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_2) /*!< PLLCLK selection as MCO1 source */
  363. #define RCC_MCO1SOURCE_LSI (RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSI selection as MCO1 source */
  364. #define RCC_MCO1SOURCE_LSE (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSE selection as MCO1 source */
  365. #define RCC_MCO1SOURCE_HSI48 RCC_CFGR_MCOSEL_3 /*!< HSI48 selection as MCO1 source */
  366. /**
  367. * @}
  368. */
  369. /** @defgroup RCC_MCOx_Clock_Prescaler MCO1 Clock Prescaler
  370. * @{
  371. */
  372. #define RCC_MCODIV_1 RCC_CFGR_MCOPRE_DIV1 /*!< MCO not divided */
  373. #define RCC_MCODIV_2 RCC_CFGR_MCOPRE_DIV2 /*!< MCO divided by 2 */
  374. #define RCC_MCODIV_4 RCC_CFGR_MCOPRE_DIV4 /*!< MCO divided by 4 */
  375. #define RCC_MCODIV_8 RCC_CFGR_MCOPRE_DIV8 /*!< MCO divided by 8 */
  376. #define RCC_MCODIV_16 RCC_CFGR_MCOPRE_DIV16 /*!< MCO divided by 16 */
  377. /**
  378. * @}
  379. */
  380. /** @defgroup RCC_Interrupt Interrupts
  381. * @{
  382. */
  383. #define RCC_IT_LSIRDY RCC_CIFR_LSIRDYF /*!< LSI Ready Interrupt flag */
  384. #define RCC_IT_LSERDY RCC_CIFR_LSERDYF /*!< LSE Ready Interrupt flag */
  385. #define RCC_IT_HSIRDY RCC_CIFR_HSIRDYF /*!< HSI16 Ready Interrupt flag */
  386. #define RCC_IT_HSERDY RCC_CIFR_HSERDYF /*!< HSE Ready Interrupt flag */
  387. #define RCC_IT_PLLRDY RCC_CIFR_PLLRDYF /*!< PLL Ready Interrupt flag */
  388. #define RCC_IT_CSS RCC_CIFR_CSSF /*!< Clock Security System Interrupt flag */
  389. #define RCC_IT_LSECSS RCC_CIFR_LSECSSF /*!< LSE Clock Security System Interrupt flag */
  390. #define RCC_IT_HSI48RDY RCC_CIFR_HSI48RDYF /*!< HSI48 Ready Interrupt flag */
  391. /**
  392. * @}
  393. */
  394. /** @defgroup RCC_Flag Flags
  395. * Elements values convention: XXXYYYYYb
  396. * - YYYYY : Flag position in the register
  397. * - XXX : Register index
  398. * - 001: CR register
  399. * - 010: BDCR register
  400. * - 011: CSR register
  401. * - 100: CRRCR register
  402. * @{
  403. */
  404. /* Flags in the CR register */
  405. #define RCC_FLAG_HSIRDY ((CR_REG_INDEX << 5U) | RCC_CR_HSIRDY_Pos) /*!< HSI Ready flag */
  406. #define RCC_FLAG_HSERDY ((CR_REG_INDEX << 5U) | RCC_CR_HSERDY_Pos) /*!< HSE Ready flag */
  407. #define RCC_FLAG_PLLRDY ((CR_REG_INDEX << 5U) | RCC_CR_PLLRDY_Pos) /*!< PLL Ready flag */
  408. /* Flags in the BDCR register */
  409. #define RCC_FLAG_LSERDY ((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSERDY_Pos) /*!< LSE Ready flag */
  410. #define RCC_FLAG_LSECSSD ((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSECSSD_Pos) /*!< LSE Clock Security System Interrupt flag */
  411. /* Flags in the CSR register */
  412. #define RCC_FLAG_LSIRDY ((CSR_REG_INDEX << 5U) | RCC_CSR_LSIRDY_Pos) /*!< LSI Ready flag */
  413. #define RCC_FLAG_OBLRST ((CSR_REG_INDEX << 5U) | RCC_CSR_OBLRSTF_Pos) /*!< Option Byte Loader reset flag */
  414. #define RCC_FLAG_PINRST ((CSR_REG_INDEX << 5U) | RCC_CSR_PINRSTF_Pos) /*!< PIN reset flag */
  415. #define RCC_FLAG_BORRST ((CSR_REG_INDEX << 5U) | RCC_CSR_BORRSTF_Pos) /*!< BOR reset flag */
  416. #define RCC_FLAG_SFTRST ((CSR_REG_INDEX << 5U) | RCC_CSR_SFTRSTF_Pos) /*!< Software Reset flag */
  417. #define RCC_FLAG_IWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_IWDGRSTF_Pos) /*!< Independent Watchdog reset flag */
  418. #define RCC_FLAG_WWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_WWDGRSTF_Pos) /*!< Window watchdog reset flag */
  419. #define RCC_FLAG_LPWRRST ((CSR_REG_INDEX << 5U) | RCC_CSR_LPWRRSTF_Pos) /*!< Low-Power reset flag */
  420. /* Flags in the CRRCR register */
  421. #define RCC_FLAG_HSI48RDY ((CRRCR_REG_INDEX << 5U) | RCC_CRRCR_HSI48RDY_Pos) /*!< HSI48 Ready flag */
  422. /**
  423. * @}
  424. */
  425. /** @defgroup RCC_LSEDrive_Config LSE Drive Config
  426. * @{
  427. */
  428. #define RCC_LSEDRIVE_LOW 0x00000000U /*!< LSE low drive capability */
  429. #define RCC_LSEDRIVE_MEDIUMLOW RCC_BDCR_LSEDRV_0 /*!< LSE medium low drive capability */
  430. #define RCC_LSEDRIVE_MEDIUMHIGH RCC_BDCR_LSEDRV_1 /*!< LSE medium high drive capability */
  431. #define RCC_LSEDRIVE_HIGH RCC_BDCR_LSEDRV /*!< LSE high drive capability */
  432. /**
  433. * @}
  434. */
  435. /**
  436. * @}
  437. */
  438. /* Exported macros -----------------------------------------------------------*/
  439. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  440. * @{
  441. */
  442. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  443. * @brief Enable or disable the AHB1 peripheral clock.
  444. * @note After reset, the peripheral clock (used for registers read/write access)
  445. * is disabled and the application software has to enable this clock before
  446. * using it.
  447. * @{
  448. */
  449. #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
  450. __IO uint32_t tmpreg; \
  451. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN); \
  452. /* Delay after an RCC peripheral clock enabling */ \
  453. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN); \
  454. UNUSED(tmpreg); \
  455. } while(0)
  456. #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
  457. __IO uint32_t tmpreg; \
  458. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN); \
  459. /* Delay after an RCC peripheral clock enabling */ \
  460. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN); \
  461. UNUSED(tmpreg); \
  462. } while(0)
  463. #define __HAL_RCC_DMAMUX1_CLK_ENABLE() do { \
  464. __IO uint32_t tmpreg; \
  465. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN); \
  466. /* Delay after an RCC peripheral clock enabling */ \
  467. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN); \
  468. UNUSED(tmpreg); \
  469. } while(0)
  470. #define __HAL_RCC_CORDIC_CLK_ENABLE() do { \
  471. __IO uint32_t tmpreg; \
  472. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN); \
  473. /* Delay after an RCC peripheral clock enabling */ \
  474. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN); \
  475. UNUSED(tmpreg); \
  476. } while(0)
  477. #define __HAL_RCC_FMAC_CLK_ENABLE() do { \
  478. __IO uint32_t tmpreg; \
  479. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN); \
  480. /* Delay after an RCC peripheral clock enabling */ \
  481. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN); \
  482. UNUSED(tmpreg); \
  483. } while(0)
  484. #define __HAL_RCC_FLASH_CLK_ENABLE() do { \
  485. __IO uint32_t tmpreg; \
  486. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN); \
  487. /* Delay after an RCC peripheral clock enabling */ \
  488. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN); \
  489. UNUSED(tmpreg); \
  490. } while(0)
  491. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  492. __IO uint32_t tmpreg; \
  493. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  494. /* Delay after an RCC peripheral clock enabling */ \
  495. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  496. UNUSED(tmpreg); \
  497. } while(0)
  498. #define __HAL_RCC_DMA1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN)
  499. #define __HAL_RCC_DMA2_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN)
  500. #define __HAL_RCC_DMAMUX1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN)
  501. #define __HAL_RCC_CORDIC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN)
  502. #define __HAL_RCC_FMAC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN)
  503. #define __HAL_RCC_FLASH_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN)
  504. #define __HAL_RCC_CRC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN)
  505. /**
  506. * @}
  507. */
  508. /** @defgroup RCC_AHB2_Peripheral_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  509. * @brief Enable or disable the AHB2 peripheral clock.
  510. * @note After reset, the peripheral clock (used for registers read/write access)
  511. * is disabled and the application software has to enable this clock before
  512. * using it.
  513. * @{
  514. */
  515. #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
  516. __IO uint32_t tmpreg; \
  517. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  518. /* Delay after an RCC peripheral clock enabling */ \
  519. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  520. UNUSED(tmpreg); \
  521. } while(0)
  522. #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
  523. __IO uint32_t tmpreg; \
  524. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  525. /* Delay after an RCC peripheral clock enabling */ \
  526. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  527. UNUSED(tmpreg); \
  528. } while(0)
  529. #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
  530. __IO uint32_t tmpreg; \
  531. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  532. /* Delay after an RCC peripheral clock enabling */ \
  533. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  534. UNUSED(tmpreg); \
  535. } while(0)
  536. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  537. __IO uint32_t tmpreg; \
  538. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  539. /* Delay after an RCC peripheral clock enabling */ \
  540. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  541. UNUSED(tmpreg); \
  542. } while(0)
  543. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  544. __IO uint32_t tmpreg; \
  545. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  546. /* Delay after an RCC peripheral clock enabling */ \
  547. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  548. UNUSED(tmpreg); \
  549. } while(0)
  550. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  551. __IO uint32_t tmpreg; \
  552. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  553. /* Delay after an RCC peripheral clock enabling */ \
  554. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  555. UNUSED(tmpreg); \
  556. } while(0)
  557. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  558. __IO uint32_t tmpreg; \
  559. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  560. /* Delay after an RCC peripheral clock enabling */ \
  561. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  562. UNUSED(tmpreg); \
  563. } while(0)
  564. #define __HAL_RCC_ADC12_CLK_ENABLE() do { \
  565. __IO uint32_t tmpreg; \
  566. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC12EN); \
  567. /* Delay after an RCC peripheral clock enabling */ \
  568. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC12EN); \
  569. UNUSED(tmpreg); \
  570. } while(0)
  571. #if defined(ADC345_COMMON)
  572. #define __HAL_RCC_ADC345_CLK_ENABLE() do { \
  573. __IO uint32_t tmpreg; \
  574. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC345EN); \
  575. /* Delay after an RCC peripheral clock enabling */ \
  576. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC345EN); \
  577. UNUSED(tmpreg); \
  578. } while(0)
  579. #endif /* ADC345_COMMON */
  580. #define __HAL_RCC_DAC1_CLK_ENABLE() do { \
  581. __IO uint32_t tmpreg; \
  582. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN); \
  583. /* Delay after an RCC peripheral clock enabling */ \
  584. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN); \
  585. UNUSED(tmpreg); \
  586. } while(0)
  587. #if defined(DAC2)
  588. #define __HAL_RCC_DAC2_CLK_ENABLE() do { \
  589. __IO uint32_t tmpreg; \
  590. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC2EN); \
  591. /* Delay after an RCC peripheral clock enabling */ \
  592. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC2EN); \
  593. UNUSED(tmpreg); \
  594. } while(0)
  595. #endif /* DAC2 */
  596. #define __HAL_RCC_DAC3_CLK_ENABLE() do { \
  597. __IO uint32_t tmpreg; \
  598. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC3EN); \
  599. /* Delay after an RCC peripheral clock enabling */ \
  600. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC3EN); \
  601. UNUSED(tmpreg); \
  602. } while(0)
  603. #if defined(DAC4)
  604. #define __HAL_RCC_DAC4_CLK_ENABLE() do { \
  605. __IO uint32_t tmpreg; \
  606. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC4EN); \
  607. /* Delay after an RCC peripheral clock enabling */ \
  608. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC4EN); \
  609. UNUSED(tmpreg); \
  610. } while(0)
  611. #endif /* DAC4 */
  612. #if defined(AES)
  613. #define __HAL_RCC_AES_CLK_ENABLE() do { \
  614. __IO uint32_t tmpreg; \
  615. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  616. /* Delay after an RCC peripheral clock enabling */ \
  617. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  618. UNUSED(tmpreg); \
  619. } while(0)
  620. #endif /* AES */
  621. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  622. __IO uint32_t tmpreg; \
  623. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  624. /* Delay after an RCC peripheral clock enabling */ \
  625. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  626. UNUSED(tmpreg); \
  627. } while(0)
  628. #define __HAL_RCC_GPIOA_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN)
  629. #define __HAL_RCC_GPIOB_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN)
  630. #define __HAL_RCC_GPIOC_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN)
  631. #define __HAL_RCC_GPIOD_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN)
  632. #define __HAL_RCC_GPIOE_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN)
  633. #define __HAL_RCC_GPIOF_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN)
  634. #define __HAL_RCC_GPIOG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN)
  635. #define __HAL_RCC_ADC12_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC12EN)
  636. #if defined(ADC345_COMMON)
  637. #define __HAL_RCC_ADC345_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC345EN)
  638. #endif /* ADC345_COMMON */
  639. #define __HAL_RCC_DAC1_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN)
  640. #if defined(DAC2)
  641. #define __HAL_RCC_DAC2_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC2EN)
  642. #endif /* DAC2 */
  643. #define __HAL_RCC_DAC3_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC3EN)
  644. #if defined(DAC4)
  645. #define __HAL_RCC_DAC4_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC4EN)
  646. #endif /* DAC4 */
  647. #if defined(AES)
  648. #define __HAL_RCC_AES_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN);
  649. #endif /* AES */
  650. #define __HAL_RCC_RNG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN)
  651. /**
  652. * @}
  653. */
  654. /** @defgroup RCC_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  655. * @brief Enable or disable the AHB3 peripheral clock.
  656. * @note After reset, the peripheral clock (used for registers read/write access)
  657. * is disabled and the application software has to enable this clock before
  658. * using it.
  659. * @{
  660. */
  661. #if defined(FMC_BANK1)
  662. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  663. __IO uint32_t tmpreg; \
  664. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); \
  665. /* Delay after an RCC peripheral clock enabling */ \
  666. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); \
  667. UNUSED(tmpreg); \
  668. } while(0)
  669. #endif /* FMC_BANK1 */
  670. #if defined(QUADSPI)
  671. #define __HAL_RCC_QSPI_CLK_ENABLE() do { \
  672. __IO uint32_t tmpreg; \
  673. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN); \
  674. /* Delay after an RCC peripheral clock enabling */ \
  675. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN); \
  676. UNUSED(tmpreg); \
  677. } while(0)
  678. #endif /* QUADSPI */
  679. #if defined(FMC_BANK1)
  680. #define __HAL_RCC_FMC_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN)
  681. #endif /* FMC_BANK1 */
  682. #if defined(QUADSPI)
  683. #define __HAL_RCC_QSPI_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN)
  684. #endif /* QUADSPI */
  685. /**
  686. * @}
  687. */
  688. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  689. * @brief Enable or disable the APB1 peripheral clock.
  690. * @note After reset, the peripheral clock (used for registers read/write access)
  691. * is disabled and the application software has to enable this clock before
  692. * using it.
  693. * @{
  694. */
  695. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  696. __IO uint32_t tmpreg; \
  697. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN); \
  698. /* Delay after an RCC peripheral clock enabling */ \
  699. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN); \
  700. UNUSED(tmpreg); \
  701. } while(0)
  702. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  703. __IO uint32_t tmpreg; \
  704. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN); \
  705. /* Delay after an RCC peripheral clock enabling */ \
  706. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN); \
  707. UNUSED(tmpreg); \
  708. } while(0)
  709. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  710. __IO uint32_t tmpreg; \
  711. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN); \
  712. /* Delay after an RCC peripheral clock enabling */ \
  713. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN); \
  714. UNUSED(tmpreg); \
  715. } while(0)
  716. #if defined(TIM5)
  717. #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
  718. __IO uint32_t tmpreg; \
  719. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN); \
  720. /* Delay after an RCC peripheral clock enabling */ \
  721. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN); \
  722. UNUSED(tmpreg); \
  723. } while(0)
  724. #endif /* TIM5 */
  725. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  726. __IO uint32_t tmpreg; \
  727. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN); \
  728. /* Delay after an RCC peripheral clock enabling */ \
  729. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN); \
  730. UNUSED(tmpreg); \
  731. } while(0)
  732. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  733. __IO uint32_t tmpreg; \
  734. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN); \
  735. /* Delay after an RCC peripheral clock enabling */ \
  736. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN); \
  737. UNUSED(tmpreg); \
  738. } while(0)
  739. #define __HAL_RCC_CRS_CLK_ENABLE() do { \
  740. __IO uint32_t tmpreg; \
  741. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN); \
  742. /* Delay after an RCC peripheral clock enabling */ \
  743. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN); \
  744. UNUSED(tmpreg); \
  745. } while(0)
  746. #define __HAL_RCC_RTCAPB_CLK_ENABLE() do { \
  747. __IO uint32_t tmpreg; \
  748. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN); \
  749. /* Delay after an RCC peripheral clock enabling */ \
  750. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN); \
  751. UNUSED(tmpreg); \
  752. } while(0)
  753. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  754. __IO uint32_t tmpreg; \
  755. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN); \
  756. /* Delay after an RCC peripheral clock enabling */ \
  757. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN); \
  758. UNUSED(tmpreg); \
  759. } while(0)
  760. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  761. __IO uint32_t tmpreg; \
  762. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN); \
  763. /* Delay after an RCC peripheral clock enabling */ \
  764. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN); \
  765. UNUSED(tmpreg); \
  766. } while(0)
  767. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  768. __IO uint32_t tmpreg; \
  769. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN); \
  770. /* Delay after an RCC peripheral clock enabling */ \
  771. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN); \
  772. UNUSED(tmpreg); \
  773. } while(0)
  774. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  775. __IO uint32_t tmpreg; \
  776. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN); \
  777. /* Delay after an RCC peripheral clock enabling */ \
  778. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN); \
  779. UNUSED(tmpreg); \
  780. } while(0)
  781. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  782. __IO uint32_t tmpreg; \
  783. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \
  784. /* Delay after an RCC peripheral clock enabling */ \
  785. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \
  786. UNUSED(tmpreg); \
  787. } while(0)
  788. #if defined(UART4)
  789. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  790. __IO uint32_t tmpreg; \
  791. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN); \
  792. /* Delay after an RCC peripheral clock enabling */ \
  793. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN); \
  794. UNUSED(tmpreg); \
  795. } while(0)
  796. #endif /* UART4 */
  797. #if defined(UART5)
  798. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  799. __IO uint32_t tmpreg; \
  800. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN); \
  801. /* Delay after an RCC peripheral clock enabling */ \
  802. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN); \
  803. UNUSED(tmpreg); \
  804. } while(0)
  805. #endif /* UART5 */
  806. #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
  807. __IO uint32_t tmpreg; \
  808. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN); \
  809. /* Delay after an RCC peripheral clock enabling */ \
  810. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN); \
  811. UNUSED(tmpreg); \
  812. } while(0)
  813. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  814. __IO uint32_t tmpreg; \
  815. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN); \
  816. /* Delay after an RCC peripheral clock enabling */ \
  817. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN); \
  818. UNUSED(tmpreg); \
  819. } while(0)
  820. #define __HAL_RCC_USB_CLK_ENABLE() do { \
  821. __IO uint32_t tmpreg; \
  822. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBEN); \
  823. /* Delay after an RCC peripheral clock enabling */ \
  824. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBEN); \
  825. UNUSED(tmpreg); \
  826. } while(0)
  827. #if defined(FDCAN1)
  828. #define __HAL_RCC_FDCAN_CLK_ENABLE() do { \
  829. __IO uint32_t tmpreg; \
  830. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_FDCANEN); \
  831. /* Delay after an RCC peripheral clock enabling */ \
  832. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_FDCANEN); \
  833. UNUSED(tmpreg); \
  834. } while(0)
  835. #endif /* FDCAN1 */
  836. #define __HAL_RCC_PWR_CLK_ENABLE() do { \
  837. __IO uint32_t tmpreg; \
  838. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN); \
  839. /* Delay after an RCC peripheral clock enabling */ \
  840. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN); \
  841. UNUSED(tmpreg); \
  842. } while(0)
  843. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  844. __IO uint32_t tmpreg; \
  845. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN); \
  846. /* Delay after an RCC peripheral clock enabling */ \
  847. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN); \
  848. UNUSED(tmpreg); \
  849. } while(0)
  850. #define __HAL_RCC_LPTIM1_CLK_ENABLE() do { \
  851. __IO uint32_t tmpreg; \
  852. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN); \
  853. /* Delay after an RCC peripheral clock enabling */ \
  854. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN); \
  855. UNUSED(tmpreg); \
  856. } while(0)
  857. #define __HAL_RCC_LPUART1_CLK_ENABLE() do { \
  858. __IO uint32_t tmpreg; \
  859. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN); \
  860. /* Delay after an RCC peripheral clock enabling */ \
  861. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN); \
  862. UNUSED(tmpreg); \
  863. } while(0)
  864. #if defined(I2C4)
  865. #define __HAL_RCC_I2C4_CLK_ENABLE() do { \
  866. __IO uint32_t tmpreg; \
  867. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN); \
  868. /* Delay after an RCC peripheral clock enabling */ \
  869. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN); \
  870. UNUSED(tmpreg); \
  871. } while(0)
  872. #endif /* I2C4 */
  873. #define __HAL_RCC_UCPD1_CLK_ENABLE() do { \
  874. __IO uint32_t tmpreg; \
  875. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_UCPD1EN); \
  876. /* Delay after an RCC peripheral clock enabling */ \
  877. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_UCPD1EN); \
  878. UNUSED(tmpreg); \
  879. } while(0)
  880. #define __HAL_RCC_TIM2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN)
  881. #define __HAL_RCC_TIM3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN)
  882. #define __HAL_RCC_TIM4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN)
  883. #if defined(TIM5)
  884. #define __HAL_RCC_TIM5_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN)
  885. #endif /* TIM5 */
  886. #define __HAL_RCC_TIM6_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN)
  887. #define __HAL_RCC_TIM7_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN)
  888. #define __HAL_RCC_CRS_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN);
  889. #define __HAL_RCC_RTCAPB_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN);
  890. #define __HAL_RCC_WWDG_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN)
  891. #define __HAL_RCC_SPI2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN)
  892. #define __HAL_RCC_SPI3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN)
  893. #define __HAL_RCC_USART2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN)
  894. #define __HAL_RCC_USART3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN)
  895. #if defined(UART4)
  896. #define __HAL_RCC_UART4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN)
  897. #endif /* UART4 */
  898. #if defined(UART5)
  899. #define __HAL_RCC_UART5_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN)
  900. #endif /* UART5 */
  901. #define __HAL_RCC_I2C1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN)
  902. #define __HAL_RCC_I2C2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN)
  903. #define __HAL_RCC_USB_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBEN)
  904. #if defined(FDCAN1)
  905. #define __HAL_RCC_FDCAN_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_FDCANEN)
  906. #endif /* FDCAN1 */
  907. #define __HAL_RCC_PWR_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN)
  908. #define __HAL_RCC_I2C3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN)
  909. #define __HAL_RCC_LPTIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN)
  910. #define __HAL_RCC_LPUART1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN)
  911. #if defined(I2C4)
  912. #define __HAL_RCC_I2C4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN)
  913. #endif /* I2C4 */
  914. #define __HAL_RCC_UCPD1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_UCPD1EN)
  915. /**
  916. * @}
  917. */
  918. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  919. * @brief Enable or disable the APB2 peripheral clock.
  920. * @note After reset, the peripheral clock (used for registers read/write access)
  921. * is disabled and the application software has to enable this clock before
  922. * using it.
  923. * @{
  924. */
  925. #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
  926. __IO uint32_t tmpreg; \
  927. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN); \
  928. /* Delay after an RCC peripheral clock enabling */ \
  929. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN); \
  930. UNUSED(tmpreg); \
  931. } while(0)
  932. #define __HAL_RCC_TIM1_CLK_ENABLE() do { \
  933. __IO uint32_t tmpreg; \
  934. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  935. /* Delay after an RCC peripheral clock enabling */ \
  936. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  937. UNUSED(tmpreg); \
  938. } while(0)
  939. #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
  940. __IO uint32_t tmpreg; \
  941. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  942. /* Delay after an RCC peripheral clock enabling */ \
  943. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  944. UNUSED(tmpreg); \
  945. } while(0)
  946. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  947. __IO uint32_t tmpreg; \
  948. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  949. /* Delay after an RCC peripheral clock enabling */ \
  950. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  951. UNUSED(tmpreg); \
  952. } while(0)
  953. #define __HAL_RCC_USART1_CLK_ENABLE() do { \
  954. __IO uint32_t tmpreg; \
  955. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  956. /* Delay after an RCC peripheral clock enabling */ \
  957. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  958. UNUSED(tmpreg); \
  959. } while(0)
  960. #if defined(SPI4)
  961. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  962. __IO uint32_t tmpreg; \
  963. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN); \
  964. /* Delay after an RCC peripheral clock enabling */ \
  965. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN); \
  966. UNUSED(tmpreg); \
  967. } while(0)
  968. #endif /* SPI4 */
  969. #define __HAL_RCC_TIM15_CLK_ENABLE() do { \
  970. __IO uint32_t tmpreg; \
  971. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  972. /* Delay after an RCC peripheral clock enabling */ \
  973. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  974. UNUSED(tmpreg); \
  975. } while(0)
  976. #define __HAL_RCC_TIM16_CLK_ENABLE() do { \
  977. __IO uint32_t tmpreg; \
  978. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  979. /* Delay after an RCC peripheral clock enabling */ \
  980. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  981. UNUSED(tmpreg); \
  982. } while(0)
  983. #define __HAL_RCC_TIM17_CLK_ENABLE() do { \
  984. __IO uint32_t tmpreg; \
  985. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  986. /* Delay after an RCC peripheral clock enabling */ \
  987. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  988. UNUSED(tmpreg); \
  989. } while(0)
  990. #if defined(TIM20)
  991. #define __HAL_RCC_TIM20_CLK_ENABLE() do { \
  992. __IO uint32_t tmpreg; \
  993. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM20EN); \
  994. /* Delay after an RCC peripheral clock enabling */ \
  995. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM20EN); \
  996. UNUSED(tmpreg); \
  997. } while(0)
  998. #endif /* TIM20 */
  999. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  1000. __IO uint32_t tmpreg; \
  1001. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  1002. /* Delay after an RCC peripheral clock enabling */ \
  1003. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  1004. UNUSED(tmpreg); \
  1005. } while(0)
  1006. #if defined(HRTIM1)
  1007. #define __HAL_RCC_HRTIM1_CLK_ENABLE() do { \
  1008. __IO uint32_t tmpreg; \
  1009. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_HRTIM1EN); \
  1010. /* Delay after an RCC peripheral clock enabling */ \
  1011. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_HRTIM1EN); \
  1012. UNUSED(tmpreg); \
  1013. } while(0)
  1014. #endif /* HRTIM1 */
  1015. #define __HAL_RCC_SYSCFG_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN)
  1016. #define __HAL_RCC_TIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN)
  1017. #define __HAL_RCC_SPI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN)
  1018. #define __HAL_RCC_TIM8_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN)
  1019. #define __HAL_RCC_USART1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN)
  1020. #if defined(SPI4)
  1021. #define __HAL_RCC_SPI4_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN)
  1022. #endif /* SPI4 */
  1023. #define __HAL_RCC_TIM15_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN)
  1024. #define __HAL_RCC_TIM16_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN)
  1025. #define __HAL_RCC_TIM17_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN)
  1026. #if defined(TIM20)
  1027. #define __HAL_RCC_TIM20_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM20EN)
  1028. #endif /* TIM20 */
  1029. #define __HAL_RCC_SAI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN)
  1030. #if defined(HRTIM1)
  1031. #define __HAL_RCC_HRTIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_HRTIM1EN)
  1032. #endif /* HRTIM1 */
  1033. /**
  1034. * @}
  1035. */
  1036. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enabled or Disabled Status
  1037. * @brief Check whether the AHB1 peripheral clock is enabled or not.
  1038. * @note After reset, the peripheral clock (used for registers read/write access)
  1039. * is disabled and the application software has to enable this clock before
  1040. * using it.
  1041. * @{
  1042. */
  1043. #define __HAL_RCC_DMA1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN) != 0U)
  1044. #define __HAL_RCC_DMA2_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN) != 0U)
  1045. #define __HAL_RCC_DMAMUX1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN) != 0U)
  1046. #define __HAL_RCC_CORDIC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN) != 0U)
  1047. #define __HAL_RCC_FMAC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN) != 0U)
  1048. #define __HAL_RCC_FLASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN) != 0U)
  1049. #define __HAL_RCC_CRC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) != 0U)
  1050. #define __HAL_RCC_DMA1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN) == 0U)
  1051. #define __HAL_RCC_DMA2_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN) == 0U)
  1052. #define __HAL_RCC_DMAMUX1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN) == 0U)
  1053. #define __HAL_RCC_CORDIC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN) == 0U)
  1054. #define __HAL_RCC_FMAC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN) == 0U)
  1055. #define __HAL_RCC_FLASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN) == 0U)
  1056. #define __HAL_RCC_CRC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) == 0U)
  1057. /**
  1058. * @}
  1059. */
  1060. /** @defgroup RCC_AHB2_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enabled or Disabled Status
  1061. * @brief Check whether the AHB2 peripheral clock is enabled or not.
  1062. * @note After reset, the peripheral clock (used for registers read/write access)
  1063. * is disabled and the application software has to enable this clock before
  1064. * using it.
  1065. * @{
  1066. */
  1067. #define __HAL_RCC_GPIOA_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) != 0U)
  1068. #define __HAL_RCC_GPIOB_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN) != 0U)
  1069. #define __HAL_RCC_GPIOC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) != 0U)
  1070. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) != 0U)
  1071. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) != 0U)
  1072. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) != 0U)
  1073. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) != 0U)
  1074. #define __HAL_RCC_ADC12_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC12EN) != 0U)
  1075. #if defined(ADC345_COMMON)
  1076. #define __HAL_RCC_ADC345_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC345EN) != 0U)
  1077. #endif /* ADC345_COMMON */
  1078. #define __HAL_RCC_DAC1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN) != 0U)
  1079. #if defined(DAC2)
  1080. #define __HAL_RCC_DAC2_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC2EN) != 0U)
  1081. #endif /* DAC2 */
  1082. #define __HAL_RCC_DAC3_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC3EN) != 0U)
  1083. #if defined(DAC4)
  1084. #define __HAL_RCC_DAC4_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC4EN) != 0U)
  1085. #endif /* DAC4 */
  1086. #if defined(AES)
  1087. #define __HAL_RCC_AES_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) != 0U)
  1088. #endif /* AES */
  1089. #define __HAL_RCC_RNG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) != 0U)
  1090. #define __HAL_RCC_GPIOA_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) == 0U)
  1091. #define __HAL_RCC_GPIOB_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN) == 0U)
  1092. #define __HAL_RCC_GPIOC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) == 0U)
  1093. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) == 0U)
  1094. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) == 0U)
  1095. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) == 0U)
  1096. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) == 0U)
  1097. #define __HAL_RCC_ADC12_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC12EN) == 0U)
  1098. #if defined(ADC345_COMMON)
  1099. #define __HAL_RCC_ADC345_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADC345EN) == 0U)
  1100. #endif /* ADC345_COMMON */
  1101. #define __HAL_RCC_DAC1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN) == 0U)
  1102. #if defined(DAC2)
  1103. #define __HAL_RCC_DAC2_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC2EN) == 0U)
  1104. #endif /* DAC2 */
  1105. #define __HAL_RCC_DAC3_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC3EN) == 0U)
  1106. #if defined(DAC4)
  1107. #define __HAL_RCC_DAC4_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC4EN) == 0U)
  1108. #endif /* DAC4 */
  1109. #if defined(AES)
  1110. #define __HAL_RCC_AES_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) == 0U)
  1111. #endif /* AES */
  1112. #define __HAL_RCC_RNG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) == 0U)
  1113. /**
  1114. * @}
  1115. */
  1116. /** @defgroup RCC_AHB3_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enabled or Disabled Status
  1117. * @brief Check whether the AHB3 peripheral clock is enabled or not.
  1118. * @note After reset, the peripheral clock (used for registers read/write access)
  1119. * is disabled and the application software has to enable this clock before
  1120. * using it.
  1121. * @{
  1122. */
  1123. #if defined(FMC_BANK1)
  1124. #define __HAL_RCC_FMC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) != 0U)
  1125. #endif /* FMC_BANK1 */
  1126. #if defined(QUADSPI)
  1127. #define __HAL_RCC_QSPI_IS_CLK_ENABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN) != 0U)
  1128. #endif /* QUADSPI */
  1129. #if defined(FMC_BANK1)
  1130. #define __HAL_RCC_FMC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) == 0U)
  1131. #endif /* FMC_BANK1 */
  1132. #if defined(QUADSPI)
  1133. #define __HAL_RCC_QSPI_IS_CLK_DISABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN) == 0U)
  1134. #endif /* QUADSPI */
  1135. /**
  1136. * @}
  1137. */
  1138. /** @defgroup RCC_APB1_Clock_Enable_Disable_Status APB1 Peripheral Clock Enabled or Disabled Status
  1139. * @brief Check whether the APB1 peripheral clock is enabled or not.
  1140. * @note After reset, the peripheral clock (used for registers read/write access)
  1141. * is disabled and the application software has to enable this clock before
  1142. * using it.
  1143. * @{
  1144. */
  1145. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN) != 0U)
  1146. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN) != 0U)
  1147. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN) != 0U)
  1148. #if defined(TIM5)
  1149. #define __HAL_RCC_TIM5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN) != 0U)
  1150. #endif /* TIM5 */
  1151. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN) != 0U)
  1152. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN) != 0U)
  1153. #define __HAL_RCC_CRS_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN) != 0U)
  1154. #define __HAL_RCC_RTCAPB_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN) != 0U)
  1155. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN) != 0U)
  1156. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN) != 0U)
  1157. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN) != 0U)
  1158. #define __HAL_RCC_USART2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN) != 0U)
  1159. #define __HAL_RCC_USART3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN) != 0U)
  1160. #if defined(UART4)
  1161. #define __HAL_RCC_UART4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN) != 0U)
  1162. #endif /* UART4 */
  1163. #if defined(UART5)
  1164. #define __HAL_RCC_UART5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN) != 0U)
  1165. #endif /* UART5 */
  1166. #define __HAL_RCC_I2C1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN) != 0U)
  1167. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN) != 0U)
  1168. #define __HAL_RCC_USB_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBEN) != 0U)
  1169. #if defined(FDCAN1)
  1170. #define __HAL_RCC_FDCAN_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_FDCANEN) != 0U)
  1171. #endif /* FDCAN1 */
  1172. #define __HAL_RCC_PWR_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN) != 0U)
  1173. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN) != 0U)
  1174. #define __HAL_RCC_LPTIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN) != 0U)
  1175. #define __HAL_RCC_LPUART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN) != 0U)
  1176. #if defined(I2C4)
  1177. #define __HAL_RCC_I2C4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN) != 0U)
  1178. #endif /* I2C4 */
  1179. #define __HAL_RCC_UCPD1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_UCPD1EN) != 0U)
  1180. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN) == 0U)
  1181. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN) == 0U)
  1182. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN) == 0U)
  1183. #if defined(TIM5)
  1184. #define __HAL_RCC_TIM5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN) == 0U)
  1185. #endif /* TIM5 */
  1186. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN) == 0U)
  1187. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN) == 0U)
  1188. #define __HAL_RCC_CRS_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN) == 0U)
  1189. #define __HAL_RCC_RTCAPB_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN) == 0U)
  1190. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN) == 0U)
  1191. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN) == 0U)
  1192. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN) == 0U)
  1193. #define __HAL_RCC_USART2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN) == 0U)
  1194. #define __HAL_RCC_USART3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN) == 0U)
  1195. #if defined(UART4)
  1196. #define __HAL_RCC_UART4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN) == 0U)
  1197. #endif /* UART4 */
  1198. #if defined(UART5)
  1199. #define __HAL_RCC_UART5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN) == 0U)
  1200. #endif /* UART5 */
  1201. #define __HAL_RCC_I2C1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN) == 0U)
  1202. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN) == 0U)
  1203. #if defined(USB)
  1204. #define __HAL_RCC_USB_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBEN) == 0U)
  1205. #endif /* USB */
  1206. #if defined(FDCAN1)
  1207. #define __HAL_RCC_FDCAN_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_FDCANEN) == 0U)
  1208. #endif /* FDCAN1 */
  1209. #define __HAL_RCC_PWR_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN) == 0U)
  1210. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN) == 0U)
  1211. #define __HAL_RCC_LPTIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN) == 0U)
  1212. #define __HAL_RCC_LPUART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN) == 0U)
  1213. #if defined(I2C4)
  1214. #define __HAL_RCC_I2C4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN) == 0U)
  1215. #endif /* I2C4 */
  1216. #define __HAL_RCC_UCPD1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_UCPD1EN) == 0U)
  1217. /**
  1218. * @}
  1219. */
  1220. /** @defgroup RCC_APB2_Clock_Enable_Disable_Status APB2 Peripheral Clock Enabled or Disabled Status
  1221. * @brief Check whether the APB2 peripheral clock is enabled or not.
  1222. * @note After reset, the peripheral clock (used for registers read/write access)
  1223. * is disabled and the application software has to enable this clock before
  1224. * using it.
  1225. * @{
  1226. */
  1227. #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN) != 0U)
  1228. #define __HAL_RCC_TIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) != 0U)
  1229. #define __HAL_RCC_SPI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) != 0U)
  1230. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) != 0U)
  1231. #define __HAL_RCC_USART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) != 0U)
  1232. #if defined(SPI4)
  1233. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN) != 0U)
  1234. #endif /* SPI4 */
  1235. #define __HAL_RCC_TIM15_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) != 0U)
  1236. #define __HAL_RCC_TIM16_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) != 0U)
  1237. #define __HAL_RCC_TIM17_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) != 0U)
  1238. #if defined(TIM20)
  1239. #define __HAL_RCC_TIM20_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM20EN) != 0U)
  1240. #endif /* TIM20 */
  1241. #define __HAL_RCC_SAI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) != 0U)
  1242. #if defined(HRTIM1)
  1243. #define __HAL_RCC_HRTIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_HRTIM1EN) != 0U)
  1244. #endif /* HRTIM1 */
  1245. #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN) == 0U)
  1246. #define __HAL_RCC_TIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) == 0U)
  1247. #define __HAL_RCC_SPI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) == 0U)
  1248. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) == 0U)
  1249. #define __HAL_RCC_USART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) == 0U)
  1250. #if defined(SPI4)
  1251. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN) == 0U)
  1252. #endif /* SPI4 */
  1253. #define __HAL_RCC_TIM15_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) == 0U)
  1254. #define __HAL_RCC_TIM16_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) == 0U)
  1255. #define __HAL_RCC_TIM17_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) == 0U)
  1256. #if defined(TIM20)
  1257. #define __HAL_RCC_TIM20_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM20EN) == 0U)
  1258. #endif /* TIM20 */
  1259. #define __HAL_RCC_SAI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) == 0U)
  1260. #if defined(HRTIM1)
  1261. #define __HAL_RCC_HRTIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_HRTIM1EN) == 0U)
  1262. #endif /* HRTIM1 */
  1263. /**
  1264. * @}
  1265. */
  1266. /** @defgroup RCC_AHB1_Force_Release_Reset AHB1 Peripheral Force Release Reset
  1267. * @brief Force or release AHB1 peripheral reset.
  1268. * @{
  1269. */
  1270. #define __HAL_RCC_AHB1_FORCE_RESET() WRITE_REG(RCC->AHB1RSTR, 0xFFFFFFFFU)
  1271. #define __HAL_RCC_DMA1_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA1RST)
  1272. #define __HAL_RCC_DMA2_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2RST)
  1273. #define __HAL_RCC_DMAMUX1_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMAMUX1RST)
  1274. #define __HAL_RCC_CORDIC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CORDICRST)
  1275. #define __HAL_RCC_FMAC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FMACRST)
  1276. #define __HAL_RCC_FLASH_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FLASHRST)
  1277. #define __HAL_RCC_CRC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  1278. #define __HAL_RCC_AHB1_RELEASE_RESET() WRITE_REG(RCC->AHB1RSTR, 0x00000000U)
  1279. #define __HAL_RCC_DMA1_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA1RST)
  1280. #define __HAL_RCC_DMA2_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2RST)
  1281. #define __HAL_RCC_DMAMUX1_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMAMUX1RST)
  1282. #define __HAL_RCC_CORDIC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CORDICRST)
  1283. #define __HAL_RCC_FMAC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FMACRST)
  1284. #define __HAL_RCC_FLASH_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FLASHRST)
  1285. #define __HAL_RCC_CRC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  1286. /**
  1287. * @}
  1288. */
  1289. /** @defgroup RCC_AHB2_Force_Release_Reset AHB2 Peripheral Force Release Reset
  1290. * @brief Force or release AHB2 peripheral reset.
  1291. * @{
  1292. */
  1293. #define __HAL_RCC_AHB2_FORCE_RESET() WRITE_REG(RCC->AHB2RSTR, 0xFFFFFFFFU)
  1294. #define __HAL_RCC_GPIOA_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  1295. #define __HAL_RCC_GPIOB_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  1296. #define __HAL_RCC_GPIOC_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  1297. #define __HAL_RCC_GPIOD_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  1298. #define __HAL_RCC_GPIOE_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  1299. #define __HAL_RCC_GPIOF_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  1300. #define __HAL_RCC_GPIOG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  1301. #define __HAL_RCC_ADC12_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADC12RST)
  1302. #if defined(ADC345_COMMON)
  1303. #define __HAL_RCC_ADC345_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADC345RST)
  1304. #endif /* ADC345_COMMON */
  1305. #define __HAL_RCC_DAC1_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC1RST)
  1306. #if defined(DAC2)
  1307. #define __HAL_RCC_DAC2_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC2RST)
  1308. #endif /* DAC2 */
  1309. #define __HAL_RCC_DAC3_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC3RST)
  1310. #if defined(DAC4)
  1311. #define __HAL_RCC_DAC4_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC4RST)
  1312. #endif /* DAC4 */
  1313. #if defined(AES)
  1314. #define __HAL_RCC_AES_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  1315. #endif /* AES */
  1316. #define __HAL_RCC_RNG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  1317. #define __HAL_RCC_AHB2_RELEASE_RESET() WRITE_REG(RCC->AHB2RSTR, 0x00000000U)
  1318. #define __HAL_RCC_GPIOA_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  1319. #define __HAL_RCC_GPIOB_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  1320. #define __HAL_RCC_GPIOC_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  1321. #define __HAL_RCC_GPIOD_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  1322. #define __HAL_RCC_GPIOE_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  1323. #define __HAL_RCC_GPIOF_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  1324. #define __HAL_RCC_GPIOG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  1325. #define __HAL_RCC_ADC12_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADC12RST)
  1326. #if defined(ADC345_COMMON)
  1327. #define __HAL_RCC_ADC345_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADC345RST)
  1328. #endif /* ADC345_COMMON */
  1329. #define __HAL_RCC_DAC1_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC1RST)
  1330. #if defined(DAC2)
  1331. #define __HAL_RCC_DAC2_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC2RST)
  1332. #endif /* DAC2 */
  1333. #define __HAL_RCC_DAC3_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC3RST)
  1334. #if defined(DAC4)
  1335. #define __HAL_RCC_DAC4_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC4RST)
  1336. #endif /* DAC4 */
  1337. #if defined(AES)
  1338. #define __HAL_RCC_AES_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  1339. #endif /* AES */
  1340. #define __HAL_RCC_RNG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  1341. /**
  1342. * @}
  1343. */
  1344. /** @defgroup RCC_AHB3_Force_Release_Reset AHB3 Peripheral Force Release Reset
  1345. * @brief Force or release AHB3 peripheral reset.
  1346. * @{
  1347. */
  1348. #define __HAL_RCC_AHB3_FORCE_RESET() WRITE_REG(RCC->AHB3RSTR, 0xFFFFFFFFU)
  1349. #if defined(FMC_BANK1)
  1350. #define __HAL_RCC_FMC_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_FMCRST)
  1351. #endif /* FMC_BANK1 */
  1352. #if defined(QUADSPI)
  1353. #define __HAL_RCC_QSPI_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_QSPIRST)
  1354. #endif /* QUADSPI */
  1355. #define __HAL_RCC_AHB3_RELEASE_RESET() WRITE_REG(RCC->AHB3RSTR, 0x00000000U)
  1356. #if defined(FMC_BANK1)
  1357. #define __HAL_RCC_FMC_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_FMCRST)
  1358. #endif /* FMC_BANK1 */
  1359. #if defined(QUADSPI)
  1360. #define __HAL_RCC_QSPI_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_QSPIRST)
  1361. #endif /* QUADSPI */
  1362. /**
  1363. * @}
  1364. */
  1365. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Peripheral Force Release Reset
  1366. * @brief Force or release APB1 peripheral reset.
  1367. * @{
  1368. */
  1369. #define __HAL_RCC_APB1_FORCE_RESET() WRITE_REG(RCC->APB1RSTR1, 0xFFFFFFFFU)
  1370. #define __HAL_RCC_TIM2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM2RST)
  1371. #define __HAL_RCC_TIM3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM3RST)
  1372. #define __HAL_RCC_TIM4_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM4RST)
  1373. #if defined(TIM5)
  1374. #define __HAL_RCC_TIM5_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM5RST)
  1375. #endif /* TIM5 */
  1376. #define __HAL_RCC_TIM6_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM6RST)
  1377. #define __HAL_RCC_TIM7_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM7RST)
  1378. #define __HAL_RCC_CRS_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CRSRST)
  1379. #define __HAL_RCC_SPI2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI2RST)
  1380. #define __HAL_RCC_SPI3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI3RST)
  1381. #define __HAL_RCC_USART2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART2RST)
  1382. #define __HAL_RCC_USART3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART3RST)
  1383. #if defined(UART4)
  1384. #define __HAL_RCC_UART4_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART4RST)
  1385. #endif /* UART4 */
  1386. #if defined(UART5)
  1387. #define __HAL_RCC_UART5_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART5RST)
  1388. #endif /* UART5 */
  1389. #define __HAL_RCC_I2C1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C1RST)
  1390. #define __HAL_RCC_I2C2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C2RST)
  1391. #define __HAL_RCC_USB_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USBRST)
  1392. #if defined(FDCAN1)
  1393. #define __HAL_RCC_FDCAN_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_FDCANRST)
  1394. #endif /* FDCAN1 */
  1395. #define __HAL_RCC_PWR_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_PWRRST)
  1396. #define __HAL_RCC_I2C3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C3RST)
  1397. #define __HAL_RCC_LPTIM1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LPTIM1RST)
  1398. #define __HAL_RCC_LPUART1_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPUART1RST)
  1399. #if defined(I2C4)
  1400. #define __HAL_RCC_I2C4_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_I2C4RST)
  1401. #endif /* I2C4 */
  1402. #define __HAL_RCC_UCPD1_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_UCPD1RST)
  1403. #define __HAL_RCC_APB1_RELEASE_RESET() WRITE_REG(RCC->APB1RSTR1, 0x00000000U)
  1404. #define __HAL_RCC_TIM2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM2RST)
  1405. #define __HAL_RCC_TIM3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM3RST)
  1406. #define __HAL_RCC_TIM4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM4RST)
  1407. #if defined(TIM5)
  1408. #define __HAL_RCC_TIM5_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM5RST)
  1409. #endif /* TIM5 */
  1410. #define __HAL_RCC_TIM6_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM6RST)
  1411. #define __HAL_RCC_TIM7_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM7RST)
  1412. #define __HAL_RCC_CRS_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CRSRST)
  1413. #define __HAL_RCC_SPI2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI2RST)
  1414. #define __HAL_RCC_SPI3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI3RST)
  1415. #define __HAL_RCC_USART2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART2RST)
  1416. #define __HAL_RCC_USART3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART3RST)
  1417. #if defined(UART4)
  1418. #define __HAL_RCC_UART4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART4RST)
  1419. #endif /* UART4 */
  1420. #if defined(UART5)
  1421. #define __HAL_RCC_UART5_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART5RST)
  1422. #endif /* UART5 */
  1423. #define __HAL_RCC_I2C1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C1RST)
  1424. #define __HAL_RCC_I2C2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C2RST)
  1425. #define __HAL_RCC_USB_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USBRST)
  1426. #if defined(FDCAN1)
  1427. #define __HAL_RCC_FDCAN_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_FDCANRST)
  1428. #endif /* FDCAN1 */
  1429. #define __HAL_RCC_PWR_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_PWRRST)
  1430. #define __HAL_RCC_I2C3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C3RST)
  1431. #define __HAL_RCC_LPTIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LPTIM1RST)
  1432. #define __HAL_RCC_LPUART1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPUART1RST)
  1433. #if defined(I2C4)
  1434. #define __HAL_RCC_I2C4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_I2C4RST)
  1435. #endif /* I2C4 */
  1436. #define __HAL_RCC_UCPD1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_UCPD1RST)
  1437. /**
  1438. * @}
  1439. */
  1440. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Peripheral Force Release Reset
  1441. * @brief Force or release APB2 peripheral reset.
  1442. * @{
  1443. */
  1444. #define __HAL_RCC_APB2_FORCE_RESET() WRITE_REG(RCC->APB2RSTR, 0xFFFFFFFFU)
  1445. #define __HAL_RCC_SYSCFG_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SYSCFGRST)
  1446. #define __HAL_RCC_TIM1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  1447. #define __HAL_RCC_SPI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  1448. #define __HAL_RCC_TIM8_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  1449. #define __HAL_RCC_USART1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  1450. #if defined(SPI4)
  1451. #define __HAL_RCC_SPI4_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI4RST)
  1452. #endif /* SPI4 */
  1453. #define __HAL_RCC_TIM15_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  1454. #define __HAL_RCC_TIM16_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  1455. #define __HAL_RCC_TIM17_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  1456. #if defined(TIM20)
  1457. #define __HAL_RCC_TIM20_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM20RST)
  1458. #endif /* TIM20 */
  1459. #define __HAL_RCC_SAI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  1460. #if defined(HRTIM1)
  1461. #define __HAL_RCC_HRTIM1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_HRTIM1RST)
  1462. #endif /* HRTIM1 */
  1463. #define __HAL_RCC_APB2_RELEASE_RESET() WRITE_REG(RCC->APB2RSTR, 0x00000000U)
  1464. #define __HAL_RCC_SYSCFG_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SYSCFGRST)
  1465. #define __HAL_RCC_TIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  1466. #define __HAL_RCC_SPI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  1467. #define __HAL_RCC_TIM8_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  1468. #define __HAL_RCC_USART1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  1469. #if defined(SPI4)
  1470. #define __HAL_RCC_SPI4_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI4RST)
  1471. #endif /* SPI4 */
  1472. #define __HAL_RCC_TIM15_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  1473. #define __HAL_RCC_TIM16_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  1474. #define __HAL_RCC_TIM17_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  1475. #if defined(TIM20)
  1476. #define __HAL_RCC_TIM20_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM20RST)
  1477. #endif /* TIM20 */
  1478. #define __HAL_RCC_SAI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  1479. #if defined(HRTIM1)
  1480. #define __HAL_RCC_HRTIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_HRTIM1RST)
  1481. #endif /* HRTIM1 */
  1482. /**
  1483. * @}
  1484. */
  1485. /** @defgroup RCC_AHB1_Clock_Sleep_Enable_Disable AHB1 Peripheral Clock Sleep Enable Disable
  1486. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  1487. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1488. * power consumption.
  1489. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1490. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1491. * @{
  1492. */
  1493. #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN)
  1494. #define __HAL_RCC_DMA2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN)
  1495. #define __HAL_RCC_DMAMUX1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN)
  1496. #define __HAL_RCC_CORDIC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CORDICSMEN)
  1497. #define __HAL_RCC_FMAC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FMACSMEN)
  1498. #define __HAL_RCC_FLASH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN)
  1499. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN)
  1500. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN)
  1501. #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN)
  1502. #define __HAL_RCC_DMA2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN)
  1503. #define __HAL_RCC_DMAMUX1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN)
  1504. #define __HAL_RCC_CORDIC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CORDICSMEN)
  1505. #define __HAL_RCC_FMAC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FMACSMEN)
  1506. #define __HAL_RCC_FLASH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN)
  1507. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN)
  1508. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN)
  1509. /**
  1510. * @}
  1511. */
  1512. /** @defgroup RCC_AHB2_Clock_Sleep_Enable_Disable AHB2 Peripheral Clock Sleep Enable Disable
  1513. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  1514. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1515. * power consumption.
  1516. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1517. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1518. * @{
  1519. */
  1520. #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN)
  1521. #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN)
  1522. #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN)
  1523. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN)
  1524. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN)
  1525. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN)
  1526. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN)
  1527. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN)
  1528. #define __HAL_RCC_CCM_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_CCMSRAMSMEN)
  1529. #define __HAL_RCC_ADC12_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC12SMEN)
  1530. #if defined(ADC345_COMMON)
  1531. #define __HAL_RCC_ADC345_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC345SMEN)
  1532. #endif /* ADC345_COMMON */
  1533. #define __HAL_RCC_DAC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC1SMEN)
  1534. #if defined(DAC2)
  1535. #define __HAL_RCC_DAC2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC2SMEN)
  1536. #endif /* DAC2 */
  1537. #define __HAL_RCC_DAC3_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC3SMEN)
  1538. #if defined(DAC4)
  1539. #define __HAL_RCC_DAC4_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC4SMEN)
  1540. #endif /* DAC4 */
  1541. #if defined(AES)
  1542. #define __HAL_RCC_AES_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN)
  1543. #endif /* AES */
  1544. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN)
  1545. #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN)
  1546. #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN)
  1547. #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN)
  1548. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN)
  1549. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN)
  1550. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN)
  1551. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN)
  1552. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN)
  1553. #define __HAL_RCC_CCM_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_CCMSRAMSMEN)
  1554. #define __HAL_RCC_ADC12_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC12SMEN)
  1555. #if defined(ADC345_COMMON)
  1556. #define __HAL_RCC_ADC345_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC345SMEN)
  1557. #endif /* ADC345_COMMON */
  1558. #define __HAL_RCC_DAC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC1SMEN)
  1559. #if defined(DAC2)
  1560. #define __HAL_RCC_DAC2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC2SMEN)
  1561. #endif /* DAC2 */
  1562. #define __HAL_RCC_DAC3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC3SMEN)
  1563. #if defined(DAC4)
  1564. #define __HAL_RCC_DAC4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC4SMEN)
  1565. #endif /* DAC4 */
  1566. #if defined(AES)
  1567. #define __HAL_RCC_AES_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN)
  1568. #endif /* AES */
  1569. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN)
  1570. /**
  1571. * @}
  1572. */
  1573. /** @defgroup RCC_AHB3_Clock_Sleep_Enable_Disable AHB3 Peripheral Clock Sleep Enable Disable
  1574. * @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  1575. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1576. * power consumption.
  1577. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1578. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1579. * @{
  1580. */
  1581. #if defined(FMC_BANK1)
  1582. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN)
  1583. #endif /* FMC_BANK1 */
  1584. #if defined(QUADSPI)
  1585. #define __HAL_RCC_QSPI_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN)
  1586. #endif /* QUADSPI */
  1587. #if defined(FMC_BANK1)
  1588. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN)
  1589. #endif /* FMC_BANK1 */
  1590. #if defined(QUADSPI)
  1591. #define __HAL_RCC_QSPI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN)
  1592. #endif /* QUADSPI */
  1593. /**
  1594. * @}
  1595. */
  1596. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable APB1 Peripheral Clock Sleep Enable Disable
  1597. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  1598. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1599. * power consumption.
  1600. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1601. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1602. * @{
  1603. */
  1604. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN)
  1605. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN)
  1606. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN)
  1607. #if defined(TIM5)
  1608. #define __HAL_RCC_TIM5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN)
  1609. #endif /* TIM5 */
  1610. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN)
  1611. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN)
  1612. #define __HAL_RCC_CRS_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN)
  1613. #define __HAL_RCC_RTCAPB_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN)
  1614. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN)
  1615. #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN)
  1616. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN)
  1617. #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN)
  1618. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN)
  1619. #if defined(UART4)
  1620. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN)
  1621. #endif /* UART4 */
  1622. #if defined(UART5)
  1623. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN)
  1624. #endif /* UART5 */
  1625. #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN)
  1626. #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN)
  1627. #if defined(USB)
  1628. #define __HAL_RCC_USB_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBSMEN)
  1629. #endif /* USB */
  1630. #if defined(FDCAN1)
  1631. #define __HAL_RCC_FDCAN_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_FDCANSMEN)
  1632. #endif /* FDCAN1 */
  1633. #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN)
  1634. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN)
  1635. #define __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN)
  1636. #define __HAL_RCC_LPUART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN)
  1637. #if defined(I2C4)
  1638. #define __HAL_RCC_I2C4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN)
  1639. #endif /* I2C4 */
  1640. #define __HAL_RCC_UCPD1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_UCPD1SMEN)
  1641. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN)
  1642. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN)
  1643. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN)
  1644. #if defined(TIM5)
  1645. #define __HAL_RCC_TIM5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN)
  1646. #endif /* TIM5 */
  1647. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN)
  1648. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN)
  1649. #define __HAL_RCC_CRS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN)
  1650. #define __HAL_RCC_RTCAPB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN)
  1651. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN)
  1652. #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN)
  1653. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN)
  1654. #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN)
  1655. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN)
  1656. #if defined(UART4)
  1657. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN)
  1658. #endif /* UART4 */
  1659. #if defined(UART5)
  1660. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN)
  1661. #endif /* UART5 */
  1662. #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN)
  1663. #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN)
  1664. #if defined(USB)
  1665. #define __HAL_RCC_USB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBSMEN)
  1666. #endif /* USB */
  1667. #if defined(FDCAN1)
  1668. #define __HAL_RCC_FDCAN_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_FDCANSMEN)
  1669. #endif /* FDCAN1 */
  1670. #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN)
  1671. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN)
  1672. #define __HAL_RCC_LPTIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN)
  1673. #define __HAL_RCC_LPUART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN)
  1674. #if defined(I2C4)
  1675. #define __HAL_RCC_I2C4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN)
  1676. #endif /* I2C4 */
  1677. #define __HAL_RCC_UCPD1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_UCPD1SMEN)
  1678. /**
  1679. * @}
  1680. */
  1681. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable APB2 Peripheral Clock Sleep Enable Disable
  1682. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1683. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1684. * power consumption.
  1685. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1686. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1687. * @{
  1688. */
  1689. #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN)
  1690. #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN)
  1691. #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN)
  1692. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN)
  1693. #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN)
  1694. #if defined(SPI4)
  1695. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI4SMEN)
  1696. #endif /* SPI4 */
  1697. #define __HAL_RCC_TIM15_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN)
  1698. #define __HAL_RCC_TIM16_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN)
  1699. #define __HAL_RCC_TIM17_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN)
  1700. #if defined(TIM20)
  1701. #define __HAL_RCC_TIM20_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM20SMEN)
  1702. #endif /* TIM20 */
  1703. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN)
  1704. #if defined(HRTIM1)
  1705. #define __HAL_RCC_HRTIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_HRTIM1SMEN)
  1706. #endif /* HRTIM1 */
  1707. #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN)
  1708. #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN)
  1709. #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN)
  1710. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN)
  1711. #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN)
  1712. #if defined(SPI4)
  1713. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI4SMEN)
  1714. #endif /* SPI4 */
  1715. #define __HAL_RCC_TIM15_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN)
  1716. #define __HAL_RCC_TIM16_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN)
  1717. #define __HAL_RCC_TIM17_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN)
  1718. #if defined(TIM20)
  1719. #define __HAL_RCC_TIM20_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM20SMEN)
  1720. #endif /* TIM20 */
  1721. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN)
  1722. #if defined(HRTIM1)
  1723. #define __HAL_RCC_HRTIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_HRTIM1SMEN)
  1724. #endif /* HRTIM1 */
  1725. /**
  1726. * @}
  1727. */
  1728. /** @defgroup RCC_AHB1_Clock_Sleep_Enable_Disable_Status AHB1 Peripheral Clock Sleep Enabled or Disabled Status
  1729. * @brief Check whether the AHB1 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1730. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1731. * power consumption.
  1732. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1733. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1734. * @{
  1735. */
  1736. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN) != 0U)
  1737. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN) != 0U)
  1738. #define __HAL_RCC_DMAMUX1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN) != 0U)
  1739. #define __HAL_RCC_CORDIC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CORDICSMEN) != 0U)
  1740. #define __HAL_RCC_FMAC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FMACSMEN) != 0U)
  1741. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN) != 0U)
  1742. #define __HAL_RCC_SRAM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN) != 0U)
  1743. #define __HAL_RCC_CRC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN) != 0U)
  1744. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN) == 0U)
  1745. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN) == 0U)
  1746. #define __HAL_RCC_DMAMUX1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN) == 0U)
  1747. #define __HAL_RCC_CORDIC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CORDICSMEN) == 0U)
  1748. #define __HAL_RCC_FMAC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FMACSMEN) == 0U)
  1749. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN) == 0U)
  1750. #define __HAL_RCC_SRAM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN) == 0U)
  1751. #define __HAL_RCC_CRC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN) == 0U)
  1752. /**
  1753. * @}
  1754. */
  1755. /** @defgroup RCC_AHB2_Clock_Sleep_Enable_Disable_Status AHB2 Peripheral Clock Sleep Enabled or Disabled Status
  1756. * @brief Check whether the AHB2 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1757. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1758. * power consumption.
  1759. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1760. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1761. * @{
  1762. */
  1763. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN) != 0U)
  1764. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN) != 0U)
  1765. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN) != 0U)
  1766. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN) != 0U)
  1767. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN) != 0U)
  1768. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN) != 0U)
  1769. #define __HAL_RCC_GPIOG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN) != 0U)
  1770. #define __HAL_RCC_SRAM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN) != 0U)
  1771. #define __HAL_RCC_CCM_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_CCMSRAMSMEN) != 0U)
  1772. #define __HAL_RCC_ADC12_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC12SMEN) != 0U)
  1773. #if defined(ADC345_COMMON)
  1774. #define __HAL_RCC_ADC345_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC345SMEN) != 0U)
  1775. #endif /* ADC345_COMMON */
  1776. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC1SMEN) != 0U)
  1777. #if defined(DAC2)
  1778. #define __HAL_RCC_DAC2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC2SMEN) != 0U)
  1779. #endif /* DAC2 */
  1780. #define __HAL_RCC_DAC3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC3SMEN) != 0U)
  1781. #if defined(DAC4)
  1782. #define __HAL_RCC_DAC4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC4SMEN) != 0U)
  1783. #endif /* DAC4 */
  1784. #if defined(AES)
  1785. #define __HAL_RCC_AES_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN) != 0U)
  1786. #endif /* AES */
  1787. #define __HAL_RCC_RNG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN) != 0U)
  1788. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN) == 0U)
  1789. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN) == 0U)
  1790. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN) == 0U)
  1791. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN) == 0U)
  1792. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN) == 0U)
  1793. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN) == 0U)
  1794. #define __HAL_RCC_GPIOG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN) == 0U)
  1795. #define __HAL_RCC_SRAM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN) == 0U)
  1796. #define __HAL_RCC_CCM_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_CCMSRAMSMEN) == 0U)
  1797. #define __HAL_RCC_ADC12_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC12SMEN) == 0U)
  1798. #if defined(ADC345_COMMON)
  1799. #define __HAL_RCC_ADC345_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADC345SMEN) == 0U)
  1800. #endif /* ADC345_COMMON */
  1801. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC1SMEN) == 0U)
  1802. #if defined(DAC2)
  1803. #define __HAL_RCC_DAC2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC2SMEN) == 0U)
  1804. #endif /* DAC2 */
  1805. #define __HAL_RCC_DAC3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC3SMEN) == 0U)
  1806. #if defined(DAC4)
  1807. #define __HAL_RCC_DAC4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DAC4SMEN) == 0U)
  1808. #endif /* DAC4 */
  1809. #if defined(AES)
  1810. #define __HAL_RCC_AES_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN) == 0U)
  1811. #endif /* AES */
  1812. #define __HAL_RCC_RNG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN) == 0U)
  1813. /**
  1814. * @}
  1815. */
  1816. /** @defgroup RCC_AHB3_Clock_Sleep_Enable_Disable_Status AHB3 Peripheral Clock Sleep Enabled or Disabled Status
  1817. * @brief Check whether the AHB3 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1818. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1819. * power consumption.
  1820. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1821. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1822. * @{
  1823. */
  1824. #if defined(FMC_BANK1)
  1825. #define __HAL_RCC_FMC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN) != 0U)
  1826. #endif /* FMC_BANK1 */
  1827. #if defined(QUADSPI)
  1828. #define __HAL_RCC_QSPI_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN) != 0U)
  1829. #endif /* QUADSPI */
  1830. #if defined(FMC_BANK1)
  1831. #define __HAL_RCC_FMC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN) == 0U)
  1832. #endif /* FMC_BANK1 */
  1833. #if defined(QUADSPI)
  1834. #define __HAL_RCC_QSPI_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN) == 0U)
  1835. #endif /* QUADSPI */
  1836. /**
  1837. * @}
  1838. */
  1839. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable_Status APB1 Peripheral Clock Sleep Enabled or Disabled Status
  1840. * @brief Check whether the APB1 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1841. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1842. * power consumption.
  1843. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1844. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1845. * @{
  1846. */
  1847. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN) != 0U)
  1848. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN) != 0U)
  1849. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN) != 0U)
  1850. #if defined(TIM5)
  1851. #define __HAL_RCC_TIM5_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN) != 0U)
  1852. #endif /* TIM5 */
  1853. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN) != 0U)
  1854. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN) != 0U)
  1855. #define __HAL_RCC_CRS_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN) != 0U)
  1856. #define __HAL_RCC_RTCAPB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN) != 0U)
  1857. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN) != 0U)
  1858. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN) != 0U)
  1859. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN) != 0U)
  1860. #define __HAL_RCC_USART2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN) != 0U)
  1861. #define __HAL_RCC_USART3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN) != 0U)
  1862. #if defined(UART4)
  1863. #define __HAL_RCC_UART4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN) != 0U)
  1864. #endif /* UART4 */
  1865. #if defined(UART5)
  1866. #define __HAL_RCC_UART5_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN) != 0U)
  1867. #endif /* UART5 */
  1868. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN) != 0U)
  1869. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN) != 0U)
  1870. #define __HAL_RCC_USB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBSMEN) != 0U)
  1871. #if defined(FDCAN1)
  1872. #define __HAL_RCC_FDCAN_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_FDCANSMEN) != 0U)
  1873. #endif /* FDCAN1 */
  1874. #define __HAL_RCC_PWR_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN) != 0U)
  1875. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN) != 0U)
  1876. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN) != 0U)
  1877. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN) != 0U)
  1878. #if defined(I2C4)
  1879. #define __HAL_RCC_I2C4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN) != 0U)
  1880. #endif /* I2C4 */
  1881. #define __HAL_RCC_UCPD1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_UCPD1SMEN) != 0U)
  1882. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN) == 0U)
  1883. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN) == 0U)
  1884. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN) == 0U)
  1885. #if defined(TIM5)
  1886. #define __HAL_RCC_TIM5_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN) == 0U)
  1887. #endif /* TIM5 */
  1888. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN) == 0U)
  1889. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN) == 0U)
  1890. #define __HAL_RCC_CRS_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN) == 0U)
  1891. #define __HAL_RCC_RTCAPB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN) == 0U)
  1892. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN) == 0U)
  1893. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN) == 0U)
  1894. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN) == 0U)
  1895. #define __HAL_RCC_USART2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN) == 0U)
  1896. #define __HAL_RCC_USART3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN) == 0U)
  1897. #if defined(UART4)
  1898. #define __HAL_RCC_UART4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN) == 0U)
  1899. #endif /* UART4 */
  1900. #if defined(UART5)
  1901. #define __HAL_RCC_UART5_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN) == 0U)
  1902. #endif /* UART5 */
  1903. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN) == 0U)
  1904. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN) == 0U)
  1905. #define __HAL_RCC_USB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBSMEN) == 0U)
  1906. #if defined(FDCAN1)
  1907. #define __HAL_RCC_FDCAN_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_FDCANSMEN) == 0U)
  1908. #endif /* FDCAN1 */
  1909. #define __HAL_RCC_PWR_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN) == 0U)
  1910. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN) == 0U)
  1911. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN) == 0U)
  1912. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN) == 0U)
  1913. #if defined(I2C4)
  1914. #define __HAL_RCC_I2C4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN) == 0U)
  1915. #endif /* I2C4 */
  1916. #define __HAL_RCC_UCPD1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_UCPD1SMEN) == 0U)
  1917. /**
  1918. * @}
  1919. */
  1920. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable_Status APB2 Peripheral Clock Sleep Enabled or Disabled Status
  1921. * @brief Check whether the APB2 peripheral clock during Low Power (Sleep) mode is enabled or not.
  1922. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1923. * power consumption.
  1924. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1925. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1926. * @{
  1927. */
  1928. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN) != 0U)
  1929. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN) != 0U)
  1930. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN) != 0U)
  1931. #define __HAL_RCC_TIM8_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN) != 0U)
  1932. #define __HAL_RCC_USART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN) != 0U)
  1933. #if defined(SPI4)
  1934. #define __HAL_RCC_SPI4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI4SMEN) != 0U)
  1935. #endif /* SPI4 */
  1936. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN) != 0U)
  1937. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN) != 0U)
  1938. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN) != 0U)
  1939. #if defined(TIM20)
  1940. #define __HAL_RCC_TIM20_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM20SMEN) != 0U)
  1941. #endif /* TIM20 */
  1942. #define __HAL_RCC_SAI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN) != 0U)
  1943. #if defined(HRTIM1)
  1944. #define __HAL_RCC_HRTIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_HRTIM1SMEN) != 0U)
  1945. #endif /* HRTIM1 */
  1946. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN) == 0U)
  1947. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN) == 0U)
  1948. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN) == 0U)
  1949. #define __HAL_RCC_TIM8_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN) == 0U)
  1950. #define __HAL_RCC_USART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN) == 0U)
  1951. #if defined(SPI4)
  1952. #define __HAL_RCC_SPI4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI4SMEN) == 0U)
  1953. #endif /* SPI4 */
  1954. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN) == 0U)
  1955. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN) == 0U)
  1956. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN) == 0U)
  1957. #if defined(TIM20)
  1958. #define __HAL_RCC_TIM20_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM20SMEN) == 0U)
  1959. #endif /* TIM20 */
  1960. #define __HAL_RCC_SAI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN) == 0U)
  1961. #if defined(HRTIM1)
  1962. #define __HAL_RCC_HRTIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_HRTIM1SMEN) == 0U)
  1963. #endif /* HRTIM1 */
  1964. /**
  1965. * @}
  1966. */
  1967. /** @defgroup RCC_Backup_Domain_Reset RCC Backup Domain Reset
  1968. * @{
  1969. */
  1970. /** @brief Macros to force or release the Backup domain reset.
  1971. * @note This function resets the RTC peripheral (including the backup registers)
  1972. * and the RTC clock source selection in RCC_CSR register.
  1973. * @note The BKPSRAM is not affected by this reset.
  1974. * @retval None
  1975. */
  1976. #define __HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  1977. #define __HAL_RCC_BACKUPRESET_RELEASE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  1978. /**
  1979. * @}
  1980. */
  1981. /** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
  1982. * @{
  1983. */
  1984. /** @brief Macros to enable or disable the RTC clock.
  1985. * @note As the RTC is in the Backup domain and write access is denied to
  1986. * this domain after reset, you have to enable write access using
  1987. * HAL_PWR_EnableBkUpAccess() function before to configure the RTC
  1988. * (to be done once after reset).
  1989. * @note These macros must be used after the RTC clock source was selected.
  1990. * @retval None
  1991. */
  1992. #define __HAL_RCC_RTC_ENABLE() SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  1993. #define __HAL_RCC_RTC_DISABLE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  1994. /**
  1995. * @}
  1996. */
  1997. /** @brief Macros to enable or disable the Internal High Speed 16MHz oscillator (HSI).
  1998. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  1999. * It is used (enabled by hardware) as system clock source after startup
  2000. * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
  2001. * of the HSE used directly or indirectly as system clock (if the Clock
  2002. * Security System CSS is enabled).
  2003. * @note HSI can not be stopped if it is used as system clock source. In this case,
  2004. * you have to select another source of the system clock then stop the HSI.
  2005. * @note After enabling the HSI, the application software should wait on HSIRDY
  2006. * flag to be set indicating that HSI clock is stable and can be used as
  2007. * system clock source.
  2008. * This parameter can be: ENABLE or DISABLE.
  2009. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  2010. * clock cycles.
  2011. * @retval None
  2012. */
  2013. #define __HAL_RCC_HSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSION)
  2014. #define __HAL_RCC_HSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSION)
  2015. /** @brief Macro to adjust the Internal High Speed 16MHz oscillator (HSI) calibration value.
  2016. * @note The calibration is used to compensate for the variations in voltage
  2017. * and temperature that influence the frequency of the internal HSI RC.
  2018. * @param __HSICALIBRATIONVALUE__ specifies the calibration trimming value
  2019. * (default is RCC_HSICALIBRATION_DEFAULT).
  2020. * This parameter must be a number between 0 and 0x7F.
  2021. * @retval None
  2022. */
  2023. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICALIBRATIONVALUE__) \
  2024. MODIFY_REG(RCC->ICSCR, RCC_ICSCR_HSITRIM, (__HSICALIBRATIONVALUE__) << RCC_ICSCR_HSITRIM_Pos)
  2025. /**
  2026. * @brief Macros to enable or disable the force of the Internal High Speed oscillator (HSI)
  2027. * in STOP mode to be quickly available as kernel clock for USARTs and I2Cs.
  2028. * @note Keeping the HSI ON in STOP mode allows to avoid slowing down the communication
  2029. * speed because of the HSI startup time.
  2030. * @note The enable of this function has not effect on the HSION bit.
  2031. * This parameter can be: ENABLE or DISABLE.
  2032. * @retval None
  2033. */
  2034. #define __HAL_RCC_HSISTOP_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIKERON)
  2035. #define __HAL_RCC_HSISTOP_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIKERON)
  2036. /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
  2037. * @note After enabling the LSI, the application software should wait on
  2038. * LSIRDY flag to be set indicating that LSI clock is stable and can
  2039. * be used to clock the IWDG and/or the RTC.
  2040. * @note LSI can not be disabled if the IWDG is running.
  2041. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  2042. * clock cycles.
  2043. * @retval None
  2044. */
  2045. #define __HAL_RCC_LSI_ENABLE() SET_BIT(RCC->CSR, RCC_CSR_LSION)
  2046. #define __HAL_RCC_LSI_DISABLE() CLEAR_BIT(RCC->CSR, RCC_CSR_LSION)
  2047. /**
  2048. * @brief Macro to configure the External High Speed oscillator (HSE).
  2049. * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
  2050. * supported by this macro. User should request a transition to HSE Off
  2051. * first and then HSE On or HSE Bypass.
  2052. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  2053. * software should wait on HSERDY flag to be set indicating that HSE clock
  2054. * is stable and can be used to clock the PLL and/or system clock.
  2055. * @note HSE state can not be changed if it is used directly or through the
  2056. * PLL as system clock. In this case, you have to select another source
  2057. * of the system clock then change the HSE state (ex. disable it).
  2058. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  2059. * @note This function reset the CSSON bit, so if the clock security system(CSS)
  2060. * was previously enabled you have to enable it again after calling this
  2061. * function.
  2062. * @param __STATE__ specifies the new state of the HSE.
  2063. * This parameter can be one of the following values:
  2064. * @arg @ref RCC_HSE_OFF Turn OFF the HSE oscillator, HSERDY flag goes low after
  2065. * 6 HSE oscillator clock cycles.
  2066. * @arg @ref RCC_HSE_ON Turn ON the HSE oscillator.
  2067. * @arg @ref RCC_HSE_BYPASS HSE oscillator bypassed with external clock.
  2068. * @retval None
  2069. */
  2070. #define __HAL_RCC_HSE_CONFIG(__STATE__) \
  2071. do { \
  2072. if((__STATE__) == RCC_HSE_ON) \
  2073. { \
  2074. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  2075. } \
  2076. else if((__STATE__) == RCC_HSE_BYPASS) \
  2077. { \
  2078. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  2079. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  2080. } \
  2081. else \
  2082. { \
  2083. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  2084. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  2085. } \
  2086. } while(0)
  2087. /**
  2088. * @brief Macro to configure the External Low Speed oscillator (LSE).
  2089. * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
  2090. * supported by this macro. User should request a transition to LSE Off
  2091. * first and then LSE On or LSE Bypass.
  2092. * @note As the LSE is in the Backup domain and write access is denied to
  2093. * this domain after reset, you have to enable write access using
  2094. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  2095. * (to be done once after reset).
  2096. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  2097. * software should wait on LSERDY flag to be set indicating that LSE clock
  2098. * is stable and can be used to clock the RTC.
  2099. * @param __STATE__ specifies the new state of the LSE.
  2100. * This parameter can be one of the following values:
  2101. * @arg @ref RCC_LSE_OFF Turn OFF the LSE oscillator, LSERDY flag goes low after
  2102. * 6 LSE oscillator clock cycles.
  2103. * @arg @ref RCC_LSE_ON Turn ON the LSE oscillator.
  2104. * @arg @ref RCC_LSE_BYPASS LSE oscillator bypassed with external clock.
  2105. * @retval None
  2106. */
  2107. #define __HAL_RCC_LSE_CONFIG(__STATE__) \
  2108. do { \
  2109. if((__STATE__) == RCC_LSE_ON) \
  2110. { \
  2111. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  2112. } \
  2113. else if((__STATE__) == RCC_LSE_BYPASS) \
  2114. { \
  2115. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  2116. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  2117. } \
  2118. else \
  2119. { \
  2120. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  2121. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  2122. } \
  2123. } while(0)
  2124. /** @brief Macros to enable or disable the Internal High Speed 48MHz oscillator (HSI48).
  2125. * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes.
  2126. * @note After enabling the HSI48, the application software should wait on HSI48RDY
  2127. * flag to be set indicating that HSI48 clock is stable.
  2128. * This parameter can be: ENABLE or DISABLE.
  2129. * @retval None
  2130. */
  2131. #define __HAL_RCC_HSI48_ENABLE() SET_BIT(RCC->CRRCR, RCC_CRRCR_HSI48ON)
  2132. #define __HAL_RCC_HSI48_DISABLE() CLEAR_BIT(RCC->CRRCR, RCC_CRRCR_HSI48ON)
  2133. /** @brief Macros to configure the RTC clock (RTCCLK).
  2134. * @note As the RTC clock configuration bits are in the Backup domain and write
  2135. * access is denied to this domain after reset, you have to enable write
  2136. * access using the Power Backup Access macro before to configure
  2137. * the RTC clock source (to be done once after reset).
  2138. * @note Once the RTC clock is configured it cannot be changed unless the
  2139. * Backup domain is reset using __HAL_RCC_BACKUPRESET_FORCE() macro, or by
  2140. * a Power On Reset (POR).
  2141. *
  2142. * @param __RTC_CLKSOURCE__ specifies the RTC clock source.
  2143. * This parameter can be one of the following values:
  2144. * @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
  2145. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  2146. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  2147. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  2148. *
  2149. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  2150. * work in STOP and STANDBY modes, and can be used as wakeup source.
  2151. * However, when the HSE clock is used as RTC clock source, the RTC
  2152. * cannot be used in STOP and STANDBY modes.
  2153. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  2154. * RTC clock source).
  2155. * @retval None
  2156. */
  2157. #define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) \
  2158. MODIFY_REG( RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
  2159. /** @brief Macro to get the RTC clock source.
  2160. * @retval The returned value can be one of the following:
  2161. * @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
  2162. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  2163. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  2164. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  2165. */
  2166. #define __HAL_RCC_GET_RTC_SOURCE() (READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL))
  2167. /** @brief Macros to enable or disable the main PLL.
  2168. * @note After enabling the main PLL, the application software should wait on
  2169. * PLLRDY flag to be set indicating that PLL clock is stable and can
  2170. * be used as system clock source.
  2171. * @note The main PLL can not be disabled if it is used as system clock source
  2172. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  2173. * @retval None
  2174. */
  2175. #define __HAL_RCC_PLL_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLON)
  2176. #define __HAL_RCC_PLL_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLON)
  2177. /** @brief Macro to configure the PLL clock source.
  2178. * @note This function must be used only when the main PLL is disabled.
  2179. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  2180. * This parameter can be one of the following values:
  2181. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  2182. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  2183. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  2184. * @retval None
  2185. *
  2186. */
  2187. #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) \
  2188. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
  2189. /** @brief Macro to configure the PLL source division factor M.
  2190. * @note This function must be used only when the main PLL is disabled.
  2191. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  2192. * This parameter must be a value of @ref RCC_PLLM_Clock_Divider.
  2193. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  2194. * frequency ranges from 2.66 to 8 MHz. It is recommended to select a frequency
  2195. * of 8 MHz to limit PLL jitter.
  2196. * @retval None
  2197. *
  2198. */
  2199. #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) \
  2200. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, ((__PLLM__) - 1) << RCC_PLLCFGR_PLLM_Pos)
  2201. /**
  2202. * @brief Macro to configure the main PLL clock source, multiplication and division factors.
  2203. * @note This macro must be used only when the main PLL is disabled.
  2204. * @note This macro preserves the PLL's output clocks enable state.
  2205. *
  2206. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  2207. * This parameter can be one of the following values:
  2208. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  2209. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  2210. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  2211. *
  2212. * @param __PLLM__ specifies the division factor for PLL VCO input clock.
  2213. * This parameter must be a value of @ref RCC_PLLM_Clock_Divider
  2214. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  2215. * frequency ranges from 2.66 to 8 MHz. It is recommended to select a frequency
  2216. * of 8 MHz to limit PLL jitter.
  2217. *
  2218. * @param __PLLN__ specifies the multiplication factor for PLL VCO output clock.
  2219. * This parameter must be a number between 8 and 127.
  2220. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  2221. * output frequency is between 64 and 344 MHz.
  2222. *
  2223. * @param __PLLP__ specifies the division factor for SAI clock.
  2224. * This parameter must be a number in the range (2 to 31).
  2225. *
  2226. * @param __PLLQ__ specifies the division factor for OTG FS, SDMMC1 and RNG clocks.
  2227. * This parameter must be in the range (2, 4, 6 or 8).
  2228. * @note If the USB OTG FS is used in your application, you have to set the
  2229. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  2230. * the SDMMC1 and RNG need a frequency lower than or equal to 48 MHz to work
  2231. * correctly.
  2232. * @param __PLLR__ specifies the division factor for the main system clock.
  2233. * @note You have to set the PLLR parameter correctly to not exceed 170MHZ.
  2234. * This parameter must be in the range (2, 4, 6 or 8).
  2235. * @retval None
  2236. */
  2237. #define __HAL_RCC_PLL_CONFIG(__PLLSOURCE__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__,__PLLR__ ) \
  2238. MODIFY_REG(RCC->PLLCFGR, \
  2239. (RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | \
  2240. RCC_PLLCFGR_PLLQ | RCC_PLLCFGR_PLLR | RCC_PLLCFGR_PLLPDIV), \
  2241. ((__PLLSOURCE__) | \
  2242. (((__PLLM__) - 1U) << RCC_PLLCFGR_PLLM_Pos) | \
  2243. ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  2244. ((((__PLLQ__) >> 1U) - 1U) << RCC_PLLCFGR_PLLQ_Pos) | \
  2245. ((((__PLLR__) >> 1U) - 1U) << RCC_PLLCFGR_PLLR_Pos) | \
  2246. ((__PLLP__) << RCC_PLLCFGR_PLLPDIV_Pos)))
  2247. /** @brief Macro to get the oscillator used as PLL clock source.
  2248. * @retval The oscillator used as PLL clock source. The returned value can be one
  2249. * of the following:
  2250. * - RCC_PLLSOURCE_NONE: No oscillator is used as PLL clock source.
  2251. * - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source.
  2252. * - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source.
  2253. */
  2254. #define __HAL_RCC_GET_PLL_OSCSOURCE() (READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC))
  2255. /**
  2256. * @brief Enable or disable each clock output (RCC_PLL_SYSCLK, RCC_PLL_48M1CLK, RCC_PLL_ADCCLK)
  2257. * @note Enabling/disabling clock outputs RCC_PLL_ADCCLK and RCC_PLL_48M1CLK can be done at anytime
  2258. * without the need to stop the PLL in order to save power. But RCC_PLL_SYSCLK cannot
  2259. * be stopped if used as System Clock.
  2260. * @param __PLLCLOCKOUT__ specifies the PLL clock to be output.
  2261. * This parameter can be one or a combination of the following values:
  2262. * @arg @ref RCC_PLL_ADCCLK This clock is used to generate a clock on ADC.
  2263. * @arg @ref RCC_PLL_48M1CLK This Clock is used to generate the clock for the USB (48 MHz),
  2264. * FDCAN (<=48 MHz) and QSPI (<=48 MHz).
  2265. * @arg @ref RCC_PLL_SYSCLK This Clock is used to generate the high speed system clock (up to 170MHz)
  2266. * @retval None
  2267. */
  2268. #define __HAL_RCC_PLLCLKOUT_ENABLE(__PLLCLOCKOUT__) SET_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2269. #define __HAL_RCC_PLLCLKOUT_DISABLE(__PLLCLOCKOUT__) CLEAR_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2270. /**
  2271. * @brief Get clock output enable status (RCC_PLL_SYSCLK, RCC_PLL_48M1CLK, RCC_PLL_SAI3CLK)
  2272. * @param __PLLCLOCKOUT__ specifies the output PLL clock to be checked.
  2273. * This parameter can be one of the following values:
  2274. * @arg @ref RCC_PLL_ADCCLK This clock is used to generate a clock on ADC.
  2275. * @arg @ref RCC_PLL_48M1CLK This Clock is used to generate the clock for the USB (48 MHz),
  2276. * FDCAN (<=48 MHz) and QSPI (<=48 MHz).
  2277. * @arg @ref RCC_PLL_SYSCLK This Clock is used to generate the high speed system clock (up to 170MHz)
  2278. * @retval SET / RESET
  2279. */
  2280. #define __HAL_RCC_GET_PLLCLKOUT_CONFIG(__PLLCLOCKOUT__) READ_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  2281. /**
  2282. * @brief Macro to configure the system clock source.
  2283. * @param __SYSCLKSOURCE__ specifies the system clock source.
  2284. * This parameter can be one of the following values:
  2285. * - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
  2286. * - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
  2287. * - RCC_SYSCLKSOURCE_PLLCLK: PLL output is used as system clock source.
  2288. * @retval None
  2289. */
  2290. #define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
  2291. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__SYSCLKSOURCE__))
  2292. /** @brief Macro to get the clock source used as system clock.
  2293. * @retval The clock source used as system clock. The returned value can be one
  2294. * of the following:
  2295. * - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
  2296. * - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
  2297. * - RCC_SYSCLKSOURCE_STATUS_PLLCLK: PLL used as system clock.
  2298. */
  2299. #define __HAL_RCC_GET_SYSCLK_SOURCE() (READ_BIT(RCC->CFGR, RCC_CFGR_SWS))
  2300. /**
  2301. * @brief Macro to configure the External Low Speed oscillator (LSE) drive capability.
  2302. * @note As the LSE is in the Backup domain and write access is denied to
  2303. * this domain after reset, you have to enable write access using
  2304. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  2305. * (to be done once after reset).
  2306. * @param __LSEDRIVE__ specifies the new state of the LSE drive capability.
  2307. * This parameter can be one of the following values:
  2308. * @arg @ref RCC_LSEDRIVE_LOW LSE oscillator low drive capability.
  2309. * @arg @ref RCC_LSEDRIVE_MEDIUMLOW LSE oscillator medium low drive capability.
  2310. * @arg @ref RCC_LSEDRIVE_MEDIUMHIGH LSE oscillator medium high drive capability.
  2311. * @arg @ref RCC_LSEDRIVE_HIGH LSE oscillator high drive capability.
  2312. * @retval None
  2313. */
  2314. #define __HAL_RCC_LSEDRIVE_CONFIG(__LSEDRIVE__) \
  2315. MODIFY_REG(RCC->BDCR, RCC_BDCR_LSEDRV, (__LSEDRIVE__))
  2316. /** @brief Macro to configure the MCO clock.
  2317. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  2318. * This parameter can be one of the following values:
  2319. * @arg @ref RCC_MCO1SOURCE_NOCLOCK MCO output disabled
  2320. * @arg @ref RCC_MCO1SOURCE_SYSCLK System clock selected as MCO source
  2321. * @arg @ref RCC_MCO1SOURCE_HSI HSI clock selected as MCO source
  2322. * @arg @ref RCC_MCO1SOURCE_HSE HSE clock selected as MCO source
  2323. * @arg @ref RCC_MCO1SOURCE_PLLCLK Main PLL clock selected as MCO source
  2324. * @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO source
  2325. * @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO source
  2326. * @arg @ref RCC_MCO1SOURCE_HSI48 HSI48 clock selected as MCO source for devices with HSI48
  2327. * @param __MCODIV__ specifies the MCO clock prescaler.
  2328. * This parameter can be one of the following values:
  2329. * @arg @ref RCC_MCODIV_1 MCO clock source is divided by 1
  2330. * @arg @ref RCC_MCODIV_2 MCO clock source is divided by 2
  2331. * @arg @ref RCC_MCODIV_4 MCO clock source is divided by 4
  2332. * @arg @ref RCC_MCODIV_8 MCO clock source is divided by 8
  2333. * @arg @ref RCC_MCODIV_16 MCO clock source is divided by 16
  2334. */
  2335. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  2336. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  2337. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  2338. * @brief macros to manage the specified RCC Flags and interrupts.
  2339. * @{
  2340. */
  2341. /** @brief Enable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to enable
  2342. * the selected interrupts).
  2343. * @param __INTERRUPT__ specifies the RCC interrupt sources to be enabled.
  2344. * This parameter can be any combination of the following values:
  2345. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2346. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2347. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2348. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2349. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2350. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2351. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2352. * @retval None
  2353. */
  2354. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) SET_BIT(RCC->CIER, (__INTERRUPT__))
  2355. /** @brief Disable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to disable
  2356. * the selected interrupts).
  2357. * @param __INTERRUPT__ specifies the RCC interrupt sources to be disabled.
  2358. * This parameter can be any combination of the following values:
  2359. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2360. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2361. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2362. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2363. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2364. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2365. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2366. * @retval None
  2367. */
  2368. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(RCC->CIER, (__INTERRUPT__))
  2369. /** @brief Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CIR[23:16]
  2370. * bits to clear the selected interrupt pending bits.
  2371. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  2372. * This parameter can be any combination of the following values:
  2373. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2374. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2375. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2376. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2377. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2378. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  2379. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2380. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2381. * @retval None
  2382. */
  2383. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (RCC->CICR = (__INTERRUPT__))
  2384. /** @brief Check whether the RCC interrupt has occurred or not.
  2385. * @param __INTERRUPT__ specifies the RCC interrupt source to check.
  2386. * This parameter can be one of the following values:
  2387. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  2388. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  2389. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  2390. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  2391. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  2392. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  2393. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  2394. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  2395. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  2396. */
  2397. #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIFR & (__INTERRUPT__)) == (__INTERRUPT__))
  2398. /** @brief Set RMVF bit to clear the reset flags.
  2399. * The reset flags are: RCC_FLAG_FWRRST, RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_BORRST,
  2400. * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
  2401. * @retval None
  2402. */
  2403. #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
  2404. /** @brief Check whether the selected RCC flag is set or not.
  2405. * @param __FLAG__ specifies the flag to check.
  2406. * This parameter can be one of the following values:
  2407. * @arg @ref RCC_FLAG_HSIRDY HSI oscillator clock ready
  2408. * @arg @ref RCC_FLAG_HSERDY HSE oscillator clock ready
  2409. * @arg @ref RCC_FLAG_PLLRDY Main PLL clock ready
  2410. * @arg @ref RCC_FLAG_HSI48RDY HSI48 clock ready for devices with HSI48
  2411. * @arg @ref RCC_FLAG_LSERDY LSE oscillator clock ready
  2412. * @arg @ref RCC_FLAG_LSECSSD Clock security system failure on LSE oscillator detection
  2413. * @arg @ref RCC_FLAG_LSIRDY LSI oscillator clock ready
  2414. * @arg @ref RCC_FLAG_BORRST BOR reset
  2415. * @arg @ref RCC_FLAG_OBLRST OBLRST reset
  2416. * @arg @ref RCC_FLAG_PINRST Pin reset
  2417. * @arg @ref RCC_FLAG_SFTRST Software reset
  2418. * @arg @ref RCC_FLAG_IWDGRST Independent Watchdog reset
  2419. * @arg @ref RCC_FLAG_WWDGRST Window Watchdog reset
  2420. * @arg @ref RCC_FLAG_LPWRRST Low Power reset
  2421. * @retval The new state of __FLAG__ (TRUE or FALSE).
  2422. */
  2423. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U) ? RCC->CR : \
  2424. ((((__FLAG__) >> 5U) == 4U) ? RCC->CRRCR : \
  2425. ((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR : \
  2426. ((((__FLAG__) >> 5U) == 3U) ? RCC->CSR : RCC->CIFR)))) & \
  2427. ((uint32_t)1U << ((__FLAG__) & RCC_FLAG_MASK))) != 0U) \
  2428. ? 1U : 0U)
  2429. /**
  2430. * @}
  2431. */
  2432. /**
  2433. * @}
  2434. */
  2435. /* Private constants ---------------------------------------------------------*/
  2436. /** @addtogroup RCC_Private_Constants
  2437. * @{
  2438. */
  2439. /* Defines used for Flags */
  2440. #define CR_REG_INDEX 1U
  2441. #define BDCR_REG_INDEX 2U
  2442. #define CSR_REG_INDEX 3U
  2443. #define CRRCR_REG_INDEX 4U
  2444. #define RCC_FLAG_MASK 0x1FU
  2445. /* Define used for IS_RCC_CLOCKTYPE() */
  2446. #define RCC_CLOCKTYPE_ALL (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2) /*!< All clcoktype to configure */
  2447. /**
  2448. * @}
  2449. */
  2450. /* Private macros ------------------------------------------------------------*/
  2451. /** @addtogroup RCC_Private_Macros
  2452. * @{
  2453. */
  2454. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  2455. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  2456. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  2457. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI48) == RCC_OSCILLATORTYPE_HSI48) || \
  2458. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  2459. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
  2460. #define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
  2461. ((__HSE__) == RCC_HSE_BYPASS))
  2462. #define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
  2463. ((__LSE__) == RCC_LSE_BYPASS))
  2464. #define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
  2465. #define IS_RCC_HSI_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= (RCC_ICSCR_HSITRIM >> RCC_ICSCR_HSITRIM_Pos))
  2466. #define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
  2467. #define IS_RCC_HSI48(__HSI48__) (((__HSI48__) == RCC_HSI48_OFF) || ((__HSI48__) == RCC_HSI48_ON))
  2468. #define IS_RCC_PLL(__PLL__) (((__PLL__) == RCC_PLL_NONE) ||((__PLL__) == RCC_PLL_OFF) || \
  2469. ((__PLL__) == RCC_PLL_ON))
  2470. #define IS_RCC_PLLSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLSOURCE_NONE) || \
  2471. ((__SOURCE__) == RCC_PLLSOURCE_HSI) || \
  2472. ((__SOURCE__) == RCC_PLLSOURCE_HSE))
  2473. #define IS_RCC_PLLM_VALUE(__VALUE__) ((1U <= (__VALUE__)) && ((__VALUE__) <= 16U))
  2474. #define IS_RCC_PLLN_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 127U))
  2475. #define IS_RCC_PLLP_VALUE(__VALUE__) (((__VALUE__) >= 2U) && ((__VALUE__) <= 31U))
  2476. #define IS_RCC_PLLQ_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2477. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2478. #define IS_RCC_PLLR_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2479. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2480. #define IS_RCC_CLOCKTYPE(__CLK__) ((((__CLK__) & RCC_CLOCKTYPE_ALL) != 0x00UL) && (((__CLK__) & ~RCC_CLOCKTYPE_ALL) == 0x00UL))
  2481. #define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
  2482. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
  2483. ((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
  2484. #define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
  2485. ((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
  2486. ((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
  2487. ((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
  2488. ((__HCLK__) == RCC_SYSCLK_DIV512))
  2489. #define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
  2490. ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
  2491. ((__PCLK__) == RCC_HCLK_DIV16))
  2492. #define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_NONE) || \
  2493. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
  2494. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
  2495. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV32))
  2496. #define IS_RCC_MCO(__MCOX__) (((__MCOX__) == RCC_MCO_PA8) || \
  2497. ((__MCOX__) == RCC_MCO_PG10))
  2498. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
  2499. ((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
  2500. ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
  2501. ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
  2502. ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
  2503. ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
  2504. ((__SOURCE__) == RCC_MCO1SOURCE_LSE) || \
  2505. ((__SOURCE__) == RCC_MCO1SOURCE_HSI48))
  2506. #define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1) || ((__DIV__) == RCC_MCODIV_2) || \
  2507. ((__DIV__) == RCC_MCODIV_4) || ((__DIV__) == RCC_MCODIV_8) || \
  2508. ((__DIV__) == RCC_MCODIV_16))
  2509. #define IS_RCC_LSE_DRIVE(__DRIVE__) (((__DRIVE__) == RCC_LSEDRIVE_LOW) || \
  2510. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMLOW) || \
  2511. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMHIGH) || \
  2512. ((__DRIVE__) == RCC_LSEDRIVE_HIGH))
  2513. /**
  2514. * @}
  2515. */
  2516. /* Include RCC HAL Extended module */
  2517. #include "stm32g4xx_hal_rcc_ex.h"
  2518. /* Exported functions --------------------------------------------------------*/
  2519. /** @addtogroup RCC_Exported_Functions
  2520. * @{
  2521. */
  2522. /** @addtogroup RCC_Exported_Functions_Group1
  2523. * @{
  2524. */
  2525. /* Initialization and de-initialization functions ******************************/
  2526. HAL_StatusTypeDef HAL_RCC_DeInit(void);
  2527. HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  2528. HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
  2529. /**
  2530. * @}
  2531. */
  2532. /** @addtogroup RCC_Exported_Functions_Group2
  2533. * @{
  2534. */
  2535. /* Peripheral Control functions ************************************************/
  2536. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  2537. void HAL_RCC_EnableCSS(void);
  2538. void HAL_RCC_EnableLSECSS(void);
  2539. void HAL_RCC_DisableLSECSS(void);
  2540. uint32_t HAL_RCC_GetSysClockFreq(void);
  2541. uint32_t HAL_RCC_GetHCLKFreq(void);
  2542. uint32_t HAL_RCC_GetPCLK1Freq(void);
  2543. uint32_t HAL_RCC_GetPCLK2Freq(void);
  2544. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  2545. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
  2546. /* CSS NMI IRQ handler */
  2547. void HAL_RCC_NMI_IRQHandler(void);
  2548. /* User Callbacks in non blocking mode (IT mode) */
  2549. void HAL_RCC_CSSCallback(void);
  2550. /**
  2551. * @}
  2552. */
  2553. /**
  2554. * @}
  2555. */
  2556. /**
  2557. * @}
  2558. */
  2559. /**
  2560. * @}
  2561. */
  2562. #ifdef __cplusplus
  2563. }
  2564. #endif
  2565. #endif /* STM32G4xx_HAL_RCC_H */