stm32l4xx_hal_rcc.h 214 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32L4xx_HAL_RCC_H
  21. #define __STM32L4xx_HAL_RCC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32l4xx_hal_def.h"
  27. /** @addtogroup STM32L4xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup RCC
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup RCC_Exported_Types RCC Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief RCC PLL configuration structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t PLLState; /*!< The new state of the PLL.
  43. This parameter can be a value of @ref RCC_PLL_Config */
  44. uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
  45. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  46. uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock.
  47. This parameter must be a number between Min_Data = 1 and Max_Data = 16 on STM32L4Rx/STM32L4Sx devices.
  48. This parameter must be a number between Min_Data = 1 and Max_Data = 8 on the other devices */
  49. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock.
  50. This parameter must be a number between Min_Data = 8 and Max_Data = 86 */
  51. #if defined(RCC_PLLP_SUPPORT)
  52. uint32_t PLLP; /*!< PLLP: Division factor for SAI clock.
  53. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  54. #endif /* RCC_PLLP_SUPPORT */
  55. uint32_t PLLQ; /*!< PLLQ: Division factor for SDMMC1, RNG and USB clocks.
  56. This parameter must be a value of @ref RCC_PLLQ_Clock_Divider */
  57. uint32_t PLLR; /*!< PLLR: Division for the main system clock.
  58. User have to set the PLLR parameter correctly to not exceed max frequency 120MHZ
  59. on STM32L4Rx/STM32L4Sx devices else 80MHz on the other devices.
  60. This parameter must be a value of @ref RCC_PLLR_Clock_Divider */
  61. }RCC_PLLInitTypeDef;
  62. /**
  63. * @brief RCC Internal/External Oscillator (HSE, HSI, MSI, LSE and LSI) configuration structure definition
  64. */
  65. typedef struct
  66. {
  67. uint32_t OscillatorType; /*!< The oscillators to be configured.
  68. This parameter can be a value of @ref RCC_Oscillator_Type */
  69. uint32_t HSEState; /*!< The new state of the HSE.
  70. This parameter can be a value of @ref RCC_HSE_Config */
  71. uint32_t LSEState; /*!< The new state of the LSE.
  72. This parameter can be a value of @ref RCC_LSE_Config */
  73. uint32_t HSIState; /*!< The new state of the HSI.
  74. This parameter can be a value of @ref RCC_HSI_Config */
  75. uint32_t HSICalibrationValue; /*!< The calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  76. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F on STM32L43x/STM32L44x/STM32L47x/STM32L48x devices.
  77. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F on the other devices */
  78. uint32_t LSIState; /*!< The new state of the LSI.
  79. This parameter can be a value of @ref RCC_LSI_Config */
  80. #if defined(RCC_CSR_LSIPREDIV)
  81. uint32_t LSIDiv; /*!< The division factor of the LSI.
  82. This parameter can be a value of @ref RCC_LSI_Div */
  83. #endif /* RCC_CSR_LSIPREDIV */
  84. uint32_t MSIState; /*!< The new state of the MSI.
  85. This parameter can be a value of @ref RCC_MSI_Config */
  86. uint32_t MSICalibrationValue; /*!< The calibration trimming value (default is RCC_MSICALIBRATION_DEFAULT).
  87. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */
  88. uint32_t MSIClockRange; /*!< The MSI frequency range.
  89. This parameter can be a value of @ref RCC_MSI_Clock_Range */
  90. uint32_t HSI48State; /*!< The new state of the HSI48 (only applicable to STM32L43x/STM32L44x/STM32L49x/STM32L4Ax devices).
  91. This parameter can be a value of @ref RCC_HSI48_Config */
  92. RCC_PLLInitTypeDef PLL; /*!< Main PLL structure parameters */
  93. }RCC_OscInitTypeDef;
  94. /**
  95. * @brief RCC System, AHB and APB busses clock configuration structure definition
  96. */
  97. typedef struct
  98. {
  99. uint32_t ClockType; /*!< The clock to be configured.
  100. This parameter can be a value of @ref RCC_System_Clock_Type */
  101. uint32_t SYSCLKSource; /*!< The clock source used as system clock (SYSCLK).
  102. This parameter can be a value of @ref RCC_System_Clock_Source */
  103. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  104. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  105. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  106. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  107. uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
  108. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  109. }RCC_ClkInitTypeDef;
  110. /**
  111. * @}
  112. */
  113. /* Exported constants --------------------------------------------------------*/
  114. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  115. * @{
  116. */
  117. /** @defgroup RCC_Timeout_Value Timeout Values
  118. * @{
  119. */
  120. #define RCC_DBP_TIMEOUT_VALUE 2U /* 2 ms (minimum Tick + 1) */
  121. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
  122. /**
  123. * @}
  124. */
  125. /** @defgroup RCC_Oscillator_Type Oscillator Type
  126. * @{
  127. */
  128. #define RCC_OSCILLATORTYPE_NONE 0x00000000U /*!< Oscillator configuration unchanged */
  129. #define RCC_OSCILLATORTYPE_HSE 0x00000001U /*!< HSE to configure */
  130. #define RCC_OSCILLATORTYPE_HSI 0x00000002U /*!< HSI to configure */
  131. #define RCC_OSCILLATORTYPE_LSE 0x00000004U /*!< LSE to configure */
  132. #define RCC_OSCILLATORTYPE_LSI 0x00000008U /*!< LSI to configure */
  133. #define RCC_OSCILLATORTYPE_MSI 0x00000010U /*!< MSI to configure */
  134. #if defined(RCC_HSI48_SUPPORT)
  135. #define RCC_OSCILLATORTYPE_HSI48 0x00000020U /*!< HSI48 to configure */
  136. #endif /* RCC_HSI48_SUPPORT */
  137. /**
  138. * @}
  139. */
  140. /** @defgroup RCC_HSE_Config HSE Config
  141. * @{
  142. */
  143. #define RCC_HSE_OFF 0x00000000U /*!< HSE clock deactivation */
  144. #define RCC_HSE_ON RCC_CR_HSEON /*!< HSE clock activation */
  145. #define RCC_HSE_BYPASS (RCC_CR_HSEBYP | RCC_CR_HSEON) /*!< External clock source for HSE clock */
  146. /**
  147. * @}
  148. */
  149. /** @defgroup RCC_LSE_Config LSE Config
  150. * @{
  151. */
  152. #define RCC_LSE_OFF 0x00000000U /*!< LSE clock deactivation */
  153. #define RCC_LSE_ON RCC_BDCR_LSEON /*!< LSE clock activation */
  154. #define RCC_LSE_BYPASS (RCC_BDCR_LSEBYP | RCC_BDCR_LSEON) /*!< External clock source for LSE clock */
  155. #if defined(RCC_BDCR_LSESYSDIS)
  156. #define RCC_LSE_ON_RTC_ONLY (RCC_BDCR_LSESYSDIS | RCC_BDCR_LSEON) /*!< LSE clock activation without propagation to system */
  157. #define RCC_LSE_BYPASS_RTC_ONLY (RCC_BDCR_LSEBYP | RCC_BDCR_LSESYSDIS | RCC_BDCR_LSEON) /*!< External clock source for LSE clock without propagation to system */
  158. #endif /* RCC_BDCR_LSESYSDIS */
  159. /**
  160. * @}
  161. */
  162. /** @defgroup RCC_HSI_Config HSI Config
  163. * @{
  164. */
  165. #define RCC_HSI_OFF 0x00000000U /*!< HSI clock deactivation */
  166. #define RCC_HSI_ON RCC_CR_HSION /*!< HSI clock activation */
  167. #if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx) || \
  168. defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
  169. #define RCC_HSICALIBRATION_DEFAULT 0x10U /* Default HSI calibration trimming value */
  170. #else
  171. #define RCC_HSICALIBRATION_DEFAULT 0x40U /* Default HSI calibration trimming value */
  172. #endif /* STM32L431xx || STM32L432xx || STM32L433xx || STM32L442xx || STM32L443xx || */
  173. /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup RCC_LSI_Config LSI Config
  178. * @{
  179. */
  180. #define RCC_LSI_OFF 0x00000000U /*!< LSI clock deactivation */
  181. #define RCC_LSI_ON RCC_CSR_LSION /*!< LSI clock activation */
  182. /**
  183. * @}
  184. */
  185. #if defined(RCC_CSR_LSIPREDIV)
  186. /** @defgroup RCC_LSI_Div LSI Div
  187. * @{
  188. */
  189. #define RCC_LSI_DIV1 0x00000000U /*!< LSI clock not divided */
  190. #define RCC_LSI_DIV128 RCC_CSR_LSIPREDIV /*!< LSI clock divided by 128 */
  191. /**
  192. * @}
  193. */
  194. #endif /* RCC_CSR_LSIPREDIV */
  195. /** @defgroup RCC_MSI_Config MSI Config
  196. * @{
  197. */
  198. #define RCC_MSI_OFF 0x00000000U /*!< MSI clock deactivation */
  199. #define RCC_MSI_ON RCC_CR_MSION /*!< MSI clock activation */
  200. #define RCC_MSICALIBRATION_DEFAULT 0U /*!< Default MSI calibration trimming value */
  201. /**
  202. * @}
  203. */
  204. #if defined(RCC_HSI48_SUPPORT)
  205. /** @defgroup RCC_HSI48_Config HSI48 Config
  206. * @{
  207. */
  208. #define RCC_HSI48_OFF 0x00000000U /*!< HSI48 clock deactivation */
  209. #define RCC_HSI48_ON RCC_CRRCR_HSI48ON /*!< HSI48 clock activation */
  210. /**
  211. * @}
  212. */
  213. #else
  214. /** @defgroup RCC_HSI48_Config HSI48 Config
  215. * @{
  216. */
  217. #define RCC_HSI48_OFF 0x00000000U /*!< HSI48 clock deactivation */
  218. /**
  219. * @}
  220. */
  221. #endif /* RCC_HSI48_SUPPORT */
  222. /** @defgroup RCC_PLL_Config PLL Config
  223. * @{
  224. */
  225. #define RCC_PLL_NONE 0x00000000U /*!< PLL configuration unchanged */
  226. #define RCC_PLL_OFF 0x00000001U /*!< PLL deactivation */
  227. #define RCC_PLL_ON 0x00000002U /*!< PLL activation */
  228. /**
  229. * @}
  230. */
  231. #if defined(RCC_PLLP_SUPPORT)
  232. /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
  233. * @{
  234. */
  235. #if defined(RCC_PLLP_DIV_2_31_SUPPORT)
  236. #define RCC_PLLP_DIV2 0x00000002U /*!< PLLP division factor = 2 */
  237. #define RCC_PLLP_DIV3 0x00000003U /*!< PLLP division factor = 3 */
  238. #define RCC_PLLP_DIV4 0x00000004U /*!< PLLP division factor = 4 */
  239. #define RCC_PLLP_DIV5 0x00000005U /*!< PLLP division factor = 5 */
  240. #define RCC_PLLP_DIV6 0x00000006U /*!< PLLP division factor = 6 */
  241. #define RCC_PLLP_DIV7 0x00000007U /*!< PLLP division factor = 7 */
  242. #define RCC_PLLP_DIV8 0x00000008U /*!< PLLP division factor = 8 */
  243. #define RCC_PLLP_DIV9 0x00000009U /*!< PLLP division factor = 9 */
  244. #define RCC_PLLP_DIV10 0x0000000AU /*!< PLLP division factor = 10 */
  245. #define RCC_PLLP_DIV11 0x0000000BU /*!< PLLP division factor = 11 */
  246. #define RCC_PLLP_DIV12 0x0000000CU /*!< PLLP division factor = 12 */
  247. #define RCC_PLLP_DIV13 0x0000000DU /*!< PLLP division factor = 13 */
  248. #define RCC_PLLP_DIV14 0x0000000EU /*!< PLLP division factor = 14 */
  249. #define RCC_PLLP_DIV15 0x0000000FU /*!< PLLP division factor = 15 */
  250. #define RCC_PLLP_DIV16 0x00000010U /*!< PLLP division factor = 16 */
  251. #define RCC_PLLP_DIV17 0x00000011U /*!< PLLP division factor = 17 */
  252. #define RCC_PLLP_DIV18 0x00000012U /*!< PLLP division factor = 18 */
  253. #define RCC_PLLP_DIV19 0x00000013U /*!< PLLP division factor = 19 */
  254. #define RCC_PLLP_DIV20 0x00000014U /*!< PLLP division factor = 20 */
  255. #define RCC_PLLP_DIV21 0x00000015U /*!< PLLP division factor = 21 */
  256. #define RCC_PLLP_DIV22 0x00000016U /*!< PLLP division factor = 22 */
  257. #define RCC_PLLP_DIV23 0x00000017U /*!< PLLP division factor = 23 */
  258. #define RCC_PLLP_DIV24 0x00000018U /*!< PLLP division factor = 24 */
  259. #define RCC_PLLP_DIV25 0x00000019U /*!< PLLP division factor = 25 */
  260. #define RCC_PLLP_DIV26 0x0000001AU /*!< PLLP division factor = 26 */
  261. #define RCC_PLLP_DIV27 0x0000001BU /*!< PLLP division factor = 27 */
  262. #define RCC_PLLP_DIV28 0x0000001CU /*!< PLLP division factor = 28 */
  263. #define RCC_PLLP_DIV29 0x0000001DU /*!< PLLP division factor = 29 */
  264. #define RCC_PLLP_DIV30 0x0000001EU /*!< PLLP division factor = 30 */
  265. #define RCC_PLLP_DIV31 0x0000001FU /*!< PLLP division factor = 31 */
  266. #else
  267. #define RCC_PLLP_DIV7 0x00000007U /*!< PLLP division factor = 7 */
  268. #define RCC_PLLP_DIV17 0x00000011U /*!< PLLP division factor = 17 */
  269. #endif /* RCC_PLLP_DIV_2_31_SUPPORT */
  270. /**
  271. * @}
  272. */
  273. #endif /* RCC_PLLP_SUPPORT */
  274. /** @defgroup RCC_PLLQ_Clock_Divider PLLQ Clock Divider
  275. * @{
  276. */
  277. #define RCC_PLLQ_DIV2 0x00000002U /*!< PLLQ division factor = 2 */
  278. #define RCC_PLLQ_DIV4 0x00000004U /*!< PLLQ division factor = 4 */
  279. #define RCC_PLLQ_DIV6 0x00000006U /*!< PLLQ division factor = 6 */
  280. #define RCC_PLLQ_DIV8 0x00000008U /*!< PLLQ division factor = 8 */
  281. /**
  282. * @}
  283. */
  284. /** @defgroup RCC_PLLR_Clock_Divider PLLR Clock Divider
  285. * @{
  286. */
  287. #define RCC_PLLR_DIV2 0x00000002U /*!< PLLR division factor = 2 */
  288. #define RCC_PLLR_DIV4 0x00000004U /*!< PLLR division factor = 4 */
  289. #define RCC_PLLR_DIV6 0x00000006U /*!< PLLR division factor = 6 */
  290. #define RCC_PLLR_DIV8 0x00000008U /*!< PLLR division factor = 8 */
  291. /**
  292. * @}
  293. */
  294. /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
  295. * @{
  296. */
  297. #define RCC_PLLSOURCE_NONE 0x00000000U /*!< No clock selected as PLL entry clock source */
  298. #define RCC_PLLSOURCE_MSI RCC_PLLCFGR_PLLSRC_MSI /*!< MSI clock selected as PLL entry clock source */
  299. #define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI /*!< HSI clock selected as PLL entry clock source */
  300. #define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */
  301. /**
  302. * @}
  303. */
  304. /** @defgroup RCC_PLL_Clock_Output PLL Clock Output
  305. * @{
  306. */
  307. #if defined(RCC_PLLSAI2_SUPPORT)
  308. #define RCC_PLL_SAI3CLK RCC_PLLCFGR_PLLPEN /*!< PLLSAI3CLK selection from main PLL (for devices with PLLSAI2) */
  309. #elif defined(RCC_PLLSAI1_SUPPORT)
  310. #define RCC_PLL_SAI2CLK RCC_PLLCFGR_PLLPEN /*!< PLLSAI2CLK selection from main PLL (for devices without PLLSAI2) */
  311. #endif /* RCC_PLLSAI2_SUPPORT */
  312. #define RCC_PLL_48M1CLK RCC_PLLCFGR_PLLQEN /*!< PLL48M1CLK selection from main PLL */
  313. #define RCC_PLL_SYSCLK RCC_PLLCFGR_PLLREN /*!< PLLCLK selection from main PLL */
  314. /**
  315. * @}
  316. */
  317. #if defined(RCC_PLLSAI1_SUPPORT)
  318. /** @defgroup RCC_PLLSAI1_Clock_Output PLLSAI1 Clock Output
  319. * @{
  320. */
  321. #define RCC_PLLSAI1_SAI1CLK RCC_PLLSAI1CFGR_PLLSAI1PEN /*!< PLLSAI1CLK selection from PLLSAI1 */
  322. #define RCC_PLLSAI1_48M2CLK RCC_PLLSAI1CFGR_PLLSAI1QEN /*!< PLL48M2CLK selection from PLLSAI1 */
  323. #define RCC_PLLSAI1_ADC1CLK RCC_PLLSAI1CFGR_PLLSAI1REN /*!< PLLADC1CLK selection from PLLSAI1 */
  324. /**
  325. * @}
  326. */
  327. #endif /* RCC_PLLSAI1_SUPPORT */
  328. #if defined(RCC_PLLSAI2_SUPPORT)
  329. /** @defgroup RCC_PLLSAI2_Clock_Output PLLSAI2 Clock Output
  330. * @{
  331. */
  332. #define RCC_PLLSAI2_SAI2CLK RCC_PLLSAI2CFGR_PLLSAI2PEN /*!< PLLSAI2CLK selection from PLLSAI2 */
  333. #if defined(RCC_PLLSAI2Q_DIV_SUPPORT)
  334. #define RCC_PLLSAI2_DSICLK RCC_PLLSAI2CFGR_PLLSAI2QEN /*!< PLLDSICLK selection from PLLSAI2 */
  335. #endif /* RCC_PLLSAI2Q_DIV_SUPPORT */
  336. #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)
  337. #define RCC_PLLSAI2_ADC2CLK RCC_PLLSAI2CFGR_PLLSAI2REN /*!< PLLADC2CLK selection from PLLSAI2 */
  338. #else
  339. #define RCC_PLLSAI2_LTDCCLK RCC_PLLSAI2CFGR_PLLSAI2REN /*!< PLLLTDCCLK selection from PLLSAI2 */
  340. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || STM32L496xx || STM32L4A6xx */
  341. /**
  342. * @}
  343. */
  344. #endif /* RCC_PLLSAI2_SUPPORT */
  345. /** @defgroup RCC_MSI_Clock_Range MSI Clock Range
  346. * @{
  347. */
  348. #define RCC_MSIRANGE_0 RCC_CR_MSIRANGE_0 /*!< MSI = 100 KHz */
  349. #define RCC_MSIRANGE_1 RCC_CR_MSIRANGE_1 /*!< MSI = 200 KHz */
  350. #define RCC_MSIRANGE_2 RCC_CR_MSIRANGE_2 /*!< MSI = 400 KHz */
  351. #define RCC_MSIRANGE_3 RCC_CR_MSIRANGE_3 /*!< MSI = 800 KHz */
  352. #define RCC_MSIRANGE_4 RCC_CR_MSIRANGE_4 /*!< MSI = 1 MHz */
  353. #define RCC_MSIRANGE_5 RCC_CR_MSIRANGE_5 /*!< MSI = 2 MHz */
  354. #define RCC_MSIRANGE_6 RCC_CR_MSIRANGE_6 /*!< MSI = 4 MHz */
  355. #define RCC_MSIRANGE_7 RCC_CR_MSIRANGE_7 /*!< MSI = 8 MHz */
  356. #define RCC_MSIRANGE_8 RCC_CR_MSIRANGE_8 /*!< MSI = 16 MHz */
  357. #define RCC_MSIRANGE_9 RCC_CR_MSIRANGE_9 /*!< MSI = 24 MHz */
  358. #define RCC_MSIRANGE_10 RCC_CR_MSIRANGE_10 /*!< MSI = 32 MHz */
  359. #define RCC_MSIRANGE_11 RCC_CR_MSIRANGE_11 /*!< MSI = 48 MHz */
  360. /**
  361. * @}
  362. */
  363. /** @defgroup RCC_System_Clock_Type System Clock Type
  364. * @{
  365. */
  366. #define RCC_CLOCKTYPE_SYSCLK 0x00000001U /*!< SYSCLK to configure */
  367. #define RCC_CLOCKTYPE_HCLK 0x00000002U /*!< HCLK to configure */
  368. #define RCC_CLOCKTYPE_PCLK1 0x00000004U /*!< PCLK1 to configure */
  369. #define RCC_CLOCKTYPE_PCLK2 0x00000008U /*!< PCLK2 to configure */
  370. /**
  371. * @}
  372. */
  373. /** @defgroup RCC_System_Clock_Source System Clock Source
  374. * @{
  375. */
  376. #define RCC_SYSCLKSOURCE_MSI RCC_CFGR_SW_MSI /*!< MSI selection as system clock */
  377. #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI /*!< HSI selection as system clock */
  378. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE /*!< HSE selection as system clock */
  379. #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL /*!< PLL selection as system clock */
  380. /**
  381. * @}
  382. */
  383. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  384. * @{
  385. */
  386. #define RCC_SYSCLKSOURCE_STATUS_MSI RCC_CFGR_SWS_MSI /*!< MSI used as system clock */
  387. #define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  388. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  389. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  390. /**
  391. * @}
  392. */
  393. /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
  394. * @{
  395. */
  396. #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1 /*!< SYSCLK not divided */
  397. #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2 /*!< SYSCLK divided by 2 */
  398. #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4 /*!< SYSCLK divided by 4 */
  399. #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8 /*!< SYSCLK divided by 8 */
  400. #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16 /*!< SYSCLK divided by 16 */
  401. #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64 /*!< SYSCLK divided by 64 */
  402. #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128 /*!< SYSCLK divided by 128 */
  403. #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256 /*!< SYSCLK divided by 256 */
  404. #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
  405. /**
  406. * @}
  407. */
  408. /** @defgroup RCC_APB1_APB2_Clock_Source APB1 APB2 Clock Source
  409. * @{
  410. */
  411. #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1 /*!< HCLK not divided */
  412. #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2 /*!< HCLK divided by 2 */
  413. #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4 /*!< HCLK divided by 4 */
  414. #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8 /*!< HCLK divided by 8 */
  415. #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16 /*!< HCLK divided by 16 */
  416. /**
  417. * @}
  418. */
  419. /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
  420. * @{
  421. */
  422. #define RCC_RTCCLKSOURCE_NONE 0x00000000U /*!< No clock used as RTC clock */
  423. #define RCC_RTCCLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
  424. #define RCC_RTCCLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
  425. #define RCC_RTCCLKSOURCE_HSE_DIV32 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 32 used as RTC clock */
  426. /**
  427. * @}
  428. */
  429. /** @defgroup RCC_MCO_Index MCO Index
  430. * @{
  431. */
  432. #define RCC_MCO1 0x00000000U
  433. #define RCC_MCO RCC_MCO1 /*!< MCO1 to be compliant with other families with 2 MCOs*/
  434. /**
  435. * @}
  436. */
  437. /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
  438. * @{
  439. */
  440. #define RCC_MCO1SOURCE_NOCLOCK 0x00000000U /*!< MCO1 output disabled, no clock on MCO1 */
  441. #define RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCOSEL_0 /*!< SYSCLK selection as MCO1 source */
  442. #define RCC_MCO1SOURCE_MSI RCC_CFGR_MCOSEL_1 /*!< MSI selection as MCO1 source */
  443. #define RCC_MCO1SOURCE_HSI (RCC_CFGR_MCOSEL_0| RCC_CFGR_MCOSEL_1) /*!< HSI selection as MCO1 source */
  444. #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCOSEL_2 /*!< HSE selection as MCO1 source */
  445. #define RCC_MCO1SOURCE_PLLCLK (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_2) /*!< PLLCLK selection as MCO1 source */
  446. #define RCC_MCO1SOURCE_LSI (RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSI selection as MCO1 source */
  447. #define RCC_MCO1SOURCE_LSE (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSE selection as MCO1 source */
  448. #if defined(RCC_HSI48_SUPPORT)
  449. #define RCC_MCO1SOURCE_HSI48 RCC_CFGR_MCOSEL_3 /*!< HSI48 selection as MCO1 source (STM32L43x/STM32L44x devices) */
  450. #endif /* RCC_HSI48_SUPPORT */
  451. /**
  452. * @}
  453. */
  454. /** @defgroup RCC_MCOx_Clock_Prescaler MCO1 Clock Prescaler
  455. * @{
  456. */
  457. #define RCC_MCODIV_1 RCC_CFGR_MCOPRE_DIV1 /*!< MCO not divided */
  458. #define RCC_MCODIV_2 RCC_CFGR_MCOPRE_DIV2 /*!< MCO divided by 2 */
  459. #define RCC_MCODIV_4 RCC_CFGR_MCOPRE_DIV4 /*!< MCO divided by 4 */
  460. #define RCC_MCODIV_8 RCC_CFGR_MCOPRE_DIV8 /*!< MCO divided by 8 */
  461. #define RCC_MCODIV_16 RCC_CFGR_MCOPRE_DIV16 /*!< MCO divided by 16 */
  462. /**
  463. * @}
  464. */
  465. /** @defgroup RCC_Interrupt Interrupts
  466. * @{
  467. */
  468. #define RCC_IT_LSIRDY RCC_CIFR_LSIRDYF /*!< LSI Ready Interrupt flag */
  469. #define RCC_IT_LSERDY RCC_CIFR_LSERDYF /*!< LSE Ready Interrupt flag */
  470. #define RCC_IT_MSIRDY RCC_CIFR_MSIRDYF /*!< MSI Ready Interrupt flag */
  471. #define RCC_IT_HSIRDY RCC_CIFR_HSIRDYF /*!< HSI16 Ready Interrupt flag */
  472. #define RCC_IT_HSERDY RCC_CIFR_HSERDYF /*!< HSE Ready Interrupt flag */
  473. #define RCC_IT_PLLRDY RCC_CIFR_PLLRDYF /*!< PLL Ready Interrupt flag */
  474. #if defined(RCC_PLLSAI1_SUPPORT)
  475. #define RCC_IT_PLLSAI1RDY RCC_CIFR_PLLSAI1RDYF /*!< PLLSAI1 Ready Interrupt flag */
  476. #endif /* RCC_PLLSAI1_SUPPORT */
  477. #if defined(RCC_PLLSAI2_SUPPORT)
  478. #define RCC_IT_PLLSAI2RDY RCC_CIFR_PLLSAI2RDYF /*!< PLLSAI2 Ready Interrupt flag */
  479. #endif /* RCC_PLLSAI2_SUPPORT */
  480. #define RCC_IT_CSS RCC_CIFR_CSSF /*!< Clock Security System Interrupt flag */
  481. #define RCC_IT_LSECSS RCC_CIFR_LSECSSF /*!< LSE Clock Security System Interrupt flag */
  482. #if defined(RCC_HSI48_SUPPORT)
  483. #define RCC_IT_HSI48RDY RCC_CIFR_HSI48RDYF /*!< HSI48 Ready Interrupt flag */
  484. #endif /* RCC_HSI48_SUPPORT */
  485. /**
  486. * @}
  487. */
  488. /** @defgroup RCC_Flag Flags
  489. * Elements values convention: XXXYYYYYb
  490. * - YYYYY : Flag position in the register
  491. * - XXX : Register index
  492. * - 001: CR register
  493. * - 010: BDCR register
  494. * - 011: CSR register
  495. * - 100: CRRCR register
  496. * @{
  497. */
  498. /* Flags in the CR register */
  499. #define RCC_FLAG_MSIRDY ((CR_REG_INDEX << 5U) | RCC_CR_MSIRDY_Pos) /*!< MSI Ready flag */
  500. #define RCC_FLAG_HSIRDY ((CR_REG_INDEX << 5U) | RCC_CR_HSIRDY_Pos) /*!< HSI Ready flag */
  501. #define RCC_FLAG_HSERDY ((CR_REG_INDEX << 5U) | RCC_CR_HSERDY_Pos) /*!< HSE Ready flag */
  502. #define RCC_FLAG_PLLRDY ((CR_REG_INDEX << 5U) | RCC_CR_PLLRDY_Pos) /*!< PLL Ready flag */
  503. #if defined(RCC_PLLSAI1_SUPPORT)
  504. #define RCC_FLAG_PLLSAI1RDY ((CR_REG_INDEX << 5U) | RCC_CR_PLLSAI1RDY_Pos) /*!< PLLSAI1 Ready flag */
  505. #endif /* RCC_PLLSAI1_SUPPORT */
  506. #if defined(RCC_PLLSAI2_SUPPORT)
  507. #define RCC_FLAG_PLLSAI2RDY ((CR_REG_INDEX << 5U) | RCC_CR_PLLSAI2RDY_Pos) /*!< PLLSAI2 Ready flag */
  508. #endif /* RCC_PLLSAI2_SUPPORT */
  509. /* Flags in the BDCR register */
  510. #define RCC_FLAG_LSERDY ((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSERDY_Pos) /*!< LSE Ready flag */
  511. #define RCC_FLAG_LSECSSD ((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSECSSD_Pos) /*!< LSE Clock Security System Interrupt flag */
  512. /* Flags in the CSR register */
  513. #define RCC_FLAG_LSIRDY ((CSR_REG_INDEX << 5U) | RCC_CSR_LSIRDY_Pos) /*!< LSI Ready flag */
  514. #define RCC_FLAG_FWRST ((CSR_REG_INDEX << 5U) | RCC_CSR_FWRSTF_Pos) /*!< Firewall reset flag */
  515. #define RCC_FLAG_OBLRST ((CSR_REG_INDEX << 5U) | RCC_CSR_OBLRSTF_Pos) /*!< Option Byte Loader reset flag */
  516. #define RCC_FLAG_PINRST ((CSR_REG_INDEX << 5U) | RCC_CSR_PINRSTF_Pos) /*!< PIN reset flag */
  517. #define RCC_FLAG_BORRST ((CSR_REG_INDEX << 5U) | RCC_CSR_BORRSTF_Pos) /*!< BOR reset flag */
  518. #define RCC_FLAG_SFTRST ((CSR_REG_INDEX << 5U) | RCC_CSR_SFTRSTF_Pos) /*!< Software Reset flag */
  519. #define RCC_FLAG_IWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_IWDGRSTF_Pos) /*!< Independent Watchdog reset flag */
  520. #define RCC_FLAG_WWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_WWDGRSTF_Pos) /*!< Window watchdog reset flag */
  521. #define RCC_FLAG_LPWRRST ((CSR_REG_INDEX << 5U) | RCC_CSR_LPWRRSTF_Pos) /*!< Low-Power reset flag */
  522. #if defined(RCC_HSI48_SUPPORT)
  523. /* Flags in the CRRCR register */
  524. #define RCC_FLAG_HSI48RDY ((CRRCR_REG_INDEX << 5U) | RCC_CRRCR_HSI48RDY_Pos) /*!< HSI48 Ready flag */
  525. #endif /* RCC_HSI48_SUPPORT */
  526. /**
  527. * @}
  528. */
  529. /** @defgroup RCC_LSEDrive_Config LSE Drive Config
  530. * @{
  531. */
  532. #define RCC_LSEDRIVE_LOW 0x00000000U /*!< LSE low drive capability */
  533. #define RCC_LSEDRIVE_MEDIUMLOW RCC_BDCR_LSEDRV_0 /*!< LSE medium low drive capability */
  534. #define RCC_LSEDRIVE_MEDIUMHIGH RCC_BDCR_LSEDRV_1 /*!< LSE medium high drive capability */
  535. #define RCC_LSEDRIVE_HIGH RCC_BDCR_LSEDRV /*!< LSE high drive capability */
  536. /**
  537. * @}
  538. */
  539. /** @defgroup RCC_Stop_WakeUpClock Wake-Up from STOP Clock
  540. * @{
  541. */
  542. #define RCC_STOP_WAKEUPCLOCK_MSI 0x00000000U /*!< MSI selection after wake-up from STOP */
  543. #define RCC_STOP_WAKEUPCLOCK_HSI RCC_CFGR_STOPWUCK /*!< HSI selection after wake-up from STOP */
  544. /**
  545. * @}
  546. */
  547. /**
  548. * @}
  549. */
  550. /* Exported macros -----------------------------------------------------------*/
  551. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  552. * @{
  553. */
  554. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  555. * @brief Enable or disable the AHB1 peripheral clock.
  556. * @note After reset, the peripheral clock (used for registers read/write access)
  557. * is disabled and the application software has to enable this clock before
  558. * using it.
  559. * @{
  560. */
  561. #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
  562. __IO uint32_t tmpreg; \
  563. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN); \
  564. /* Delay after an RCC peripheral clock enabling */ \
  565. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN); \
  566. UNUSED(tmpreg); \
  567. } while(0)
  568. #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
  569. __IO uint32_t tmpreg; \
  570. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN); \
  571. /* Delay after an RCC peripheral clock enabling */ \
  572. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN); \
  573. UNUSED(tmpreg); \
  574. } while(0)
  575. #if defined(DMAMUX1)
  576. #define __HAL_RCC_DMAMUX1_CLK_ENABLE() do { \
  577. __IO uint32_t tmpreg; \
  578. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN); \
  579. /* Delay after an RCC peripheral clock enabling */ \
  580. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN); \
  581. UNUSED(tmpreg); \
  582. } while(0)
  583. #endif /* DMAMUX1 */
  584. #define __HAL_RCC_FLASH_CLK_ENABLE() do { \
  585. __IO uint32_t tmpreg; \
  586. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN); \
  587. /* Delay after an RCC peripheral clock enabling */ \
  588. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN); \
  589. UNUSED(tmpreg); \
  590. } while(0)
  591. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  592. __IO uint32_t tmpreg; \
  593. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  594. /* Delay after an RCC peripheral clock enabling */ \
  595. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  596. UNUSED(tmpreg); \
  597. } while(0)
  598. #define __HAL_RCC_TSC_CLK_ENABLE() do { \
  599. __IO uint32_t tmpreg; \
  600. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN); \
  601. /* Delay after an RCC peripheral clock enabling */ \
  602. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN); \
  603. UNUSED(tmpreg); \
  604. } while(0)
  605. #if defined(DMA2D)
  606. #define __HAL_RCC_DMA2D_CLK_ENABLE() do { \
  607. __IO uint32_t tmpreg; \
  608. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN); \
  609. /* Delay after an RCC peripheral clock enabling */ \
  610. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN); \
  611. UNUSED(tmpreg); \
  612. } while(0)
  613. #endif /* DMA2D */
  614. #if defined(GFXMMU)
  615. #define __HAL_RCC_GFXMMU_CLK_ENABLE() do { \
  616. __IO uint32_t tmpreg; \
  617. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GFXMMUEN); \
  618. /* Delay after an RCC peripheral clock enabling */ \
  619. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GFXMMUEN); \
  620. UNUSED(tmpreg); \
  621. } while(0)
  622. #endif /* GFXMMU */
  623. #define __HAL_RCC_DMA1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN)
  624. #define __HAL_RCC_DMA2_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN)
  625. #if defined(DMAMUX1)
  626. #define __HAL_RCC_DMAMUX1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN)
  627. #endif /* DMAMUX1 */
  628. #define __HAL_RCC_FLASH_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN)
  629. #define __HAL_RCC_CRC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN)
  630. #define __HAL_RCC_TSC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN)
  631. #if defined(DMA2D)
  632. #define __HAL_RCC_DMA2D_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN)
  633. #endif /* DMA2D */
  634. #if defined(GFXMMU)
  635. #define __HAL_RCC_GFXMMU_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GFXMMUEN)
  636. #endif /* GFXMMU */
  637. /**
  638. * @}
  639. */
  640. /** @defgroup RCC_AHB2_Peripheral_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  641. * @brief Enable or disable the AHB2 peripheral clock.
  642. * @note After reset, the peripheral clock (used for registers read/write access)
  643. * is disabled and the application software has to enable this clock before
  644. * using it.
  645. * @{
  646. */
  647. #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
  648. __IO uint32_t tmpreg; \
  649. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  650. /* Delay after an RCC peripheral clock enabling */ \
  651. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  652. UNUSED(tmpreg); \
  653. } while(0)
  654. #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
  655. __IO uint32_t tmpreg; \
  656. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  657. /* Delay after an RCC peripheral clock enabling */ \
  658. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  659. UNUSED(tmpreg); \
  660. } while(0)
  661. #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
  662. __IO uint32_t tmpreg; \
  663. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  664. /* Delay after an RCC peripheral clock enabling */ \
  665. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  666. UNUSED(tmpreg); \
  667. } while(0)
  668. #if defined(GPIOD)
  669. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  670. __IO uint32_t tmpreg; \
  671. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  672. /* Delay after an RCC peripheral clock enabling */ \
  673. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  674. UNUSED(tmpreg); \
  675. } while(0)
  676. #endif /* GPIOD */
  677. #if defined(GPIOE)
  678. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  679. __IO uint32_t tmpreg; \
  680. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  681. /* Delay after an RCC peripheral clock enabling */ \
  682. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  683. UNUSED(tmpreg); \
  684. } while(0)
  685. #endif /* GPIOE */
  686. #if defined(GPIOF)
  687. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  688. __IO uint32_t tmpreg; \
  689. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  690. /* Delay after an RCC peripheral clock enabling */ \
  691. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  692. UNUSED(tmpreg); \
  693. } while(0)
  694. #endif /* GPIOF */
  695. #if defined(GPIOG)
  696. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  697. __IO uint32_t tmpreg; \
  698. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  699. /* Delay after an RCC peripheral clock enabling */ \
  700. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  701. UNUSED(tmpreg); \
  702. } while(0)
  703. #endif /* GPIOG */
  704. #define __HAL_RCC_GPIOH_CLK_ENABLE() do { \
  705. __IO uint32_t tmpreg; \
  706. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN); \
  707. /* Delay after an RCC peripheral clock enabling */ \
  708. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN); \
  709. UNUSED(tmpreg); \
  710. } while(0)
  711. #if defined(GPIOI)
  712. #define __HAL_RCC_GPIOI_CLK_ENABLE() do { \
  713. __IO uint32_t tmpreg; \
  714. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN); \
  715. /* Delay after an RCC peripheral clock enabling */ \
  716. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN); \
  717. UNUSED(tmpreg); \
  718. } while(0)
  719. #endif /* GPIOI */
  720. #if defined(USB_OTG_FS)
  721. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do { \
  722. __IO uint32_t tmpreg; \
  723. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN); \
  724. /* Delay after an RCC peripheral clock enabling */ \
  725. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN); \
  726. UNUSED(tmpreg); \
  727. } while(0)
  728. #endif /* USB_OTG_FS */
  729. #define __HAL_RCC_ADC_CLK_ENABLE() do { \
  730. __IO uint32_t tmpreg; \
  731. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN); \
  732. /* Delay after an RCC peripheral clock enabling */ \
  733. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN); \
  734. UNUSED(tmpreg); \
  735. } while(0)
  736. #if defined(DCMI)
  737. #define __HAL_RCC_DCMI_CLK_ENABLE() do { \
  738. __IO uint32_t tmpreg; \
  739. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN); \
  740. /* Delay after an RCC peripheral clock enabling */ \
  741. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN); \
  742. UNUSED(tmpreg); \
  743. } while(0)
  744. #endif /* DCMI */
  745. #if defined(AES)
  746. #define __HAL_RCC_AES_CLK_ENABLE() do { \
  747. __IO uint32_t tmpreg; \
  748. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  749. /* Delay after an RCC peripheral clock enabling */ \
  750. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  751. UNUSED(tmpreg); \
  752. } while(0)
  753. #endif /* AES */
  754. #if defined(HASH)
  755. #define __HAL_RCC_HASH_CLK_ENABLE() do { \
  756. __IO uint32_t tmpreg; \
  757. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN); \
  758. /* Delay after an RCC peripheral clock enabling */ \
  759. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN); \
  760. UNUSED(tmpreg); \
  761. } while(0)
  762. #endif /* HASH */
  763. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  764. __IO uint32_t tmpreg; \
  765. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  766. /* Delay after an RCC peripheral clock enabling */ \
  767. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  768. UNUSED(tmpreg); \
  769. } while(0)
  770. #if defined(OCTOSPIM)
  771. #define __HAL_RCC_OSPIM_CLK_ENABLE() do { \
  772. __IO uint32_t tmpreg; \
  773. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OSPIMEN); \
  774. /* Delay after an RCC peripheral clock enabling */ \
  775. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OSPIMEN); \
  776. UNUSED(tmpreg); \
  777. } while(0)
  778. #endif /* OCTOSPIM */
  779. #if defined(SDMMC1) && defined(RCC_AHB2ENR_SDMMC1EN)
  780. #define __HAL_RCC_SDMMC1_CLK_ENABLE() do { \
  781. __IO uint32_t tmpreg; \
  782. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SDMMC1EN); \
  783. /* Delay after an RCC peripheral clock enabling */ \
  784. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SDMMC1EN); \
  785. UNUSED(tmpreg); \
  786. } while(0)
  787. #endif /* SDMMC1 && RCC_AHB2ENR_SDMMC1EN */
  788. #define __HAL_RCC_GPIOA_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN)
  789. #define __HAL_RCC_GPIOB_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN)
  790. #define __HAL_RCC_GPIOC_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN)
  791. #if defined(GPIOD)
  792. #define __HAL_RCC_GPIOD_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN)
  793. #endif /* GPIOD */
  794. #if defined(GPIOE)
  795. #define __HAL_RCC_GPIOE_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN)
  796. #endif /* GPIOE */
  797. #if defined(GPIOF)
  798. #define __HAL_RCC_GPIOF_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN)
  799. #endif /* GPIOF */
  800. #if defined(GPIOG)
  801. #define __HAL_RCC_GPIOG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN)
  802. #endif /* GPIOG */
  803. #define __HAL_RCC_GPIOH_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN)
  804. #if defined(GPIOI)
  805. #define __HAL_RCC_GPIOI_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN)
  806. #endif /* GPIOI */
  807. #if defined(USB_OTG_FS)
  808. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN);
  809. #endif /* USB_OTG_FS */
  810. #define __HAL_RCC_ADC_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN)
  811. #if defined(DCMI)
  812. #define __HAL_RCC_DCMI_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN)
  813. #endif /* DCMI */
  814. #if defined(AES)
  815. #define __HAL_RCC_AES_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN);
  816. #endif /* AES */
  817. #if defined(HASH)
  818. #define __HAL_RCC_HASH_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN)
  819. #endif /* HASH */
  820. #define __HAL_RCC_RNG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN)
  821. #if defined(OCTOSPIM)
  822. #define __HAL_RCC_OSPIM_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OSPIMEN)
  823. #endif /* OCTOSPIM */
  824. #if defined(SDMMC1) && defined(RCC_AHB2ENR_SDMMC1EN)
  825. #define __HAL_RCC_SDMMC1_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SDMMC1EN)
  826. #endif /* SDMMC1 && RCC_AHB2ENR_SDMMC1EN */
  827. /**
  828. * @}
  829. */
  830. /** @defgroup RCC_AHB3_Clock_Enable_Disable AHB3 Peripheral Clock Enable Disable
  831. * @brief Enable or disable the AHB3 peripheral clock.
  832. * @note After reset, the peripheral clock (used for registers read/write access)
  833. * is disabled and the application software has to enable this clock before
  834. * using it.
  835. * @{
  836. */
  837. #if defined(FMC_BANK1)
  838. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  839. __IO uint32_t tmpreg; \
  840. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); \
  841. /* Delay after an RCC peripheral clock enabling */ \
  842. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); \
  843. UNUSED(tmpreg); \
  844. } while(0)
  845. #endif /* FMC_BANK1 */
  846. #if defined(QUADSPI)
  847. #define __HAL_RCC_QSPI_CLK_ENABLE() do { \
  848. __IO uint32_t tmpreg; \
  849. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN); \
  850. /* Delay after an RCC peripheral clock enabling */ \
  851. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN); \
  852. UNUSED(tmpreg); \
  853. } while(0)
  854. #endif /* QUADSPI */
  855. #if defined(OCTOSPI1)
  856. #define __HAL_RCC_OSPI1_CLK_ENABLE() do { \
  857. __IO uint32_t tmpreg; \
  858. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_OSPI1EN); \
  859. /* Delay after an RCC peripheral clock enabling */ \
  860. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_OSPI1EN); \
  861. UNUSED(tmpreg); \
  862. } while(0)
  863. #endif /* OCTOSPI1 */
  864. #if defined(OCTOSPI2)
  865. #define __HAL_RCC_OSPI2_CLK_ENABLE() do { \
  866. __IO uint32_t tmpreg; \
  867. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_OSPI2EN); \
  868. /* Delay after an RCC peripheral clock enabling */ \
  869. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_OSPI2EN); \
  870. UNUSED(tmpreg); \
  871. } while(0)
  872. #endif /* OCTOSPI2 */
  873. #if defined(FMC_BANK1)
  874. #define __HAL_RCC_FMC_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN)
  875. #endif /* FMC_BANK1 */
  876. #if defined(QUADSPI)
  877. #define __HAL_RCC_QSPI_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN)
  878. #endif /* QUADSPI */
  879. #if defined(OCTOSPI1)
  880. #define __HAL_RCC_OSPI1_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_OSPI1EN)
  881. #endif /* OCTOSPI1 */
  882. #if defined(OCTOSPI2)
  883. #define __HAL_RCC_OSPI2_CLK_DISABLE() CLEAR_BIT(RCC->AHB3ENR, RCC_AHB3ENR_OSPI2EN)
  884. #endif /* OCTOSPI2 */
  885. /**
  886. * @}
  887. */
  888. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  889. * @brief Enable or disable the APB1 peripheral clock.
  890. * @note After reset, the peripheral clock (used for registers read/write access)
  891. * is disabled and the application software has to enable this clock before
  892. * using it.
  893. * @{
  894. */
  895. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  896. __IO uint32_t tmpreg; \
  897. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN); \
  898. /* Delay after an RCC peripheral clock enabling */ \
  899. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN); \
  900. UNUSED(tmpreg); \
  901. } while(0)
  902. #if defined(TIM3)
  903. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  904. __IO uint32_t tmpreg; \
  905. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN); \
  906. /* Delay after an RCC peripheral clock enabling */ \
  907. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN); \
  908. UNUSED(tmpreg); \
  909. } while(0)
  910. #endif /* TIM3 */
  911. #if defined(TIM4)
  912. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  913. __IO uint32_t tmpreg; \
  914. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN); \
  915. /* Delay after an RCC peripheral clock enabling */ \
  916. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN); \
  917. UNUSED(tmpreg); \
  918. } while(0)
  919. #endif /* TIM4 */
  920. #if defined(TIM5)
  921. #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
  922. __IO uint32_t tmpreg; \
  923. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN); \
  924. /* Delay after an RCC peripheral clock enabling */ \
  925. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN); \
  926. UNUSED(tmpreg); \
  927. } while(0)
  928. #endif /* TIM5 */
  929. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  930. __IO uint32_t tmpreg; \
  931. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN); \
  932. /* Delay after an RCC peripheral clock enabling */ \
  933. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN); \
  934. UNUSED(tmpreg); \
  935. } while(0)
  936. #if defined(TIM7)
  937. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  938. __IO uint32_t tmpreg; \
  939. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN); \
  940. /* Delay after an RCC peripheral clock enabling */ \
  941. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN); \
  942. UNUSED(tmpreg); \
  943. } while(0)
  944. #endif /* TIM7 */
  945. #if defined(LCD)
  946. #define __HAL_RCC_LCD_CLK_ENABLE() do { \
  947. __IO uint32_t tmpreg; \
  948. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN); \
  949. /* Delay after an RCC peripheral clock enabling */ \
  950. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN); \
  951. UNUSED(tmpreg); \
  952. } while(0)
  953. #endif /* LCD */
  954. #if defined(RCC_APB1ENR1_RTCAPBEN)
  955. #define __HAL_RCC_RTCAPB_CLK_ENABLE() do { \
  956. __IO uint32_t tmpreg; \
  957. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN); \
  958. /* Delay after an RCC peripheral clock enabling */ \
  959. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN); \
  960. UNUSED(tmpreg); \
  961. } while(0)
  962. #endif /* RCC_APB1ENR1_RTCAPBEN */
  963. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  964. __IO uint32_t tmpreg; \
  965. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN); \
  966. /* Delay after an RCC peripheral clock enabling */ \
  967. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN); \
  968. UNUSED(tmpreg); \
  969. } while(0)
  970. #if defined(SPI2)
  971. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  972. __IO uint32_t tmpreg; \
  973. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN); \
  974. /* Delay after an RCC peripheral clock enabling */ \
  975. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN); \
  976. UNUSED(tmpreg); \
  977. } while(0)
  978. #endif /* SPI2 */
  979. #if defined(SPI3)
  980. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  981. __IO uint32_t tmpreg; \
  982. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN); \
  983. /* Delay after an RCC peripheral clock enabling */ \
  984. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN); \
  985. UNUSED(tmpreg); \
  986. } while(0)
  987. #endif /* SPI3 */
  988. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  989. __IO uint32_t tmpreg; \
  990. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN); \
  991. /* Delay after an RCC peripheral clock enabling */ \
  992. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN); \
  993. UNUSED(tmpreg); \
  994. } while(0)
  995. #if defined(USART3)
  996. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  997. __IO uint32_t tmpreg; \
  998. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \
  999. /* Delay after an RCC peripheral clock enabling */ \
  1000. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN); \
  1001. UNUSED(tmpreg); \
  1002. } while(0)
  1003. #endif /* USART3 */
  1004. #if defined(UART4)
  1005. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  1006. __IO uint32_t tmpreg; \
  1007. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN); \
  1008. /* Delay after an RCC peripheral clock enabling */ \
  1009. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN); \
  1010. UNUSED(tmpreg); \
  1011. } while(0)
  1012. #endif /* UART4 */
  1013. #if defined(UART5)
  1014. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  1015. __IO uint32_t tmpreg; \
  1016. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN); \
  1017. /* Delay after an RCC peripheral clock enabling */ \
  1018. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN); \
  1019. UNUSED(tmpreg); \
  1020. } while(0)
  1021. #endif /* UART5 */
  1022. #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
  1023. __IO uint32_t tmpreg; \
  1024. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN); \
  1025. /* Delay after an RCC peripheral clock enabling */ \
  1026. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN); \
  1027. UNUSED(tmpreg); \
  1028. } while(0)
  1029. #if defined(I2C2)
  1030. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  1031. __IO uint32_t tmpreg; \
  1032. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN); \
  1033. /* Delay after an RCC peripheral clock enabling */ \
  1034. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN); \
  1035. UNUSED(tmpreg); \
  1036. } while(0)
  1037. #endif /* I2C2 */
  1038. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  1039. __IO uint32_t tmpreg; \
  1040. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN); \
  1041. /* Delay after an RCC peripheral clock enabling */ \
  1042. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN); \
  1043. UNUSED(tmpreg); \
  1044. } while(0)
  1045. #if defined(I2C4)
  1046. #define __HAL_RCC_I2C4_CLK_ENABLE() do { \
  1047. __IO uint32_t tmpreg; \
  1048. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN); \
  1049. /* Delay after an RCC peripheral clock enabling */ \
  1050. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN); \
  1051. UNUSED(tmpreg); \
  1052. } while(0)
  1053. #endif /* I2C4 */
  1054. #if defined(CRS)
  1055. #define __HAL_RCC_CRS_CLK_ENABLE() do { \
  1056. __IO uint32_t tmpreg; \
  1057. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN); \
  1058. /* Delay after an RCC peripheral clock enabling */ \
  1059. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN); \
  1060. UNUSED(tmpreg); \
  1061. } while(0)
  1062. #endif /* CRS */
  1063. #if defined(CAN1)
  1064. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  1065. __IO uint32_t tmpreg; \
  1066. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN); \
  1067. /* Delay after an RCC peripheral clock enabling */ \
  1068. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN); \
  1069. UNUSED(tmpreg); \
  1070. } while(0)
  1071. #endif /* CAN1 */
  1072. #if defined(CAN2)
  1073. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  1074. __IO uint32_t tmpreg; \
  1075. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN2EN); \
  1076. /* Delay after an RCC peripheral clock enabling */ \
  1077. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN2EN); \
  1078. UNUSED(tmpreg); \
  1079. } while(0)
  1080. #endif /* CAN2 */
  1081. #if defined(USB)
  1082. #define __HAL_RCC_USB_CLK_ENABLE() do { \
  1083. __IO uint32_t tmpreg; \
  1084. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBFSEN); \
  1085. /* Delay after an RCC peripheral clock enabling */ \
  1086. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBFSEN); \
  1087. UNUSED(tmpreg); \
  1088. } while(0)
  1089. #endif /* USB */
  1090. #define __HAL_RCC_PWR_CLK_ENABLE() do { \
  1091. __IO uint32_t tmpreg; \
  1092. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN); \
  1093. /* Delay after an RCC peripheral clock enabling */ \
  1094. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN); \
  1095. UNUSED(tmpreg); \
  1096. } while(0)
  1097. #if defined(DAC1)
  1098. #define __HAL_RCC_DAC1_CLK_ENABLE() do { \
  1099. __IO uint32_t tmpreg; \
  1100. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN); \
  1101. /* Delay after an RCC peripheral clock enabling */ \
  1102. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN); \
  1103. UNUSED(tmpreg); \
  1104. } while(0)
  1105. #endif /* DAC1 */
  1106. #define __HAL_RCC_OPAMP_CLK_ENABLE() do { \
  1107. __IO uint32_t tmpreg; \
  1108. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN); \
  1109. /* Delay after an RCC peripheral clock enabling */ \
  1110. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN); \
  1111. UNUSED(tmpreg); \
  1112. } while(0)
  1113. #define __HAL_RCC_LPTIM1_CLK_ENABLE() do { \
  1114. __IO uint32_t tmpreg; \
  1115. SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN); \
  1116. /* Delay after an RCC peripheral clock enabling */ \
  1117. tmpreg = READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN); \
  1118. UNUSED(tmpreg); \
  1119. } while(0)
  1120. #define __HAL_RCC_LPUART1_CLK_ENABLE() do { \
  1121. __IO uint32_t tmpreg; \
  1122. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN); \
  1123. /* Delay after an RCC peripheral clock enabling */ \
  1124. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN); \
  1125. UNUSED(tmpreg); \
  1126. } while(0)
  1127. #if defined(SWPMI1)
  1128. #define __HAL_RCC_SWPMI1_CLK_ENABLE() do { \
  1129. __IO uint32_t tmpreg; \
  1130. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN); \
  1131. /* Delay after an RCC peripheral clock enabling */ \
  1132. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN); \
  1133. UNUSED(tmpreg); \
  1134. } while(0)
  1135. #endif /* SWPMI1 */
  1136. #define __HAL_RCC_LPTIM2_CLK_ENABLE() do { \
  1137. __IO uint32_t tmpreg; \
  1138. SET_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN); \
  1139. /* Delay after an RCC peripheral clock enabling */ \
  1140. tmpreg = READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN); \
  1141. UNUSED(tmpreg); \
  1142. } while(0)
  1143. #define __HAL_RCC_TIM2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN)
  1144. #if defined(TIM3)
  1145. #define __HAL_RCC_TIM3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN)
  1146. #endif /* TIM3 */
  1147. #if defined(TIM4)
  1148. #define __HAL_RCC_TIM4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN)
  1149. #endif /* TIM4 */
  1150. #if defined(TIM5)
  1151. #define __HAL_RCC_TIM5_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN)
  1152. #endif /* TIM5 */
  1153. #define __HAL_RCC_TIM6_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN)
  1154. #if defined(TIM7)
  1155. #define __HAL_RCC_TIM7_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN)
  1156. #endif /* TIM7 */
  1157. #if defined(LCD)
  1158. #define __HAL_RCC_LCD_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN);
  1159. #endif /* LCD */
  1160. #if defined(RCC_APB1ENR1_RTCAPBEN)
  1161. #define __HAL_RCC_RTCAPB_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN);
  1162. #endif /* RCC_APB1ENR1_RTCAPBEN */
  1163. #if defined(SPI2)
  1164. #define __HAL_RCC_SPI2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN)
  1165. #endif /* SPI2 */
  1166. #if defined(SPI3)
  1167. #define __HAL_RCC_SPI3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN)
  1168. #endif /* SPI3 */
  1169. #define __HAL_RCC_USART2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN)
  1170. #if defined(USART3)
  1171. #define __HAL_RCC_USART3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN)
  1172. #endif /* USART3 */
  1173. #if defined(UART4)
  1174. #define __HAL_RCC_UART4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN)
  1175. #endif /* UART4 */
  1176. #if defined(UART5)
  1177. #define __HAL_RCC_UART5_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN)
  1178. #endif /* UART5 */
  1179. #define __HAL_RCC_I2C1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN)
  1180. #if defined(I2C2)
  1181. #define __HAL_RCC_I2C2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN)
  1182. #endif /* I2C2 */
  1183. #define __HAL_RCC_I2C3_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN)
  1184. #if defined(I2C4)
  1185. #define __HAL_RCC_I2C4_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN)
  1186. #endif /* I2C4 */
  1187. #if defined(CRS)
  1188. #define __HAL_RCC_CRS_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN);
  1189. #endif /* CRS */
  1190. #if defined(CAN1)
  1191. #define __HAL_RCC_CAN1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN)
  1192. #endif /* CAN1 */
  1193. #if defined(CAN2)
  1194. #define __HAL_RCC_CAN2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN2EN)
  1195. #endif /* CAN2 */
  1196. #if defined(USB)
  1197. #define __HAL_RCC_USB_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBFSEN);
  1198. #endif /* USB */
  1199. #define __HAL_RCC_PWR_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN)
  1200. #if defined(DAC1)
  1201. #define __HAL_RCC_DAC1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN)
  1202. #endif /* DAC1 */
  1203. #define __HAL_RCC_OPAMP_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN)
  1204. #define __HAL_RCC_LPTIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN)
  1205. #define __HAL_RCC_LPUART1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN)
  1206. #if defined(SWPMI1)
  1207. #define __HAL_RCC_SWPMI1_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN)
  1208. #endif /* SWPMI1 */
  1209. #define __HAL_RCC_LPTIM2_CLK_DISABLE() CLEAR_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN)
  1210. /**
  1211. * @}
  1212. */
  1213. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  1214. * @brief Enable or disable the APB2 peripheral clock.
  1215. * @note After reset, the peripheral clock (used for registers read/write access)
  1216. * is disabled and the application software has to enable this clock before
  1217. * using it.
  1218. * @{
  1219. */
  1220. #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
  1221. __IO uint32_t tmpreg; \
  1222. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN); \
  1223. /* Delay after an RCC peripheral clock enabling */ \
  1224. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN); \
  1225. UNUSED(tmpreg); \
  1226. } while(0)
  1227. #define __HAL_RCC_FIREWALL_CLK_ENABLE() do { \
  1228. __IO uint32_t tmpreg; \
  1229. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_FWEN); \
  1230. /* Delay after an RCC peripheral clock enabling */ \
  1231. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_FWEN); \
  1232. UNUSED(tmpreg); \
  1233. } while(0)
  1234. #if defined(SDMMC1) && defined(RCC_APB2ENR_SDMMC1EN)
  1235. #define __HAL_RCC_SDMMC1_CLK_ENABLE() do { \
  1236. __IO uint32_t tmpreg; \
  1237. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN); \
  1238. /* Delay after an RCC peripheral clock enabling */ \
  1239. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN); \
  1240. UNUSED(tmpreg); \
  1241. } while(0)
  1242. #endif /* SDMMC1 && RCC_APB2ENR_SDMMC1EN */
  1243. #define __HAL_RCC_TIM1_CLK_ENABLE() do { \
  1244. __IO uint32_t tmpreg; \
  1245. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  1246. /* Delay after an RCC peripheral clock enabling */ \
  1247. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  1248. UNUSED(tmpreg); \
  1249. } while(0)
  1250. #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
  1251. __IO uint32_t tmpreg; \
  1252. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  1253. /* Delay after an RCC peripheral clock enabling */ \
  1254. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  1255. UNUSED(tmpreg); \
  1256. } while(0)
  1257. #if defined(TIM8)
  1258. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  1259. __IO uint32_t tmpreg; \
  1260. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  1261. /* Delay after an RCC peripheral clock enabling */ \
  1262. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  1263. UNUSED(tmpreg); \
  1264. } while(0)
  1265. #endif /* TIM8 */
  1266. #define __HAL_RCC_USART1_CLK_ENABLE() do { \
  1267. __IO uint32_t tmpreg; \
  1268. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  1269. /* Delay after an RCC peripheral clock enabling */ \
  1270. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  1271. UNUSED(tmpreg); \
  1272. } while(0)
  1273. #define __HAL_RCC_TIM15_CLK_ENABLE() do { \
  1274. __IO uint32_t tmpreg; \
  1275. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  1276. /* Delay after an RCC peripheral clock enabling */ \
  1277. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  1278. UNUSED(tmpreg); \
  1279. } while(0)
  1280. #define __HAL_RCC_TIM16_CLK_ENABLE() do { \
  1281. __IO uint32_t tmpreg; \
  1282. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  1283. /* Delay after an RCC peripheral clock enabling */ \
  1284. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  1285. UNUSED(tmpreg); \
  1286. } while(0)
  1287. #if defined(TIM17)
  1288. #define __HAL_RCC_TIM17_CLK_ENABLE() do { \
  1289. __IO uint32_t tmpreg; \
  1290. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  1291. /* Delay after an RCC peripheral clock enabling */ \
  1292. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  1293. UNUSED(tmpreg); \
  1294. } while(0)
  1295. #endif /* TIM17 */
  1296. #if defined(SAI1)
  1297. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  1298. __IO uint32_t tmpreg; \
  1299. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  1300. /* Delay after an RCC peripheral clock enabling */ \
  1301. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  1302. UNUSED(tmpreg); \
  1303. } while(0)
  1304. #endif /* SAI1 */
  1305. #if defined(SAI2)
  1306. #define __HAL_RCC_SAI2_CLK_ENABLE() do { \
  1307. __IO uint32_t tmpreg; \
  1308. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN); \
  1309. /* Delay after an RCC peripheral clock enabling */ \
  1310. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN); \
  1311. UNUSED(tmpreg); \
  1312. } while(0)
  1313. #endif /* SAI2 */
  1314. #if defined(DFSDM1_Filter0)
  1315. #define __HAL_RCC_DFSDM1_CLK_ENABLE() do { \
  1316. __IO uint32_t tmpreg; \
  1317. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM1EN); \
  1318. /* Delay after an RCC peripheral clock enabling */ \
  1319. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM1EN); \
  1320. UNUSED(tmpreg); \
  1321. } while(0)
  1322. #endif /* DFSDM1_Filter0 */
  1323. #if defined(LTDC)
  1324. #define __HAL_RCC_LTDC_CLK_ENABLE() do { \
  1325. __IO uint32_t tmpreg; \
  1326. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_LTDCEN); \
  1327. /* Delay after an RCC peripheral clock enabling */ \
  1328. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_LTDCEN); \
  1329. UNUSED(tmpreg); \
  1330. } while(0)
  1331. #endif /* LTDC */
  1332. #if defined(DSI)
  1333. #define __HAL_RCC_DSI_CLK_ENABLE() do { \
  1334. __IO uint32_t tmpreg; \
  1335. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_DSIEN); \
  1336. /* Delay after an RCC peripheral clock enabling */ \
  1337. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DSIEN); \
  1338. UNUSED(tmpreg); \
  1339. } while(0)
  1340. #endif /* DSI */
  1341. #define __HAL_RCC_SYSCFG_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN)
  1342. #if defined(SDMMC1) && defined(RCC_APB2ENR_SDMMC1EN)
  1343. #define __HAL_RCC_SDMMC1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN)
  1344. #endif /* SDMMC1 && RCC_APB2ENR_SDMMC1EN */
  1345. #define __HAL_RCC_TIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN)
  1346. #define __HAL_RCC_SPI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN)
  1347. #if defined(TIM8)
  1348. #define __HAL_RCC_TIM8_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN)
  1349. #endif /* TIM8 */
  1350. #define __HAL_RCC_USART1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN)
  1351. #define __HAL_RCC_TIM15_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN)
  1352. #define __HAL_RCC_TIM16_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN)
  1353. #if defined(TIM17)
  1354. #define __HAL_RCC_TIM17_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN)
  1355. #endif /* TIM17 */
  1356. #if defined(SAI1)
  1357. #define __HAL_RCC_SAI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN)
  1358. #endif /* SAI1 */
  1359. #if defined(SAI2)
  1360. #define __HAL_RCC_SAI2_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN)
  1361. #endif /* SAI2 */
  1362. #if defined(DFSDM1_Filter0)
  1363. #define __HAL_RCC_DFSDM1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM1EN)
  1364. #endif /* DFSDM1_Filter0 */
  1365. #if defined(LTDC)
  1366. #define __HAL_RCC_LTDC_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_LTDCEN)
  1367. #endif /* LTDC */
  1368. #if defined(DSI)
  1369. #define __HAL_RCC_DSI_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_DSIEN)
  1370. #endif /* DSI */
  1371. /**
  1372. * @}
  1373. */
  1374. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enabled or Disabled Status
  1375. * @brief Check whether the AHB1 peripheral clock is enabled or not.
  1376. * @note After reset, the peripheral clock (used for registers read/write access)
  1377. * is disabled and the application software has to enable this clock before
  1378. * using it.
  1379. * @{
  1380. */
  1381. #define __HAL_RCC_DMA1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN) != 0U)
  1382. #define __HAL_RCC_DMA2_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN) != 0U)
  1383. #if defined(DMAMUX1)
  1384. #define __HAL_RCC_DMAMUX1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN) != 0U)
  1385. #endif /* DMAMUX1 */
  1386. #define __HAL_RCC_FLASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN) != 0U)
  1387. #define __HAL_RCC_CRC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) != 0U)
  1388. #define __HAL_RCC_TSC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN) != 0U)
  1389. #if defined(DMA2D)
  1390. #define __HAL_RCC_DMA2D_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN) != 0U)
  1391. #endif /* DMA2D */
  1392. #if defined(GFXMMU)
  1393. #define __HAL_RCC_GFXMMU_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GFXMMUEN) != 0U)
  1394. #endif /* GFXMMU */
  1395. #define __HAL_RCC_DMA1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN) == 0U)
  1396. #define __HAL_RCC_DMA2_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN) == 0U)
  1397. #if defined(DMAMUX1)
  1398. #define __HAL_RCC_DMAMUX1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMAMUX1EN) == 0U)
  1399. #endif /* DMAMUX1 */
  1400. #define __HAL_RCC_FLASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLASHEN) == 0U)
  1401. #define __HAL_RCC_CRC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) == 0U)
  1402. #define __HAL_RCC_TSC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TSCEN) == 0U)
  1403. #if defined(DMA2D)
  1404. #define __HAL_RCC_DMA2D_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN) == 0U)
  1405. #endif /* DMA2D */
  1406. #if defined(GFXMMU)
  1407. #define __HAL_RCC_GFXMMU_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GFXMMUEN) == 0U)
  1408. #endif /* GFXMMU */
  1409. /**
  1410. * @}
  1411. */
  1412. /** @defgroup RCC_AHB2_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enabled or Disabled Status
  1413. * @brief Check whether the AHB2 peripheral clock is enabled or not.
  1414. * @note After reset, the peripheral clock (used for registers read/write access)
  1415. * is disabled and the application software has to enable this clock before
  1416. * using it.
  1417. * @{
  1418. */
  1419. #define __HAL_RCC_GPIOA_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) != 0U)
  1420. #define __HAL_RCC_GPIOB_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN) != 0U)
  1421. #define __HAL_RCC_GPIOC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) != 0U)
  1422. #if defined(GPIOD)
  1423. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) != 0U)
  1424. #endif /* GPIOD */
  1425. #if defined(GPIOE)
  1426. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) != 0U)
  1427. #endif /* GPIOE */
  1428. #if defined(GPIOF)
  1429. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) != 0U)
  1430. #endif /* GPIOF */
  1431. #if defined(GPIOG)
  1432. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) != 0U)
  1433. #endif /* GPIOG */
  1434. #define __HAL_RCC_GPIOH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN) != 0U)
  1435. #if defined(GPIOI)
  1436. #define __HAL_RCC_GPIOI_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN) != 0U)
  1437. #endif /* GPIOI */
  1438. #if defined(USB_OTG_FS)
  1439. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN) != 0U)
  1440. #endif /* USB_OTG_FS */
  1441. #define __HAL_RCC_ADC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN) != 0U)
  1442. #if defined(DCMI)
  1443. #define __HAL_RCC_DCMI_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN) != 0U)
  1444. #endif /* DCMI */
  1445. #if defined(AES)
  1446. #define __HAL_RCC_AES_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) != 0U)
  1447. #endif /* AES */
  1448. #if defined(HASH)
  1449. #define __HAL_RCC_HASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN) != 0U)
  1450. #endif /* HASH */
  1451. #define __HAL_RCC_RNG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) != 0U)
  1452. #define __HAL_RCC_GPIOA_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) == 0U)
  1453. #define __HAL_RCC_GPIOB_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN) == 0U)
  1454. #define __HAL_RCC_GPIOC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) == 0U)
  1455. #if defined(GPIOD)
  1456. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) == 0U)
  1457. #endif /* GPIOD */
  1458. #if defined(GPIOE)
  1459. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) == 0U)
  1460. #endif /* GPIOE */
  1461. #if defined(GPIOF)
  1462. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) == 0U)
  1463. #endif /* GPIOF */
  1464. #if defined(GPIOG)
  1465. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) == 0U)
  1466. #endif /* GPIOG */
  1467. #define __HAL_RCC_GPIOH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN) == 0U)
  1468. #if defined(GPIOI)
  1469. #define __HAL_RCC_GPIOI_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN) == 0U)
  1470. #endif /* GPIOI */
  1471. #if defined(USB_OTG_FS)
  1472. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN) == 0U)
  1473. #endif /* USB_OTG_FS */
  1474. #define __HAL_RCC_ADC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN) == 0U)
  1475. #if defined(DCMI)
  1476. #define __HAL_RCC_DCMI_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN) == 0U)
  1477. #endif /* DCMI */
  1478. #if defined(AES)
  1479. #define __HAL_RCC_AES_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) == 0U)
  1480. #endif /* AES */
  1481. #if defined(HASH)
  1482. #define __HAL_RCC_HASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN) == 0U)
  1483. #endif /* HASH */
  1484. #define __HAL_RCC_RNG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) == 0U)
  1485. /**
  1486. * @}
  1487. */
  1488. /** @defgroup RCC_AHB3_Clock_Enable_Disable_Status AHB3 Peripheral Clock Enabled or Disabled Status
  1489. * @brief Check whether the AHB3 peripheral clock is enabled or not.
  1490. * @note After reset, the peripheral clock (used for registers read/write access)
  1491. * is disabled and the application software has to enable this clock before
  1492. * using it.
  1493. * @{
  1494. */
  1495. #if defined(FMC_BANK1)
  1496. #define __HAL_RCC_FMC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) != 0U)
  1497. #endif /* FMC_BANK1 */
  1498. #if defined(QUADSPI)
  1499. #define __HAL_RCC_QSPI_IS_CLK_ENABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN) != 0U)
  1500. #endif /* QUADSPI */
  1501. #if defined(FMC_BANK1)
  1502. #define __HAL_RCC_FMC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN) == 0U)
  1503. #endif /* FMC_BANK1 */
  1504. #if defined(QUADSPI)
  1505. #define __HAL_RCC_QSPI_IS_CLK_DISABLED() (READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN) == 0U)
  1506. #endif /* QUADSPI */
  1507. /**
  1508. * @}
  1509. */
  1510. /** @defgroup RCC_APB1_Clock_Enable_Disable_Status APB1 Peripheral Clock Enabled or Disabled Status
  1511. * @brief Check whether the APB1 peripheral clock is enabled or not.
  1512. * @note After reset, the peripheral clock (used for registers read/write access)
  1513. * is disabled and the application software has to enable this clock before
  1514. * using it.
  1515. * @{
  1516. */
  1517. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN) != 0U)
  1518. #if defined(TIM3)
  1519. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN) != 0U)
  1520. #endif /* TIM3 */
  1521. #if defined(TIM4)
  1522. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN) != 0U)
  1523. #endif /* TIM4 */
  1524. #if defined(TIM5)
  1525. #define __HAL_RCC_TIM5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN) != 0U)
  1526. #endif /* TIM5 */
  1527. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN) != 0U)
  1528. #if defined(TIM7)
  1529. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN) != 0U)
  1530. #endif /* TIM7 */
  1531. #if defined(LCD)
  1532. #define __HAL_RCC_LCD_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN) != 0U)
  1533. #endif /* LCD */
  1534. #if defined(RCC_APB1ENR1_RTCAPBEN)
  1535. #define __HAL_RCC_RTCAPB_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN) != 0U)
  1536. #endif /* RCC_APB1ENR1_RTCAPBEN */
  1537. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN) != 0U)
  1538. #if defined(SPI2)
  1539. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN) != 0U)
  1540. #endif /* SPI2 */
  1541. #if defined(SPI3)
  1542. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN) != 0U)
  1543. #endif /* SPI3 */
  1544. #define __HAL_RCC_USART2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN) != 0U)
  1545. #if defined(USART3)
  1546. #define __HAL_RCC_USART3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN) != 0U)
  1547. #endif /* USART3 */
  1548. #if defined(UART4)
  1549. #define __HAL_RCC_UART4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN) != 0U)
  1550. #endif /* UART4 */
  1551. #if defined(UART5)
  1552. #define __HAL_RCC_UART5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN) != 0U)
  1553. #endif /* UART5 */
  1554. #define __HAL_RCC_I2C1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN) != 0U)
  1555. #if defined(I2C2)
  1556. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN) != 0U)
  1557. #endif /* I2C2 */
  1558. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN) != 0U)
  1559. #if defined(I2C4)
  1560. #define __HAL_RCC_I2C4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN) != 0U)
  1561. #endif /* I2C4 */
  1562. #if defined(CRS)
  1563. #define __HAL_RCC_CRS_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN) != 0U)
  1564. #endif /* CRS */
  1565. #if defined(CAN1)
  1566. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN) != 0U)
  1567. #endif /* CAN1 */
  1568. #if defined(CAN2)
  1569. #define __HAL_RCC_CAN2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN2EN) != 0U)
  1570. #endif /* CAN2 */
  1571. #if defined(USB)
  1572. #define __HAL_RCC_USB_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBFSEN) != 0U)
  1573. #endif /* USB */
  1574. #define __HAL_RCC_PWR_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN) != 0U)
  1575. #if defined(DAC1)
  1576. #define __HAL_RCC_DAC1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN) != 0U)
  1577. #endif /* DAC1 */
  1578. #define __HAL_RCC_OPAMP_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN) != 0U)
  1579. #define __HAL_RCC_LPTIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN) != 0U)
  1580. #define __HAL_RCC_LPUART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN) != 0U)
  1581. #if defined(SWPMI1)
  1582. #define __HAL_RCC_SWPMI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN) != 0U)
  1583. #endif /* SWPMI1 */
  1584. #define __HAL_RCC_LPTIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN) != 0U)
  1585. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM2EN) == 0U)
  1586. #if defined(TIM3)
  1587. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM3EN) == 0U)
  1588. #endif /* TIM3 */
  1589. #if defined(TIM4)
  1590. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM4EN) == 0U)
  1591. #endif /* TIM4 */
  1592. #if defined(TIM5)
  1593. #define __HAL_RCC_TIM5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM5EN) == 0U)
  1594. #endif /* TIM5 */
  1595. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM6EN) == 0U)
  1596. #if defined(TIM7)
  1597. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_TIM7EN) == 0U)
  1598. #endif /* TIM7 */
  1599. #if defined(LCD)
  1600. #define __HAL_RCC_LCD_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LCDEN) == 0U)
  1601. #endif /* LCD */
  1602. #if defined(RCC_APB1ENR1_RTCAPBEN)
  1603. #define __HAL_RCC_RTCAPB_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_RTCAPBEN) == 0U)
  1604. #endif /* RCC_APB1ENR1_RTCAPBEN */
  1605. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_WWDGEN) == 0U)
  1606. #if defined(SPI2)
  1607. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI2EN) == 0U)
  1608. #endif /* SPI2 */
  1609. #if defined(SPI3)
  1610. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_SPI3EN) == 0U)
  1611. #endif /* SPI3 */
  1612. #define __HAL_RCC_USART2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART2EN) == 0U)
  1613. #if defined(USART3)
  1614. #define __HAL_RCC_USART3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USART3EN) == 0U)
  1615. #endif /* USART3 */
  1616. #if defined(UART4)
  1617. #define __HAL_RCC_UART4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART4EN) == 0U)
  1618. #endif /* UART4 */
  1619. #if defined(UART5)
  1620. #define __HAL_RCC_UART5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_UART5EN) == 0U)
  1621. #endif /* UART5 */
  1622. #define __HAL_RCC_I2C1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C1EN) == 0U)
  1623. #if defined(I2C2)
  1624. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C2EN) == 0U)
  1625. #endif /* I2C2 */
  1626. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_I2C3EN) == 0U)
  1627. #if defined(I2C4)
  1628. #define __HAL_RCC_I2C4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_I2C4EN) == 0U)
  1629. #endif /* I2C4 */
  1630. #if defined(CRS)
  1631. #define __HAL_RCC_CRS_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CRSEN) == 0U)
  1632. #endif /* CRS */
  1633. #if defined(CAN1)
  1634. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN1EN) == 0U)
  1635. #endif /* CAN1 */
  1636. #if defined(CAN2)
  1637. #define __HAL_RCC_CAN2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_CAN2EN) == 0U)
  1638. #endif /* CAN2 */
  1639. #if defined(USB)
  1640. #define __HAL_RCC_USB_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_USBFSEN) == 0U)
  1641. #endif /* USB */
  1642. #define __HAL_RCC_PWR_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN) == 0U)
  1643. #if defined(DAC1)
  1644. #define __HAL_RCC_DAC1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_DAC1EN) == 0U)
  1645. #endif /* DAC1 */
  1646. #define __HAL_RCC_OPAMP_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_OPAMPEN) == 0U)
  1647. #define __HAL_RCC_LPTIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR1, RCC_APB1ENR1_LPTIM1EN) == 0U)
  1648. #define __HAL_RCC_LPUART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPUART1EN) == 0U)
  1649. #if defined(SWPMI1)
  1650. #define __HAL_RCC_SWPMI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_SWPMI1EN) == 0U)
  1651. #endif /* SWPMI1 */
  1652. #define __HAL_RCC_LPTIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1ENR2, RCC_APB1ENR2_LPTIM2EN) == 0U)
  1653. /**
  1654. * @}
  1655. */
  1656. /** @defgroup RCC_APB2_Clock_Enable_Disable_Status APB2 Peripheral Clock Enabled or Disabled Status
  1657. * @brief Check whether the APB2 peripheral clock is enabled or not.
  1658. * @note After reset, the peripheral clock (used for registers read/write access)
  1659. * is disabled and the application software has to enable this clock before
  1660. * using it.
  1661. * @{
  1662. */
  1663. #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN) != 0U)
  1664. #define __HAL_RCC_FIREWALL_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_FWEN) != 0U)
  1665. #if defined(SDMMC1) && defined(RCC_APB2ENR_SDMMC1EN)
  1666. #define __HAL_RCC_SDMMC1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN) != 0U)
  1667. #endif /* SDMMC1 && RCC_APB2ENR_SDMMC1EN */
  1668. #define __HAL_RCC_TIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) != 0U)
  1669. #define __HAL_RCC_SPI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) != 0U)
  1670. #if defined(TIM8)
  1671. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) != 0U)
  1672. #endif /* TIM8 */
  1673. #define __HAL_RCC_USART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) != 0U)
  1674. #define __HAL_RCC_TIM15_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) != 0U)
  1675. #define __HAL_RCC_TIM16_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) != 0U)
  1676. #if defined(TIM17)
  1677. #define __HAL_RCC_TIM17_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) != 0U)
  1678. #endif /* TIM17 */
  1679. #if defined(SAI1)
  1680. #define __HAL_RCC_SAI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) != 0U)
  1681. #endif /* SAI1 */
  1682. #if defined(SAI2)
  1683. #define __HAL_RCC_SAI2_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN) != 0U)
  1684. #endif /* SAI2 */
  1685. #if defined(DFSDM1_Filter0)
  1686. #define __HAL_RCC_DFSDM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM1EN) != 0U)
  1687. #endif /* DFSDM1_Filter0 */
  1688. #if defined(LTDC)
  1689. #define __HAL_RCC_LTDC_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_LTDCEN) != 0U)
  1690. #endif /* LTDC */
  1691. #if defined(DSI)
  1692. #define __HAL_RCC_DSI_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DSIEN) != 0U)
  1693. #endif /* DSI */
  1694. #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN) == 0U)
  1695. #if defined(SDMMC1) && defined(RCC_APB2ENR_SDMMC1EN)
  1696. #define __HAL_RCC_SDMMC1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SDMMC1EN) == 0U)
  1697. #endif /* SDMMC1 && RCC_APB2ENR_SDMMC1EN */
  1698. #define __HAL_RCC_TIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) == 0U)
  1699. #define __HAL_RCC_SPI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) == 0U)
  1700. #if defined(TIM8)
  1701. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) == 0U)
  1702. #endif /* TIM8 */
  1703. #define __HAL_RCC_USART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) == 0U)
  1704. #define __HAL_RCC_TIM15_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) == 0U)
  1705. #define __HAL_RCC_TIM16_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) == 0U)
  1706. #if defined(TIM17)
  1707. #define __HAL_RCC_TIM17_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) == 0U)
  1708. #endif /* TIM17 */
  1709. #if defined(SAI1)
  1710. #define __HAL_RCC_SAI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) == 0U)
  1711. #endif /* SAI1 */
  1712. #if defined(SAI2)
  1713. #define __HAL_RCC_SAI2_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN) == 0U)
  1714. #endif /* SAI2 */
  1715. #if defined(DFSDM1_Filter0)
  1716. #define __HAL_RCC_DFSDM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DFSDM1EN) == 0U)
  1717. #endif /* DFSDM1_Filter0 */
  1718. #if defined(LTDC)
  1719. #define __HAL_RCC_LTDC_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_LTDCEN) == 0U)
  1720. #endif /* LTDC */
  1721. #if defined(DSI)
  1722. #define __HAL_RCC_DSI_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_DSIEN) == 0U)
  1723. #endif /* DSI */
  1724. /**
  1725. * @}
  1726. */
  1727. /** @defgroup RCC_AHB1_Force_Release_Reset AHB1 Peripheral Force Release Reset
  1728. * @brief Force or release AHB1 peripheral reset.
  1729. * @{
  1730. */
  1731. #define __HAL_RCC_AHB1_FORCE_RESET() WRITE_REG(RCC->AHB1RSTR, 0xFFFFFFFFU)
  1732. #define __HAL_RCC_DMA1_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA1RST)
  1733. #define __HAL_RCC_DMA2_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2RST)
  1734. #if defined(DMAMUX1)
  1735. #define __HAL_RCC_DMAMUX1_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMAMUX1RST)
  1736. #endif /* DMAMUX1 */
  1737. #define __HAL_RCC_FLASH_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FLASHRST)
  1738. #define __HAL_RCC_CRC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  1739. #define __HAL_RCC_TSC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_TSCRST)
  1740. #if defined(DMA2D)
  1741. #define __HAL_RCC_DMA2D_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2DRST)
  1742. #endif /* DMA2D */
  1743. #if defined(GFXMMU)
  1744. #define __HAL_RCC_GFXMMU_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_GFXMMURST)
  1745. #endif /* GFXMMU */
  1746. #define __HAL_RCC_AHB1_RELEASE_RESET() WRITE_REG(RCC->AHB1RSTR, 0x00000000U)
  1747. #define __HAL_RCC_DMA1_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA1RST)
  1748. #define __HAL_RCC_DMA2_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2RST)
  1749. #if defined(DMAMUX1)
  1750. #define __HAL_RCC_DMAMUX1_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMAMUX1RST)
  1751. #endif /* DMAMUX1 */
  1752. #define __HAL_RCC_FLASH_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FLASHRST)
  1753. #define __HAL_RCC_CRC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  1754. #define __HAL_RCC_TSC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_TSCRST)
  1755. #if defined(DMA2D)
  1756. #define __HAL_RCC_DMA2D_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_DMA2DRST)
  1757. #endif /* DMA2D */
  1758. #if defined(GFXMMU)
  1759. #define __HAL_RCC_GFXMMU_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_GFXMMURST)
  1760. #endif /* GFXMMU */
  1761. /**
  1762. * @}
  1763. */
  1764. /** @defgroup RCC_AHB2_Force_Release_Reset AHB2 Peripheral Force Release Reset
  1765. * @brief Force or release AHB2 peripheral reset.
  1766. * @{
  1767. */
  1768. #define __HAL_RCC_AHB2_FORCE_RESET() WRITE_REG(RCC->AHB2RSTR, 0xFFFFFFFFU)
  1769. #define __HAL_RCC_GPIOA_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  1770. #define __HAL_RCC_GPIOB_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  1771. #define __HAL_RCC_GPIOC_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  1772. #if defined(GPIOD)
  1773. #define __HAL_RCC_GPIOD_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  1774. #endif /* GPIOD */
  1775. #if defined(GPIOE)
  1776. #define __HAL_RCC_GPIOE_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  1777. #endif /* GPIOE */
  1778. #if defined(GPIOF)
  1779. #define __HAL_RCC_GPIOF_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  1780. #endif /* GPIOF */
  1781. #if defined(GPIOG)
  1782. #define __HAL_RCC_GPIOG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  1783. #endif /* GPIOG */
  1784. #define __HAL_RCC_GPIOH_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOHRST)
  1785. #if defined(GPIOI)
  1786. #define __HAL_RCC_GPIOI_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOIRST)
  1787. #endif /* GPIOI */
  1788. #if defined(USB_OTG_FS)
  1789. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_OTGFSRST)
  1790. #endif /* USB_OTG_FS */
  1791. #define __HAL_RCC_ADC_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADCRST)
  1792. #if defined(DCMI)
  1793. #define __HAL_RCC_DCMI_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DCMIRST)
  1794. #endif /* DCMI */
  1795. #if defined(AES)
  1796. #define __HAL_RCC_AES_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  1797. #endif /* AES */
  1798. #if defined(HASH)
  1799. #define __HAL_RCC_HASH_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_HASHRST)
  1800. #endif /* HASH */
  1801. #define __HAL_RCC_RNG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  1802. #if defined(OCTOSPIM)
  1803. #define __HAL_RCC_OSPIM_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_OSPIMRST)
  1804. #endif /* OCTOSPIM */
  1805. #if defined(SDMMC1) && defined(RCC_AHB2RSTR_SDMMC1RST)
  1806. #define __HAL_RCC_SDMMC1_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_SDMMC1RST)
  1807. #endif /* SDMMC1 && RCC_AHB2RSTR_SDMMC1RST */
  1808. #define __HAL_RCC_AHB2_RELEASE_RESET() WRITE_REG(RCC->AHB2RSTR, 0x00000000U)
  1809. #define __HAL_RCC_GPIOA_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  1810. #define __HAL_RCC_GPIOB_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  1811. #define __HAL_RCC_GPIOC_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  1812. #if defined(GPIOD)
  1813. #define __HAL_RCC_GPIOD_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  1814. #endif /* GPIOD */
  1815. #if defined(GPIOE)
  1816. #define __HAL_RCC_GPIOE_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  1817. #endif /* GPIOE */
  1818. #if defined(GPIOF)
  1819. #define __HAL_RCC_GPIOF_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  1820. #endif /* GPIOF */
  1821. #if defined(GPIOG)
  1822. #define __HAL_RCC_GPIOG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  1823. #endif /* GPIOG */
  1824. #define __HAL_RCC_GPIOH_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOHRST)
  1825. #if defined(GPIOI)
  1826. #define __HAL_RCC_GPIOI_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOIRST)
  1827. #endif /* GPIOI */
  1828. #if defined(USB_OTG_FS)
  1829. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_OTGFSRST)
  1830. #endif /* USB_OTG_FS */
  1831. #define __HAL_RCC_ADC_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADCRST)
  1832. #if defined(DCMI)
  1833. #define __HAL_RCC_DCMI_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DCMIRST)
  1834. #endif /* DCMI */
  1835. #if defined(AES)
  1836. #define __HAL_RCC_AES_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  1837. #endif /* AES */
  1838. #if defined(HASH)
  1839. #define __HAL_RCC_HASH_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_HASHRST)
  1840. #endif /* HASH */
  1841. #define __HAL_RCC_RNG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  1842. #if defined(OCTOSPIM)
  1843. #define __HAL_RCC_OSPIM_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_OSPIMRST)
  1844. #endif /* OCTOSPIM */
  1845. #if defined(SDMMC1) && defined(RCC_AHB2RSTR_SDMMC1RST)
  1846. #define __HAL_RCC_SDMMC1_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_SDMMC1RST)
  1847. #endif /* SDMMC1 && RCC_AHB2RSTR_SDMMC1RST */
  1848. /**
  1849. * @}
  1850. */
  1851. /** @defgroup RCC_AHB3_Force_Release_Reset AHB3 Peripheral Force Release Reset
  1852. * @brief Force or release AHB3 peripheral reset.
  1853. * @{
  1854. */
  1855. #define __HAL_RCC_AHB3_FORCE_RESET() WRITE_REG(RCC->AHB3RSTR, 0xFFFFFFFFU)
  1856. #if defined(FMC_BANK1)
  1857. #define __HAL_RCC_FMC_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_FMCRST)
  1858. #endif /* FMC_BANK1 */
  1859. #if defined(QUADSPI)
  1860. #define __HAL_RCC_QSPI_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_QSPIRST)
  1861. #endif /* QUADSPI */
  1862. #if defined(OCTOSPI1)
  1863. #define __HAL_RCC_OSPI1_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_OSPI1RST)
  1864. #endif /* OCTOSPI1 */
  1865. #if defined(OCTOSPI2)
  1866. #define __HAL_RCC_OSPI2_FORCE_RESET() SET_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_OSPI2RST)
  1867. #endif /* OCTOSPI2 */
  1868. #define __HAL_RCC_AHB3_RELEASE_RESET() WRITE_REG(RCC->AHB3RSTR, 0x00000000U)
  1869. #if defined(FMC_BANK1)
  1870. #define __HAL_RCC_FMC_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_FMCRST)
  1871. #endif /* FMC_BANK1 */
  1872. #if defined(QUADSPI)
  1873. #define __HAL_RCC_QSPI_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_QSPIRST)
  1874. #endif /* QUADSPI */
  1875. #if defined(OCTOSPI1)
  1876. #define __HAL_RCC_OSPI1_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_OSPI1RST)
  1877. #endif /* OCTOSPI1 */
  1878. #if defined(OCTOSPI2)
  1879. #define __HAL_RCC_OSPI2_RELEASE_RESET() CLEAR_BIT(RCC->AHB3RSTR, RCC_AHB3RSTR_OSPI2RST)
  1880. #endif /* OCTOSPI2 */
  1881. /**
  1882. * @}
  1883. */
  1884. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Peripheral Force Release Reset
  1885. * @brief Force or release APB1 peripheral reset.
  1886. * @{
  1887. */
  1888. #define __HAL_RCC_APB1_FORCE_RESET() WRITE_REG(RCC->APB1RSTR1, 0xFFFFFFFFU)
  1889. #define __HAL_RCC_TIM2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM2RST)
  1890. #if defined(TIM3)
  1891. #define __HAL_RCC_TIM3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM3RST)
  1892. #endif /* TIM3 */
  1893. #if defined(TIM4)
  1894. #define __HAL_RCC_TIM4_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM4RST)
  1895. #endif /* TIM4 */
  1896. #if defined(TIM5)
  1897. #define __HAL_RCC_TIM5_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM5RST)
  1898. #endif /* TIM5 */
  1899. #define __HAL_RCC_TIM6_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM6RST)
  1900. #if defined(TIM7)
  1901. #define __HAL_RCC_TIM7_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM7RST)
  1902. #endif /* TIM7 */
  1903. #if defined(LCD)
  1904. #define __HAL_RCC_LCD_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LCDRST)
  1905. #endif /* LCD */
  1906. #if defined(SPI2)
  1907. #define __HAL_RCC_SPI2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI2RST)
  1908. #endif /* SPI2 */
  1909. #if defined(SPI3)
  1910. #define __HAL_RCC_SPI3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI3RST)
  1911. #endif /* SPI3 */
  1912. #define __HAL_RCC_USART2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART2RST)
  1913. #if defined(USART3)
  1914. #define __HAL_RCC_USART3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART3RST)
  1915. #endif /* USART3 */
  1916. #if defined(UART4)
  1917. #define __HAL_RCC_UART4_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART4RST)
  1918. #endif /* UART4 */
  1919. #if defined(UART5)
  1920. #define __HAL_RCC_UART5_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART5RST)
  1921. #endif /* UART5 */
  1922. #define __HAL_RCC_I2C1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C1RST)
  1923. #if defined(I2C2)
  1924. #define __HAL_RCC_I2C2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C2RST)
  1925. #endif /* I2C2 */
  1926. #define __HAL_RCC_I2C3_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C3RST)
  1927. #if defined(I2C4)
  1928. #define __HAL_RCC_I2C4_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_I2C4RST)
  1929. #endif /* I2C4 */
  1930. #if defined(CRS)
  1931. #define __HAL_RCC_CRS_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CRSRST)
  1932. #endif /* CRS */
  1933. #if defined(CAN1)
  1934. #define __HAL_RCC_CAN1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CAN1RST)
  1935. #endif /* CAN1 */
  1936. #if defined(CAN2)
  1937. #define __HAL_RCC_CAN2_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CAN2RST)
  1938. #endif /* CAN2 */
  1939. #if defined(USB)
  1940. #define __HAL_RCC_USB_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USBFSRST)
  1941. #endif /* USB */
  1942. #define __HAL_RCC_PWR_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_PWRRST)
  1943. #if defined(DAC1)
  1944. #define __HAL_RCC_DAC1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_DAC1RST)
  1945. #endif /* DAC1 */
  1946. #define __HAL_RCC_OPAMP_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_OPAMPRST)
  1947. #define __HAL_RCC_LPTIM1_FORCE_RESET() SET_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LPTIM1RST)
  1948. #define __HAL_RCC_LPUART1_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPUART1RST)
  1949. #if defined(SWPMI1)
  1950. #define __HAL_RCC_SWPMI1_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_SWPMI1RST)
  1951. #endif /* SWPMI1 */
  1952. #define __HAL_RCC_LPTIM2_FORCE_RESET() SET_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPTIM2RST)
  1953. #define __HAL_RCC_APB1_RELEASE_RESET() WRITE_REG(RCC->APB1RSTR1, 0x00000000U)
  1954. #define __HAL_RCC_TIM2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM2RST)
  1955. #if defined(TIM3)
  1956. #define __HAL_RCC_TIM3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM3RST)
  1957. #endif /* TIM3 */
  1958. #if defined(TIM4)
  1959. #define __HAL_RCC_TIM4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM4RST)
  1960. #endif /* TIM4 */
  1961. #if defined(TIM5)
  1962. #define __HAL_RCC_TIM5_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM5RST)
  1963. #endif /* TIM5 */
  1964. #define __HAL_RCC_TIM6_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM6RST)
  1965. #if defined(TIM7)
  1966. #define __HAL_RCC_TIM7_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_TIM7RST)
  1967. #endif /* TIM7 */
  1968. #if defined(LCD)
  1969. #define __HAL_RCC_LCD_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LCDRST)
  1970. #endif /* LCD */
  1971. #if defined(SPI2)
  1972. #define __HAL_RCC_SPI2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI2RST)
  1973. #endif /* SPI2 */
  1974. #if defined(SPI3)
  1975. #define __HAL_RCC_SPI3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_SPI3RST)
  1976. #endif /* SPI3 */
  1977. #define __HAL_RCC_USART2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART2RST)
  1978. #if defined(USART3)
  1979. #define __HAL_RCC_USART3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USART3RST)
  1980. #endif /* USART3 */
  1981. #if defined(UART4)
  1982. #define __HAL_RCC_UART4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART4RST)
  1983. #endif /* UART4 */
  1984. #if defined(UART5)
  1985. #define __HAL_RCC_UART5_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_UART5RST)
  1986. #endif /* UART5 */
  1987. #define __HAL_RCC_I2C1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C1RST)
  1988. #if defined(I2C2)
  1989. #define __HAL_RCC_I2C2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C2RST)
  1990. #endif /* I2C2 */
  1991. #define __HAL_RCC_I2C3_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_I2C3RST)
  1992. #if defined(I2C4)
  1993. #define __HAL_RCC_I2C4_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_I2C4RST)
  1994. #endif /* I2C4 */
  1995. #if defined(CRS)
  1996. #define __HAL_RCC_CRS_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CRSRST)
  1997. #endif /* CRS */
  1998. #if defined(CAN1)
  1999. #define __HAL_RCC_CAN1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CAN1RST)
  2000. #endif /* CAN1 */
  2001. #if defined(CAN2)
  2002. #define __HAL_RCC_CAN2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_CAN2RST)
  2003. #endif /* CAN2 */
  2004. #if defined(USB)
  2005. #define __HAL_RCC_USB_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_USBFSRST)
  2006. #endif /* USB */
  2007. #define __HAL_RCC_PWR_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_PWRRST)
  2008. #if defined(DAC1)
  2009. #define __HAL_RCC_DAC1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_DAC1RST)
  2010. #endif /* DAC1 */
  2011. #define __HAL_RCC_OPAMP_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_OPAMPRST)
  2012. #define __HAL_RCC_LPTIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR1, RCC_APB1RSTR1_LPTIM1RST)
  2013. #define __HAL_RCC_LPUART1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPUART1RST)
  2014. #if defined(SWPMI1)
  2015. #define __HAL_RCC_SWPMI1_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_SWPMI1RST)
  2016. #endif /* SWPMI1 */
  2017. #define __HAL_RCC_LPTIM2_RELEASE_RESET() CLEAR_BIT(RCC->APB1RSTR2, RCC_APB1RSTR2_LPTIM2RST)
  2018. /**
  2019. * @}
  2020. */
  2021. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Peripheral Force Release Reset
  2022. * @brief Force or release APB2 peripheral reset.
  2023. * @{
  2024. */
  2025. #define __HAL_RCC_APB2_FORCE_RESET() WRITE_REG(RCC->APB2RSTR, 0xFFFFFFFFU)
  2026. #define __HAL_RCC_SYSCFG_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SYSCFGRST)
  2027. #if defined(SDMMC1) && defined(RCC_APB2RSTR_SDMMC1RST)
  2028. #define __HAL_RCC_SDMMC1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SDMMC1RST)
  2029. #endif /* SDMMC1 && RCC_APB2RSTR_SDMMC1RST */
  2030. #define __HAL_RCC_TIM1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  2031. #define __HAL_RCC_SPI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  2032. #if defined(TIM8)
  2033. #define __HAL_RCC_TIM8_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  2034. #endif /* TIM8 */
  2035. #define __HAL_RCC_USART1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  2036. #define __HAL_RCC_TIM15_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  2037. #define __HAL_RCC_TIM16_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  2038. #if defined(TIM17)
  2039. #define __HAL_RCC_TIM17_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  2040. #endif /* TIM17 */
  2041. #if defined(SAI1)
  2042. #define __HAL_RCC_SAI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  2043. #endif /* SAI1 */
  2044. #if defined(SAI2)
  2045. #define __HAL_RCC_SAI2_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI2RST)
  2046. #endif /* SAI2 */
  2047. #if defined(DFSDM1_Filter0)
  2048. #define __HAL_RCC_DFSDM1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_DFSDM1RST)
  2049. #endif /* DFSDM1_Filter0 */
  2050. #if defined(LTDC)
  2051. #define __HAL_RCC_LTDC_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_LTDCRST)
  2052. #endif /* LTDC */
  2053. #if defined(DSI)
  2054. #define __HAL_RCC_DSI_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_DSIRST)
  2055. #endif /* DSI */
  2056. #define __HAL_RCC_APB2_RELEASE_RESET() WRITE_REG(RCC->APB2RSTR, 0x00000000U)
  2057. #define __HAL_RCC_SYSCFG_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SYSCFGRST)
  2058. #if defined(SDMMC1) && defined(RCC_APB2RSTR_SDMMC1RST)
  2059. #define __HAL_RCC_SDMMC1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SDMMC1RST)
  2060. #endif /* SDMMC1 && RCC_APB2RSTR_SDMMC1RST */
  2061. #define __HAL_RCC_TIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  2062. #define __HAL_RCC_SPI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  2063. #if defined(TIM8)
  2064. #define __HAL_RCC_TIM8_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  2065. #endif /* TIM8 */
  2066. #define __HAL_RCC_USART1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  2067. #define __HAL_RCC_TIM15_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  2068. #define __HAL_RCC_TIM16_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  2069. #if defined(TIM17)
  2070. #define __HAL_RCC_TIM17_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  2071. #endif /* TIM17 */
  2072. #if defined(SAI1)
  2073. #define __HAL_RCC_SAI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  2074. #endif /* SAI1 */
  2075. #if defined(SAI2)
  2076. #define __HAL_RCC_SAI2_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI2RST)
  2077. #endif /* SAI2 */
  2078. #if defined(DFSDM1_Filter0)
  2079. #define __HAL_RCC_DFSDM1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_DFSDM1RST)
  2080. #endif /* DFSDM1_Filter0 */
  2081. #if defined(LTDC)
  2082. #define __HAL_RCC_LTDC_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_LTDCRST)
  2083. #endif /* LTDC */
  2084. #if defined(DSI)
  2085. #define __HAL_RCC_DSI_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_DSIRST)
  2086. #endif /* DSI */
  2087. /**
  2088. * @}
  2089. */
  2090. /** @defgroup RCC_AHB1_Clock_Sleep_Enable_Disable AHB1 Peripheral Clock Sleep Enable Disable
  2091. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  2092. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2093. * power consumption.
  2094. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2095. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2096. * @{
  2097. */
  2098. #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN)
  2099. #define __HAL_RCC_DMA2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN)
  2100. #if defined(DMAMUX1)
  2101. #define __HAL_RCC_DMAMUX1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN)
  2102. #endif /* DMAMUX1 */
  2103. #define __HAL_RCC_FLASH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN)
  2104. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN)
  2105. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN)
  2106. #define __HAL_RCC_TSC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN)
  2107. #if defined(DMA2D)
  2108. #define __HAL_RCC_DMA2D_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2DSMEN)
  2109. #endif /* DMA2D */
  2110. #if defined(GFXMMU)
  2111. #define __HAL_RCC_GFXMMU_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_GFXMMUSMEN)
  2112. #endif /* GFXMMU */
  2113. #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN)
  2114. #define __HAL_RCC_DMA2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN)
  2115. #if defined(DMAMUX1)
  2116. #define __HAL_RCC_DMAMUX1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN)
  2117. #endif /* DMAMUX1 */
  2118. #define __HAL_RCC_FLASH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN)
  2119. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN)
  2120. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN)
  2121. #define __HAL_RCC_TSC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN)
  2122. #if defined(DMA2D)
  2123. #define __HAL_RCC_DMA2D_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2DSMEN)
  2124. #endif /* DMA2D */
  2125. #if defined(GFXMMU)
  2126. #define __HAL_RCC_GFXMMU_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_GFXMMUSMEN)
  2127. #endif /* GFXMMU */
  2128. /**
  2129. * @}
  2130. */
  2131. /** @defgroup RCC_AHB2_Clock_Sleep_Enable_Disable AHB2 Peripheral Clock Sleep Enable Disable
  2132. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  2133. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2134. * power consumption.
  2135. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2136. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2137. * @{
  2138. */
  2139. #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN)
  2140. #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN)
  2141. #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN)
  2142. #if defined(GPIOD)
  2143. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN)
  2144. #endif /* GPIOD */
  2145. #if defined(GPIOE)
  2146. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN)
  2147. #endif /* GPIOE */
  2148. #if defined(GPIOF)
  2149. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN)
  2150. #endif /* GPIOF */
  2151. #if defined(GPIOG)
  2152. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN)
  2153. #endif /* GPIOG */
  2154. #define __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN)
  2155. #if defined(GPIOI)
  2156. #define __HAL_RCC_GPIOI_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOISMEN)
  2157. #endif /* GPIOI */
  2158. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN)
  2159. #if defined(SRAM3)
  2160. #define __HAL_RCC_SRAM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM3SMEN)
  2161. #endif /* SRAM3 */
  2162. #if defined(USB_OTG_FS)
  2163. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN)
  2164. #endif /* USB_OTG_FS */
  2165. #define __HAL_RCC_ADC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN)
  2166. #if defined(DCMI)
  2167. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DCMISMEN)
  2168. #endif /* DCMI */
  2169. #if defined(AES)
  2170. #define __HAL_RCC_AES_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN)
  2171. #endif /* AES */
  2172. #if defined(HASH)
  2173. #define __HAL_RCC_HASH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_HASHSMEN)
  2174. #endif /* HASH */
  2175. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN)
  2176. #if defined(OCTOSPIM)
  2177. #define __HAL_RCC_OSPIM_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OSPIMSMEN)
  2178. #endif /* OCTOSPIM */
  2179. #if defined(SDMMC1) && defined(RCC_AHB2SMENR_SDMMC1SMEN)
  2180. #define __HAL_RCC_SDMMC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SDMMC1SMEN)
  2181. #endif /* SDMMC1 && RCC_AHB2SMENR_SDMMC1SMEN */
  2182. #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN)
  2183. #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN)
  2184. #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN)
  2185. #if defined(GPIOD)
  2186. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN)
  2187. #endif /* GPIOD */
  2188. #if defined(GPIOE)
  2189. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN)
  2190. #endif /* GPIOE */
  2191. #if defined(GPIOF)
  2192. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN)
  2193. #endif /* GPIOF */
  2194. #if defined(GPIOG)
  2195. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN)
  2196. #endif /* GPIOG */
  2197. #define __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN)
  2198. #if defined(GPIOI)
  2199. #define __HAL_RCC_GPIOI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOISMEN)
  2200. #endif /* GPIOI */
  2201. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN)
  2202. #if defined(SRAM3)
  2203. #define __HAL_RCC_SRAM3_IS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM3SMEN)
  2204. #endif /* SRAM3 */
  2205. #if defined(USB_OTG_FS)
  2206. #define __HAL_RCC_USB_OTG_FS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN)
  2207. #endif /* USB_OTG_FS */
  2208. #define __HAL_RCC_ADC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN)
  2209. #if defined(DCMI)
  2210. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DCMISMEN)
  2211. #endif /* DCMI */
  2212. #if defined(AES)
  2213. #define __HAL_RCC_AES_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN)
  2214. #endif /* AES */
  2215. #if defined(HASH)
  2216. #define __HAL_RCC_HASH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_HASHSMEN)
  2217. #endif /* HASH */
  2218. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN)
  2219. #if defined(OCTOSPIM)
  2220. #define __HAL_RCC_OSPIM_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OSPIMSMEN)
  2221. #endif /* OCTOSPIM */
  2222. #if defined(SDMMC1) && defined(RCC_AHB2SMENR_SDMMC1SMEN)
  2223. #define __HAL_RCC_SDMMC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SDMMC1SMEN)
  2224. #endif /* SDMMC1 && RCC_AHB2SMENR_SDMMC1SMEN */
  2225. /**
  2226. * @}
  2227. */
  2228. /** @defgroup RCC_AHB3_Clock_Sleep_Enable_Disable AHB3 Peripheral Clock Sleep Enable Disable
  2229. * @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  2230. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2231. * power consumption.
  2232. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2233. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2234. * @{
  2235. */
  2236. #if defined(QUADSPI)
  2237. #define __HAL_RCC_QSPI_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN)
  2238. #endif /* QUADSPI */
  2239. #if defined(OCTOSPI1)
  2240. #define __HAL_RCC_OSPI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI1SMEN)
  2241. #endif /* OCTOSPI1 */
  2242. #if defined(OCTOSPI2)
  2243. #define __HAL_RCC_OSPI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI2SMEN)
  2244. #endif /* OCTOSPI2 */
  2245. #if defined(FMC_BANK1)
  2246. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN)
  2247. #endif /* FMC_BANK1 */
  2248. #if defined(QUADSPI)
  2249. #define __HAL_RCC_QSPI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN)
  2250. #endif /* QUADSPI */
  2251. #if defined(OCTOSPI1)
  2252. #define __HAL_RCC_OSPI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI1SMEN)
  2253. #endif /* OCTOSPI1 */
  2254. #if defined(OCTOSPI2)
  2255. #define __HAL_RCC_OSPI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI2SMEN)
  2256. #endif /* OCTOSPI2 */
  2257. #if defined(FMC_BANK1)
  2258. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN)
  2259. #endif /* FMC_BANK1 */
  2260. /**
  2261. * @}
  2262. */
  2263. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable APB1 Peripheral Clock Sleep Enable Disable
  2264. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  2265. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2266. * power consumption.
  2267. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2268. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2269. * @{
  2270. */
  2271. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN)
  2272. #if defined(TIM3)
  2273. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN)
  2274. #endif /* TIM3 */
  2275. #if defined(TIM4)
  2276. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN)
  2277. #endif /* TIM4 */
  2278. #if defined(TIM5)
  2279. #define __HAL_RCC_TIM5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN)
  2280. #endif /* TIM5 */
  2281. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN)
  2282. #if defined(TIM7)
  2283. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN)
  2284. #endif /* TIM7 */
  2285. #if defined(LCD)
  2286. #define __HAL_RCC_LCD_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN)
  2287. #endif /* LCD */
  2288. #if defined(RCC_APB1SMENR1_RTCAPBSMEN)
  2289. #define __HAL_RCC_RTCAPB_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN)
  2290. #endif /* RCC_APB1SMENR1_RTCAPBSMEN */
  2291. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN)
  2292. #if defined(SPI2)
  2293. #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN)
  2294. #endif /* SPI2 */
  2295. #if defined(SPI3)
  2296. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN)
  2297. #endif /* SPI3 */
  2298. #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN)
  2299. #if defined(USART3)
  2300. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN)
  2301. #endif /* USART3 */
  2302. #if defined(UART4)
  2303. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN)
  2304. #endif /* UART4 */
  2305. #if defined(UART5)
  2306. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN)
  2307. #endif /* UART5 */
  2308. #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN)
  2309. #if defined(I2C2)
  2310. #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN)
  2311. #endif /* I2C2 */
  2312. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN)
  2313. #if defined(I2C4)
  2314. #define __HAL_RCC_I2C4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN)
  2315. #endif /* I2C4 */
  2316. #if defined(CRS)
  2317. #define __HAL_RCC_CRS_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN)
  2318. #endif /* CRS */
  2319. #if defined(CAN1)
  2320. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN)
  2321. #endif /* CAN1 */
  2322. #if defined(CAN2)
  2323. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN2SMEN)
  2324. #endif /* CAN2 */
  2325. #if defined(USB)
  2326. #define __HAL_RCC_USB_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBFSSMEN)
  2327. #endif /* USB */
  2328. #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN)
  2329. #if defined(DAC1)
  2330. #define __HAL_RCC_DAC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN)
  2331. #endif /* DAC1 */
  2332. #define __HAL_RCC_OPAMP_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN)
  2333. #define __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN)
  2334. #define __HAL_RCC_LPUART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN)
  2335. #if defined(SWPMI1)
  2336. #define __HAL_RCC_SWPMI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN)
  2337. #endif /* SWPMI1 */
  2338. #define __HAL_RCC_LPTIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN)
  2339. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN)
  2340. #if defined(TIM3)
  2341. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN)
  2342. #endif /* TIM3 */
  2343. #if defined(TIM4)
  2344. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN)
  2345. #endif /* TIM4 */
  2346. #if defined(TIM5)
  2347. #define __HAL_RCC_TIM5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN)
  2348. #endif /* TIM5 */
  2349. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN)
  2350. #if defined(TIM7)
  2351. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN)
  2352. #endif /* TIM7 */
  2353. #if defined(LCD)
  2354. #define __HAL_RCC_LCD_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN)
  2355. #endif /* LCD */
  2356. #if defined(RCC_APB1SMENR1_RTCAPBSMEN)
  2357. #define __HAL_RCC_RTCAPB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN)
  2358. #endif /* RCC_APB1SMENR1_RTCAPBSMEN */
  2359. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN)
  2360. #if defined(SPI2)
  2361. #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN)
  2362. #endif /* SPI2 */
  2363. #if defined(SPI3)
  2364. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN)
  2365. #endif /* SPI3 */
  2366. #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN)
  2367. #if defined(USART3)
  2368. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN)
  2369. #endif /* USART3 */
  2370. #if defined(UART4)
  2371. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN)
  2372. #endif /* UART4 */
  2373. #if defined(UART5)
  2374. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN)
  2375. #endif /* UART5 */
  2376. #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN)
  2377. #if defined(I2C2)
  2378. #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN)
  2379. #endif /* I2C2 */
  2380. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN)
  2381. #if defined(I2C4)
  2382. #define __HAL_RCC_I2C4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN)
  2383. #endif /* I2C4 */
  2384. #if defined(CRS)
  2385. #define __HAL_RCC_CRS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN)
  2386. #endif /* CRS */
  2387. #if defined(CAN1)
  2388. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN)
  2389. #endif /* CAN1 */
  2390. #if defined(CAN2)
  2391. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN2SMEN)
  2392. #endif /* CAN2 */
  2393. #if defined(USB)
  2394. #define __HAL_RCC_USB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBFSSMEN)
  2395. #endif /* USB */
  2396. #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN)
  2397. #if defined(DAC1)
  2398. #define __HAL_RCC_DAC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN)
  2399. #endif /* DAC1 */
  2400. #define __HAL_RCC_OPAMP_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN)
  2401. #define __HAL_RCC_LPTIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN)
  2402. #define __HAL_RCC_LPUART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN)
  2403. #if defined(SWPMI1)
  2404. #define __HAL_RCC_SWPMI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN)
  2405. #endif /* SWPMI1 */
  2406. #define __HAL_RCC_LPTIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN)
  2407. /**
  2408. * @}
  2409. */
  2410. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable APB2 Peripheral Clock Sleep Enable Disable
  2411. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  2412. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2413. * power consumption.
  2414. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2415. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2416. * @{
  2417. */
  2418. #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN)
  2419. #if defined(SDMMC1) && defined(RCC_APB2SMENR_SDMMC1SMEN)
  2420. #define __HAL_RCC_SDMMC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN)
  2421. #endif /* SDMMC1 && RCC_APB2SMENR_SDMMC1SMEN */
  2422. #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN)
  2423. #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN)
  2424. #if defined(TIM8)
  2425. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN)
  2426. #endif /* TIM8 */
  2427. #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN)
  2428. #define __HAL_RCC_TIM15_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN)
  2429. #define __HAL_RCC_TIM16_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN)
  2430. #if defined(TIM17)
  2431. #define __HAL_RCC_TIM17_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN)
  2432. #endif /* TIM17 */
  2433. #if defined(SAI1)
  2434. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN)
  2435. #endif /* SAI1 */
  2436. #if defined(SAI2)
  2437. #define __HAL_RCC_SAI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN)
  2438. #endif /* SAI2 */
  2439. #if defined(DFSDM1_Filter0)
  2440. #define __HAL_RCC_DFSDM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDM1SMEN)
  2441. #endif /* DFSDM1_Filter0 */
  2442. #if defined(LTDC)
  2443. #define __HAL_RCC_LTDC_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_LTDCSMEN)
  2444. #endif /* LTDC */
  2445. #if defined(DSI)
  2446. #define __HAL_RCC_DSI_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DSISMEN)
  2447. #endif /* DSI */
  2448. #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN)
  2449. #if defined(SDMMC1) && defined(RCC_APB2SMENR_SDMMC1SMEN)
  2450. #define __HAL_RCC_SDMMC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN)
  2451. #endif /* SDMMC1 && RCC_APB2SMENR_SDMMC1SMEN */
  2452. #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN)
  2453. #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN)
  2454. #if defined(TIM8)
  2455. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN)
  2456. #endif /* TIM8 */
  2457. #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN)
  2458. #define __HAL_RCC_TIM15_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN)
  2459. #define __HAL_RCC_TIM16_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN)
  2460. #if defined(TIM17)
  2461. #define __HAL_RCC_TIM17_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN)
  2462. #endif /* TIM17 */
  2463. #if defined(SAI1)
  2464. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN)
  2465. #endif /* SAI1 */
  2466. #if defined(SAI2)
  2467. #define __HAL_RCC_SAI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN)
  2468. #endif /* SAI2 */
  2469. #if defined(DFSDM1_Filter0)
  2470. #define __HAL_RCC_DFSDM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDM1SMEN)
  2471. #endif /* DFSDM1_Filter0 */
  2472. #if defined(LTDC)
  2473. #define __HAL_RCC_LTDC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_LTDCSMEN)
  2474. #endif /* LTDC */
  2475. #if defined(DSI)
  2476. #define __HAL_RCC_DSI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DSISMEN)
  2477. #endif /* DSI */
  2478. /**
  2479. * @}
  2480. */
  2481. /** @defgroup RCC_AHB1_Clock_Sleep_Enable_Disable_Status AHB1 Peripheral Clock Sleep Enabled or Disabled Status
  2482. * @brief Check whether the AHB1 peripheral clock during Low Power (Sleep) mode is enabled or not.
  2483. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2484. * power consumption.
  2485. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2486. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2487. * @{
  2488. */
  2489. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN) != 0U)
  2490. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN) != 0U)
  2491. #if defined(DMAMUX1)
  2492. #define __HAL_RCC_DMAMUX1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN) != 0U)
  2493. #endif /* DMAMUX1 */
  2494. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN) != 0U)
  2495. #define __HAL_RCC_SRAM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN) != 0U)
  2496. #define __HAL_RCC_CRC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN) != 0U)
  2497. #define __HAL_RCC_TSC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN) != 0U)
  2498. #if defined(DMA2D)
  2499. #define __HAL_RCC_DMA2D_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2DSMEN) != 0U)
  2500. #endif /* DMA2D */
  2501. #if defined(GFXMMU)
  2502. #define __HAL_RCC_GFXMMU_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_GFXMMUSMEN) != 0U)
  2503. #endif /* GFXMMU */
  2504. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA1SMEN) == 0U)
  2505. #define __HAL_RCC_DMA2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2SMEN) == 0U)
  2506. #if defined(DMAMUX1)
  2507. #define __HAL_RCC_DMAMUX1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMAMUX1SMEN) == 0U)
  2508. #endif /* DMAMUX1 */
  2509. #define __HAL_RCC_FLASH_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_FLASHSMEN) == 0U)
  2510. #define __HAL_RCC_SRAM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_SRAM1SMEN) == 0U)
  2511. #define __HAL_RCC_CRC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_CRCSMEN) == 0U)
  2512. #define __HAL_RCC_TSC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_TSCSMEN) == 0U)
  2513. #if defined(DMA2D)
  2514. #define __HAL_RCC_DMA2D_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_DMA2DSMEN) == 0U)
  2515. #endif /* DMA2D */
  2516. #if defined(GFXMMU)
  2517. #define __HAL_RCC_GFXMMU_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB1SMENR, RCC_AHB1SMENR_GFXMMUSMEN) == 0U)
  2518. #endif /* GFXMMU */
  2519. /**
  2520. * @}
  2521. */
  2522. /** @defgroup RCC_AHB2_Clock_Sleep_Enable_Disable_Status AHB2 Peripheral Clock Sleep Enabled or Disabled Status
  2523. * @brief Check whether the AHB2 peripheral clock during Low Power (Sleep) mode is enabled or not.
  2524. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2525. * power consumption.
  2526. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2527. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2528. * @{
  2529. */
  2530. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN) != 0U)
  2531. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN) != 0U)
  2532. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN) != 0U)
  2533. #if defined(GPIOD)
  2534. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN) != 0U)
  2535. #endif /* GPIOD */
  2536. #if defined(GPIOE)
  2537. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN) != 0U)
  2538. #endif /* GPIOE */
  2539. #if defined(GPIOF)
  2540. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN) != 0U)
  2541. #endif /* GPIOF */
  2542. #if defined(GPIOG)
  2543. #define __HAL_RCC_GPIOG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN) != 0U)
  2544. #endif /* GPIOG */
  2545. #define __HAL_RCC_GPIOH_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN) != 0U)
  2546. #if defined(GPIOI)
  2547. #define __HAL_RCC_GPIOI_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOISMEN) != 0U)
  2548. #endif /* GPIOI */
  2549. #define __HAL_RCC_SRAM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN) != 0U)
  2550. #if defined(SRAM3)
  2551. #define __HAL_RCC_SRAM3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM3SMEN) != 0U)
  2552. #endif /* SRAM3 */
  2553. #if defined(USB_OTG_FS)
  2554. #define __HAL_RCC_USB_OTG_FS_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN) != 0U)
  2555. #endif /* USB_OTG_FS */
  2556. #define __HAL_RCC_ADC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN) != 0U)
  2557. #if defined(DCMI)
  2558. #define __HAL_RCC_DCMI_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DCMISMEN) != 0U)
  2559. #endif /* DCMI */
  2560. #if defined(AES)
  2561. #define __HAL_RCC_AES_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN) != 0U)
  2562. #endif /* AES */
  2563. #if defined(HASH)
  2564. #define __HAL_RCC_HASH_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_HASHSMEN) != 0U)
  2565. #endif /* HASH */
  2566. #define __HAL_RCC_RNG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN) != 0U)
  2567. #if defined(OCTOSPIM)
  2568. #define __HAL_RCC_OSPIM_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OSPIMSMEN) != 0U)
  2569. #endif /* OCTOSPIM */
  2570. #if defined(SDMMC1) && defined(RCC_AHB2SMENR_SDMMC1SMEN)
  2571. #define __HAL_RCC_SDMMC1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SDMMC1SMEN) != 0U)
  2572. #endif /* SDMMC1 && RCC_AHB2SMENR_SDMMC1SMEN */
  2573. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOASMEN) == 0U)
  2574. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOBSMEN) == 0U)
  2575. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOCSMEN) == 0U)
  2576. #if defined(GPIOD)
  2577. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIODSMEN) == 0U)
  2578. #endif /* GPIOD */
  2579. #if defined(GPIOE)
  2580. #define __HAL_RCC_GPIOE_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOESMEN) == 0U)
  2581. #endif /* GPIOE */
  2582. #if defined(GPIOF)
  2583. #define __HAL_RCC_GPIOF_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOFSMEN) == 0U)
  2584. #endif /* GPIOF */
  2585. #if defined(GPIOG)
  2586. #define __HAL_RCC_GPIOG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOGSMEN) == 0U)
  2587. #endif /* GPIOG */
  2588. #define __HAL_RCC_GPIOH_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOHSMEN) == 0U)
  2589. #if defined(GPIOI)
  2590. #define __HAL_RCC_GPIOI_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_GPIOISMEN) == 0U)
  2591. #endif /* GPIOI */
  2592. #define __HAL_RCC_SRAM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM2SMEN) == 0U)
  2593. #if defined(SRAM3)
  2594. #define __HAL_RCC_SRAM3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SRAM3SMEN) == 0U)
  2595. #endif /* SRAM3 */
  2596. #if defined(USB_OTG_FS)
  2597. #define __HAL_RCC_USB_OTG_FS_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OTGFSSMEN) == 0U)
  2598. #endif /* USB_OTG_FS */
  2599. #define __HAL_RCC_ADC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_ADCSMEN) == 0U)
  2600. #if defined(DCMI)
  2601. #define __HAL_RCC_DCMI_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_DCMISMEN) == 0U)
  2602. #endif /* DCMI */
  2603. #if defined(AES)
  2604. #define __HAL_RCC_AES_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_AESSMEN) == 0U)
  2605. #endif /* AES */
  2606. #if defined(HASH)
  2607. #define __HAL_RCC_HASH_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_HASHSMEN) == 0U)
  2608. #endif /* HASH */
  2609. #define __HAL_RCC_RNG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_RNGSMEN) == 0U)
  2610. #if defined(OCTOSPIM)
  2611. #define __HAL_RCC_OSPIM_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_OSPIMSMEN) == 0U)
  2612. #endif /* OCTOSPIM */
  2613. #if defined(SDMMC1) && defined(RCC_AHB2SMENR_SDMMC1SMEN)
  2614. #define __HAL_RCC_SDMMC1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB2SMENR, RCC_AHB2SMENR_SDMMC1SMEN) == 0U)
  2615. #endif /* SDMMC1 && RCC_AHB2SMENR_SDMMC1SMEN */
  2616. /**
  2617. * @}
  2618. */
  2619. /** @defgroup RCC_AHB3_Clock_Sleep_Enable_Disable_Status AHB3 Peripheral Clock Sleep Enabled or Disabled Status
  2620. * @brief Check whether the AHB3 peripheral clock during Low Power (Sleep) mode is enabled or not.
  2621. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2622. * power consumption.
  2623. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2624. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2625. * @{
  2626. */
  2627. #if defined(QUADSPI)
  2628. #define __HAL_RCC_QSPI_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN) != 0U)
  2629. #endif /* QUADSPI */
  2630. #if defined(OCTOSPI1)
  2631. #define __HAL_RCC_OSPI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI1SMEN) != 0U)
  2632. #endif /* OCTOSPI1 */
  2633. #if defined(OCTOSPI2)
  2634. #define __HAL_RCC_OSPI2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI2SMEN) != 0U)
  2635. #endif /* OCTOSPI2 */
  2636. #if defined(FMC_BANK1)
  2637. #define __HAL_RCC_FMC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN) != 0U)
  2638. #endif /* FMC_BANK1 */
  2639. #if defined(QUADSPI)
  2640. #define __HAL_RCC_QSPI_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_QSPISMEN) == 0U)
  2641. #endif /* QUADSPI */
  2642. #if defined(OCTOSPI1)
  2643. #define __HAL_RCC_OSPI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI1SMEN) == 0U)
  2644. #endif /* OCTOSPI1 */
  2645. #if defined(OCTOSPI2)
  2646. #define __HAL_RCC_OSPI2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_OSPI2SMEN) == 0U)
  2647. #endif /* OCTOSPI2 */
  2648. #if defined(FMC_BANK1)
  2649. #define __HAL_RCC_FMC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->AHB3SMENR, RCC_AHB3SMENR_FMCSMEN) == 0U)
  2650. #endif /* FMC_BANK1 */
  2651. /**
  2652. * @}
  2653. */
  2654. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable_Status APB1 Peripheral Clock Sleep Enabled or Disabled Status
  2655. * @brief Check whether the APB1 peripheral clock during Low Power (Sleep) mode is enabled or not.
  2656. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2657. * power consumption.
  2658. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2659. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2660. * @{
  2661. */
  2662. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN) != 0U)
  2663. #if defined(TIM3)
  2664. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN) != 0U)
  2665. #endif /* TIM3 */
  2666. #if defined(TIM4)
  2667. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN) != 0U)
  2668. #endif /* TIM4 */
  2669. #if defined(TIM5)
  2670. #define __HAL_RCC_TIM5_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN) != 0U)
  2671. #endif /* TIM5 */
  2672. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN) != 0U)
  2673. #if defined(TIM7)
  2674. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN) != 0U)
  2675. #endif /* TIM7 */
  2676. #if defined(LCD)
  2677. #define __HAL_RCC_LCD_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN) != 0U)
  2678. #endif /* LCD */
  2679. #if defined(RCC_APB1SMENR1_RTCAPBSMEN)
  2680. #define __HAL_RCC_RTCAPB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN) != 0U)
  2681. #endif /* RCC_APB1SMENR1_RTCAPBSMEN */
  2682. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN) != 0U)
  2683. #if defined(SPI2)
  2684. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN) != 0U)
  2685. #endif /* SPI2 */
  2686. #if defined(SPI3)
  2687. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN) != 0U)
  2688. #endif /* SPI3 */
  2689. #define __HAL_RCC_USART2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN) != 0U)
  2690. #if defined(USART3)
  2691. #define __HAL_RCC_USART3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN) != 0U)
  2692. #endif /* USART3 */
  2693. #if defined(UART4)
  2694. #define __HAL_RCC_UART4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN) != 0U)
  2695. #endif /* UART4 */
  2696. #if defined(UART5)
  2697. #define __HAL_RCC_UART5_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN) != 0U)
  2698. #endif /* UART5 */
  2699. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN) != 0U)
  2700. #if defined(I2C2)
  2701. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN) != 0U)
  2702. #endif /* I2C2 */
  2703. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN) != 0U)
  2704. #if defined(I2C4)
  2705. #define __HAL_RCC_I2C4_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN) != 0U)
  2706. #endif /* I2C4 */
  2707. #if defined(CRS)
  2708. #define __HAL_RCC_CRS_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN) != 0U)
  2709. #endif /* CRS */
  2710. #if defined(CAN1)
  2711. #define __HAL_RCC_CAN1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN) != 0U)
  2712. #endif /* CAN1 */
  2713. #if defined(CAN2)
  2714. #define __HAL_RCC_CAN2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN2SMEN) != 0U)
  2715. #endif /* CAN2 */
  2716. #if defined(USB)
  2717. #define __HAL_RCC_USB_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBFSSMEN) != 0U)
  2718. #endif /* USB */
  2719. #define __HAL_RCC_PWR_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN) != 0U)
  2720. #if defined(DAC1)
  2721. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN) != 0U)
  2722. #endif /* DAC1 */
  2723. #define __HAL_RCC_OPAMP_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN) != 0U)
  2724. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN) != 0U)
  2725. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN) != 0U)
  2726. #if defined(SWPMI1)
  2727. #define __HAL_RCC_SWPMI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN) != 0U)
  2728. #endif /* SWPMI1 */
  2729. #define __HAL_RCC_LPTIM2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN) != 0U)
  2730. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM2SMEN) == 0U)
  2731. #if defined(TIM3)
  2732. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM3SMEN) == 0U)
  2733. #endif /* TIM3 */
  2734. #if defined(TIM4)
  2735. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM4SMEN) == 0U)
  2736. #endif /* TIM4 */
  2737. #if defined(TIM5)
  2738. #define __HAL_RCC_TIM5_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM5SMEN) == 0U)
  2739. #endif /* TIM5 */
  2740. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM6SMEN) == 0U)
  2741. #if defined(TIM7)
  2742. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_TIM7SMEN) == 0U)
  2743. #endif /* TIM7 */
  2744. #if defined(LCD)
  2745. #define __HAL_RCC_LCD_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LCDSMEN) == 0U)
  2746. #endif /* LCD */
  2747. #if defined(RCC_APB1SMENR1_RTCAPBSMEN)
  2748. #define __HAL_RCC_RTCAPB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_RTCAPBSMEN) == 0U)
  2749. #endif /* RCC_APB1SMENR1_RTCAPBSMEN */
  2750. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_WWDGSMEN) == 0U)
  2751. #if defined(SPI2)
  2752. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI2SMEN) == 0U)
  2753. #endif /* SPI2 */
  2754. #if defined(SPI3)
  2755. #define __HAL_RCC_SPI3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_SPI3SMEN) == 0U)
  2756. #endif /* SPI3 */
  2757. #define __HAL_RCC_USART2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART2SMEN) == 0U)
  2758. #if defined(USART3)
  2759. #define __HAL_RCC_USART3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USART3SMEN) == 0U)
  2760. #endif /* USART3 */
  2761. #if defined(UART4)
  2762. #define __HAL_RCC_UART4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART4SMEN) == 0U)
  2763. #endif /* UART4 */
  2764. #if defined(UART5)
  2765. #define __HAL_RCC_UART5_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_UART5SMEN) == 0U)
  2766. #endif /* UART5 */
  2767. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C1SMEN) == 0U)
  2768. #if defined(I2C2)
  2769. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C2SMEN) == 0U)
  2770. #endif /* I2C2 */
  2771. #define __HAL_RCC_I2C3_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_I2C3SMEN) == 0U)
  2772. #if defined(I2C4)
  2773. #define __HAL_RCC_I2C4_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_I2C4SMEN) == 0U)
  2774. #endif /* I2C4 */
  2775. #if defined(CRS)
  2776. #define __HAL_RCC_CRS_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CRSSMEN) == 0U)
  2777. #endif /* CRS */
  2778. #if defined(CAN1)
  2779. #define __HAL_RCC_CAN1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN1SMEN) == 0U)
  2780. #endif /* CAN1 */
  2781. #if defined(CAN2)
  2782. #define __HAL_RCC_CAN2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_CAN2SMEN) == 0U)
  2783. #endif /* CAN2 */
  2784. #if defined(USB)
  2785. #define __HAL_RCC_USB_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_USBFSSMEN) == 0U)
  2786. #endif /* USB */
  2787. #define __HAL_RCC_PWR_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_PWRSMEN) == 0U)
  2788. #if defined(DAC1)
  2789. #define __HAL_RCC_DAC1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_DAC1SMEN) == 0U)
  2790. #endif /* DAC1 */
  2791. #define __HAL_RCC_OPAMP_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_OPAMPSMEN) == 0U)
  2792. #define __HAL_RCC_LPTIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR1, RCC_APB1SMENR1_LPTIM1SMEN) == 0U)
  2793. #define __HAL_RCC_LPUART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPUART1SMEN) == 0U)
  2794. #if defined(SWPMI1)
  2795. #define __HAL_RCC_SWPMI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_SWPMI1SMEN) == 0U)
  2796. #endif /* SWPMI1 */
  2797. #define __HAL_RCC_LPTIM2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB1SMENR2, RCC_APB1SMENR2_LPTIM2SMEN) == 0U)
  2798. /**
  2799. * @}
  2800. */
  2801. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable_Status APB2 Peripheral Clock Sleep Enabled or Disabled Status
  2802. * @brief Check whether the APB2 peripheral clock during Low Power (Sleep) mode is enabled or not.
  2803. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  2804. * power consumption.
  2805. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2806. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2807. * @{
  2808. */
  2809. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN) != 0U)
  2810. #if defined(SDMMC1) && defined(RCC_APB2SMENR_SDMMC1SMEN)
  2811. #define __HAL_RCC_SDMMC1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN) != 0U)
  2812. #endif /* SDMMC1 && RCC_APB2SMENR_SDMMC1SMEN */
  2813. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN) != 0U)
  2814. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN) != 0U)
  2815. #if defined(TIM8)
  2816. #define __HAL_RCC_TIM8_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN) != 0U)
  2817. #endif /* TIM8 */
  2818. #define __HAL_RCC_USART1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN) != 0U)
  2819. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN) != 0U)
  2820. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN) != 0U)
  2821. #if defined(TIM17)
  2822. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN) != 0U)
  2823. #endif /* TIM17 */
  2824. #if defined(SAI1)
  2825. #define __HAL_RCC_SAI1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN) != 0U)
  2826. #endif /* SAI1 */
  2827. #if defined(SAI2)
  2828. #define __HAL_RCC_SAI2_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN) != 0U)
  2829. #endif /* SAI2 */
  2830. #if defined(DFSDM1_Filter0)
  2831. #define __HAL_RCC_DFSDM1_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDM1SMEN) != 0U)
  2832. #endif /* DFSDM1_Filter0 */
  2833. #if defined(LTDC)
  2834. #define __HAL_RCC_LTDC_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_LTDCSMEN) != 0U)
  2835. #endif /* LTDC */
  2836. #if defined(DSI)
  2837. #define __HAL_RCC_DSI_IS_CLK_SLEEP_ENABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DSISMEN) != 0U)
  2838. #endif /* DSI */
  2839. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SYSCFGSMEN) == 0U)
  2840. #if defined(SDMMC1) && defined(RCC_APB2SMENR_SDMMC1SMEN)
  2841. #define __HAL_RCC_SDMMC1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SDMMC1SMEN) == 0U)
  2842. #endif /* SDMMC1 && RCC_APB2SMENR_SDMMC1SMEN */
  2843. #define __HAL_RCC_TIM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM1SMEN) == 0U)
  2844. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SPI1SMEN) == 0U)
  2845. #if defined(TIM8)
  2846. #define __HAL_RCC_TIM8_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM8SMEN) == 0U)
  2847. #endif /* TIM8 */
  2848. #define __HAL_RCC_USART1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_USART1SMEN) == 0U)
  2849. #define __HAL_RCC_TIM15_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM15SMEN) == 0U)
  2850. #define __HAL_RCC_TIM16_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM16SMEN) == 0U)
  2851. #if defined(TIM17)
  2852. #define __HAL_RCC_TIM17_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_TIM17SMEN) == 0U)
  2853. #endif /* TIM17 */
  2854. #if defined(SAI1)
  2855. #define __HAL_RCC_SAI1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI1SMEN) == 0U)
  2856. #endif /* SAI1 */
  2857. #if defined(SAI2)
  2858. #define __HAL_RCC_SAI2_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_SAI2SMEN) == 0U)
  2859. #endif /* SAI2 */
  2860. #if defined(DFSDM1_Filter0)
  2861. #define __HAL_RCC_DFSDM1_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DFSDM1SMEN) == 0U)
  2862. #endif /* DFSDM1_Filter0 */
  2863. #if defined(LTDC)
  2864. #define __HAL_RCC_LTDC_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_LTDCSMEN) == 0U)
  2865. #endif /* LTDC */
  2866. #if defined(DSI)
  2867. #define __HAL_RCC_DSI_IS_CLK_SLEEP_DISABLED() (READ_BIT(RCC->APB2SMENR, RCC_APB2SMENR_DSISMEN) == 0U)
  2868. #endif /* DSI */
  2869. /**
  2870. * @}
  2871. */
  2872. /** @defgroup RCC_Backup_Domain_Reset RCC Backup Domain Reset
  2873. * @{
  2874. */
  2875. /** @brief Macros to force or release the Backup domain reset.
  2876. * @note This function resets the RTC peripheral (including the backup registers)
  2877. * and the RTC clock source selection in RCC_CSR register.
  2878. * @note The BKPSRAM is not affected by this reset.
  2879. * @retval None
  2880. */
  2881. #define __HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  2882. #define __HAL_RCC_BACKUPRESET_RELEASE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST)
  2883. /**
  2884. * @}
  2885. */
  2886. /** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
  2887. * @{
  2888. */
  2889. /** @brief Macros to enable or disable the RTC clock.
  2890. * @note As the RTC is in the Backup domain and write access is denied to
  2891. * this domain after reset, you have to enable write access using
  2892. * HAL_PWR_EnableBkUpAccess() function before to configure the RTC
  2893. * (to be done once after reset).
  2894. * @note These macros must be used after the RTC clock source was selected.
  2895. * @retval None
  2896. */
  2897. #define __HAL_RCC_RTC_ENABLE() SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  2898. #define __HAL_RCC_RTC_DISABLE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  2899. /**
  2900. * @}
  2901. */
  2902. /** @brief Macros to enable or disable the Internal High Speed 16MHz oscillator (HSI).
  2903. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  2904. * It is used (enabled by hardware) as system clock source after startup
  2905. * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
  2906. * of the HSE used directly or indirectly as system clock (if the Clock
  2907. * Security System CSS is enabled).
  2908. * @note HSI can not be stopped if it is used as system clock source. In this case,
  2909. * you have to select another source of the system clock then stop the HSI.
  2910. * @note After enabling the HSI, the application software should wait on HSIRDY
  2911. * flag to be set indicating that HSI clock is stable and can be used as
  2912. * system clock source.
  2913. * This parameter can be: ENABLE or DISABLE.
  2914. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  2915. * clock cycles.
  2916. * @retval None
  2917. */
  2918. #define __HAL_RCC_HSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSION)
  2919. #define __HAL_RCC_HSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSION)
  2920. /** @brief Macro to adjust the Internal High Speed 16MHz oscillator (HSI) calibration value.
  2921. * @note The calibration is used to compensate for the variations in voltage
  2922. * and temperature that influence the frequency of the internal HSI RC.
  2923. * @param __HSICALIBRATIONVALUE__ specifies the calibration trimming value
  2924. * (default is RCC_HSICALIBRATION_DEFAULT).
  2925. * This parameter must be a number between 0 and 0x1F (STM32L43x/STM32L44x/STM32L47x/STM32L48x) or 0x7F (for other devices).
  2926. * @retval None
  2927. */
  2928. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICALIBRATIONVALUE__) \
  2929. MODIFY_REG(RCC->ICSCR, RCC_ICSCR_HSITRIM, (__HSICALIBRATIONVALUE__) << RCC_ICSCR_HSITRIM_Pos)
  2930. /**
  2931. * @brief Macros to enable or disable the wakeup the Internal High Speed oscillator (HSI)
  2932. * in parallel to the Internal Multi Speed oscillator (MSI) used at system wakeup.
  2933. * @note The enable of this function has not effect on the HSION bit.
  2934. * This parameter can be: ENABLE or DISABLE.
  2935. * @retval None
  2936. */
  2937. #define __HAL_RCC_HSIAUTOMATIC_START_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIASFS)
  2938. #define __HAL_RCC_HSIAUTOMATIC_START_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIASFS)
  2939. /**
  2940. * @brief Macros to enable or disable the force of the Internal High Speed oscillator (HSI)
  2941. * in STOP mode to be quickly available as kernel clock for USARTs and I2Cs.
  2942. * @note Keeping the HSI ON in STOP mode allows to avoid slowing down the communication
  2943. * speed because of the HSI startup time.
  2944. * @note The enable of this function has not effect on the HSION bit.
  2945. * This parameter can be: ENABLE or DISABLE.
  2946. * @retval None
  2947. */
  2948. #define __HAL_RCC_HSISTOP_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIKERON)
  2949. #define __HAL_RCC_HSISTOP_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIKERON)
  2950. /**
  2951. * @brief Macros to enable or disable the Internal Multi Speed oscillator (MSI).
  2952. * @note The MSI is stopped by hardware when entering STOP and STANDBY modes.
  2953. * It is used (enabled by hardware) as system clock source after
  2954. * startup from Reset, wakeup from STOP and STANDBY mode, or in case
  2955. * of failure of the HSE used directly or indirectly as system clock
  2956. * (if the Clock Security System CSS is enabled).
  2957. * @note MSI can not be stopped if it is used as system clock source.
  2958. * In this case, you have to select another source of the system
  2959. * clock then stop the MSI.
  2960. * @note After enabling the MSI, the application software should wait on
  2961. * MSIRDY flag to be set indicating that MSI clock is stable and can
  2962. * be used as system clock source.
  2963. * @note When the MSI is stopped, MSIRDY flag goes low after 6 MSI oscillator
  2964. * clock cycles.
  2965. * @retval None
  2966. */
  2967. #define __HAL_RCC_MSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_MSION)
  2968. #define __HAL_RCC_MSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_MSION)
  2969. /** @brief Macro Adjusts the Internal Multi Speed oscillator (MSI) calibration value.
  2970. * @note The calibration is used to compensate for the variations in voltage
  2971. * and temperature that influence the frequency of the internal MSI RC.
  2972. * Refer to the Application Note AN3300 for more details on how to
  2973. * calibrate the MSI.
  2974. * @param __MSICALIBRATIONVALUE__ specifies the calibration trimming value
  2975. * (default is RCC_MSICALIBRATION_DEFAULT).
  2976. * This parameter must be a number between 0 and 255.
  2977. * @retval None
  2978. */
  2979. #define __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(__MSICALIBRATIONVALUE__) \
  2980. MODIFY_REG(RCC->ICSCR, RCC_ICSCR_MSITRIM, (__MSICALIBRATIONVALUE__) << RCC_ICSCR_MSITRIM_Pos)
  2981. /**
  2982. * @brief Macro configures the Internal Multi Speed oscillator (MSI) clock range in run mode
  2983. * @note After restart from Reset , the MSI clock is around 4 MHz.
  2984. * After stop the startup clock can be MSI (at any of its possible
  2985. * frequencies, the one that was used before entering stop mode) or HSI.
  2986. * After Standby its frequency can be selected between 4 possible values
  2987. * (1, 2, 4 or 8 MHz).
  2988. * @note MSIRANGE can be modified when MSI is OFF (MSION=0) or when MSI is ready
  2989. * (MSIRDY=1).
  2990. * @note The MSI clock range after reset can be modified on the fly.
  2991. * @param __MSIRANGEVALUE__ specifies the MSI clock range.
  2992. * This parameter must be one of the following values:
  2993. * @arg @ref RCC_MSIRANGE_0 MSI clock is around 100 KHz
  2994. * @arg @ref RCC_MSIRANGE_1 MSI clock is around 200 KHz
  2995. * @arg @ref RCC_MSIRANGE_2 MSI clock is around 400 KHz
  2996. * @arg @ref RCC_MSIRANGE_3 MSI clock is around 800 KHz
  2997. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1 MHz
  2998. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2 MHz
  2999. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4 MHz (default after Reset)
  3000. * @arg @ref RCC_MSIRANGE_7 MSI clock is around 8 MHz
  3001. * @arg @ref RCC_MSIRANGE_8 MSI clock is around 16 MHz
  3002. * @arg @ref RCC_MSIRANGE_9 MSI clock is around 24 MHz
  3003. * @arg @ref RCC_MSIRANGE_10 MSI clock is around 32 MHz
  3004. * @arg @ref RCC_MSIRANGE_11 MSI clock is around 48 MHz
  3005. * @retval None
  3006. */
  3007. #define __HAL_RCC_MSI_RANGE_CONFIG(__MSIRANGEVALUE__) \
  3008. do { \
  3009. SET_BIT(RCC->CR, RCC_CR_MSIRGSEL); \
  3010. MODIFY_REG(RCC->CR, RCC_CR_MSIRANGE, (__MSIRANGEVALUE__)); \
  3011. } while(0)
  3012. /**
  3013. * @brief Macro configures the Internal Multi Speed oscillator (MSI) clock range after Standby mode
  3014. * After Standby its frequency can be selected between 4 possible values (1, 2, 4 or 8 MHz).
  3015. * @param __MSIRANGEVALUE__ specifies the MSI clock range.
  3016. * This parameter must be one of the following values:
  3017. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1 MHz
  3018. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2 MHz
  3019. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4 MHz (default after Reset)
  3020. * @arg @ref RCC_MSIRANGE_7 MSI clock is around 8 MHz
  3021. * @retval None
  3022. */
  3023. #define __HAL_RCC_MSI_STANDBY_RANGE_CONFIG(__MSIRANGEVALUE__) \
  3024. MODIFY_REG(RCC->CSR, RCC_CSR_MSISRANGE, (__MSIRANGEVALUE__) << 4U)
  3025. /** @brief Macro to get the Internal Multi Speed oscillator (MSI) clock range in run mode
  3026. * @retval MSI clock range.
  3027. * This parameter must be one of the following values:
  3028. * @arg @ref RCC_MSIRANGE_0 MSI clock is around 100 KHz
  3029. * @arg @ref RCC_MSIRANGE_1 MSI clock is around 200 KHz
  3030. * @arg @ref RCC_MSIRANGE_2 MSI clock is around 400 KHz
  3031. * @arg @ref RCC_MSIRANGE_3 MSI clock is around 800 KHz
  3032. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1 MHz
  3033. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2 MHz
  3034. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4 MHz (default after Reset)
  3035. * @arg @ref RCC_MSIRANGE_7 MSI clock is around 8 MHz
  3036. * @arg @ref RCC_MSIRANGE_8 MSI clock is around 16 MHz
  3037. * @arg @ref RCC_MSIRANGE_9 MSI clock is around 24 MHz
  3038. * @arg @ref RCC_MSIRANGE_10 MSI clock is around 32 MHz
  3039. * @arg @ref RCC_MSIRANGE_11 MSI clock is around 48 MHz
  3040. */
  3041. #define __HAL_RCC_GET_MSI_RANGE() \
  3042. ((READ_BIT(RCC->CR, RCC_CR_MSIRGSEL) != 0U) ? \
  3043. READ_BIT(RCC->CR, RCC_CR_MSIRANGE) : \
  3044. (READ_BIT(RCC->CSR, RCC_CSR_MSISRANGE) >> 4U))
  3045. /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
  3046. * @note After enabling the LSI, the application software should wait on
  3047. * LSIRDY flag to be set indicating that LSI clock is stable and can
  3048. * be used to clock the IWDG and/or the RTC.
  3049. * @note LSI can not be disabled if the IWDG is running.
  3050. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  3051. * clock cycles.
  3052. * @retval None
  3053. */
  3054. #define __HAL_RCC_LSI_ENABLE() SET_BIT(RCC->CSR, RCC_CSR_LSION)
  3055. #define __HAL_RCC_LSI_DISABLE() CLEAR_BIT(RCC->CSR, RCC_CSR_LSION)
  3056. /**
  3057. * @brief Macro to configure the External High Speed oscillator (HSE).
  3058. * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
  3059. * supported by this macro. User should request a transition to HSE Off
  3060. * first and then HSE On or HSE Bypass.
  3061. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  3062. * software should wait on HSERDY flag to be set indicating that HSE clock
  3063. * is stable and can be used to clock the PLL and/or system clock.
  3064. * @note HSE state can not be changed if it is used directly or through the
  3065. * PLL as system clock. In this case, you have to select another source
  3066. * of the system clock then change the HSE state (ex. disable it).
  3067. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  3068. * @note This function reset the CSSON bit, so if the clock security system(CSS)
  3069. * was previously enabled you have to enable it again after calling this
  3070. * function.
  3071. * @param __STATE__ specifies the new state of the HSE.
  3072. * This parameter can be one of the following values:
  3073. * @arg @ref RCC_HSE_OFF Turn OFF the HSE oscillator, HSERDY flag goes low after
  3074. * 6 HSE oscillator clock cycles.
  3075. * @arg @ref RCC_HSE_ON Turn ON the HSE oscillator.
  3076. * @arg @ref RCC_HSE_BYPASS HSE oscillator bypassed with external clock.
  3077. * @retval None
  3078. */
  3079. #define __HAL_RCC_HSE_CONFIG(__STATE__) \
  3080. do { \
  3081. if((__STATE__) == RCC_HSE_ON) \
  3082. { \
  3083. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  3084. } \
  3085. else if((__STATE__) == RCC_HSE_BYPASS) \
  3086. { \
  3087. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  3088. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  3089. } \
  3090. else \
  3091. { \
  3092. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  3093. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  3094. } \
  3095. } while(0)
  3096. /**
  3097. * @brief Macro to configure the External Low Speed oscillator (LSE).
  3098. * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
  3099. * supported by this macro. User should request a transition to LSE Off
  3100. * first and then LSE On or LSE Bypass.
  3101. * @note As the LSE is in the Backup domain and write access is denied to
  3102. * this domain after reset, you have to enable write access using
  3103. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  3104. * (to be done once after reset).
  3105. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  3106. * software should wait on LSERDY flag to be set indicating that LSE clock
  3107. * is stable and can be used to clock the RTC.
  3108. * @param __STATE__ specifies the new state of the LSE.
  3109. * This parameter can be one of the following values:
  3110. * @arg @ref RCC_LSE_OFF Turn OFF the LSE oscillator, LSERDY flag goes low after
  3111. * 6 LSE oscillator clock cycles.
  3112. * @arg @ref RCC_LSE_ON Turn ON the LSE oscillator.
  3113. * @arg @ref RCC_LSE_BYPASS LSE oscillator bypassed with external clock.
  3114. * @retval None
  3115. */
  3116. #define __HAL_RCC_LSE_CONFIG(__STATE__) \
  3117. do { \
  3118. if((__STATE__) == RCC_LSE_ON) \
  3119. { \
  3120. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3121. } \
  3122. else if((__STATE__) == RCC_LSE_BYPASS) \
  3123. { \
  3124. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  3125. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3126. } \
  3127. else \
  3128. { \
  3129. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3130. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  3131. } \
  3132. } while(0)
  3133. #if defined(RCC_HSI48_SUPPORT)
  3134. /** @brief Macros to enable or disable the Internal High Speed 48MHz oscillator (HSI48).
  3135. * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes.
  3136. * @note After enabling the HSI48, the application software should wait on HSI48RDY
  3137. * flag to be set indicating that HSI48 clock is stable.
  3138. * This parameter can be: ENABLE or DISABLE.
  3139. * @retval None
  3140. */
  3141. #define __HAL_RCC_HSI48_ENABLE() SET_BIT(RCC->CRRCR, RCC_CRRCR_HSI48ON)
  3142. #define __HAL_RCC_HSI48_DISABLE() CLEAR_BIT(RCC->CRRCR, RCC_CRRCR_HSI48ON)
  3143. #endif /* RCC_HSI48_SUPPORT */
  3144. /** @brief Macros to configure the RTC clock (RTCCLK).
  3145. * @note As the RTC clock configuration bits are in the Backup domain and write
  3146. * access is denied to this domain after reset, you have to enable write
  3147. * access using the Power Backup Access macro before to configure
  3148. * the RTC clock source (to be done once after reset).
  3149. * @note Once the RTC clock is configured it cannot be changed unless the
  3150. * Backup domain is reset using __HAL_RCC_BACKUPRESET_FORCE() macro, or by
  3151. * a Power On Reset (POR).
  3152. *
  3153. * @param __RTC_CLKSOURCE__ specifies the RTC clock source.
  3154. * This parameter can be one of the following values:
  3155. * @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
  3156. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  3157. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  3158. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  3159. *
  3160. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  3161. * work in STOP and STANDBY modes, and can be used as wakeup source.
  3162. * However, when the HSE clock is used as RTC clock source, the RTC
  3163. * cannot be used in STOP and STANDBY modes.
  3164. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  3165. * RTC clock source).
  3166. * @retval None
  3167. */
  3168. #define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) \
  3169. MODIFY_REG( RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
  3170. /** @brief Macro to get the RTC clock source.
  3171. * @retval The returned value can be one of the following:
  3172. * @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
  3173. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  3174. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  3175. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
  3176. */
  3177. #define __HAL_RCC_GET_RTC_SOURCE() (READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL))
  3178. /** @brief Macros to enable or disable the main PLL.
  3179. * @note After enabling the main PLL, the application software should wait on
  3180. * PLLRDY flag to be set indicating that PLL clock is stable and can
  3181. * be used as system clock source.
  3182. * @note The main PLL can not be disabled if it is used as system clock source
  3183. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  3184. * @retval None
  3185. */
  3186. #define __HAL_RCC_PLL_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLON)
  3187. #define __HAL_RCC_PLL_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLON)
  3188. /** @brief Macro to configure the PLL clock source.
  3189. * @note This function must be used only when the main PLL is disabled.
  3190. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  3191. * This parameter can be one of the following values:
  3192. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  3193. * @arg @ref RCC_PLLSOURCE_MSI MSI oscillator clock selected as PLL clock entry
  3194. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  3195. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  3196. * @note This clock source is common for the main PLL and audio PLL (PLLSAI1 and PLLSAI2).
  3197. * @retval None
  3198. *
  3199. */
  3200. #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) \
  3201. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
  3202. /** @brief Macro to configure the PLL source division factor M.
  3203. * @note This function must be used only when the main PLL is disabled.
  3204. * @param __PLLM__ specifies the division factor for PLL VCO input clock
  3205. * This parameter must be a number between Min_Data = 1 and Max_Data = 16 on STM32L4Rx/STM32L4Sx devices.
  3206. * This parameter must be a number between Min_Data = 1 and Max_Data = 8 on other devices.
  3207. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  3208. * frequency ranges from 4 to 16 MHz. It is recommended to select a frequency
  3209. * of 16 MHz to limit PLL jitter.
  3210. * @retval None
  3211. *
  3212. */
  3213. #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) \
  3214. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, ((__PLLM__) - 1) << 4U)
  3215. /**
  3216. * @brief Macro to configure the main PLL clock source, multiplication and division factors.
  3217. * @note This function must be used only when the main PLL is disabled.
  3218. *
  3219. * @param __PLLSOURCE__ specifies the PLL entry clock source.
  3220. * This parameter can be one of the following values:
  3221. * @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
  3222. * @arg @ref RCC_PLLSOURCE_MSI MSI oscillator clock selected as PLL clock entry
  3223. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  3224. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  3225. * @note This clock source is common for the main PLL and audio PLL (PLLSAI1 and PLLSAI2).
  3226. *
  3227. * @param __PLLM__ specifies the division factor for PLL VCO input clock.
  3228. * This parameter must be a number between Min_Data = 1 and Max_Data = 16 on STM32L4Rx/STM32L4Sx devices.
  3229. * This parameter must be a number between Min_Data = 1 and Max_Data = 8 on other devices.
  3230. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  3231. * frequency ranges from 4 to 16 MHz. It is recommended to select a frequency
  3232. * of 16 MHz to limit PLL jitter.
  3233. *
  3234. * @param __PLLN__ specifies the multiplication factor for PLL VCO output clock.
  3235. * This parameter must be a number between 8 and 86.
  3236. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  3237. * output frequency is between 64 and 344 MHz.
  3238. *
  3239. * @param __PLLP__ specifies the division factor for SAI clock when SAI available on device.
  3240. * This parameter must be a number in the range (7 or 17) for STM32L47x/STM32L48x
  3241. * else (2 to 31).
  3242. *
  3243. * @param __PLLQ__ specifies the division factor for OTG FS, SDMMC1 and RNG clocks.
  3244. * This parameter must be in the range (2, 4, 6 or 8).
  3245. * @note If the USB OTG FS is used in your application, you have to set the
  3246. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  3247. * the SDMMC1 and RNG need a frequency lower than or equal to 48 MHz to work
  3248. * correctly.
  3249. * @param __PLLR__ specifies the division factor for the main system clock.
  3250. * @note You have to set the PLLR parameter correctly to not exceed 80MHZ.
  3251. * This parameter must be in the range (2, 4, 6 or 8).
  3252. * @retval None
  3253. */
  3254. #if defined(RCC_PLLP_DIV_2_31_SUPPORT)
  3255. #define __HAL_RCC_PLL_CONFIG(__PLLSOURCE__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__,__PLLR__ ) \
  3256. MODIFY_REG(RCC->PLLCFGR, \
  3257. (RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | \
  3258. RCC_PLLCFGR_PLLQ | RCC_PLLCFGR_PLLR | RCC_PLLCFGR_PLLP | RCC_PLLCFGR_PLLPDIV), \
  3259. ((__PLLSOURCE__) | \
  3260. (((__PLLM__) - 1U) << RCC_PLLCFGR_PLLM_Pos) | \
  3261. ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  3262. ((((__PLLQ__) >> 1U) - 1U) << RCC_PLLCFGR_PLLQ_Pos) | \
  3263. ((((__PLLR__) >> 1U) - 1U) << RCC_PLLCFGR_PLLR_Pos) | \
  3264. ((uint32_t)(__PLLP__) << RCC_PLLCFGR_PLLPDIV_Pos)))
  3265. #elif defined(RCC_PLLP_SUPPORT)
  3266. #define __HAL_RCC_PLL_CONFIG(__PLLSOURCE__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__,__PLLR__ ) \
  3267. MODIFY_REG(RCC->PLLCFGR, \
  3268. (RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | \
  3269. RCC_PLLCFGR_PLLQ | RCC_PLLCFGR_PLLR | RCC_PLLCFGR_PLLP), \
  3270. ((__PLLSOURCE__) | \
  3271. (((__PLLM__) - 1U) << RCC_PLLCFGR_PLLM_Pos) | \
  3272. ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  3273. ((((__PLLQ__) >> 1U) - 1U) << RCC_PLLCFGR_PLLQ_Pos) | \
  3274. ((((__PLLR__) >> 1U) - 1U) << RCC_PLLCFGR_PLLR_Pos) | \
  3275. (((__PLLP__) >> 4U) << RCC_PLLCFGR_PLLP_Pos)))
  3276. #else
  3277. #define __HAL_RCC_PLL_CONFIG(__PLLSOURCE__, __PLLM__, __PLLN__, __PLLQ__,__PLLR__ ) \
  3278. MODIFY_REG(RCC->PLLCFGR, \
  3279. (RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | \
  3280. RCC_PLLCFGR_PLLQ | RCC_PLLCFGR_PLLR), \
  3281. ((__PLLSOURCE__) | \
  3282. (((__PLLM__) - 1U) << RCC_PLLCFGR_PLLM_Pos) | \
  3283. ((__PLLN__) << RCC_PLLCFGR_PLLN_Pos) | \
  3284. ((((__PLLQ__) >> 1U) - 1U) << RCC_PLLCFGR_PLLQ_Pos) | \
  3285. ((((__PLLR__) >> 1U) - 1U) << RCC_PLLCFGR_PLLR_Pos)))
  3286. #endif /* RCC_PLLP_DIV_2_31_SUPPORT */
  3287. /** @brief Macro to get the oscillator used as PLL clock source.
  3288. * @retval The oscillator used as PLL clock source. The returned value can be one
  3289. * of the following:
  3290. * - RCC_PLLSOURCE_NONE: No oscillator is used as PLL clock source.
  3291. * - RCC_PLLSOURCE_MSI: MSI oscillator is used as PLL clock source.
  3292. * - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source.
  3293. * - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source.
  3294. */
  3295. #define __HAL_RCC_GET_PLL_OSCSOURCE() (READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC))
  3296. /**
  3297. * @brief Enable or disable each clock output (RCC_PLL_SYSCLK, RCC_PLL_48M1CLK, RCC_PLL_SAI3CLK)
  3298. * @note Enabling/disabling clock outputs RCC_PLL_SAI3CLK and RCC_PLL_48M1CLK can be done at anytime
  3299. * without the need to stop the PLL in order to save power. But RCC_PLL_SYSCLK cannot
  3300. * be stopped if used as System Clock.
  3301. * @param __PLLCLOCKOUT__ specifies the PLL clock to be output.
  3302. * This parameter can be one or a combination of the following values:
  3303. * @arg @ref RCC_PLL_SAI3CLK This clock is used to generate an accurate clock to achieve
  3304. * high-quality audio performance on SAI interface in case.
  3305. * @arg @ref RCC_PLL_48M1CLK This Clock is used to generate the clock for the USB OTG FS (48 MHz),
  3306. * the random analog generator (<=48 MHz) and the SDMMC1 (<= 48 MHz).
  3307. * @arg @ref RCC_PLL_SYSCLK This Clock is used to generate the high speed system clock (up to 80MHz)
  3308. * @retval None
  3309. */
  3310. #define __HAL_RCC_PLLCLKOUT_ENABLE(__PLLCLOCKOUT__) SET_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  3311. #define __HAL_RCC_PLLCLKOUT_DISABLE(__PLLCLOCKOUT__) CLEAR_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  3312. /**
  3313. * @brief Get clock output enable status (RCC_PLL_SYSCLK, RCC_PLL_48M1CLK, RCC_PLL_SAI3CLK)
  3314. * @param __PLLCLOCKOUT__ specifies the output PLL clock to be checked.
  3315. * This parameter can be one of the following values:
  3316. * @arg @ref RCC_PLL_SAI3CLK This clock is used to generate an accurate clock to achieve
  3317. * high-quality audio performance on SAI interface in case.
  3318. * @arg @ref RCC_PLL_48M1CLK This Clock is used to generate the clock for the USB OTG FS (48 MHz),
  3319. * the random analog generator (<=48 MHz) and the SDMMC1 (<= 48 MHz).
  3320. * @arg @ref RCC_PLL_SYSCLK This Clock is used to generate the high speed system clock (up to 80MHz)
  3321. * @retval SET / RESET
  3322. */
  3323. #define __HAL_RCC_GET_PLLCLKOUT_CONFIG(__PLLCLOCKOUT__) READ_BIT(RCC->PLLCFGR, (__PLLCLOCKOUT__))
  3324. /**
  3325. * @brief Macro to configure the system clock source.
  3326. * @param __SYSCLKSOURCE__ specifies the system clock source.
  3327. * This parameter can be one of the following values:
  3328. * - RCC_SYSCLKSOURCE_MSI: MSI oscillator is used as system clock source.
  3329. * - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
  3330. * - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
  3331. * - RCC_SYSCLKSOURCE_PLLCLK: PLL output is used as system clock source.
  3332. * @retval None
  3333. */
  3334. #define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
  3335. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__SYSCLKSOURCE__))
  3336. /** @brief Macro to get the clock source used as system clock.
  3337. * @retval The clock source used as system clock. The returned value can be one
  3338. * of the following:
  3339. * - RCC_SYSCLKSOURCE_STATUS_MSI: MSI used as system clock.
  3340. * - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
  3341. * - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
  3342. * - RCC_SYSCLKSOURCE_STATUS_PLLCLK: PLL used as system clock.
  3343. */
  3344. #define __HAL_RCC_GET_SYSCLK_SOURCE() (READ_BIT(RCC->CFGR, RCC_CFGR_SWS))
  3345. /**
  3346. * @brief Macro to configure the External Low Speed oscillator (LSE) drive capability.
  3347. * @note As the LSE is in the Backup domain and write access is denied to
  3348. * this domain after reset, you have to enable write access using
  3349. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  3350. * (to be done once after reset).
  3351. * @param __LSEDRIVE__ specifies the new state of the LSE drive capability.
  3352. * This parameter can be one of the following values:
  3353. * @arg @ref RCC_LSEDRIVE_LOW LSE oscillator low drive capability.
  3354. * @arg @ref RCC_LSEDRIVE_MEDIUMLOW LSE oscillator medium low drive capability.
  3355. * @arg @ref RCC_LSEDRIVE_MEDIUMHIGH LSE oscillator medium high drive capability.
  3356. * @arg @ref RCC_LSEDRIVE_HIGH LSE oscillator high drive capability.
  3357. * @retval None
  3358. */
  3359. #define __HAL_RCC_LSEDRIVE_CONFIG(__LSEDRIVE__) \
  3360. MODIFY_REG(RCC->BDCR, RCC_BDCR_LSEDRV, (__LSEDRIVE__))
  3361. /**
  3362. * @brief Macro to configure the wake up from stop clock.
  3363. * @param __STOPWUCLK__ specifies the clock source used after wake up from stop.
  3364. * This parameter can be one of the following values:
  3365. * @arg @ref RCC_STOP_WAKEUPCLOCK_MSI MSI selected as system clock source
  3366. * @arg @ref RCC_STOP_WAKEUPCLOCK_HSI HSI selected as system clock source
  3367. * @retval None
  3368. */
  3369. #define __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(__STOPWUCLK__) \
  3370. MODIFY_REG(RCC->CFGR, RCC_CFGR_STOPWUCK, (__STOPWUCLK__))
  3371. /** @brief Macro to configure the MCO clock.
  3372. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  3373. * This parameter can be one of the following values:
  3374. * @arg @ref RCC_MCO1SOURCE_NOCLOCK MCO output disabled
  3375. * @arg @ref RCC_MCO1SOURCE_SYSCLK System clock selected as MCO source
  3376. * @arg @ref RCC_MCO1SOURCE_MSI MSI clock selected as MCO source
  3377. * @arg @ref RCC_MCO1SOURCE_HSI HSI clock selected as MCO source
  3378. * @arg @ref RCC_MCO1SOURCE_HSE HSE clock selected as MCO sourcee
  3379. * @arg @ref RCC_MCO1SOURCE_PLLCLK Main PLL clock selected as MCO source
  3380. * @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO source
  3381. * @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO source
  3382. @if STM32L443xx
  3383. * @arg @ref RCC_MCO1SOURCE_HSI48 HSI48 clock selected as MCO source for devices with HSI48
  3384. @endif
  3385. @if STM32L4A6xx
  3386. * @arg @ref RCC_MCO1SOURCE_HSI48 HSI48 clock selected as MCO source for devices with HSI48
  3387. @endif
  3388. * @param __MCODIV__ specifies the MCO clock prescaler.
  3389. * This parameter can be one of the following values:
  3390. * @arg @ref RCC_MCODIV_1 MCO clock source is divided by 1
  3391. * @arg @ref RCC_MCODIV_2 MCO clock source is divided by 2
  3392. * @arg @ref RCC_MCODIV_4 MCO clock source is divided by 4
  3393. * @arg @ref RCC_MCODIV_8 MCO clock source is divided by 8
  3394. * @arg @ref RCC_MCODIV_16 MCO clock source is divided by 16
  3395. */
  3396. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  3397. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  3398. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  3399. * @brief macros to manage the specified RCC Flags and interrupts.
  3400. * @{
  3401. */
  3402. /** @brief Enable RCC interrupt(s).
  3403. * @param __INTERRUPT__ specifies the RCC interrupt source(s) to be enabled.
  3404. * This parameter can be any combination of the following values:
  3405. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3406. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3407. * @arg @ref RCC_IT_MSIRDY HSI ready interrupt
  3408. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3409. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3410. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  3411. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt for devices with PLLSAI1
  3412. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt for devices with PLLSAI2
  3413. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  3414. @if STM32L443xx
  3415. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3416. @endif
  3417. @if STM32L4A6xx
  3418. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3419. @endif
  3420. * @retval None
  3421. */
  3422. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) SET_BIT(RCC->CIER, (__INTERRUPT__))
  3423. /** @brief Disable RCC interrupt(s).
  3424. * @param __INTERRUPT__ specifies the RCC interrupt source(s) to be disabled.
  3425. * This parameter can be any combination of the following values:
  3426. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3427. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3428. * @arg @ref RCC_IT_MSIRDY HSI ready interrupt
  3429. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3430. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3431. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  3432. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt for devices with PLLSAI1
  3433. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt for devices with PLLSAI2
  3434. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  3435. @if STM32L443xx
  3436. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3437. @endif
  3438. @if STM32L4A6xx
  3439. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3440. @endif
  3441. * @retval None
  3442. */
  3443. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(RCC->CIER, (__INTERRUPT__))
  3444. /** @brief Clear the RCC's interrupt pending bits.
  3445. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  3446. * This parameter can be any combination of the following values:
  3447. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3448. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3449. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  3450. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3451. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3452. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  3453. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt for devices with PLLSAI1
  3454. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt for devices with PLLSAI2
  3455. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  3456. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  3457. @if STM32L443xx
  3458. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3459. @endif
  3460. @if STM32L4A6xx
  3461. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3462. @endif
  3463. * @retval None
  3464. */
  3465. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) WRITE_REG(RCC->CICR, (__INTERRUPT__))
  3466. /** @brief Check whether the RCC interrupt has occurred or not.
  3467. * @param __INTERRUPT__ specifies the RCC interrupt source to check.
  3468. * This parameter can be one of the following values:
  3469. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3470. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3471. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  3472. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3473. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3474. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
  3475. * @arg @ref RCC_IT_PLLSAI1RDY PLLSAI1 ready interrupt for devices with PLLSAI1
  3476. * @arg @ref RCC_IT_PLLSAI2RDY PLLSAI2 ready interrupt for devices with PLLSAI2
  3477. * @arg @ref RCC_IT_CSS HSE Clock security system interrupt
  3478. * @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
  3479. @if STM32L443xx
  3480. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3481. @endif
  3482. @if STM32L4A6xx
  3483. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt for devices with HSI48
  3484. @endif
  3485. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  3486. */
  3487. #define __HAL_RCC_GET_IT(__INTERRUPT__) (READ_BIT(RCC->CIFR, (__INTERRUPT__)) == (__INTERRUPT__))
  3488. /** @brief Set RMVF bit to clear the reset flags.
  3489. * The reset flags are: RCC_FLAG_FWRRST, RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_BORRST,
  3490. * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
  3491. * @retval None
  3492. */
  3493. #define __HAL_RCC_CLEAR_RESET_FLAGS() SET_BIT(RCC->CSR, RCC_CSR_RMVF)
  3494. /** @brief Check whether the selected RCC flag is set or not.
  3495. * @param __FLAG__ specifies the flag to check.
  3496. * This parameter can be one of the following values:
  3497. * @arg @ref RCC_FLAG_MSIRDY MSI oscillator clock ready
  3498. * @arg @ref RCC_FLAG_HSIRDY HSI oscillator clock ready
  3499. * @arg @ref RCC_FLAG_HSERDY HSE oscillator clock ready
  3500. * @arg @ref RCC_FLAG_PLLRDY Main PLL clock ready
  3501. * @arg @ref RCC_FLAG_PLLSAI1RDY PLLSAI1 clock ready for devices with PLLSAI1
  3502. * @arg @ref RCC_FLAG_PLLSAI2RDY PLLSAI2 clock ready for devices with PLLSAI2
  3503. @if STM32L443xx
  3504. * @arg @ref RCC_FLAG_HSI48RDY HSI48 clock ready for devices with HSI48
  3505. @endif
  3506. @if STM32L4A6xx
  3507. * @arg @ref RCC_FLAG_HSI48RDY HSI48 clock ready for devices with HSI48
  3508. @endif
  3509. * @arg @ref RCC_FLAG_LSERDY LSE oscillator clock ready
  3510. * @arg @ref RCC_FLAG_LSECSSD Clock security system failure on LSE oscillator detection
  3511. * @arg @ref RCC_FLAG_LSIRDY LSI oscillator clock ready
  3512. * @arg @ref RCC_FLAG_BORRST BOR reset
  3513. * @arg @ref RCC_FLAG_OBLRST OBLRST reset
  3514. * @arg @ref RCC_FLAG_PINRST Pin reset
  3515. * @arg @ref RCC_FLAG_FWRST FIREWALL reset
  3516. * @arg @ref RCC_FLAG_SFTRST Software reset
  3517. * @arg @ref RCC_FLAG_IWDGRST Independent Watchdog reset
  3518. * @arg @ref RCC_FLAG_WWDGRST Window Watchdog reset
  3519. * @arg @ref RCC_FLAG_LPWRRST Low Power reset
  3520. * @retval The new state of __FLAG__ (TRUE or FALSE).
  3521. */
  3522. #if defined(RCC_HSI48_SUPPORT)
  3523. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U) ? RCC->CR : \
  3524. ((((__FLAG__) >> 5U) == 4U) ? RCC->CRRCR : \
  3525. ((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR : \
  3526. ((((__FLAG__) >> 5U) == 3U) ? RCC->CSR : RCC->CIFR)))) & \
  3527. (1U << ((__FLAG__) & RCC_FLAG_MASK))) != 0U) ? 1U : 0U)
  3528. #else
  3529. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U) ? RCC->CR : \
  3530. ((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR : \
  3531. ((((__FLAG__) >> 5U) == 3U) ? RCC->CSR : RCC->CIFR))) & \
  3532. (1U << ((__FLAG__) & RCC_FLAG_MASK))) != 0U) ? 1U : 0U)
  3533. #endif /* RCC_HSI48_SUPPORT */
  3534. /**
  3535. * @}
  3536. */
  3537. /**
  3538. * @}
  3539. */
  3540. /* Private constants ---------------------------------------------------------*/
  3541. /** @defgroup RCC_Private_Constants RCC Private Constants
  3542. * @{
  3543. */
  3544. /* Defines used for Flags */
  3545. #define CR_REG_INDEX 1U
  3546. #define BDCR_REG_INDEX 2U
  3547. #define CSR_REG_INDEX 3U
  3548. #if defined(RCC_HSI48_SUPPORT)
  3549. #define CRRCR_REG_INDEX 4U
  3550. #endif /* RCC_HSI48_SUPPORT */
  3551. #define RCC_FLAG_MASK 0x1FU
  3552. /**
  3553. * @}
  3554. */
  3555. /* Private macros ------------------------------------------------------------*/
  3556. /** @addtogroup RCC_Private_Macros
  3557. * @{
  3558. */
  3559. #if defined(RCC_HSI48_SUPPORT)
  3560. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  3561. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  3562. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  3563. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI48) == RCC_OSCILLATORTYPE_HSI48) || \
  3564. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_MSI) == RCC_OSCILLATORTYPE_MSI) || \
  3565. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  3566. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
  3567. #else
  3568. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  3569. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  3570. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  3571. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_MSI) == RCC_OSCILLATORTYPE_MSI) || \
  3572. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  3573. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
  3574. #endif /* RCC_HSI48_SUPPORT */
  3575. #define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
  3576. ((__HSE__) == RCC_HSE_BYPASS))
  3577. #if defined(RCC_BDCR_LSESYSDIS)
  3578. #define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || ((__LSE__) == RCC_LSE_BYPASS_RTC_ONLY) || \
  3579. ((__LSE__) == RCC_LSE_ON_RTC_ONLY) || ((__LSE__) == RCC_LSE_BYPASS))
  3580. #else
  3581. #define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
  3582. ((__LSE__) == RCC_LSE_BYPASS))
  3583. #endif /* RCC_BDCR_LSESYSDIS */
  3584. #define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
  3585. #define IS_RCC_HSI_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= (RCC_ICSCR_HSITRIM >> RCC_ICSCR_HSITRIM_Pos))
  3586. #define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
  3587. #if defined(RCC_CSR_LSIPREDIV)
  3588. #define IS_RCC_LSIDIV(__LSIDIV__) (((__LSIDIV__) == RCC_LSI_DIV1) || ((__LSIDIV__) == RCC_LSI_DIV128))
  3589. #endif /* RCC_CSR_LSIPREDIV */
  3590. #define IS_RCC_MSI(__MSI__) (((__MSI__) == RCC_MSI_OFF) || ((__MSI__) == RCC_MSI_ON))
  3591. #define IS_RCC_MSICALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= 255U)
  3592. #if defined(RCC_HSI48_SUPPORT)
  3593. #define IS_RCC_HSI48(__HSI48__) (((__HSI48__) == RCC_HSI48_OFF) || ((__HSI48__) == RCC_HSI48_ON))
  3594. #endif /* RCC_HSI48_SUPPORT */
  3595. #define IS_RCC_PLL(__PLL__) (((__PLL__) == RCC_PLL_NONE) ||((__PLL__) == RCC_PLL_OFF) || \
  3596. ((__PLL__) == RCC_PLL_ON))
  3597. #define IS_RCC_PLLSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLSOURCE_NONE) || \
  3598. ((__SOURCE__) == RCC_PLLSOURCE_MSI) || \
  3599. ((__SOURCE__) == RCC_PLLSOURCE_HSI) || \
  3600. ((__SOURCE__) == RCC_PLLSOURCE_HSE))
  3601. #if defined(RCC_PLLM_DIV_1_16_SUPPORT)
  3602. #define IS_RCC_PLLM_VALUE(__VALUE__) ((1U <= (__VALUE__)) && ((__VALUE__) <= 16U))
  3603. #else
  3604. #define IS_RCC_PLLM_VALUE(__VALUE__) ((1U <= (__VALUE__)) && ((__VALUE__) <= 8U))
  3605. #endif /*RCC_PLLM_DIV_1_16_SUPPORT */
  3606. #define IS_RCC_PLLN_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 86U))
  3607. #if defined(RCC_PLLP_DIV_2_31_SUPPORT)
  3608. #define IS_RCC_PLLP_VALUE(__VALUE__) (((__VALUE__) >= 2U) && ((__VALUE__) <= 31U))
  3609. #else
  3610. #define IS_RCC_PLLP_VALUE(__VALUE__) (((__VALUE__) == 7U) || ((__VALUE__) == 17U))
  3611. #endif /*RCC_PLLP_DIV_2_31_SUPPORT */
  3612. #define IS_RCC_PLLQ_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  3613. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  3614. #define IS_RCC_PLLR_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  3615. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  3616. #if defined(RCC_PLLSAI1_SUPPORT)
  3617. #define IS_RCC_PLLSAI1CLOCKOUT_VALUE(__VALUE__) (((((__VALUE__) & RCC_PLLSAI1_SAI1CLK) == RCC_PLLSAI1_SAI1CLK) || \
  3618. (((__VALUE__) & RCC_PLLSAI1_48M2CLK) == RCC_PLLSAI1_48M2CLK) || \
  3619. (((__VALUE__) & RCC_PLLSAI1_ADC1CLK) == RCC_PLLSAI1_ADC1CLK)) && \
  3620. (((__VALUE__) & ~(RCC_PLLSAI1_SAI1CLK|RCC_PLLSAI1_48M2CLK|RCC_PLLSAI1_ADC1CLK)) == 0U))
  3621. #endif /* RCC_PLLSAI1_SUPPORT */
  3622. #if defined(RCC_PLLSAI2_SUPPORT)
  3623. #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)
  3624. #define IS_RCC_PLLSAI2CLOCKOUT_VALUE(__VALUE__) (((((__VALUE__) & RCC_PLLSAI2_SAI2CLK) == RCC_PLLSAI2_SAI2CLK) || \
  3625. (((__VALUE__) & RCC_PLLSAI2_ADC2CLK) == RCC_PLLSAI2_ADC2CLK)) && \
  3626. (((__VALUE__) & ~(RCC_PLLSAI2_SAI2CLK|RCC_PLLSAI2_ADC2CLK)) == 0U))
  3627. #elif defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  3628. #define IS_RCC_PLLSAI2CLOCKOUT_VALUE(__VALUE__) (((((__VALUE__) & RCC_PLLSAI2_SAI2CLK) == RCC_PLLSAI2_SAI2CLK) || \
  3629. (((__VALUE__) & RCC_PLLSAI2_DSICLK) == RCC_PLLSAI2_DSICLK) || \
  3630. (((__VALUE__) & RCC_PLLSAI2_LTDCCLK) == RCC_PLLSAI2_LTDCCLK)) && \
  3631. (((__VALUE__) & ~(RCC_PLLSAI2_SAI2CLK|RCC_PLLSAI2_DSICLK|RCC_PLLSAI2_LTDCCLK)) == 0U))
  3632. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || STM32L496xx || STM32L4A6xx */
  3633. #endif /* RCC_PLLSAI2_SUPPORT */
  3634. #define IS_RCC_MSI_CLOCK_RANGE(__RANGE__) (((__RANGE__) == RCC_MSIRANGE_0) || \
  3635. ((__RANGE__) == RCC_MSIRANGE_1) || \
  3636. ((__RANGE__) == RCC_MSIRANGE_2) || \
  3637. ((__RANGE__) == RCC_MSIRANGE_3) || \
  3638. ((__RANGE__) == RCC_MSIRANGE_4) || \
  3639. ((__RANGE__) == RCC_MSIRANGE_5) || \
  3640. ((__RANGE__) == RCC_MSIRANGE_6) || \
  3641. ((__RANGE__) == RCC_MSIRANGE_7) || \
  3642. ((__RANGE__) == RCC_MSIRANGE_8) || \
  3643. ((__RANGE__) == RCC_MSIRANGE_9) || \
  3644. ((__RANGE__) == RCC_MSIRANGE_10) || \
  3645. ((__RANGE__) == RCC_MSIRANGE_11))
  3646. #define IS_RCC_MSI_STANDBY_CLOCK_RANGE(__RANGE__) (((__RANGE__) == RCC_MSIRANGE_4) || \
  3647. ((__RANGE__) == RCC_MSIRANGE_5) || \
  3648. ((__RANGE__) == RCC_MSIRANGE_6) || \
  3649. ((__RANGE__) == RCC_MSIRANGE_7))
  3650. #define IS_RCC_CLOCKTYPE(__CLK__) ((1U <= (__CLK__)) && ((__CLK__) <= 15U))
  3651. #define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_MSI) || \
  3652. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
  3653. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
  3654. ((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
  3655. #define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
  3656. ((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
  3657. ((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
  3658. ((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
  3659. ((__HCLK__) == RCC_SYSCLK_DIV512))
  3660. #define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
  3661. ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
  3662. ((__PCLK__) == RCC_HCLK_DIV16))
  3663. #define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_NONE) || \
  3664. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
  3665. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
  3666. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV32))
  3667. #define IS_RCC_MCO(__MCOX__) ((__MCOX__) == RCC_MCO1)
  3668. #if defined(RCC_HSI48_SUPPORT)
  3669. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
  3670. ((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
  3671. ((__SOURCE__) == RCC_MCO1SOURCE_MSI) || \
  3672. ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
  3673. ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
  3674. ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
  3675. ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
  3676. ((__SOURCE__) == RCC_MCO1SOURCE_LSE) || \
  3677. ((__SOURCE__) == RCC_MCO1SOURCE_HSI48))
  3678. #else
  3679. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
  3680. ((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
  3681. ((__SOURCE__) == RCC_MCO1SOURCE_MSI) || \
  3682. ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
  3683. ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
  3684. ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
  3685. ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
  3686. ((__SOURCE__) == RCC_MCO1SOURCE_LSE))
  3687. #endif /* RCC_HSI48_SUPPORT */
  3688. #define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1) || ((__DIV__) == RCC_MCODIV_2) || \
  3689. ((__DIV__) == RCC_MCODIV_4) || ((__DIV__) == RCC_MCODIV_8) || \
  3690. ((__DIV__) == RCC_MCODIV_16))
  3691. #define IS_RCC_LSE_DRIVE(__DRIVE__) (((__DRIVE__) == RCC_LSEDRIVE_LOW) || \
  3692. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMLOW) || \
  3693. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMHIGH) || \
  3694. ((__DRIVE__) == RCC_LSEDRIVE_HIGH))
  3695. #define IS_RCC_STOP_WAKEUPCLOCK(__SOURCE__) (((__SOURCE__) == RCC_STOP_WAKEUPCLOCK_MSI) || \
  3696. ((__SOURCE__) == RCC_STOP_WAKEUPCLOCK_HSI))
  3697. /**
  3698. * @}
  3699. */
  3700. /* Include RCC HAL Extended module */
  3701. #include "stm32l4xx_hal_rcc_ex.h"
  3702. /* Exported functions --------------------------------------------------------*/
  3703. /** @addtogroup RCC_Exported_Functions
  3704. * @{
  3705. */
  3706. /** @addtogroup RCC_Exported_Functions_Group1
  3707. * @{
  3708. */
  3709. /* Initialization and de-initialization functions ******************************/
  3710. HAL_StatusTypeDef HAL_RCC_DeInit(void);
  3711. HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  3712. HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
  3713. /**
  3714. * @}
  3715. */
  3716. /** @addtogroup RCC_Exported_Functions_Group2
  3717. * @{
  3718. */
  3719. /* Peripheral Control functions ************************************************/
  3720. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  3721. void HAL_RCC_EnableCSS(void);
  3722. uint32_t HAL_RCC_GetSysClockFreq(void);
  3723. uint32_t HAL_RCC_GetHCLKFreq(void);
  3724. uint32_t HAL_RCC_GetPCLK1Freq(void);
  3725. uint32_t HAL_RCC_GetPCLK2Freq(void);
  3726. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  3727. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
  3728. /* CSS NMI IRQ handler */
  3729. void HAL_RCC_NMI_IRQHandler(void);
  3730. /* User Callbacks in non blocking mode (IT mode) */
  3731. void HAL_RCC_CSSCallback(void);
  3732. /**
  3733. * @}
  3734. */
  3735. /**
  3736. * @}
  3737. */
  3738. /**
  3739. * @}
  3740. */
  3741. /**
  3742. * @}
  3743. */
  3744. #ifdef __cplusplus
  3745. }
  3746. #endif
  3747. #endif /* __STM32L4xx_HAL_RCC_H */
  3748. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/