stm32h5xx_hal_rcc.h 241 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174
  1. /**
  2. ******************************************************************************
  3. * @file stm32h5xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __STM32H5xx_HAL_RCC_H
  20. #define __STM32H5xx_HAL_RCC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h5xx_hal_def.h"
  26. /** @addtogroup STM32H5xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup RCC
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup RCC_Exported_Types RCC Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief RCC PLL1 configuration structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t PLLState; /*!< PLLState: The new state of the PLL1.
  42. This parameter can be a value of @ref RCC_PLL1_Config */
  43. uint32_t PLLSource; /*!< PLLSource: PLL entry clock source.
  44. This parameter must be a value of @ref RCC_PLL1_Clock_Source */
  45. uint32_t PLLM; /*!< PLLM: Division factor for PLL1 VCO input clock.
  46. This parameter must be a number between Min_Data = 0 and Max_Data = 63 */
  47. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL1 VCO output clock.
  48. This parameter must be a number between Min_Data = 4 and Max_Data = 512 */
  49. uint32_t PLLP; /*!< PLLP: Division factor for system clock.
  50. This parameter must be a number between Min_Data = 2 and Max_Data = 128
  51. odd division factors are not allowed */
  52. uint32_t PLLQ; /*!< PLLQ: Division factor for peripheral clocks.
  53. This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
  54. uint32_t PLLR; /*!< PLLR: Division factor for peripheral clocks.
  55. This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
  56. uint32_t PLLRGE; /*!< PLLRGE: PLL1 clock Input range
  57. This parameter must be a value of @ref RCC_PLL1_VCI_Range */
  58. uint32_t PLLVCOSEL; /*!< PLLVCOSEL: PLL1 clock Output range
  59. This parameter must be a value of @ref RCC_PLL1_VCO_Range */
  60. uint32_t PLLFRACN; /*!< PLLFRACN: Specifies Fractional Part Of The Multiplication Factor for
  61. PLL1 VCO It should be a value between 0 and 8191 */
  62. } RCC_PLLInitTypeDef;
  63. /**
  64. * @brief RCC Internal/External Oscillator (HSE, HSI, CSI, LSE and LSI) configuration structure definition
  65. */
  66. typedef struct
  67. {
  68. uint32_t OscillatorType; /*!< The oscillators to be configured.
  69. This parameter can be a value of @ref RCC_Oscillator_Type */
  70. uint32_t HSEState; /*!< The new state of the HSE.
  71. This parameter can be a value of @ref RCC_HSE_Config */
  72. uint32_t LSEState; /*!< The new state of the LSE.
  73. This parameter can be a value of @ref RCC_LSE_Config */
  74. uint32_t HSIState; /*!< The new state of the HSI.
  75. This parameter can be a value of @ref RCC_HSI_Config */
  76. uint32_t HSIDiv; /*!< The division factor of the HSI.
  77. This parameter can be a value of @ref RCC_HSI_Div */
  78. uint32_t HSICalibrationValue; /*!< The calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  79. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
  80. on the other devices */
  81. uint32_t LSIState; /*!< The new state of the LSI.
  82. This parameter can be a value of @ref RCC_LSI_Config */
  83. uint32_t CSIState; /*!< The new state of the CSI.
  84. This parameter can be a value of @ref RCC_CSI_Config */
  85. uint32_t CSICalibrationValue; /*!< The calibration trimming value (default is RCC_CSICALIBRATION_DEFAULT).
  86. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x3F */
  87. uint32_t HSI48State; /*!< The new state of the HSI48.
  88. This parameter can be a value of @ref RCC_HSI48_Config */
  89. RCC_PLLInitTypeDef PLL; /*!< PLL1 structure parameters */
  90. } RCC_OscInitTypeDef;
  91. /**
  92. * @brief RCC System, AHB and APB busses clock configuration structure definition
  93. */
  94. typedef struct
  95. {
  96. uint32_t ClockType; /*!< The clock to be configured.
  97. This parameter can be a value of @ref RCC_System_Clock_Type */
  98. uint32_t SYSCLKSource; /*!< The clock source used as system clock (SYSCLK).
  99. This parameter can be a value of @ref RCC_System_Clock_Source */
  100. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  101. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  102. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  103. This parameter can be a value of @ref RCC_APB1_APB2_APB3_Clock_Source */
  104. uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
  105. This parameter can be a value of @ref RCC_APB1_APB2_APB3_Clock_Source */
  106. uint32_t APB3CLKDivider; /*!< The APB3 clock (PCLK3) divider. This clock is derived from the AHB clock (HCLK).
  107. This parameter can be a value of @ref RCC_APB1_APB2_APB3_Clock_Source */
  108. } RCC_ClkInitTypeDef;
  109. /**
  110. * @}
  111. */
  112. /* Exported constants --------------------------------------------------------*/
  113. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  114. * @{
  115. */
  116. /** @defgroup RCC_Peripheral_Memory_Mapping Peripheral Memory Mapping
  117. * @{
  118. */
  119. /**
  120. * @}
  121. */
  122. /** @defgroup RCC_Oscillator_Type Oscillator Type
  123. * @{
  124. */
  125. #define RCC_OSCILLATORTYPE_NONE (0x00000000U) /*!< Oscillator configuration unchanged */
  126. #define RCC_OSCILLATORTYPE_HSE (0x00000001U) /*!< HSE to configure */
  127. #define RCC_OSCILLATORTYPE_HSI (0x00000002U) /*!< HSI to configure */
  128. #define RCC_OSCILLATORTYPE_LSE (0x00000004U) /*!< LSE to configure */
  129. #define RCC_OSCILLATORTYPE_LSI (0x00000008U) /*!< LSI to configure */
  130. #define RCC_OSCILLATORTYPE_CSI (0x00000010U) /*!< CSI to configure */
  131. #define RCC_OSCILLATORTYPE_HSI48 (0x00000020U) /*!< HSI48 to configure */
  132. /**
  133. * @}
  134. */
  135. /** @defgroup RCC_HSE_Config HSE Config
  136. * @{
  137. */
  138. #define RCC_HSE_OFF (0x00000000U) /*!< HSE clock deactivation */
  139. #define RCC_HSE_ON RCC_CR_HSEON /*!< HSE clock activation */
  140. #define RCC_HSE_BYPASS ((uint32_t)(RCC_CR_HSEBYP | RCC_CR_HSEON)) /*!< External Analog clock source for HSE clock */
  141. #define RCC_HSE_BYPASS_DIGITAL ((uint32_t)(RCC_CR_HSEEXT | RCC_CR_HSEBYP | RCC_CR_HSEON)) /*!< External Digital clock source for HSE clock */
  142. /**
  143. * @}
  144. */
  145. /** @defgroup RCC_LSE_Config LSE Config
  146. * @{
  147. */
  148. #define RCC_LSE_OFF 0U /*!< LSE clock deactivation */
  149. #define RCC_LSE_ON RCC_BDCR_LSEON /*!< LSE clock activation */
  150. #define RCC_LSE_BYPASS ((uint32_t)(RCC_BDCR_LSEBYP | RCC_BDCR_LSEON)) /*!< External Analog clock source for LSE clock Bypassed*/
  151. #define RCC_LSE_BYPASS_DIGITAL ((uint32_t)(RCC_BDCR_LSEEXT | RCC_BDCR_LSEBYP | RCC_BDCR_LSEON)) /*!< External Digital clock source for LSE clock Bypassed */
  152. /**
  153. * @}
  154. */
  155. /** @defgroup RCC_HSI_Config HSI Config
  156. * @{
  157. */
  158. #define RCC_HSI_OFF 0x00000000U /*!< HSI clock deactivation */
  159. #define RCC_HSI_ON RCC_CR_HSION /*!< HSI clock activation */
  160. #define RCC_HSICALIBRATION_DEFAULT (0x40U) /* Default HSI calibration trimming value */
  161. /**
  162. * @}
  163. */
  164. /** @defgroup RCC_HSI_Div HSI Div
  165. * @{
  166. */
  167. #define RCC_HSI_DIV1 0x00000000U /*!< HSI clock is not divided */
  168. #define RCC_HSI_DIV2 RCC_CR_HSIDIV_0 /*!< HSI clock is divided by 2 */
  169. #define RCC_HSI_DIV4 RCC_CR_HSIDIV_1 /*!< HSI clock is divided by 4 */
  170. #define RCC_HSI_DIV8 (RCC_CR_HSIDIV_1|RCC_CR_HSIDIV_0) /*!< HSI clock is divided by 8 */
  171. /**
  172. * @}
  173. */
  174. /** @defgroup RCC_LSI_Config LSI Config
  175. * @{
  176. */
  177. #define RCC_LSI_OFF (0x00000000U) /*!< LSI clock deactivation */
  178. #define RCC_LSI_ON RCC_BDCR_LSION /*!< LSI clock activation */
  179. /**
  180. * @}
  181. */
  182. /** @defgroup RCC_CSI_Config CSI Config
  183. * @{
  184. */
  185. #define RCC_CSI_OFF (0x00000000U) /*!< CSI clock deactivation */
  186. #define RCC_CSI_ON RCC_CR_CSION /*!< CSI clock activation */
  187. #define RCC_CSICALIBRATION_DEFAULT (0x20U) /*!< Default CSI calibration trimming value */
  188. /**
  189. * @}
  190. */
  191. /** @defgroup RCC_HSI48_Config HSI48 Config
  192. * @{
  193. */
  194. #define RCC_HSI48_OFF (0x00000000U) /*!< HSI48 clock deactivation */
  195. #define RCC_HSI48_ON RCC_CR_HSI48ON /*!< HSI48 clock activation */
  196. /**
  197. * @}
  198. */
  199. /** @defgroup RCC_PLL1_Config RCC PLL1 Config
  200. * @{
  201. */
  202. #define RCC_PLL_NONE (0x00000000U)
  203. #define RCC_PLL_OFF (0x00000001U)
  204. #define RCC_PLL_ON (0x00000002U)
  205. /**
  206. * @}
  207. */
  208. /** @defgroup RCC_PLL1_Clock_Output RCC PLL1 Clock Output
  209. * @{
  210. */
  211. #define RCC_PLL1_DIVP RCC_PLL1CFGR_PLL1PEN
  212. #define RCC_PLL1_DIVQ RCC_PLL1CFGR_PLL1QEN
  213. #define RCC_PLL1_DIVR RCC_PLL1CFGR_PLL1REN
  214. /**
  215. * @}
  216. */
  217. /** @defgroup RCC_PLL1_VCI_Range RCC PLL1 VCI Range
  218. * @{
  219. */
  220. #define RCC_PLL1_VCIRANGE_0 (0x00000000U) /*!< Clock range frequency between 1 and 2 MHz */
  221. #define RCC_PLL1_VCIRANGE_1 RCC_PLL1CFGR_PLL1RGE_0 /*!< Clock range frequency between 2 and 4 MHz */
  222. #define RCC_PLL1_VCIRANGE_2 RCC_PLL1CFGR_PLL1RGE_1 /*!< Clock range frequency between 4 and 8 MHz */
  223. #define RCC_PLL1_VCIRANGE_3 (RCC_PLL1CFGR_PLL1RGE_0 | RCC_PLL1CFGR_PLL1RGE_1) /*!< Clock range frequency between 8 and 16 MHz */
  224. /**
  225. * @}
  226. */
  227. /** @defgroup RCC_PLL1_VCO_Range RCC PLL1 VCO Range
  228. * @{
  229. */
  230. #define RCC_PLL1_VCORANGE_WIDE (0x00000000U) /*!< Clock range frequency between 192 and 836 MHz */
  231. #define RCC_PLL1_VCORANGE_MEDIUM RCC_PLL1CFGR_PLL1VCOSEL /*!< Clock range frequency between 150 and 420 MHz */
  232. /**
  233. * @}
  234. */
  235. /** @defgroup RCC_PLL1_Clock_Source RCC PLL1 Clock Source
  236. * @{
  237. */
  238. #define RCC_PLL1_SOURCE_NONE (0x00000000U)
  239. #define RCC_PLL1_SOURCE_HSI RCC_PLL1CFGR_PLL1SRC_0
  240. #define RCC_PLL1_SOURCE_CSI RCC_PLL1CFGR_PLL1SRC_1
  241. #define RCC_PLL1_SOURCE_HSE (RCC_PLL1CFGR_PLL1SRC_0 | RCC_PLL1CFGR_PLL1SRC_1)
  242. /**
  243. * @}
  244. */
  245. /** @defgroup RCC_System_Clock_Type System Clock Type
  246. * @{
  247. */
  248. #define RCC_CLOCKTYPE_SYSCLK (0x00000001U) /*!< SYSCLK to configure */
  249. #define RCC_CLOCKTYPE_HCLK (0x00000002U) /*!< HCLK to configure */
  250. #define RCC_CLOCKTYPE_PCLK1 (0x00000004U) /*!< PCLK1 to configure */
  251. #define RCC_CLOCKTYPE_PCLK2 (0x00000008U) /*!< PCLK2 to configure */
  252. #define RCC_CLOCKTYPE_PCLK3 (0x00000010U) /*!< PCLK3 to configure */
  253. /**
  254. * @}
  255. */
  256. /** @defgroup RCC_System_Clock_Source System Clock Source
  257. * @{
  258. */
  259. #define RCC_SYSCLKSOURCE_HSI (0x00000000U) /*!< HSI selection as system clock */
  260. #define RCC_SYSCLKSOURCE_CSI RCC_CFGR1_SW_0 /*!< CSI selection as system clock */
  261. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR1_SW_1 /*!< HSE selection as system clock */
  262. #define RCC_SYSCLKSOURCE_PLLCLK (RCC_CFGR1_SW_0 | RCC_CFGR1_SW_1) /*!< PLL1 selection as system clock */
  263. /**
  264. * @}
  265. */
  266. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  267. * @{
  268. */
  269. #define RCC_SYSCLKSOURCE_STATUS_HSI (0x00000000U) /*!< HSI used as system clock */
  270. #define RCC_SYSCLKSOURCE_STATUS_CSI RCC_CFGR1_SWS_0 /*!< CSI used as system clock */
  271. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR1_SWS_1 /*!< HSE used as system clock */
  272. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK (RCC_CFGR1_SWS_0 | RCC_CFGR1_SWS_1) /*!< PLL1 used as system clock */
  273. /**
  274. * @}
  275. */
  276. /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
  277. * @{
  278. */
  279. #define RCC_SYSCLK_DIV1 (0x00000000U) /*!< SYSCLK not divided */
  280. #define RCC_SYSCLK_DIV2 RCC_CFGR2_HPRE_3 /*!< SYSCLK divided by 2 */
  281. #define RCC_SYSCLK_DIV4 (RCC_CFGR2_HPRE_0 | RCC_CFGR2_HPRE_3) /*!< SYSCLK divided by 4 */
  282. #define RCC_SYSCLK_DIV8 (RCC_CFGR2_HPRE_1 | RCC_CFGR2_HPRE_3) /*!< SYSCLK divided by 8 */
  283. #define RCC_SYSCLK_DIV16 (RCC_CFGR2_HPRE_0 | RCC_CFGR2_HPRE_1 | RCC_CFGR2_HPRE_3) /*!< SYSCLK divided by 16 */
  284. #define RCC_SYSCLK_DIV64 (RCC_CFGR2_HPRE_2 | RCC_CFGR2_HPRE_3) /*!< SYSCLK divided by 64 */
  285. #define RCC_SYSCLK_DIV128 (RCC_CFGR2_HPRE_0 | RCC_CFGR2_HPRE_2 | RCC_CFGR2_HPRE_3) /*!< SYSCLK divided by 128 */
  286. #define RCC_SYSCLK_DIV256 (RCC_CFGR2_HPRE_1 | RCC_CFGR2_HPRE_2 | RCC_CFGR2_HPRE_3) /*!< SYSCLK divided by 256 */
  287. #define RCC_SYSCLK_DIV512 (RCC_CFGR2_HPRE_0 | RCC_CFGR2_HPRE_1 | RCC_CFGR2_HPRE_2 | RCC_CFGR2_HPRE_3) /*!< SYSCLK divided by 512 */
  288. /**
  289. * @}
  290. */
  291. /** @defgroup RCC_APB1_APB2_APB3_Clock_Source APB1 APB2 APB3 Clock Source
  292. * @{
  293. */
  294. #define RCC_HCLK_DIV1 (0x00000000U) /*!< HCLK not divided */
  295. #define RCC_HCLK_DIV2 RCC_CFGR2_PPRE1_2 /*!< HCLK divided by 2 */
  296. #define RCC_HCLK_DIV4 (RCC_CFGR2_PPRE1_0 | RCC_CFGR2_PPRE1_2) /*!< HCLK divided by 4 */
  297. #define RCC_HCLK_DIV8 (RCC_CFGR2_PPRE1_1 | RCC_CFGR2_PPRE1_2) /*!< HCLK divided by 8 */
  298. #define RCC_HCLK_DIV16 (RCC_CFGR2_PPRE1_0 | RCC_CFGR2_PPRE1_1 | RCC_CFGR2_PPRE1_2) /*!< HCLK divided by 16 */
  299. /**
  300. * @}
  301. */
  302. /** @defgroup RCC_HAL_EC_RTC_HSE_DIV RTC HSE Prescaler
  303. * @{
  304. */
  305. #define RCC_RTC_HSE_NOCLOCK (0x00000000U)
  306. #define RCC_RTC_HSE_DIV2 (0x00000200U)
  307. #define RCC_RTC_HSE_DIV3 (0x00000300U)
  308. #define RCC_RTC_HSE_DIV4 (0x00000400U)
  309. #define RCC_RTC_HSE_DIV5 (0x00000500U)
  310. #define RCC_RTC_HSE_DIV6 (0x00000600U)
  311. #define RCC_RTC_HSE_DIV7 (0x00000700U)
  312. #define RCC_RTC_HSE_DIV8 (0x00000800U)
  313. #define RCC_RTC_HSE_DIV9 (0x00000900U)
  314. #define RCC_RTC_HSE_DIV10 (0x00000A00U)
  315. #define RCC_RTC_HSE_DIV11 (0x00000B00U)
  316. #define RCC_RTC_HSE_DIV12 (0x00000C00U)
  317. #define RCC_RTC_HSE_DIV13 (0x00000D00U)
  318. #define RCC_RTC_HSE_DIV14 (0x00000E00U)
  319. #define RCC_RTC_HSE_DIV15 (0x00000F00U)
  320. #define RCC_RTC_HSE_DIV16 (0x00001000U)
  321. #define RCC_RTC_HSE_DIV17 (0x00001100U)
  322. #define RCC_RTC_HSE_DIV18 (0x00001200U)
  323. #define RCC_RTC_HSE_DIV19 (0x00001300U)
  324. #define RCC_RTC_HSE_DIV20 (0x00001400U)
  325. #define RCC_RTC_HSE_DIV21 (0x00001500U)
  326. #define RCC_RTC_HSE_DIV22 (0x00001600U)
  327. #define RCC_RTC_HSE_DIV23 (0x00001700U)
  328. #define RCC_RTC_HSE_DIV24 (0x00001800U)
  329. #define RCC_RTC_HSE_DIV25 (0x00001900U)
  330. #define RCC_RTC_HSE_DIV26 (0x00001A00U)
  331. #define RCC_RTC_HSE_DIV27 (0x00001B00U)
  332. #define RCC_RTC_HSE_DIV28 (0x00001C00U)
  333. #define RCC_RTC_HSE_DIV29 (0x00001D00U)
  334. #define RCC_RTC_HSE_DIV30 (0x00001E00U)
  335. #define RCC_RTC_HSE_DIV31 (0x00001F00U)
  336. #define RCC_RTC_HSE_DIV32 (0x00002000U)
  337. #define RCC_RTC_HSE_DIV33 (0x00002100U)
  338. #define RCC_RTC_HSE_DIV34 (0x00002200U)
  339. #define RCC_RTC_HSE_DIV35 (0x00002300U)
  340. #define RCC_RTC_HSE_DIV36 (0x00002400U)
  341. #define RCC_RTC_HSE_DIV37 (0x00002500U)
  342. #define RCC_RTC_HSE_DIV38 (0x00002600U)
  343. #define RCC_RTC_HSE_DIV39 (0x00002700U)
  344. #define RCC_RTC_HSE_DIV40 (0x00002800U)
  345. #define RCC_RTC_HSE_DIV41 (0x00002900U)
  346. #define RCC_RTC_HSE_DIV42 (0x00002A00U)
  347. #define RCC_RTC_HSE_DIV43 (0x00002B00U)
  348. #define RCC_RTC_HSE_DIV44 (0x00002C00U)
  349. #define RCC_RTC_HSE_DIV45 (0x00002D00U)
  350. #define RCC_RTC_HSE_DIV46 (0x00002E00U)
  351. #define RCC_RTC_HSE_DIV47 (0x00002F00U)
  352. #define RCC_RTC_HSE_DIV48 (0x00003000U)
  353. #define RCC_RTC_HSE_DIV49 (0x00003100U)
  354. #define RCC_RTC_HSE_DIV50 (0x00003200U)
  355. #define RCC_RTC_HSE_DIV51 (0x00003300U)
  356. #define RCC_RTC_HSE_DIV52 (0x00003400U)
  357. #define RCC_RTC_HSE_DIV53 (0x00003500U)
  358. #define RCC_RTC_HSE_DIV54 (0x00003600U)
  359. #define RCC_RTC_HSE_DIV55 (0x00003700U)
  360. #define RCC_RTC_HSE_DIV56 (0x00003800U)
  361. #define RCC_RTC_HSE_DIV57 (0x00003900U)
  362. #define RCC_RTC_HSE_DIV58 (0x00003A00U)
  363. #define RCC_RTC_HSE_DIV59 (0x00003B00U)
  364. #define RCC_RTC_HSE_DIV60 (0x00003C00U)
  365. #define RCC_RTC_HSE_DIV61 (0x00003D00U)
  366. #define RCC_RTC_HSE_DIV62 (0x00003E00U)
  367. #define RCC_RTC_HSE_DIV63 (0x00003F00U)
  368. /**
  369. * @}
  370. */
  371. /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
  372. * @{
  373. */
  374. #define RCC_RTCCLKSOURCE_NO_CLK (0x00000000U) /*!< No clock used as RTC clock source */
  375. #define RCC_RTCCLKSOURCE_LSE (0x00000100U) /*!< LSE oscillator clock used as RTC clock source */
  376. #define RCC_RTCCLKSOURCE_LSI (0x00000200U) /*!< LSI oscillator clock used as RTC clock source */
  377. #define RCC_RTCCLKSOURCE_HSE_DIVx (0x00000300U) /*!< HSE oscillator clock divided by X used as RTC clock source */
  378. #define RCC_RTCCLKSOURCE_HSE_DIV2 (0x00002300U)
  379. #define RCC_RTCCLKSOURCE_HSE_DIV3 (0x00003300U)
  380. #define RCC_RTCCLKSOURCE_HSE_DIV4 (0x00004300U)
  381. #define RCC_RTCCLKSOURCE_HSE_DIV5 (0x00005300U)
  382. #define RCC_RTCCLKSOURCE_HSE_DIV6 (0x00006300U)
  383. #define RCC_RTCCLKSOURCE_HSE_DIV7 (0x00007300U)
  384. #define RCC_RTCCLKSOURCE_HSE_DIV8 (0x00008300U)
  385. #define RCC_RTCCLKSOURCE_HSE_DIV9 (0x00009300U)
  386. #define RCC_RTCCLKSOURCE_HSE_DIV10 (0x0000A300U)
  387. #define RCC_RTCCLKSOURCE_HSE_DIV11 (0x0000B300U)
  388. #define RCC_RTCCLKSOURCE_HSE_DIV12 (0x0000C300U)
  389. #define RCC_RTCCLKSOURCE_HSE_DIV13 (0x0000D300U)
  390. #define RCC_RTCCLKSOURCE_HSE_DIV14 (0x0000E300U)
  391. #define RCC_RTCCLKSOURCE_HSE_DIV15 (0x0000F300U)
  392. #define RCC_RTCCLKSOURCE_HSE_DIV16 (0x00010300U)
  393. #define RCC_RTCCLKSOURCE_HSE_DIV17 (0x00011300U)
  394. #define RCC_RTCCLKSOURCE_HSE_DIV18 (0x00012300U)
  395. #define RCC_RTCCLKSOURCE_HSE_DIV19 (0x00013300U)
  396. #define RCC_RTCCLKSOURCE_HSE_DIV20 (0x00014300U)
  397. #define RCC_RTCCLKSOURCE_HSE_DIV21 (0x00015300U)
  398. #define RCC_RTCCLKSOURCE_HSE_DIV22 (0x00016300U)
  399. #define RCC_RTCCLKSOURCE_HSE_DIV23 (0x00017300U)
  400. #define RCC_RTCCLKSOURCE_HSE_DIV24 (0x00018300U)
  401. #define RCC_RTCCLKSOURCE_HSE_DIV25 (0x00019300U)
  402. #define RCC_RTCCLKSOURCE_HSE_DIV26 (0x0001A300U)
  403. #define RCC_RTCCLKSOURCE_HSE_DIV27 (0x0001B300U)
  404. #define RCC_RTCCLKSOURCE_HSE_DIV28 (0x0001C300U)
  405. #define RCC_RTCCLKSOURCE_HSE_DIV29 (0x0001D300U)
  406. #define RCC_RTCCLKSOURCE_HSE_DIV30 (0x0001E300U)
  407. #define RCC_RTCCLKSOURCE_HSE_DIV31 (0x0001F300U)
  408. #define RCC_RTCCLKSOURCE_HSE_DIV32 (0x00020300U)
  409. #define RCC_RTCCLKSOURCE_HSE_DIV33 (0x00021300U)
  410. #define RCC_RTCCLKSOURCE_HSE_DIV34 (0x00022300U)
  411. #define RCC_RTCCLKSOURCE_HSE_DIV35 (0x00023300U)
  412. #define RCC_RTCCLKSOURCE_HSE_DIV36 (0x00024300U)
  413. #define RCC_RTCCLKSOURCE_HSE_DIV37 (0x00025300U)
  414. #define RCC_RTCCLKSOURCE_HSE_DIV38 (0x00026300U)
  415. #define RCC_RTCCLKSOURCE_HSE_DIV39 (0x00027300U)
  416. #define RCC_RTCCLKSOURCE_HSE_DIV40 (0x00028300U)
  417. #define RCC_RTCCLKSOURCE_HSE_DIV41 (0x00029300U)
  418. #define RCC_RTCCLKSOURCE_HSE_DIV42 (0x0002A300U)
  419. #define RCC_RTCCLKSOURCE_HSE_DIV43 (0x0002B300U)
  420. #define RCC_RTCCLKSOURCE_HSE_DIV44 (0x0002C300U)
  421. #define RCC_RTCCLKSOURCE_HSE_DIV45 (0x0002D300U)
  422. #define RCC_RTCCLKSOURCE_HSE_DIV46 (0x0002E300U)
  423. #define RCC_RTCCLKSOURCE_HSE_DIV47 (0x0002F300U)
  424. #define RCC_RTCCLKSOURCE_HSE_DIV48 (0x00030300U)
  425. #define RCC_RTCCLKSOURCE_HSE_DIV49 (0x00031300U)
  426. #define RCC_RTCCLKSOURCE_HSE_DIV50 (0x00032300U)
  427. #define RCC_RTCCLKSOURCE_HSE_DIV51 (0x00033300U)
  428. #define RCC_RTCCLKSOURCE_HSE_DIV52 (0x00034300U)
  429. #define RCC_RTCCLKSOURCE_HSE_DIV53 (0x00035300U)
  430. #define RCC_RTCCLKSOURCE_HSE_DIV54 (0x00036300U)
  431. #define RCC_RTCCLKSOURCE_HSE_DIV55 (0x00037300U)
  432. #define RCC_RTCCLKSOURCE_HSE_DIV56 (0x00038300U)
  433. #define RCC_RTCCLKSOURCE_HSE_DIV57 (0x00039300U)
  434. #define RCC_RTCCLKSOURCE_HSE_DIV58 (0x0003A300U)
  435. #define RCC_RTCCLKSOURCE_HSE_DIV59 (0x0003B300U)
  436. #define RCC_RTCCLKSOURCE_HSE_DIV60 (0x0003C300U)
  437. #define RCC_RTCCLKSOURCE_HSE_DIV61 (0x0003D300U)
  438. #define RCC_RTCCLKSOURCE_HSE_DIV62 (0x0003E300U)
  439. #define RCC_RTCCLKSOURCE_HSE_DIV63 (0x0003F300U)
  440. /**
  441. * @}
  442. */
  443. /** @defgroup RCC_MCO_Index MCO Index
  444. * @{
  445. */
  446. #define RCC_MCO1 (0x00000000U)
  447. #define RCC_MCO2 (0x00000001U)
  448. /**
  449. * @}
  450. */
  451. /** @defgroup RCC_MCO1_Clock_Source RCC MCO1 Clock Source
  452. * @{
  453. */
  454. #define RCC_MCO1SOURCE_HSI (0x00000000U)
  455. #define RCC_MCO1SOURCE_LSE RCC_CFGR1_MCO1SEL_0
  456. #define RCC_MCO1SOURCE_HSE RCC_CFGR1_MCO1SEL_1
  457. #define RCC_MCO1SOURCE_PLL1Q ((uint32_t)RCC_CFGR1_MCO1SEL_0 | RCC_CFGR1_MCO1SEL_1)
  458. #define RCC_MCO1SOURCE_HSI48 RCC_CFGR1_MCO1SEL_2
  459. /**
  460. * @}
  461. */
  462. /** @defgroup RCC_MCO2_Clock_Source RCC MCO2 Clock Source
  463. * @{
  464. */
  465. #define RCC_MCO2SOURCE_SYSCLK (0x00000000U)
  466. #define RCC_MCO2SOURCE_PLL2P RCC_CFGR1_MCO2SEL_0
  467. #define RCC_MCO2SOURCE_HSE RCC_CFGR1_MCO2SEL_1
  468. #define RCC_MCO2SOURCE_PLL1P ((uint32_t)RCC_CFGR1_MCO2SEL_0 | RCC_CFGR1_MCO2SEL_1)
  469. #define RCC_MCO2SOURCE_CSI RCC_CFGR1_MCO2SEL_2
  470. #define RCC_MCO2SOURCE_LSI ((uint32_t)RCC_CFGR1_MCO2SEL_0 | RCC_CFGR1_MCO2SEL_2)
  471. /**
  472. * @}
  473. */
  474. /** @defgroup RCC_MCOx_Clock_Prescaler MCOx Clock Prescaler
  475. * @{
  476. */
  477. #define RCC_MCODIV_1 RCC_CFGR1_MCO1PRE_0
  478. #define RCC_MCODIV_2 RCC_CFGR1_MCO1PRE_1
  479. #define RCC_MCODIV_3 ((uint32_t)RCC_CFGR1_MCO1PRE_0 | RCC_CFGR1_MCO1PRE_1)
  480. #define RCC_MCODIV_4 RCC_CFGR1_MCO1PRE_2
  481. #define RCC_MCODIV_5 ((uint32_t)RCC_CFGR1_MCO1PRE_0 | RCC_CFGR1_MCO1PRE_2)
  482. #define RCC_MCODIV_6 ((uint32_t)RCC_CFGR1_MCO1PRE_1 | RCC_CFGR1_MCO1PRE_2)
  483. #define RCC_MCODIV_7 ((uint32_t)RCC_CFGR1_MCO1PRE_0 | RCC_CFGR1_MCO1PRE_1 | RCC_CFGR1_MCO1PRE_2)
  484. #define RCC_MCODIV_8 RCC_CFGR1_MCO1PRE_3
  485. #define RCC_MCODIV_9 ((uint32_t)RCC_CFGR1_MCO1PRE_0 | RCC_CFGR1_MCO1PRE_3)
  486. #define RCC_MCODIV_10 ((uint32_t)RCC_CFGR1_MCO1PRE_1 | RCC_CFGR1_MCO1PRE_3)
  487. #define RCC_MCODIV_11 ((uint32_t)RCC_CFGR1_MCO1PRE_0 | RCC_CFGR1_MCO1PRE_1 | RCC_CFGR1_MCO1PRE_3)
  488. #define RCC_MCODIV_12 ((uint32_t)RCC_CFGR1_MCO1PRE_2 | RCC_CFGR1_MCO1PRE_3)
  489. #define RCC_MCODIV_13 ((uint32_t)RCC_CFGR1_MCO1PRE_0 | RCC_CFGR1_MCO1PRE_2 | RCC_CFGR1_MCO1PRE_3)
  490. #define RCC_MCODIV_14 ((uint32_t)RCC_CFGR1_MCO1PRE_1 | RCC_CFGR1_MCO1PRE_2 | RCC_CFGR1_MCO1PRE_3)
  491. #define RCC_MCODIV_15 RCC_CFGR1_MCO1PRE
  492. /**
  493. * @}
  494. */
  495. /** @defgroup RCC_Interrupt Interrupts
  496. * @{
  497. */
  498. #define RCC_IT_LSIRDY RCC_CIFR_LSIRDYF /*!< LSI Ready Interrupt flag */
  499. #define RCC_IT_LSERDY RCC_CIFR_LSERDYF /*!< LSE Ready Interrupt flag */
  500. #define RCC_IT_CSIRDY RCC_CIFR_CSIRDYF /*!< CSI Ready Interrupt flag */
  501. #define RCC_IT_HSIRDY RCC_CIFR_HSIRDYF /*!< HSI16 Ready Interrupt flag */
  502. #define RCC_IT_HSERDY RCC_CIFR_HSERDYF /*!< HSE Ready Interrupt flag */
  503. #define RCC_IT_HSI48RDY RCC_CIFR_HSI48RDYF /*!< HSI48 Ready Interrupt flag */
  504. #define RCC_IT_PLL1RDY RCC_CIFR_PLL1RDYF /*!< PLL1 Ready Interrupt flag */
  505. #define RCC_IT_PLL2RDY RCC_CIFR_PLL2RDYF /*!< PLL2 Ready Interrupt flag */
  506. #if defined(RCC_CR_PLL3ON)
  507. #define RCC_IT_PLL3RDY RCC_CIFR_PLL3RDYF /*!< PLL3 Ready Interrupt flag */
  508. #endif /* RCC_CR_PLL3ON */
  509. #define RCC_IT_HSECSS RCC_CIFR_HSECSSF /*!< HSE Clock Security System Interrupt flag */
  510. /**
  511. * @}
  512. */
  513. /** @defgroup RCC_Flag Flags
  514. * Elements values convention: XXXYYYYYb
  515. * - YYYYY : Flag position in the register
  516. * - XXX : Register index
  517. * - 001: CR register
  518. * - 010: BDCR register
  519. * - 011: RSR register
  520. * @{
  521. */
  522. /* Flags in the CR register */
  523. #define RCC_FLAG_CSIRDY ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_CSIRDY_Pos)) /*!< CSI Ready flag */
  524. #define RCC_FLAG_HSIRDY ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_HSIRDY_Pos)) /*!< HSI Ready flag */
  525. #define RCC_FLAG_HSIDIVF ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_HSIDIVF_Pos)) /*!< HSI divider flag */
  526. #define RCC_FLAG_HSERDY ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_HSERDY_Pos)) /*!< HSE Ready flag */
  527. #define RCC_FLAG_PLL1RDY ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_PLL1RDY_Pos)) /*!< PLL1 Ready flag */
  528. #define RCC_FLAG_PLL2RDY ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_PLL2RDY_Pos)) /*!< PLL2 Ready flag */
  529. #if defined(RCC_CR_PLL3ON)
  530. #define RCC_FLAG_PLL3RDY ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_PLL3RDY_Pos)) /*!< PLL3 Ready flag */
  531. #endif /* RCC_CR_PLL3ON */
  532. #define RCC_FLAG_HSI48RDY ((uint32_t)((RCC_CR_REG_INDEX << 5U) | RCC_CR_HSI48RDY_Pos)) /*!< HSI48 Ready flag */
  533. /* Flags in the BDCR register */
  534. #define RCC_FLAG_LSERDY ((uint32_t)((RCC_BDCR_REG_INDEX << 5U) | RCC_BDCR_LSERDY_Pos)) /*!< LSE Ready flag */
  535. #define RCC_FLAG_LSECSSD ((uint32_t)((RCC_BDCR_REG_INDEX << 5U) | RCC_BDCR_LSECSSD_Pos)) /*!< LSE Clock Security System Interrupt flag */
  536. #define RCC_FLAG_LSIRDY ((uint32_t)((RCC_BDCR_REG_INDEX << 5U) | RCC_BDCR_LSIRDY_Pos)) /*!< LSI Ready flag */
  537. /* Flags in the RSR register */
  538. #define RCC_FLAG_RMVF ((uint32_t)((RCC_RSR_REG_INDEX << 5U) | RCC_RSR_RMVF_Pos)) /*!< Remove reset flag */
  539. #define RCC_FLAG_PINRST ((uint32_t)((RCC_RSR_REG_INDEX << 5U) | RCC_RSR_PINRSTF_Pos)) /*!< PIN reset flag */
  540. #define RCC_FLAG_BORRST ((uint32_t)((RCC_RSR_REG_INDEX << 5U) | RCC_RSR_BORRSTF_Pos)) /*!< BOR reset flag */
  541. #define RCC_FLAG_SFTRST ((uint32_t)((RCC_RSR_REG_INDEX << 5U) | RCC_RSR_SFTRSTF_Pos)) /*!< Software Reset flag */
  542. #define RCC_FLAG_IWDGRST ((uint32_t)((RCC_RSR_REG_INDEX << 5U) | RCC_RSR_IWDGRSTF_Pos)) /*!< Independent Watchdog reset flag */
  543. #define RCC_FLAG_WWDGRST ((uint32_t)((RCC_RSR_REG_INDEX << 5U) | RCC_RSR_WWDGRSTF_Pos)) /*!< Window watchdog reset flag */
  544. #define RCC_FLAG_LPWRRST ((uint32_t)((RCC_RSR_REG_INDEX << 5U) | RCC_RSR_LPWRRSTF_Pos)) /*!< Low-Power reset flag */
  545. /**
  546. * @}
  547. */
  548. /** @defgroup RCC_Reset_Flag Reset Flag
  549. * @{
  550. */
  551. #define RCC_RESET_FLAG_PIN RCC_RSR_PINRSTF /*!< PIN reset flag */
  552. #define RCC_RESET_FLAG_PWR RCC_RSR_BORRSTF /*!< BOR or POR/PDR reset flag */
  553. #define RCC_RESET_FLAG_SW RCC_RSR_SFTRSTF /*!< Software Reset flag */
  554. #define RCC_RESET_FLAG_IWDG RCC_RSR_IWDGRSTF /*!< Independent Watchdog reset flag */
  555. #define RCC_RESET_FLAG_WWDG RCC_RSR_WWDGRSTF /*!< Window watchdog reset flag */
  556. #define RCC_RESET_FLAG_LPWR RCC_RSR_LPWRRSTF /*!< Low power reset flag */
  557. #define RCC_RESET_FLAG_ALL (RCC_RESET_FLAG_PIN | RCC_RESET_FLAG_PWR | RCC_RESET_FLAG_SW | \
  558. RCC_RESET_FLAG_IWDG | RCC_RESET_FLAG_WWDG | RCC_RESET_FLAG_LPWR)
  559. /**
  560. * @}
  561. */
  562. /** @defgroup RCC_LSEDrive_Config LSE Drive Config
  563. * @{
  564. */
  565. #define RCC_LSEDRIVE_LOW (0x00000000U) /*!< LSE low drive capability */
  566. #define RCC_LSEDRIVE_MEDIUMLOW RCC_BDCR_LSEDRV_0 /*!< LSE medium low drive capability */
  567. #define RCC_LSEDRIVE_MEDIUMHIGH RCC_BDCR_LSEDRV_1 /*!< LSE medium high drive capability */
  568. #define RCC_LSEDRIVE_HIGH RCC_BDCR_LSEDRV /*!< LSE high drive capability */
  569. /**
  570. * @}
  571. */
  572. /** @defgroup RCC_Stop_WakeUpClock Wake-Up from STOP Clock
  573. * @{
  574. */
  575. #define RCC_STOP_WAKEUPCLOCK_HSI (0x00000000U) /*!< HSI selection after wake-up from STOP */
  576. #define RCC_STOP_WAKEUPCLOCK_CSI RCC_CFGR1_STOPWUCK /*!< CSI selection after wake-up from STOP */
  577. /**
  578. * @}
  579. */
  580. /** @defgroup RCC_Stop_KernelWakeUpClock RCC Stop KernelWakeUpClock
  581. * @{
  582. */
  583. #define RCC_STOP_KERWAKEUPCLOCK_HSI (0x00000000U) /*!< HSI kernel clock selection after wake-up from STOP */
  584. #define RCC_STOP_KERWAKEUPCLOCK_CSI RCC_CFGR1_STOPKERWUCK /*!< CSI kernel clock selection after wake-up from STOP */
  585. /**
  586. * @}
  587. */
  588. #if defined(RCC_SECCFGR_HSISEC)
  589. /** @defgroup RCC_items RCC items
  590. * @brief RCC items to configure attributes on
  591. * @{
  592. */
  593. #define RCC_HSI RCC_SECCFGR_HSISEC
  594. #define RCC_HSE RCC_SECCFGR_HSESEC
  595. #define RCC_CSI RCC_SECCFGR_CSISEC
  596. #define RCC_LSI RCC_SECCFGR_LSISEC
  597. #define RCC_LSE RCC_SECCFGR_LSESEC
  598. #define RCC_SYSCLK RCC_SECCFGR_SYSCLKSEC
  599. #define RCC_PRESC RCC_SECCFGR_PRESCSEC
  600. #define RCC_PLL1 RCC_SECCFGR_PLL1SEC
  601. #define RCC_PLL2 RCC_SECCFGR_PLL2SEC
  602. #define RCC_PLL3 RCC_SECCFGR_PLL3SEC
  603. #define RCC_HSI48 RCC_SECCFGR_HSI48SEC
  604. #define RCC_RMVF RCC_SECCFGR_RMVFSEC
  605. #define RCC_CKPERSEL RCC_SECCFGR_CKPERSELSEC
  606. #define RCC_ALL (RCC_HSI|RCC_HSE|RCC_CSI|RCC_LSI|RCC_LSE|RCC_HSI48| \
  607. RCC_SYSCLK|RCC_PRESC|RCC_PLL1|RCC_PLL2| \
  608. RCC_PLL3|RCC_CKPERSEL|RCC_RMVF)
  609. /**
  610. * @}
  611. */
  612. #endif /* RCC_SECCFGR_HSISEC */
  613. /** @defgroup RCC_attributes RCC attributes
  614. * @brief RCC privilege/non-privilege and secure/non-secure attributes
  615. * @{
  616. */
  617. #if defined(RCC_PRIVCFGR_NSPRIV)
  618. #define RCC_NSEC_PRIV 0x00000001U /*!< Non-secure Privilege attribute item */
  619. #define RCC_NSEC_NPRIV 0x00000002U /*!< Non-secure Non-privilege attribute item */
  620. #else
  621. #define RCC_PRIV 0x00000001U /*!< Privilege attribute item */
  622. #define RCC_NPRIV 0x00000002U /*!< Non-privilege attribute item */
  623. #endif /* RCC_PRIVCFGR_NSPRIV */
  624. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  625. #define RCC_SEC_PRIV 0x00000010U /*!< Secure Privilege attribute item */
  626. #define RCC_SEC_NPRIV 0x00000020U /*!< Secure Non-privilege attribute item */
  627. #endif /* __ARM_FEATURE_CMSE */
  628. /**
  629. * @}
  630. */
  631. /**
  632. * @}
  633. */
  634. /* Exported macros -----------------------------------------------------------*/
  635. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  636. * @{
  637. */
  638. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
  639. * @brief Enable or disable the AHB1 peripheral clock.
  640. * @note After reset, the peripheral clock (used for registers read/write access)
  641. * is disabled and the application software has to enable this clock before
  642. * using it.
  643. * @{
  644. */
  645. #define __HAL_RCC_GPDMA1_CLK_ENABLE() do { \
  646. __IO uint32_t tmpreg; \
  647. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA1EN); \
  648. /* Delay after an RCC peripheral clock enabling */ \
  649. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA1EN); \
  650. UNUSED(tmpreg); \
  651. } while(0)
  652. #define __HAL_RCC_GPDMA2_CLK_ENABLE() do { \
  653. __IO uint32_t tmpreg; \
  654. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA2EN); \
  655. /* Delay after an RCC peripheral clock enabling */ \
  656. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA2EN); \
  657. UNUSED(tmpreg); \
  658. } while(0)
  659. #if defined(CORDIC)
  660. #define __HAL_RCC_CORDIC_CLK_ENABLE() do { \
  661. __IO uint32_t tmpreg; \
  662. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN); \
  663. /* Delay after an RCC peripheral clock enabling */ \
  664. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN); \
  665. UNUSED(tmpreg); \
  666. } while(0)
  667. #endif /* CORDIC */
  668. #if defined(FMAC)
  669. #define __HAL_RCC_FMAC_CLK_ENABLE() do { \
  670. __IO uint32_t tmpreg; \
  671. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN); \
  672. /* Delay after an RCC peripheral clock enabling */ \
  673. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN); \
  674. UNUSED(tmpreg); \
  675. } while(0)
  676. #endif /* FMAC */
  677. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  678. __IO uint32_t tmpreg; \
  679. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  680. /* Delay after an RCC peripheral clock enabling */ \
  681. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN); \
  682. UNUSED(tmpreg); \
  683. } while(0)
  684. #define __HAL_RCC_RAMCFG_CLK_ENABLE() do { \
  685. __IO uint32_t tmpreg; \
  686. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_RAMCFGEN); \
  687. /* Delay after an RCC peripheral clock enabling */ \
  688. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_RAMCFGEN); \
  689. UNUSED(tmpreg); \
  690. } while(0)
  691. #define __HAL_RCC_FLASH_CLK_ENABLE() do { \
  692. __IO uint32_t tmpreg; \
  693. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLITFEN); \
  694. /* Delay after an RCC peripheral clock enabling */ \
  695. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLITFEN); \
  696. UNUSED(tmpreg); \
  697. } while(0)
  698. #if defined(ETH)
  699. #define __HAL_RCC_ETH_CLK_ENABLE() do { \
  700. __IO uint32_t tmpreg; \
  701. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHEN);\
  702. /* Delay after an RCC peripheral clock enabling */ \
  703. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHEN);\
  704. UNUSED(tmpreg); \
  705. } while(0)
  706. #define __HAL_RCC_ETHTX_CLK_ENABLE() do { \
  707. __IO uint32_t tmpreg; \
  708. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHTXEN);\
  709. /* Delay after an RCC peripheral clock enabling */ \
  710. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHTXEN);\
  711. UNUSED(tmpreg); \
  712. } while(0)
  713. #define __HAL_RCC_ETHRX_CLK_ENABLE() do { \
  714. __IO uint32_t tmpreg; \
  715. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHRXEN);\
  716. /* Delay after an RCC peripheral clock enabling */ \
  717. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHRXEN);\
  718. UNUSED(tmpreg); \
  719. } while(0)
  720. #endif /*ETH*/
  721. #define __HAL_RCC_GTZC1_CLK_ENABLE() do { \
  722. __IO uint32_t tmpreg; \
  723. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TZSC1EN); \
  724. /* Delay after an RCC peripheral clock enabling */ \
  725. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TZSC1EN); \
  726. UNUSED(tmpreg); \
  727. } while(0)
  728. #define __HAL_RCC_BKPRAM_CLK_ENABLE() do { \
  729. __IO uint32_t tmpreg; \
  730. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPRAMEN); \
  731. /* Delay after an RCC peripheral clock enabling */ \
  732. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPRAMEN); \
  733. UNUSED(tmpreg); \
  734. } while(0)
  735. #if defined(DCACHE1)
  736. #define __HAL_RCC_DCACHE1_CLK_ENABLE() do { \
  737. __IO uint32_t tmpreg; \
  738. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DCACHE1EN); \
  739. /* Delay after an RCC peripheral clock enabling */ \
  740. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DCACHE1EN); \
  741. UNUSED(tmpreg); \
  742. } while(0)
  743. #endif /* DCACHE1 */
  744. #define __HAL_RCC_SRAM1_CLK_ENABLE() do { \
  745. __IO uint32_t tmpreg; \
  746. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_SRAM1EN); \
  747. /* Delay after an RCC peripheral clock enabling */ \
  748. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_SRAM1EN); \
  749. UNUSED(tmpreg); \
  750. } while(0)
  751. #define __HAL_RCC_GPDMA1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA1EN)
  752. #define __HAL_RCC_GPDMA2_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA2EN)
  753. #if defined(CORDIC)
  754. #define __HAL_RCC_CORDIC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN)
  755. #endif /* CORDIC */
  756. #if defined(FMAC)
  757. #define __HAL_RCC_FMAC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN)
  758. #endif /* FMAC */
  759. #define __HAL_RCC_FLASH_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLITFEN)
  760. #define __HAL_RCC_CRC_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN)
  761. #define __HAL_RCC_RAMCFG_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_RAMCFGEN)
  762. #if defined(ETH)
  763. #define __HAL_RCC_ETH_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHEN)
  764. #define __HAL_RCC_ETHTX_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHTXEN)
  765. #define __HAL_RCC_ETHRX_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHRXEN)
  766. #endif /*ETH*/
  767. #define __HAL_RCC_GTZC1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TZSC1EN)
  768. #define __HAL_RCC_BKPRAM_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPRAMEN)
  769. #if defined(DCACHE1)
  770. #define __HAL_RCC_DCACHE1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DCACHE1EN)
  771. #endif /* DCACHE1 */
  772. #define __HAL_RCC_SRAM1_CLK_DISABLE() CLEAR_BIT(RCC->AHB1ENR, RCC_AHB1ENR_SRAM1EN)
  773. /**
  774. * @}
  775. */
  776. /** @defgroup RCC_AHB2_Peripheral_Clock_Enable_Disable AHB2 Peripheral Clock Enable Disable
  777. * @brief Enable or disable the AHB2 peripheral clock.
  778. * @note After reset, the peripheral clock (used for registers read/write access)
  779. * is disabled and the application software has to enable this clock before
  780. * using it.
  781. * @{
  782. */
  783. #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
  784. __IO uint32_t tmpreg; \
  785. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  786. /* Delay after an RCC peripheral clock enabling */ \
  787. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN); \
  788. UNUSED(tmpreg); \
  789. } while(0)
  790. #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
  791. __IO uint32_t tmpreg; \
  792. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  793. /* Delay after an RCC peripheral clock enabling */ \
  794. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN); \
  795. UNUSED(tmpreg); \
  796. } while(0)
  797. #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
  798. __IO uint32_t tmpreg; \
  799. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  800. /* Delay after an RCC peripheral clock enabling */ \
  801. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN); \
  802. UNUSED(tmpreg); \
  803. } while(0)
  804. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  805. __IO uint32_t tmpreg; \
  806. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  807. /* Delay after an RCC peripheral clock enabling */ \
  808. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN); \
  809. UNUSED(tmpreg); \
  810. } while(0)
  811. #if defined(GPIOE)
  812. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  813. __IO uint32_t tmpreg; \
  814. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  815. /* Delay after an RCC peripheral clock enabling */ \
  816. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN); \
  817. UNUSED(tmpreg); \
  818. } while(0)
  819. #endif /* GPIOE */
  820. #if defined(GPIOF)
  821. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  822. __IO uint32_t tmpreg; \
  823. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  824. /* Delay after an RCC peripheral clock enabling */ \
  825. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN); \
  826. UNUSED(tmpreg); \
  827. } while(0)
  828. #endif /* GPIOF */
  829. #if defined(GPIOG)
  830. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  831. __IO uint32_t tmpreg; \
  832. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  833. /* Delay after an RCC peripheral clock enabling */ \
  834. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN); \
  835. UNUSED(tmpreg); \
  836. } while(0)
  837. #endif /* GPIOG */
  838. #define __HAL_RCC_GPIOH_CLK_ENABLE() do { \
  839. __IO uint32_t tmpreg; \
  840. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN); \
  841. /* Delay after an RCC peripheral clock enabling */ \
  842. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN); \
  843. UNUSED(tmpreg); \
  844. } while(0)
  845. #if defined(GPIOI)
  846. #define __HAL_RCC_GPIOI_CLK_ENABLE() do { \
  847. __IO uint32_t tmpreg; \
  848. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN); \
  849. /* Delay after an RCC peripheral clock enabling */ \
  850. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN); \
  851. UNUSED(tmpreg); \
  852. } while(0)
  853. #endif /* GPIOI */
  854. #define __HAL_RCC_ADC_CLK_ENABLE() do { \
  855. __IO uint32_t tmpreg; \
  856. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN); \
  857. /* Delay after an RCC peripheral clock enabling */ \
  858. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN); \
  859. UNUSED(tmpreg); \
  860. } while(0)
  861. #define __HAL_RCC_DAC1_CLK_ENABLE() do { \
  862. __IO uint32_t tmpreg; \
  863. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN); \
  864. /* Delay after an RCC peripheral clock enabling */ \
  865. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN); \
  866. UNUSED(tmpreg); \
  867. } while(0)
  868. #if defined(DCMI)
  869. #define __HAL_RCC_DCMI_PSSI_CLK_ENABLE() do { \
  870. __IO uint32_t tmpreg; \
  871. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMI_PSSIEN);\
  872. /* Delay after an RCC peripheral clock enabling */ \
  873. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMI_PSSIEN);\
  874. UNUSED(tmpreg); \
  875. } while(0)
  876. #define __HAL_RCC_DCMI_CLK_ENABLE() __HAL_RCC_DCMI_PSSI_CLK_ENABLE() /* for API backward compatibility */
  877. #endif /* DCMI */
  878. #if defined(AES)
  879. #define __HAL_RCC_AES_CLK_ENABLE() do { \
  880. __IO uint32_t tmpreg; \
  881. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  882. /* Delay after an RCC peripheral clock enabling */ \
  883. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN); \
  884. UNUSED(tmpreg); \
  885. } while(0)
  886. #endif /* AES */
  887. #if defined(HASH)
  888. #define __HAL_RCC_HASH_CLK_ENABLE() do { \
  889. __IO uint32_t tmpreg; \
  890. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN); \
  891. /* Delay after an RCC peripheral clock enabling */ \
  892. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN); \
  893. UNUSED(tmpreg); \
  894. } while(0)
  895. #endif /* HASH */
  896. #define __HAL_RCC_RNG_CLK_ENABLE() do { \
  897. __IO uint32_t tmpreg; \
  898. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  899. /* Delay after an RCC peripheral clock enabling */ \
  900. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN); \
  901. UNUSED(tmpreg); \
  902. } while(0)
  903. #if defined(PKA)
  904. #define __HAL_RCC_PKA_CLK_ENABLE() do { \
  905. __IO uint32_t tmpreg; \
  906. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_PKAEN); \
  907. /* Delay after an RCC peripheral clock enabling */ \
  908. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_PKAEN); \
  909. UNUSED(tmpreg); \
  910. } while(0)
  911. #endif /* PKA */
  912. #if defined(SAES)
  913. #define __HAL_RCC_SAES_CLK_ENABLE() do { \
  914. __IO uint32_t tmpreg; \
  915. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SAESEN); \
  916. /* Delay after an RCC peripheral clock enabling */ \
  917. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SAESEN); \
  918. UNUSED(tmpreg); \
  919. } while(0)
  920. #endif /* SAES */
  921. #define __HAL_RCC_SRAM2_CLK_ENABLE() do { \
  922. __IO uint32_t tmpreg; \
  923. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM2EN); \
  924. /* Delay after an RCC peripheral clock enabling */ \
  925. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM2EN); \
  926. UNUSED(tmpreg); \
  927. } while(0)
  928. #if defined(SRAM3_BASE)
  929. #define __HAL_RCC_SRAM3_CLK_ENABLE() do { \
  930. __IO uint32_t tmpreg; \
  931. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM3EN); \
  932. /* Delay after an RCC peripheral clock enabling */ \
  933. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM3EN); \
  934. UNUSED(tmpreg); \
  935. } while(0)
  936. #endif /* SRAM3_BASE */
  937. #define __HAL_RCC_GPIOA_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN)
  938. #define __HAL_RCC_GPIOB_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN)
  939. #define __HAL_RCC_GPIOC_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN)
  940. #define __HAL_RCC_GPIOD_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN)
  941. #if defined(GPIOE)
  942. #define __HAL_RCC_GPIOE_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN)
  943. #endif /* GPIOE */
  944. #if defined(GPIOF)
  945. #define __HAL_RCC_GPIOF_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN)
  946. #endif /* GPIOF */
  947. #if defined(GPIOG)
  948. #define __HAL_RCC_GPIOG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN)
  949. #endif /* GPIOG */
  950. #define __HAL_RCC_GPIOH_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN)
  951. #if defined(GPIOI)
  952. #define __HAL_RCC_GPIOI_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN)
  953. #endif /* GPIOI */
  954. #define __HAL_RCC_ADC_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN)
  955. #define __HAL_RCC_DAC1_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN)
  956. #if defined(DCMI)
  957. #define __HAL_RCC_DCMI_PSSI_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMI_PSSIEN)
  958. #define __HAL_RCC_DCMI_CLK_DISABLE() __HAL_RCC_DCMI_PSSI_CLK_DISABLE() /* for API backward compatibility*/
  959. #endif /* DCMI */
  960. #if defined(AES)
  961. #define __HAL_RCC_AES_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN);
  962. #endif /* AES */
  963. #if defined(HASH)
  964. #define __HAL_RCC_HASH_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN)
  965. #endif /* HASH */
  966. #define __HAL_RCC_RNG_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN)
  967. #if defined(PKA)
  968. #define __HAL_RCC_PKA_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_PKAEN)
  969. #endif /* PKA */
  970. #if defined(SAES)
  971. #define __HAL_RCC_SAES_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SAESEN)
  972. #endif /* SAES */
  973. #if defined(CCB)
  974. #define __HAL_RCC_CCB_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CCBEN)
  975. #endif /* CCB */
  976. #define __HAL_RCC_SRAM2_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM2EN)
  977. #if defined(SRAM3_BASE)
  978. #define __HAL_RCC_SRAM3_CLK_DISABLE() CLEAR_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM3EN)
  979. #endif /* SRAM3_BASE */
  980. /**
  981. * @}
  982. */
  983. /** @defgroup RCC_AHB4_Clock_Enable_Disable AHB4 Peripheral Clock Enable Disable
  984. * @brief Enable or disable the AHB4 peripheral clock.
  985. * @note After reset, the peripheral clock (used for registers read/write access)
  986. * is disabled and the application software has to enable this clock before
  987. * using it.
  988. * @{
  989. */
  990. #if defined(OTFDEC1)
  991. #define __HAL_RCC_OTFDEC1_CLK_ENABLE() do { \
  992. __IO uint32_t tmpreg; \
  993. SET_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OTFDEC1EN); \
  994. /* Delay after an RCC peripheral clock enabling */ \
  995. tmpreg = READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OTFDEC1EN); \
  996. UNUSED(tmpreg); \
  997. } while(0)
  998. #endif /* OTFDEC1 */
  999. #if defined(SDMMC1)
  1000. #define __HAL_RCC_SDMMC1_CLK_ENABLE() do { \
  1001. __IO uint32_t tmpreg; \
  1002. SET_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC1EN); \
  1003. /* Delay after an RCC peripheral clock enabling */ \
  1004. tmpreg = READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC1EN); \
  1005. UNUSED(tmpreg); \
  1006. } while(0)
  1007. #endif /* SDMMC1 */
  1008. #if defined(SDMMC2)
  1009. #define __HAL_RCC_SDMMC2_CLK_ENABLE() do { \
  1010. __IO uint32_t tmpreg; \
  1011. SET_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC2EN); \
  1012. /* Delay after an RCC peripheral clock enabling */ \
  1013. tmpreg = READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC2EN); \
  1014. UNUSED(tmpreg); \
  1015. } while(0)
  1016. #endif /* SDMMC2 */
  1017. #if defined(FMC_BASE)
  1018. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  1019. __IO uint32_t tmpreg; \
  1020. SET_BIT(RCC->AHB4ENR, RCC_AHB4ENR_FMCEN); \
  1021. /* Delay after an RCC peripheral clock enabling */ \
  1022. tmpreg = READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_FMCEN); \
  1023. UNUSED(tmpreg); \
  1024. } while(0)
  1025. #endif /* FMC_BASE */
  1026. #if defined(OCTOSPI1)
  1027. #define __HAL_RCC_OSPI1_CLK_ENABLE() do { \
  1028. __IO uint32_t tmpreg; \
  1029. SET_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OCTOSPI1EN); \
  1030. /* Delay after an RCC peripheral clock enabling */ \
  1031. tmpreg = READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OCTOSPI1EN); \
  1032. UNUSED(tmpreg); \
  1033. } while(0)
  1034. #endif /* OCTOSPI1 */
  1035. #if defined(OTFDEC1)
  1036. #define __HAL_RCC_OTFDEC1_CLK_DISABLE() CLEAR_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OTFDEC1EN)
  1037. #endif /* OTFDEC1 */
  1038. #if defined(SDMMC1)
  1039. #define __HAL_RCC_SDMMC1_CLK_DISABLE() CLEAR_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC1EN)
  1040. #endif /* SDMMC1 */
  1041. #if defined(SDMMC2)
  1042. #define __HAL_RCC_SDMMC2_CLK_DISABLE() CLEAR_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC2EN)
  1043. #endif /* SDMMC2 */
  1044. #if defined(FMC_BASE)
  1045. #define __HAL_RCC_FMC_CLK_DISABLE() CLEAR_BIT(RCC->AHB4ENR, RCC_AHB4ENR_FMCEN)
  1046. #endif /* FMC_BASE */
  1047. #if defined(OCTOSPI1)
  1048. #define __HAL_RCC_OSPI1_CLK_DISABLE() CLEAR_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OCTOSPI1EN)
  1049. #endif /* OCTOSPI1 */
  1050. /**
  1051. * @}
  1052. */
  1053. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
  1054. * @brief Enable or disable the APB1 peripheral clock.
  1055. * @note After reset, the peripheral clock (used for registers read/write access)
  1056. * is disabled and the application software has to enable this clock before
  1057. * using it.
  1058. * @{
  1059. */
  1060. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  1061. __IO uint32_t tmpreg; \
  1062. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM2EN); \
  1063. /* Delay after an RCC peripheral clock enabling */ \
  1064. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM2EN); \
  1065. UNUSED(tmpreg); \
  1066. } while(0)
  1067. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  1068. __IO uint32_t tmpreg; \
  1069. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM3EN); \
  1070. /* Delay after an RCC peripheral clock enabling */ \
  1071. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM3EN); \
  1072. UNUSED(tmpreg); \
  1073. } while(0)
  1074. #if defined(TIM4)
  1075. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  1076. __IO uint32_t tmpreg; \
  1077. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM4EN); \
  1078. /* Delay after an RCC peripheral clock enabling */ \
  1079. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM4EN); \
  1080. UNUSED(tmpreg); \
  1081. } while(0)
  1082. #endif /* TIM4 */
  1083. #if defined(TIM5)
  1084. #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
  1085. __IO uint32_t tmpreg; \
  1086. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM5EN); \
  1087. /* Delay after an RCC peripheral clock enabling */ \
  1088. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM5EN); \
  1089. UNUSED(tmpreg); \
  1090. } while(0)
  1091. #endif /* TIM5 */
  1092. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  1093. __IO uint32_t tmpreg; \
  1094. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM6EN); \
  1095. /* Delay after an RCC peripheral clock enabling */ \
  1096. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM6EN); \
  1097. UNUSED(tmpreg); \
  1098. } while(0)
  1099. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  1100. __IO uint32_t tmpreg; \
  1101. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM7EN); \
  1102. /* Delay after an RCC peripheral clock enabling */ \
  1103. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM7EN); \
  1104. UNUSED(tmpreg); \
  1105. } while(0)
  1106. #if defined(TIM12)
  1107. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  1108. __IO uint32_t tmpreg; \
  1109. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM12EN); \
  1110. /* Delay after an RCC peripheral clock enabling */ \
  1111. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM12EN); \
  1112. UNUSED(tmpreg); \
  1113. } while(0)
  1114. #endif /* TIM12 */
  1115. #if defined(TIM13)
  1116. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  1117. __IO uint32_t tmpreg; \
  1118. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM13EN); \
  1119. /* Delay after an RCC peripheral clock enabling */ \
  1120. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM13EN); \
  1121. UNUSED(tmpreg); \
  1122. } while(0)
  1123. #endif /* TIM13 */
  1124. #if defined(TIM14)
  1125. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  1126. __IO uint32_t tmpreg; \
  1127. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM14EN); \
  1128. /* Delay after an RCC peripheral clock enabling */ \
  1129. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM14EN); \
  1130. UNUSED(tmpreg); \
  1131. } while(0)
  1132. #endif /* TIM14 */
  1133. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  1134. __IO uint32_t tmpreg; \
  1135. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_WWDGEN); \
  1136. /* Delay after an RCC peripheral clock enabling */ \
  1137. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_WWDGEN); \
  1138. UNUSED(tmpreg); \
  1139. } while(0)
  1140. #if defined(OPAMP1)
  1141. #define __HAL_RCC_OPAMP_CLK_ENABLE() do { \
  1142. __IO uint32_t tmpreg; \
  1143. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_OPAMPEN); \
  1144. /* Delay after an RCC peripheral clock enabling */ \
  1145. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_OPAMPEN); \
  1146. UNUSED(tmpreg); \
  1147. } while(0)
  1148. #endif /* OPAMP1 */
  1149. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  1150. __IO uint32_t tmpreg; \
  1151. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI2EN); \
  1152. /* Delay after an RCC peripheral clock enabling */ \
  1153. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI2EN); \
  1154. UNUSED(tmpreg); \
  1155. } while(0)
  1156. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  1157. __IO uint32_t tmpreg; \
  1158. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI3EN); \
  1159. /* Delay after an RCC peripheral clock enabling */ \
  1160. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI3EN); \
  1161. UNUSED(tmpreg); \
  1162. } while(0)
  1163. #if defined(COMP1)
  1164. #define __HAL_RCC_COMP_CLK_ENABLE() do { \
  1165. __IO uint32_t tmpreg; \
  1166. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_COMPEN); \
  1167. /* Delay after an RCC peripheral clock enabling */ \
  1168. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_COMPEN); \
  1169. UNUSED(tmpreg); \
  1170. } while(0)
  1171. #endif /* COMP1 */
  1172. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  1173. __IO uint32_t tmpreg; \
  1174. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_USART2EN); \
  1175. /* Delay after an RCC peripheral clock enabling */ \
  1176. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART2EN); \
  1177. UNUSED(tmpreg); \
  1178. } while(0)
  1179. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  1180. __IO uint32_t tmpreg; \
  1181. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_USART3EN); \
  1182. /* Delay after an RCC peripheral clock enabling */ \
  1183. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART3EN); \
  1184. UNUSED(tmpreg); \
  1185. } while(0)
  1186. #if defined(UART4)
  1187. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  1188. __IO uint32_t tmpreg; \
  1189. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_UART4EN); \
  1190. /* Delay after an RCC peripheral clock enabling */ \
  1191. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART4EN); \
  1192. UNUSED(tmpreg); \
  1193. } while(0)
  1194. #endif /* UART4 */
  1195. #if defined(UART5)
  1196. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  1197. __IO uint32_t tmpreg; \
  1198. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_UART5EN); \
  1199. /* Delay after an RCC peripheral clock enabling */ \
  1200. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART5EN); \
  1201. UNUSED(tmpreg); \
  1202. } while(0)
  1203. #endif /* UART5 */
  1204. #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
  1205. __IO uint32_t tmpreg; \
  1206. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C1EN); \
  1207. /* Delay after an RCC peripheral clock enabling */ \
  1208. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C1EN); \
  1209. UNUSED(tmpreg); \
  1210. } while(0)
  1211. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  1212. __IO uint32_t tmpreg; \
  1213. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C2EN); \
  1214. /* Delay after an RCC peripheral clock enabling */ \
  1215. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C2EN); \
  1216. UNUSED(tmpreg); \
  1217. } while(0)
  1218. #define __HAL_RCC_I3C1_CLK_ENABLE() do { \
  1219. __IO uint32_t tmpreg; \
  1220. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_I3C1EN); \
  1221. /* Delay after an RCC peripheral clock enabling */ \
  1222. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I3C1EN); \
  1223. UNUSED(tmpreg); \
  1224. } while(0)
  1225. #define __HAL_RCC_CRS_CLK_ENABLE() do { \
  1226. __IO uint32_t tmpreg; \
  1227. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_CRSEN); \
  1228. /* Delay after an RCC peripheral clock enabling */ \
  1229. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_CRSEN); \
  1230. UNUSED(tmpreg); \
  1231. } while(0)
  1232. #if defined(USART6)
  1233. #define __HAL_RCC_USART6_CLK_ENABLE() do { \
  1234. __IO uint32_t tmpreg; \
  1235. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_USART6EN); \
  1236. /* Delay after an RCC peripheral clock enabling */ \
  1237. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART6EN); \
  1238. UNUSED(tmpreg); \
  1239. } while(0)
  1240. #endif /* USART6 */
  1241. #if defined(USART10)
  1242. #define __HAL_RCC_USART10_CLK_ENABLE() do { \
  1243. __IO uint32_t tmpreg; \
  1244. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_USART10EN); \
  1245. /* Delay after an RCC peripheral clock enabling */ \
  1246. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART10EN); \
  1247. UNUSED(tmpreg); \
  1248. } while(0)
  1249. #endif /* USART10 */
  1250. #if defined(USART11)
  1251. #define __HAL_RCC_USART11_CLK_ENABLE() do { \
  1252. __IO uint32_t tmpreg; \
  1253. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_USART11EN); \
  1254. /* Delay after an RCC peripheral clock enabling */ \
  1255. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART11EN); \
  1256. UNUSED(tmpreg); \
  1257. } while(0)
  1258. #endif /* USART11 */
  1259. #if defined(CEC)
  1260. #define __HAL_RCC_CEC_CLK_ENABLE() do { \
  1261. __IO uint32_t tmpreg; \
  1262. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_CECEN); \
  1263. /* Delay after an RCC peripheral clock enabling */ \
  1264. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_CECEN); \
  1265. UNUSED(tmpreg); \
  1266. } while(0)
  1267. #endif /* CEC */
  1268. #if defined(UART7)
  1269. #define __HAL_RCC_UART7_CLK_ENABLE() do { \
  1270. __IO uint32_t tmpreg; \
  1271. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_UART7EN); \
  1272. /* Delay after an RCC peripheral clock enabling */ \
  1273. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART7EN); \
  1274. UNUSED(tmpreg); \
  1275. } while(0)
  1276. #endif /* UART7 */
  1277. #if defined(UART8)
  1278. #define __HAL_RCC_UART8_CLK_ENABLE() do { \
  1279. __IO uint32_t tmpreg; \
  1280. SET_BIT(RCC->APB1LENR, RCC_APB1LENR_UART8EN); \
  1281. /* Delay after an RCC peripheral clock enabling */ \
  1282. tmpreg = READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART8EN); \
  1283. UNUSED(tmpreg); \
  1284. } while(0)
  1285. #endif /* UART8 */
  1286. #if defined(UART9)
  1287. #define __HAL_RCC_UART9_CLK_ENABLE() do { \
  1288. __IO uint32_t tmpreg; \
  1289. SET_BIT(RCC->APB1HENR, RCC_APB1HENR_UART9EN); \
  1290. /* Delay after an RCC peripheral clock enabling */ \
  1291. tmpreg = READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UART9EN); \
  1292. UNUSED(tmpreg); \
  1293. } while(0)
  1294. #endif /* UART9 */
  1295. #if defined(UART12)
  1296. #define __HAL_RCC_UART12_CLK_ENABLE() do { \
  1297. __IO uint32_t tmpreg; \
  1298. SET_BIT(RCC->APB1HENR, RCC_APB1HENR_UART12EN); \
  1299. /* Delay after an RCC peripheral clock enabling */ \
  1300. tmpreg = READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UART12EN); \
  1301. UNUSED(tmpreg); \
  1302. } while(0)
  1303. #endif /* UART12 */
  1304. #define __HAL_RCC_DTS_CLK_ENABLE() do { \
  1305. __IO uint32_t tmpreg; \
  1306. SET_BIT(RCC->APB1HENR, RCC_APB1HENR_DTSEN); \
  1307. /* Delay after an RCC peripheral clock enabling */ \
  1308. tmpreg = READ_BIT(RCC->APB1HENR, RCC_APB1HENR_DTSEN); \
  1309. UNUSED(tmpreg); \
  1310. } while(0)
  1311. #define __HAL_RCC_LPTIM2_CLK_ENABLE() do { \
  1312. __IO uint32_t tmpreg; \
  1313. SET_BIT(RCC->APB1HENR, RCC_APB1HENR_LPTIM2EN); \
  1314. /* Delay after an RCC peripheral clock enabling */ \
  1315. tmpreg = READ_BIT(RCC->APB1HENR, RCC_APB1HENR_LPTIM2EN); \
  1316. UNUSED(tmpreg); \
  1317. } while(0)
  1318. #define __HAL_RCC_FDCAN_CLK_ENABLE() do { \
  1319. __IO uint32_t tmpreg; \
  1320. SET_BIT(RCC->APB1HENR, RCC_APB1HENR_FDCANEN); \
  1321. /* Delay after an RCC peripheral clock enabling */ \
  1322. tmpreg = READ_BIT(RCC->APB1HENR, RCC_APB1HENR_FDCANEN); \
  1323. UNUSED(tmpreg); \
  1324. } while(0)
  1325. #if defined(UCPD1)
  1326. #define __HAL_RCC_UCPD1_CLK_ENABLE() do { \
  1327. __IO uint32_t tmpreg; \
  1328. SET_BIT(RCC->APB1HENR, RCC_APB1HENR_UCPD1EN); \
  1329. /* Delay after an RCC peripheral clock enabling */ \
  1330. tmpreg = READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UCPD1EN); \
  1331. UNUSED(tmpreg); \
  1332. } while(0)
  1333. #endif /* UCPD1 */
  1334. #define __HAL_RCC_TIM2_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM2EN)
  1335. #define __HAL_RCC_TIM3_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM3EN)
  1336. #if defined(TIM4)
  1337. #define __HAL_RCC_TIM4_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM4EN)
  1338. #endif /* TIM4 */
  1339. #if defined(TIM5)
  1340. #define __HAL_RCC_TIM5_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM5EN)
  1341. #endif /* TIM5 */
  1342. #define __HAL_RCC_TIM6_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM6EN)
  1343. #define __HAL_RCC_TIM7_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM7EN)
  1344. #if defined(TIM12)
  1345. #define __HAL_RCC_TIM12_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM12EN)
  1346. #endif /* TIM12 */
  1347. #if defined(TIM13)
  1348. #define __HAL_RCC_TIM13_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM13EN)
  1349. #endif /* TIM13 */
  1350. #if defined(TIM14)
  1351. #define __HAL_RCC_TIM14_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM14EN)
  1352. #endif /* TIM14 */
  1353. #define __HAL_RCC_WWDG_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_WWDGEN)
  1354. #if defined(OPAMP1)
  1355. #define __HAL_RCC_OPAMP_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_OPAMPEN)
  1356. #endif /* OPAMP1 */
  1357. #define __HAL_RCC_SPI2_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI2EN)
  1358. #define __HAL_RCC_SPI3_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI3EN)
  1359. #if defined(COMP1)
  1360. #define __HAL_RCC_COMP_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_COMPEN)
  1361. #endif /* COMP1 */
  1362. #define __HAL_RCC_USART2_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_USART2EN)
  1363. #define __HAL_RCC_USART3_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_USART3EN)
  1364. #if defined(UART4)
  1365. #define __HAL_RCC_UART4_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_UART4EN)
  1366. #endif /* UART4 */
  1367. #if defined(UART5)
  1368. #define __HAL_RCC_UART5_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_UART5EN)
  1369. #endif /* UART5 */
  1370. #define __HAL_RCC_I2C1_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C1EN)
  1371. #define __HAL_RCC_I2C2_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C2EN)
  1372. #define __HAL_RCC_I3C1_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_I3C1EN)
  1373. #define __HAL_RCC_CRS_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_CRSEN)
  1374. #if defined(USART6)
  1375. #define __HAL_RCC_USART6_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_USART6EN)
  1376. #endif /* USART6 */
  1377. #if defined(USART10)
  1378. #define __HAL_RCC_USART10_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_USART10EN)
  1379. #endif /* USART10 */
  1380. #if defined(USART11)
  1381. #define __HAL_RCC_USART11_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_USART11EN)
  1382. #endif /* USART11 */
  1383. #if defined(CEC)
  1384. #define __HAL_RCC_CEC_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_CECEN)
  1385. #endif /* CEC */
  1386. #if defined(UART7)
  1387. #define __HAL_RCC_UART7_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_UART7EN)
  1388. #endif /* UART7 */
  1389. #if defined(UART8)
  1390. #define __HAL_RCC_UART8_CLK_DISABLE() CLEAR_BIT(RCC->APB1LENR, RCC_APB1LENR_UART8EN)
  1391. #endif /* UART8 */
  1392. #if defined(UART9)
  1393. #define __HAL_RCC_UART9_CLK_DISABLE() CLEAR_BIT(RCC->APB1HENR, RCC_APB1HENR_UART9EN)
  1394. #endif /* UART9 */
  1395. #if defined(UART12)
  1396. #define __HAL_RCC_UART12_CLK_DISABLE() CLEAR_BIT(RCC->APB1HENR, RCC_APB1HENR_UART12EN)
  1397. #endif /* UART12 */
  1398. #define __HAL_RCC_DTS_CLK_DISABLE() CLEAR_BIT(RCC->APB1HENR , RCC_APB1HENR_DTSEN)
  1399. #define __HAL_RCC_LPTIM2_CLK_DISABLE() CLEAR_BIT(RCC->APB1HENR, RCC_APB1HENR_LPTIM2EN)
  1400. #define __HAL_RCC_FDCAN_CLK_DISABLE() CLEAR_BIT(RCC->APB1HENR, RCC_APB1HENR_FDCANEN)
  1401. #if defined(UCPD1)
  1402. #define __HAL_RCC_UCPD1_CLK_DISABLE() CLEAR_BIT(RCC->APB1HENR, RCC_APB1HENR_UCPD1EN)
  1403. #endif /* UCPD1 */
  1404. /**
  1405. * @}
  1406. */
  1407. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
  1408. * @brief Enable or disable the APB2 peripheral clock.
  1409. * @note After reset, the peripheral clock (used for registers read/write access)
  1410. * is disabled and the application software has to enable this clock before
  1411. * using it.
  1412. * @{
  1413. */
  1414. #define __HAL_RCC_TIM1_CLK_ENABLE() do { \
  1415. __IO uint32_t tmpreg; \
  1416. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  1417. /* Delay after an RCC peripheral clock enabling */ \
  1418. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN); \
  1419. UNUSED(tmpreg); \
  1420. } while(0)
  1421. #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
  1422. __IO uint32_t tmpreg; \
  1423. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  1424. /* Delay after an RCC peripheral clock enabling */ \
  1425. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN); \
  1426. UNUSED(tmpreg); \
  1427. } while(0)
  1428. #if defined(TIM8)
  1429. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  1430. __IO uint32_t tmpreg; \
  1431. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  1432. /* Delay after an RCC peripheral clock enabling */ \
  1433. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN); \
  1434. UNUSED(tmpreg); \
  1435. } while(0)
  1436. #endif /* TIM8 */
  1437. #define __HAL_RCC_USART1_CLK_ENABLE() do { \
  1438. __IO uint32_t tmpreg; \
  1439. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  1440. /* Delay after an RCC peripheral clock enabling */ \
  1441. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN); \
  1442. UNUSED(tmpreg); \
  1443. } while(0)
  1444. #if defined(TIM15)
  1445. #define __HAL_RCC_TIM15_CLK_ENABLE() do { \
  1446. __IO uint32_t tmpreg; \
  1447. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  1448. /* Delay after an RCC peripheral clock enabling */ \
  1449. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN); \
  1450. UNUSED(tmpreg); \
  1451. } while(0)
  1452. #endif /* TIM15 */
  1453. #if defined(TIM16)
  1454. #define __HAL_RCC_TIM16_CLK_ENABLE() do { \
  1455. __IO uint32_t tmpreg; \
  1456. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  1457. /* Delay after an RCC peripheral clock enabling */ \
  1458. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN); \
  1459. UNUSED(tmpreg); \
  1460. } while(0)
  1461. #endif /* TIM16 */
  1462. #if defined(TIM17)
  1463. #define __HAL_RCC_TIM17_CLK_ENABLE() do { \
  1464. __IO uint32_t tmpreg; \
  1465. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  1466. /* Delay after an RCC peripheral clock enabling */ \
  1467. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN); \
  1468. UNUSED(tmpreg); \
  1469. } while(0)
  1470. #endif /* TIM17 */
  1471. #if defined(SPI4)
  1472. #define __HAL_RCC_SPI4_CLK_ENABLE() do { \
  1473. __IO uint32_t tmpreg; \
  1474. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN); \
  1475. /* Delay after an RCC peripheral clock enabling */ \
  1476. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN); \
  1477. UNUSED(tmpreg); \
  1478. } while(0)
  1479. #endif /* SPI4 */
  1480. #if defined(SPI6)
  1481. #define __HAL_RCC_SPI6_CLK_ENABLE() do { \
  1482. __IO uint32_t tmpreg; \
  1483. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN); \
  1484. /* Delay after an RCC peripheral clock enabling */ \
  1485. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN); \
  1486. UNUSED(tmpreg); \
  1487. } while(0)
  1488. #endif /* SPI6 */
  1489. #if defined(SAI1)
  1490. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  1491. __IO uint32_t tmpreg; \
  1492. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  1493. /* Delay after an RCC peripheral clock enabling */ \
  1494. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN); \
  1495. UNUSED(tmpreg); \
  1496. } while(0)
  1497. #endif /* SAI1 */
  1498. #if defined(SAI2)
  1499. #define __HAL_RCC_SAI2_CLK_ENABLE() do { \
  1500. __IO uint32_t tmpreg; \
  1501. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN); \
  1502. /* Delay after an RCC peripheral clock enabling */ \
  1503. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN); \
  1504. UNUSED(tmpreg); \
  1505. } while(0)
  1506. #endif /* SAI2 */
  1507. #if defined(USB_DRD_FS)
  1508. #define __HAL_RCC_USB_CLK_ENABLE() do { \
  1509. __IO uint32_t tmpreg; \
  1510. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USBEN); \
  1511. /* Delay after an RCC peripheral clock enabling */ \
  1512. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USBEN); \
  1513. UNUSED(tmpreg); \
  1514. } while(0)
  1515. #endif /*USB_DRD_FS*/
  1516. #define __HAL_RCC_TIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN)
  1517. #define __HAL_RCC_SPI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN)
  1518. #if defined(TIM8)
  1519. #define __HAL_RCC_TIM8_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN)
  1520. #endif /* TIM8 */
  1521. #define __HAL_RCC_USART1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN)
  1522. #if defined(TIM15)
  1523. #define __HAL_RCC_TIM15_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN)
  1524. #endif /* TIM15 */
  1525. #if defined(TIM16)
  1526. #define __HAL_RCC_TIM16_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN)
  1527. #endif /* TIM16 */
  1528. #if defined(TIM17)
  1529. #define __HAL_RCC_TIM17_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN)
  1530. #endif /* TIM17 */
  1531. #if defined(SPI4)
  1532. #define __HAL_RCC_SPI4_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN)
  1533. #endif /* SPI4 */
  1534. #if defined(SPI6)
  1535. #define __HAL_RCC_SPI6_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN)
  1536. #endif /* SPI6 */
  1537. #if defined(SAI1)
  1538. #define __HAL_RCC_SAI1_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN)
  1539. #endif /* SAI1 */
  1540. #if defined(SAI2)
  1541. #define __HAL_RCC_SAI2_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN)
  1542. #endif /* SAI2 */
  1543. #if defined(USB_DRD_FS)
  1544. #define __HAL_RCC_USB_CLK_DISABLE() CLEAR_BIT(RCC->APB2ENR, RCC_APB2ENR_USBEN)
  1545. #endif /* USB_DRD_FS */
  1546. /**
  1547. * @}
  1548. */
  1549. /** @defgroup RCC_APB3_Clock_Enable_Disable APB3 Peripheral Clock Enable Disable
  1550. * @brief Enable or disable the APB3 peripheral clock.
  1551. * @note After reset, the peripheral clock (used for registers read/write access)
  1552. * is disabled and the application software has to enable this clock before
  1553. * using it.
  1554. * @{
  1555. */
  1556. #define __HAL_RCC_SBS_CLK_ENABLE() do { \
  1557. __IO uint32_t tmpreg; \
  1558. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_SBSEN); \
  1559. /* Delay after an RCC peripheral clock enabling */ \
  1560. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_SBSEN); \
  1561. UNUSED(tmpreg); \
  1562. } while(0)
  1563. #if defined(SPI5)
  1564. #define __HAL_RCC_SPI5_CLK_ENABLE() do { \
  1565. __IO uint32_t tmpreg; \
  1566. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_SPI5EN); \
  1567. /* Delay after an RCC peripheral clock enabling */ \
  1568. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_SPI5EN); \
  1569. UNUSED(tmpreg); \
  1570. } while(0)
  1571. #endif /* SPI5 */
  1572. #define __HAL_RCC_LPUART1_CLK_ENABLE() do { \
  1573. __IO uint32_t tmpreg; \
  1574. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_LPUART1EN); \
  1575. /* Delay after an RCC peripheral clock enabling */ \
  1576. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPUART1EN); \
  1577. UNUSED(tmpreg); \
  1578. } while(0)
  1579. #if defined(I2C3)
  1580. #define __HAL_RCC_I2C3_CLK_ENABLE() do { \
  1581. __IO uint32_t tmpreg; \
  1582. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C3EN); \
  1583. /* Delay after an RCC peripheral clock enabling */ \
  1584. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C3EN); \
  1585. UNUSED(tmpreg); \
  1586. } while(0)
  1587. #endif /* I2C3 */
  1588. #if defined(I2C4)
  1589. #define __HAL_RCC_I2C4_CLK_ENABLE() do { \
  1590. __IO uint32_t tmpreg; \
  1591. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C4EN); \
  1592. /* Delay after an RCC peripheral clock enabling */ \
  1593. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C4EN); \
  1594. UNUSED(tmpreg); \
  1595. } while(0)
  1596. #endif /* I2C4 */
  1597. #if defined(I3C2)
  1598. #define __HAL_RCC_I3C2_CLK_ENABLE() do { \
  1599. __IO uint32_t tmpreg; \
  1600. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_I3C2EN); \
  1601. /* Delay after an RCC peripheral clock enabling */ \
  1602. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I3C2EN); \
  1603. UNUSED(tmpreg); \
  1604. } while(0)
  1605. #endif /* I3C2 */
  1606. #define __HAL_RCC_LPTIM1_CLK_ENABLE() do { \
  1607. __IO uint32_t tmpreg; \
  1608. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM1EN); \
  1609. /* Delay after an RCC peripheral clock enabling */ \
  1610. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM1EN); \
  1611. UNUSED(tmpreg); \
  1612. } while(0)
  1613. #if defined(LPTIM3)
  1614. #define __HAL_RCC_LPTIM3_CLK_ENABLE() do { \
  1615. __IO uint32_t tmpreg; \
  1616. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM3EN); \
  1617. /* Delay after an RCC peripheral clock enabling */ \
  1618. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM3EN); \
  1619. UNUSED(tmpreg); \
  1620. } while(0)
  1621. #endif /* LPTIM3 */
  1622. #if defined(LPTIM4)
  1623. #define __HAL_RCC_LPTIM4_CLK_ENABLE() do { \
  1624. __IO uint32_t tmpreg; \
  1625. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM4EN); \
  1626. /* Delay after an RCC peripheral clock enabling */ \
  1627. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM4EN); \
  1628. UNUSED(tmpreg); \
  1629. } while(0)
  1630. #endif /* LPTIM4 */
  1631. #if defined(LPTIM5)
  1632. #define __HAL_RCC_LPTIM5_CLK_ENABLE() do { \
  1633. __IO uint32_t tmpreg; \
  1634. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM5EN); \
  1635. /* Delay after an RCC peripheral clock enabling */ \
  1636. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM5EN); \
  1637. UNUSED(tmpreg); \
  1638. } while(0)
  1639. #endif /* LPTIM5 */
  1640. #if defined(LPTIM6)
  1641. #define __HAL_RCC_LPTIM6_CLK_ENABLE() do { \
  1642. __IO uint32_t tmpreg; \
  1643. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM6EN); \
  1644. /* Delay after an RCC peripheral clock enabling */ \
  1645. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM6EN); \
  1646. UNUSED(tmpreg); \
  1647. } while(0)
  1648. #endif /* LPTIM6 */
  1649. #if defined(VREFBUF)
  1650. #define __HAL_RCC_VREF_CLK_ENABLE() do { \
  1651. __IO uint32_t tmpreg; \
  1652. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_VREFEN); \
  1653. /* Delay after an RCC peripheral clock enabling */ \
  1654. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_VREFEN); \
  1655. UNUSED(tmpreg); \
  1656. } while(0)
  1657. #endif /* VREFBUF */
  1658. #define __HAL_RCC_RTC_CLK_ENABLE() do { \
  1659. __IO uint32_t tmpreg; \
  1660. SET_BIT(RCC->APB3ENR, RCC_APB3ENR_RTCAPBEN); \
  1661. /* Delay after an RCC peripheral clock enabling */ \
  1662. tmpreg = READ_BIT(RCC->APB3ENR, RCC_APB3ENR_RTCAPBEN); \
  1663. UNUSED(tmpreg); \
  1664. } while(0)
  1665. #define __HAL_RCC_SBS_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_SBSEN)
  1666. #if defined(SPI5)
  1667. #define __HAL_RCC_SPI5_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_SPI5EN)
  1668. #endif /* SPI5 */
  1669. #define __HAL_RCC_LPUART1_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_LPUART1EN)
  1670. #if defined(I2C3)
  1671. #define __HAL_RCC_I2C3_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C3EN)
  1672. #endif /* I2C3 */
  1673. #if defined(I2C4)
  1674. #define __HAL_RCC_I2C4_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C4EN)
  1675. #endif /* I2C4 */
  1676. #if defined(I3C2)
  1677. #define __HAL_RCC_I3C2_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_I3C2EN)
  1678. #endif /* I3C2 */
  1679. #define __HAL_RCC_LPTIM1_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM1EN)
  1680. #if defined(LPTIM3)
  1681. #define __HAL_RCC_LPTIM3_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM3EN)
  1682. #endif /* LPTIM3 */
  1683. #if defined(LPTIM4)
  1684. #define __HAL_RCC_LPTIM4_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM4EN)
  1685. #endif /* LPTIM4 */
  1686. #if defined(LPTIM5)
  1687. #define __HAL_RCC_LPTIM5_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM5EN)
  1688. #endif /* LPTIM5 */
  1689. #if defined(LPTIM6)
  1690. #define __HAL_RCC_LPTIM6_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM6EN)
  1691. #endif /* LPTIM6 */
  1692. #if defined(VREFBUF)
  1693. #define __HAL_RCC_VREF_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_VREFEN)
  1694. #endif /* VREFBUF */
  1695. #define __HAL_RCC_RTC_CLK_DISABLE() CLEAR_BIT(RCC->APB3ENR, RCC_APB3ENR_RTCAPBEN)
  1696. /**
  1697. * @}
  1698. */
  1699. /** @defgroup RCC_AHB_APB_Branch_Clock_Disable AHB APB Branch Clock Disable Clear Disable
  1700. * @brief Disable or clear Disable the AHBx/APBx branch clock for all AHBx/APBx peripherals.
  1701. * @note It is recommended to disable the clock of all peripherals (by writing 0 in
  1702. * the AHBxENR/APBxENR register) before Disabling the corresponding Bus Branch clock.
  1703. * Some peripheral bus clocks are not affected by branch clock disabling as IWDG (APB1),
  1704. * SRAM2/SRAM3 (AHB2) and FLITF/BKRAM/ICACHE/DCACHE/SRAM1 (AHB1).
  1705. * @{
  1706. */
  1707. #define __HAL_RCC_AHB1_CLK_DISABLE() do { \
  1708. __IO uint32_t tmpreg; \
  1709. SET_BIT(RCC->CFGR2, RCC_CFGR2_AHB1DIS); \
  1710. /* Delay after AHB peripherals bus clocks branch disable */ \
  1711. tmpreg = READ_BIT(RCC->CFGR2, RCC_CFGR2_AHB1DIS); \
  1712. UNUSED(tmpreg); \
  1713. } while(0)
  1714. #define __HAL_RCC_AHB2_CLK_DISABLE() do { \
  1715. __IO uint32_t tmpreg; \
  1716. SET_BIT(RCC->CFGR2, RCC_CFGR2_AHB2DIS); \
  1717. /* Delay after AHB peripherals bus clocks branch disable */ \
  1718. tmpreg = READ_BIT(RCC->CFGR2, RCC_CFGR2_AHB2DIS); \
  1719. UNUSED(tmpreg); \
  1720. } while(0)
  1721. #if defined(AHB4PERIPH_BASE)
  1722. #define __HAL_RCC_AHB4_CLK_DISABLE() do { \
  1723. __IO uint32_t tmpreg; \
  1724. SET_BIT(RCC->CFGR2, RCC_CFGR2_AHB4DIS); \
  1725. /* Delay after AHB peripherals bus clocks branch disable */ \
  1726. tmpreg = READ_BIT(RCC->CFGR2, RCC_CFGR2_AHB4DIS); \
  1727. UNUSED(tmpreg); \
  1728. } while(0)
  1729. #endif /* AHB4PERIPH_BASE */
  1730. #define __HAL_RCC_APB1_CLK_DISABLE() do { \
  1731. __IO uint32_t tmpreg; \
  1732. SET_BIT(RCC->CFGR2, RCC_CFGR2_APB1DIS); \
  1733. /* Delay after APB peripherals bus clocks branch disable */ \
  1734. tmpreg = READ_BIT(RCC->CFGR2, RCC_CFGR2_APB1DIS); \
  1735. UNUSED(tmpreg); \
  1736. } while(0)
  1737. #define __HAL_RCC_APB2_CLK_DISABLE() do { \
  1738. __IO uint32_t tmpreg; \
  1739. SET_BIT(RCC->CFGR2, RCC_CFGR2_APB2DIS); \
  1740. /* Delay after APB peripherals bus clocks branch disable */ \
  1741. tmpreg = READ_BIT(RCC->CFGR2, RCC_CFGR2_APB2DIS); \
  1742. UNUSED(tmpreg); \
  1743. } while(0)
  1744. #define __HAL_RCC_APB3_CLK_DISABLE() do { \
  1745. __IO uint32_t tmpreg; \
  1746. SET_BIT(RCC->CFGR2, RCC_CFGR2_APB3DIS); \
  1747. /* Delay after APB peripherals bus clocks branch disable */ \
  1748. tmpreg = READ_BIT(RCC->CFGR2, RCC_CFGR2_APB3DIS); \
  1749. UNUSED(tmpreg); \
  1750. } while(0)
  1751. #define __HAL_RCC_AHB1_CLK_ENABLE() CLEAR_BIT(RCC->CFGR2, RCC_CFGR2_AHB1DIS)
  1752. #define __HAL_RCC_AHB2_CLK_ENABLE() CLEAR_BIT(RCC->CFGR2, RCC_CFGR2_AHB2DIS)
  1753. #if defined(AHB4PERIPH_BASE)
  1754. #define __HAL_RCC_AHB4_CLK_ENABLE() CLEAR_BIT(RCC->CFGR2, RCC_CFGR2_AHB4DIS)
  1755. #endif /* AHB4PERIPH_BASE */
  1756. #define __HAL_RCC_APB1_CLK_ENABLE() CLEAR_BIT(RCC->CFGR2, RCC_CFGR2_APB1DIS)
  1757. #define __HAL_RCC_APB2_CLK_ENABLE() CLEAR_BIT(RCC->CFGR2, RCC_CFGR2_APB2DIS)
  1758. #define __HAL_RCC_APB3_CLK_ENABLE() CLEAR_BIT(RCC->CFGR2, RCC_CFGR2_APB3DIS)
  1759. /**
  1760. * @}
  1761. */
  1762. /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enabled or Disabled Status
  1763. * @brief Check whether the AHB1 peripheral clock is enabled or not.
  1764. * @note After reset, the peripheral clock (used for registers read/write access)
  1765. * is disabled and the application software has to enable this clock before
  1766. * using it.
  1767. * @{
  1768. */
  1769. #define __HAL_RCC_GPDMA1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA1EN) != 0U)
  1770. #define __HAL_RCC_GPDMA2_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA2EN) != 0U)
  1771. #define __HAL_RCC_FLASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLITFEN) != 0U)
  1772. #define __HAL_RCC_CRC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) != 0U)
  1773. #if defined(CORDIC)
  1774. #define __HAL_RCC_CORDIC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN) != 0U)
  1775. #endif /* CORDIC */
  1776. #if defined(FMAC)
  1777. #define __HAL_RCC_FMAC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN) != 0U)
  1778. #endif /* FMAC */
  1779. #define __HAL_RCC_RAMCFG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_RAMCFGEN) != 0U)
  1780. #if defined(ETH)
  1781. #define __HAL_RCC_ETH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHEN) != 0U)
  1782. #define __HAL_RCC_ETHTX_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHTXEN) != 0U)
  1783. #define __HAL_RCC_ETHRX_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHRXEN) != 0U)
  1784. #endif /*ETH*/
  1785. #define __HAL_RCC_GTZC1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TZSC1EN) != 0U)
  1786. #define __HAL_RCC_BKPRAM_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPRAMEN) != 0U)
  1787. #if defined(DCACHE1)
  1788. #define __HAL_RCC_DCACHE1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DCACHE1EN) != 0U)
  1789. #endif /* DCACHE1 */
  1790. #define __HAL_RCC_SRAM1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_SRAM1EN) != 0U)
  1791. #define __HAL_RCC_GPDMA1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA1EN) == 0U)
  1792. #define __HAL_RCC_GPDMA2_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPDMA2EN) == 0U)
  1793. #define __HAL_RCC_FLASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FLITFEN) == 0U)
  1794. #define __HAL_RCC_CRC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CRCEN) == 0U)
  1795. #if defined(CORDIC)
  1796. #define __HAL_RCC_CORDIC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_CORDICEN) == 0U)
  1797. #endif /* CORDIC */
  1798. #if defined(FMAC)
  1799. #define __HAL_RCC_FMAC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_FMACEN) == 0U)
  1800. #endif /* FMAC */
  1801. #define __HAL_RCC_RAMCFG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_RAMCFGEN) == 0U)
  1802. #if defined(ETH)
  1803. #define __HAL_RCC_ETH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHEN) == 0U)
  1804. #define __HAL_RCC_ETHTX_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHTXEN) == 0U)
  1805. #define __HAL_RCC_ETHRX_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHRXEN) == 0U)
  1806. #endif /*ETH*/
  1807. #define __HAL_RCC_GTZC1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_TZSC1EN) == 0U)
  1808. #define __HAL_RCC_BKPRAM_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_BKPRAMEN) == 0U)
  1809. #if defined(DCACHE1)
  1810. #define __HAL_RCC_DCACHE1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DCACHE1EN) == 0U)
  1811. #endif /* DCACHE1 */
  1812. #define __HAL_RCC_SRAM1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_SRAM1EN) == 0U)
  1813. /**
  1814. * @}
  1815. */
  1816. /** @defgroup RCC_AHB2_Peripheral_Clock_Enable_Disable_Status AHB2 Peripheral Clock Enabled or Disabled Status
  1817. * @brief Check whether the AHB2 peripheral clock is enabled or not.
  1818. * @note After reset, the peripheral clock (used for registers read/write access)
  1819. * is disabled and the application software has to enable this clock before
  1820. * using it.
  1821. * @{
  1822. */
  1823. #define __HAL_RCC_GPIOA_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) != 0U)
  1824. #define __HAL_RCC_GPIOB_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN) != 0U)
  1825. #define __HAL_RCC_GPIOC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) != 0U)
  1826. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) != 0U)
  1827. #if defined(GPIOE)
  1828. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) != 0U)
  1829. #endif /* GPIOE */
  1830. #if defined(GPIOF)
  1831. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) != 0U)
  1832. #endif /* GPIOF */
  1833. #if defined(GPIOG)
  1834. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) != 0U)
  1835. #endif /* GPIOG */
  1836. #define __HAL_RCC_GPIOH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN) != 0U)
  1837. #if defined(GPIOI)
  1838. #define __HAL_RCC_GPIOI_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN) != 0U)
  1839. #endif /* GPIOI */
  1840. #define __HAL_RCC_ADC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN) != 0U)
  1841. #define __HAL_RCC_DAC1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN) != 0U)
  1842. #if defined(DCMI)
  1843. #define __HAL_RCC_DCMI_PSSI_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMI_PSSIEN) != 0U)
  1844. #define __HAL_RCC_DCMI_IS_CLK_ENABLED() __HAL_RCC_DCMI_PSSI_IS_CLK_ENABLED() /* for API backward compatibility */
  1845. #endif /* DCMI */
  1846. #if defined(AES)
  1847. #define __HAL_RCC_AES_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) != 0U)
  1848. #endif /* AES */
  1849. #if defined(HASH)
  1850. #define __HAL_RCC_HASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN) != 0U)
  1851. #endif /* HASH */
  1852. #define __HAL_RCC_RNG_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) != 0U)
  1853. #define __HAL_RCC_PKA_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_PKAEN) != 0U)
  1854. #if defined(SAES)
  1855. #define __HAL_RCC_SAES_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SAESEN) != 0U)
  1856. #endif /*SAES*/
  1857. #define __HAL_RCC_SRAM2_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM2EN) != 0U)
  1858. #if defined(SRAM3_BASE)
  1859. #define __HAL_RCC_SRAM3_IS_CLK_ENABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM3EN) != 0U)
  1860. #endif /* SRAM3_BASE */
  1861. #define __HAL_RCC_GPIOA_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOAEN) == 0U)
  1862. #define __HAL_RCC_GPIOB_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOBEN) == 0U)
  1863. #define __HAL_RCC_GPIOC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOCEN) == 0U)
  1864. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIODEN) == 0U)
  1865. #if defined(GPIOE)
  1866. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOEEN) == 0U)
  1867. #endif /* GPIOE */
  1868. #if defined(GPIOF)
  1869. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOFEN) == 0U)
  1870. #endif /* GPIOF */
  1871. #if defined(GPIOG)
  1872. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOGEN) == 0U)
  1873. #endif /* GPIOG */
  1874. #define __HAL_RCC_GPIOH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOHEN) == 0U)
  1875. #if defined(GPIOI)
  1876. #define __HAL_RCC_GPIOI_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_GPIOIEN) == 0U)
  1877. #endif /* GPIOI */
  1878. #define __HAL_RCC_ADC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_ADCEN) == 0U)
  1879. #define __HAL_RCC_DAC1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DAC1EN) == 0U)
  1880. #if defined(DCMI)
  1881. #define __HAL_RCC_DCMI_PSSI_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMI_PSSIEN) == 0U)
  1882. #define __HAL_RCC_DCMI_IS_CLK_DISABLED() __HAL_RCC_DCMI_PSSI_IS_CLK_DISABLED() /* for API backward compatibility */
  1883. #endif /* DCMI */
  1884. #if defined(AES)
  1885. #define __HAL_RCC_AES_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_AESEN) == 0U)
  1886. #endif /* AES */
  1887. #if defined(HASH)
  1888. #define __HAL_RCC_HASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN) == 0U)
  1889. #endif /* HASH */
  1890. #define __HAL_RCC_RNG_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN) == 0U)
  1891. #define __HAL_RCC_PKA_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_PKAEN) == 0U)
  1892. #if defined(SAES)
  1893. #define __HAL_RCC_SAES_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SAESEN) == 0U)
  1894. #endif /* SAES */
  1895. #define __HAL_RCC_SRAM2_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM2EN) == 0U)
  1896. #if defined(SRAM3_BASE)
  1897. #define __HAL_RCC_SRAM3_IS_CLK_DISABLED() (READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_SRAM3EN) == 0U)
  1898. #endif /* SRAM3_BASE */
  1899. /**
  1900. * @}
  1901. */
  1902. /** @defgroup RCC_AHB4_Peripheral_Clock_Enable_Disable_Status AHB4 Peripheral Clock Enabled or Disabled Status
  1903. * @brief Check whether the AHB4 peripheral clock is enabled or not.
  1904. * @note After reset, the peripheral clock (used for registers read/write access)
  1905. * is disabled and the application software has to enable this clock before
  1906. * using it.
  1907. * @{
  1908. */
  1909. #if defined(OTFDEC1)
  1910. #define __HAL_RCC_OTFDEC1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OTFDEC1EN) != 0U)
  1911. #endif /* OTFDEC1 */
  1912. #if defined(SDMMC1)
  1913. #define __HAL_RCC_SDMMC1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC1EN) != 0U)
  1914. #endif /* SDMMC1 */
  1915. #if defined(SDMMC2)
  1916. #define __HAL_RCC_SDMMC2_IS_CLK_ENABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC2EN) != 0U)
  1917. #endif /* SDMMC2 */
  1918. #if defined(FMC_BASE)
  1919. #define __HAL_RCC_FMC_IS_CLK_ENABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_FMCEN) != 0U)
  1920. #endif /* FMC_BASE */
  1921. #if defined(OCTOSPI1)
  1922. #define __HAL_RCC_OSPI1_IS_CLK_ENABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OCTOSPI1EN) != 0U)
  1923. #endif /* OCTOSPI1 */
  1924. #if defined(OTFDEC1)
  1925. #define __HAL_RCC_OTFDEC1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OTFDEC1EN) == 0U)
  1926. #endif /* OTFDEC1 */
  1927. #if defined(SDMMC1)
  1928. #define __HAL_RCC_SDMMC1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC1EN) == 0U)
  1929. #endif /* SDMMC1 */
  1930. #if defined(SDMMC2)
  1931. #define __HAL_RCC_SDMMC2_IS_CLK_DISABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_SDMMC2EN) == 0U)
  1932. #endif /* SDMMC2 */
  1933. #if defined(FMC_BASE)
  1934. #define __HAL_RCC_FMC_IS_CLK_DISABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_FMCEN) == 0U)
  1935. #endif /* FMC_BASE */
  1936. #if defined(OCTOSPI1)
  1937. #define __HAL_RCC_OSPI1_IS_CLK_DISABLED() (READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_OCTOSPI1EN) == 0U)
  1938. #endif /* OCTOSPI1 */
  1939. /**
  1940. * @}
  1941. */
  1942. /** @defgroup RCC_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enabled or Disabled Status
  1943. * @brief Check whether the APB1 peripheral clock is enabled or not.
  1944. * @note After reset, the peripheral clock (used for registers read/write access)
  1945. * is disabled and the application software has to enable this clock before
  1946. * using it.
  1947. * @{
  1948. */
  1949. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM2EN) != 0U)
  1950. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM3EN) != 0U)
  1951. #if defined(TIM4)
  1952. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM4EN) != 0U)
  1953. #endif /* TIM4 */
  1954. #if defined(TIM5)
  1955. #define __HAL_RCC_TIM5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM5EN) != 0U)
  1956. #endif /* TIM5 */
  1957. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM6EN) != 0U)
  1958. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM7EN) != 0U)
  1959. #if defined(TIM12)
  1960. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM12EN) != 0U)
  1961. #endif /* TIM12 */
  1962. #if defined(TIM13)
  1963. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM13EN) != 0U)
  1964. #endif /* TIM13 */
  1965. #if defined(TIM14)
  1966. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM14EN) != 0U)
  1967. #endif /* TIM14 */
  1968. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_WWDGEN) != 0U)
  1969. #if defined(OPAMP1)
  1970. #define __HAL_RCC_OPAMP_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_OPAMPEN) != 0U)
  1971. #endif /* OPAMP1 */
  1972. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI2EN) != 0U)
  1973. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI3EN) != 0U)
  1974. #if defined(COMP1)
  1975. #define __HAL_RCC_COMP_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_COMPEN) != 0U)
  1976. #endif /* COMP1 */
  1977. #define __HAL_RCC_USART2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART2EN) != 0U)
  1978. #define __HAL_RCC_USART3_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART3EN) != 0U)
  1979. #if defined(UART4)
  1980. #define __HAL_RCC_UART4_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART4EN) != 0U)
  1981. #endif /* UART4 */
  1982. #if defined(UART5)
  1983. #define __HAL_RCC_UART5_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART5EN) != 0U)
  1984. #endif /* UART5 */
  1985. #define __HAL_RCC_I2C1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C1EN) != 0U)
  1986. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C2EN) != 0U)
  1987. #define __HAL_RCC_I3C1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I3C1EN) != 0U)
  1988. #define __HAL_RCC_CRS_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_CRSEN) != 0U)
  1989. #if defined(USART6)
  1990. #define __HAL_RCC_USART6_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART6EN) != 0U)
  1991. #endif /* USART6 */
  1992. #if defined(USART10)
  1993. #define __HAL_RCC_USART10_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART10EN) != 0U)
  1994. #endif /* USART10 */
  1995. #if defined(USART11)
  1996. #define __HAL_RCC_USART11_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART11EN) != 0U)
  1997. #endif /* USART11 */
  1998. #if defined(CEC)
  1999. #define __HAL_RCC_CEC_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_CECEN) != 0U)
  2000. #endif /* CEC */
  2001. #if defined(UART7)
  2002. #define __HAL_RCC_UART7_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART7EN) != 0U)
  2003. #endif /* UART7 */
  2004. #if defined(UART8)
  2005. #define __HAL_RCC_UART8_IS_CLK_ENABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART8EN) != 0U)
  2006. #endif /* UART8 */
  2007. #if defined(UART9)
  2008. #define __HAL_RCC_UART9_IS_CLK_ENABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UART9EN) != 0U)
  2009. #endif /* UART9 */
  2010. #if defined(UART12)
  2011. #define __HAL_RCC_UART12_IS_CLK_ENABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UART12EN) != 0U)
  2012. #endif /* UART12 */
  2013. #define __HAL_RCC_DTS_IS_CLK_ENABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_DTSEN) != 0U)
  2014. #define __HAL_RCC_LPTIM2_IS_CLK_ENABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_LPTIM2EN) != 0U)
  2015. #define __HAL_RCC_FDCAN_IS_CLK_ENABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_FDCANEN) != 0U)
  2016. #if defined(UCPD1)
  2017. #define __HAL_RCC_UCPD1_IS_CLK_ENABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UCPD1EN) != 0U)
  2018. #endif /* UCPD1 */
  2019. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM2EN) == 0U)
  2020. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM3EN) == 0U)
  2021. #if defined(TIM4)
  2022. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM4EN) == 0U)
  2023. #endif /* TIM4 */
  2024. #if defined(TIM5)
  2025. #define __HAL_RCC_TIM5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM5EN) == 0U)
  2026. #endif /* TIM5 */
  2027. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM6EN) == 0U)
  2028. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM7EN) == 0U)
  2029. #if defined(TIM12)
  2030. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM12EN) == 0U)
  2031. #endif /* TIM12 */
  2032. #if defined(TIM13)
  2033. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM13EN) == 0U)
  2034. #endif /* TIM13 */
  2035. #if defined(TIM14)
  2036. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_TIM14EN) == 0U)
  2037. #endif /* TIM14 */
  2038. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_WWDGEN) == 0U)
  2039. #if defined(OPAMP1)
  2040. #define __HAL_RCC_OPAMP_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_OPAMPEN) == 0U)
  2041. #endif /* OPAMP1 */
  2042. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI2EN) == 0U)
  2043. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_SPI3EN) == 0U)
  2044. #if defined(COMP1)
  2045. #define __HAL_RCC_COMP_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_COMPEN) == 0U)
  2046. #endif /* COMP1 */
  2047. #define __HAL_RCC_USART2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART2EN) == 0U)
  2048. #define __HAL_RCC_USART3_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART3EN) == 0U)
  2049. #if defined(UART4)
  2050. #define __HAL_RCC_UART4_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART4EN) == 0U)
  2051. #endif /* UART4 */
  2052. #if defined(UART5)
  2053. #define __HAL_RCC_UART5_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART5EN) == 0U)
  2054. #endif /* UART5 */
  2055. #define __HAL_RCC_I2C1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C1EN) == 0U)
  2056. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I2C2EN) == 0U)
  2057. #define __HAL_RCC_I3C1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_I3C1EN) == 0U)
  2058. #define __HAL_RCC_CRS_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_CRSEN) == 0U)
  2059. #if defined(USART6)
  2060. #define __HAL_RCC_USART6_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART6EN) == 0U)
  2061. #endif /* USART6 */
  2062. #if defined(USART10)
  2063. #define __HAL_RCC_USART10_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART10EN) == 0U)
  2064. #endif /* USART10 */
  2065. #if defined(USART11)
  2066. #define __HAL_RCC_USART11_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_USART11EN) == 0U)
  2067. #endif /* USART11 */
  2068. #if defined(CEC)
  2069. #define __HAL_RCC_CEC_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_CECEN) == 0U)
  2070. #endif /* CEC */
  2071. #if defined(UART7)
  2072. #define __HAL_RCC_UART7_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART7EN) == 0U)
  2073. #endif /* UART7 */
  2074. #if defined(UART8)
  2075. #define __HAL_RCC_UART8_IS_CLK_DISABLED() (READ_BIT(RCC->APB1LENR, RCC_APB1LENR_UART8EN) == 0U)
  2076. #endif /* UART8 */
  2077. #if defined(UART9)
  2078. #define __HAL_RCC_UART9_IS_CLK_DISABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UART9EN) == 0U)
  2079. #endif /* UART9 */
  2080. #if defined(UART12)
  2081. #define __HAL_RCC_UART12_IS_CLK_DISABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UART12EN) == 0U)
  2082. #endif /* UART12 */
  2083. #define __HAL_RCC_DTS_IS_CLK_DISABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_DTSEN) == 0U)
  2084. #define __HAL_RCC_LPTIM2_IS_CLK_DISABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_LPTIM2EN) == 0U)
  2085. #define __HAL_RCC_FDCAN_IS_CLK_DISABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_FDCANEN) == 0U)
  2086. #if defined(UCPD1)
  2087. #define __HAL_RCC_UCPD1_IS_CLK_DISABLED() (READ_BIT(RCC->APB1HENR, RCC_APB1HENR_UCPD1EN) == 0U)
  2088. #endif /* UCPD1 */
  2089. /**
  2090. * @}
  2091. */
  2092. /** @defgroup RCC_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enabled or Disabled Status
  2093. * @brief Check whether the APB2 peripheral clock is enabled or not.
  2094. * @note After reset, the peripheral clock (used for registers read/write access)
  2095. * is disabled and the application software has to enable this clock before
  2096. * using it.
  2097. * @{
  2098. */
  2099. #define __HAL_RCC_TIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) != 0U)
  2100. #define __HAL_RCC_SPI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) != 0U)
  2101. #if defined(TIM8)
  2102. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) != 0U)
  2103. #endif /* TIM8 */
  2104. #define __HAL_RCC_USART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) != 0U)
  2105. #if defined(TIM15)
  2106. #define __HAL_RCC_TIM15_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) != 0U)
  2107. #endif /* TIM15 */
  2108. #if defined(TIM16)
  2109. #define __HAL_RCC_TIM16_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) != 0U)
  2110. #endif /* TIM16 */
  2111. #if defined(TIM17)
  2112. #define __HAL_RCC_TIM17_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) != 0U)
  2113. #endif /* TIM17 */
  2114. #if defined(SPI4)
  2115. #define __HAL_RCC_SPI4_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN) != 0U)
  2116. #endif /* SPI4 */
  2117. #if defined(SPI6)
  2118. #define __HAL_RCC_SPI6_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN) != 0U)
  2119. #endif /* SPI6 */
  2120. #if defined(SAI1)
  2121. #define __HAL_RCC_SAI1_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) != 0U)
  2122. #endif /* SAI1 */
  2123. #if defined(SAI2)
  2124. #define __HAL_RCC_SAI2_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN) != 0U)
  2125. #endif /* SAI2 */
  2126. #if defined(USB_DRD_FS)
  2127. #define __HAL_RCC_USB_IS_CLK_ENABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USBEN) != 0U)
  2128. #endif /* USB_DRD_FS */
  2129. #define __HAL_RCC_TIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN) == 0U)
  2130. #define __HAL_RCC_SPI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN) == 0U)
  2131. #if defined(TIM8)
  2132. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN) == 0U)
  2133. #endif /* TIM8 */
  2134. #define __HAL_RCC_USART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN) == 0U)
  2135. #if defined(TIM15)
  2136. #define __HAL_RCC_TIM15_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN) == 0U)
  2137. #endif /* TIM15 */
  2138. #if defined(TIM16)
  2139. #define __HAL_RCC_TIM16_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN) == 0U)
  2140. #endif /* TIM16 */
  2141. #if defined(TIM17)
  2142. #define __HAL_RCC_TIM17_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN) == 0U)
  2143. #endif /* TIM17 */
  2144. #if defined(SPI4)
  2145. #define __HAL_RCC_SPI4_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI4EN) == 0U)
  2146. #endif /* SPI4 */
  2147. #if defined(SPI6)
  2148. #define __HAL_RCC_SPI6_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN) == 0U)
  2149. #endif /* SPI6 */
  2150. #if defined(SAI1)
  2151. #define __HAL_RCC_SAI1_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN) == 0U)
  2152. #endif /* SAI1 */
  2153. #if defined(SAI2)
  2154. #define __HAL_RCC_SAI2_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN) == 0U)
  2155. #endif /* SAI2 */
  2156. #if defined(USB_DRD_FS)
  2157. #define __HAL_RCC_USB_IS_CLK_DISABLED() (READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USBEN) == 0U)
  2158. #endif /* USB_DRD_FS */
  2159. /**
  2160. * @}
  2161. */
  2162. /** @defgroup RCC_APB3_Peripheral_Clock_Enable_Disable_Status APB3 Peripheral Clock Enabled or Disabled Status
  2163. * @brief Check whether the APB3 peripheral clock is enabled or not.
  2164. * @note After reset, the peripheral clock (used for registers read/write access)
  2165. * is disabled and the application software has to enable this clock before
  2166. * using it.
  2167. * @{
  2168. */
  2169. #define __HAL_RCC_SBS_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_SBSEN) != 0U)
  2170. #if defined(SPI5)
  2171. #define __HAL_RCC_SPI5_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_SPI5EN) != 0U)
  2172. #endif /* SPI5 */
  2173. #define __HAL_RCC_LPUART1_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPUART1EN) != 0U)
  2174. #if defined(I2C3)
  2175. #define __HAL_RCC_I2C3_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C3EN) != 0U)
  2176. #endif /* I2C3 */
  2177. #if defined(I2C4)
  2178. #define __HAL_RCC_I2C4_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C4EN) != 0U)
  2179. #endif /* I2C4 */
  2180. #if defined(I3C2)
  2181. #define __HAL_RCC_I3C2_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I3C2EN) != 0U)
  2182. #endif /* I3C2 */
  2183. #define __HAL_RCC_LPTIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM1EN) != 0U)
  2184. #if defined(LPTIM3)
  2185. #define __HAL_RCC_LPTIM3_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM3EN) != 0U)
  2186. #endif /* LPTIM3 */
  2187. #if defined(LPTIM4)
  2188. #define __HAL_RCC_LPTIM4_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM4EN) != 0U)
  2189. #endif /* LPTIM4 */
  2190. #if defined(LPTIM5)
  2191. #define __HAL_RCC_LPTIM5_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM5EN) != 0U)
  2192. #endif /* LPTIM5 */
  2193. #if defined(LPTIM6)
  2194. #define __HAL_RCC_LPTIM6_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM6EN) != 0U)
  2195. #endif /* LPTIM6 */
  2196. #if defined(VREFBUF)
  2197. #define __HAL_RCC_VREF_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_VREFEN) != 0U)
  2198. #endif /* VREFBUF */
  2199. #define __HAL_RCC_RTC_IS_CLK_ENABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_RTCAPBEN) != 0U)
  2200. #define __HAL_RCC_SBS_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_SBSEN) == 0U)
  2201. #if defined(SPI5)
  2202. #define __HAL_RCC_SPI5_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_SPI5EN) == 0U)
  2203. #endif /* SPI5 */
  2204. #define __HAL_RCC_LPUART1_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPUART1EN) == 0U)
  2205. #if defined(I2C3)
  2206. #define __HAL_RCC_I2C3_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C3EN) == 0U)
  2207. #endif /* I2C3 */
  2208. #if defined(I2C4)
  2209. #define __HAL_RCC_I2C4_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I2C4EN) == 0U)
  2210. #endif /* I2C4 */
  2211. #if defined(I3C2)
  2212. #define __HAL_RCC_I3C2_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_I3C2EN) == 0U)
  2213. #endif /* I3C2 */
  2214. #define __HAL_RCC_LPTIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM1EN) == 0U)
  2215. #if defined(LPTIM3)
  2216. #define __HAL_RCC_LPTIM3_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM3EN) == 0U)
  2217. #endif /* LPTIM3 */
  2218. #if defined(LPTIM4)
  2219. #define __HAL_RCC_LPTIM4_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM4EN) == 0U)
  2220. #endif /* LPTIM4 */
  2221. #if defined(LPTIM5)
  2222. #define __HAL_RCC_LPTIM5_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM5EN) == 0U)
  2223. #endif /* LPTIM5 */
  2224. #if defined(LPTIM6)
  2225. #define __HAL_RCC_LPTIM6_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_LPTIM6EN) == 0U)
  2226. #endif /* LPTIM6 */
  2227. #if defined(VREFBUF)
  2228. #define __HAL_RCC_VREF_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_VREFEN) == 0U)
  2229. #endif /* VREFBUF */
  2230. #define __HAL_RCC_RTC_IS_CLK_DISABLED() (READ_BIT(RCC->APB3ENR, RCC_APB3ENR_RTCAPBEN) == 0U)
  2231. /**
  2232. * @}
  2233. */
  2234. /** @defgroup RCC_AHB_APB_Branch_Clock_Disable_Status AHB APB Branch Clock Disabled Status
  2235. * @brief Check whether the AHBx/APBx branch clock for all AHBx/APBx peripherals is disabled or not.
  2236. * @note It is recommended to disable the clock of all peripherals (by writing 0 in
  2237. * the AHBxENR/APBxENR register) before Disabling the corresponding Bus Branch clock.
  2238. * Some peripheral bus clocks are not affected by branch clock disabling as IWDG (APB1),
  2239. * SRAM2/SRAM3 (AHB2) and FLITF/BKRAM/ICACHE/DCACHE/SRAM1 (AHB1).
  2240. * @{
  2241. */
  2242. #define __HAL_RCC_AHB1_IS_CLK_DISABLED() (READ_BIT(RCC->CFGR2, RCC_CFGR2_AHB1DIS) != 0U)
  2243. #define __HAL_RCC_AHB2_IS_CLK_DISABLED() (READ_BIT(RCC->CFGR2, RCC_CFGR2_AHB2DIS) != 0U)
  2244. #if defined(AHB4PERIPH_BASE)
  2245. #define __HAL_RCC_AHB4_IS_CLK_DISABLED() (READ_BIT(RCC->CFGR2, RCC_CFGR2_AHB4DIS) != 0U)
  2246. #endif /* AHB4PERIPH_BASE */
  2247. #define __HAL_RCC_APB1_IS_CLK_DISABLED() (READ_BIT(RCC->CFGR2, RCC_CFGR2_APB1DIS) != 0U)
  2248. #define __HAL_RCC_APB2_IS_CLK_DISABLED() (READ_BIT(RCC->CFGR2, RCC_CFGR2_APB2DIS) != 0U)
  2249. #define __HAL_RCC_APB3_IS_CLK_DISABLED() (READ_BIT(RCC->CFGR2, RCC_CFGR2_APB3DIS) != 0U)
  2250. /**
  2251. * @}
  2252. */
  2253. /** @defgroup RCC_AHB1_Force_Release_Reset AHB1 Peripheral Force Release Reset
  2254. * @brief Force or release AHB1 peripheral reset.
  2255. * @{
  2256. */
  2257. #define __HAL_RCC_AHB1_FORCE_RESET() WRITE_REG(RCC->AHB1RSTR, 0x010AD003U)
  2258. #define __HAL_RCC_GPDMA1_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_GPDMA1RST)
  2259. #define __HAL_RCC_GPDMA2_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_GPDMA2RST)
  2260. #if defined(CORDIC)
  2261. #define __HAL_RCC_CORDIC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CORDICRST)
  2262. #endif /* CORDIC */
  2263. #if defined(FMAC)
  2264. #define __HAL_RCC_FMAC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FMACRST)
  2265. #endif /* FMAC */
  2266. #define __HAL_RCC_CRC_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  2267. #define __HAL_RCC_RAMCFG_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_RAMCFGRST)
  2268. #if defined(ETH)
  2269. #define __HAL_RCC_ETH_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_ETHRST)
  2270. #endif /* ETH */
  2271. #define __HAL_RCC_GTZC1_FORCE_RESET() SET_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_TZSC1RST)
  2272. #define __HAL_RCC_AHB1_RELEASE_RESET() WRITE_REG(RCC->AHB1RSTR, 0x00000000U)
  2273. #define __HAL_RCC_GPDMA1_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_GPDMA1RST)
  2274. #define __HAL_RCC_GPDMA2_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_GPDMA2RST)
  2275. #if defined(CORDIC)
  2276. #define __HAL_RCC_CORDIC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CORDICRST)
  2277. #endif /* CORDIC */
  2278. #if defined(FMAC)
  2279. #define __HAL_RCC_FMAC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_FMACRST)
  2280. #endif /* FMAC */
  2281. #define __HAL_RCC_CRC_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_CRCRST)
  2282. #define __HAL_RCC_RAMCFG_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_RAMCFGRST)
  2283. #if defined(ETH)
  2284. #define __HAL_RCC_ETH_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_ETHRST)
  2285. #endif /* ETH */
  2286. #define __HAL_RCC_GTZC1_RELEASE_RESET() CLEAR_BIT(RCC->AHB1RSTR, RCC_AHB1RSTR_TZSC1RST)
  2287. /**
  2288. * @}
  2289. */
  2290. /** @defgroup RCC_AHB2_Force_Release_Reset AHB2 Peripheral Force Release Reset
  2291. * @brief Force or release AHB2 peripheral reset.
  2292. * @{
  2293. */
  2294. #define __HAL_RCC_AHB2_FORCE_RESET() WRITE_REG(RCC->AHB2RSTR, 0x001F1DFFU)
  2295. #define __HAL_RCC_GPIOA_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  2296. #define __HAL_RCC_GPIOB_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  2297. #define __HAL_RCC_GPIOC_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  2298. #define __HAL_RCC_GPIOD_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  2299. #if defined(GPIOE)
  2300. #define __HAL_RCC_GPIOE_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  2301. #endif /* GPIOE */
  2302. #if defined(GPIOF)
  2303. #define __HAL_RCC_GPIOF_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  2304. #endif /* GPIOF */
  2305. #if defined(GPIOG)
  2306. #define __HAL_RCC_GPIOG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  2307. #endif /* GPIOG */
  2308. #define __HAL_RCC_GPIOH_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOHRST)
  2309. #if defined(GPIOI)
  2310. #define __HAL_RCC_GPIOI_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOIRST)
  2311. #endif /* GPIOI */
  2312. #define __HAL_RCC_ADC_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADCRST)
  2313. #define __HAL_RCC_DAC1_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC1RST)
  2314. #if defined(DCMI)
  2315. #define __HAL_RCC_DCMI_PSSI_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DCMI_PSSIRST)
  2316. #define __HAL_RCC_DCMI_FORCE_RESET() __HAL_RCC_DCMI_PSSI_FORCE_RESET() /* for API backward compatibility */
  2317. #endif /* DCMI */
  2318. #if defined(AES)
  2319. #define __HAL_RCC_AES_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  2320. #endif /* AES */
  2321. #if defined(HASH)
  2322. #define __HAL_RCC_HASH_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_HASHRST)
  2323. #endif /* HASH */
  2324. #define __HAL_RCC_RNG_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  2325. #if defined(PKA)
  2326. #define __HAL_RCC_PKA_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_PKARST)
  2327. #endif /* PKA */
  2328. #if defined(SAES)
  2329. #define __HAL_RCC_SAES_FORCE_RESET() SET_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_SAESRST)
  2330. #endif /* SAES*/
  2331. #define __HAL_RCC_AHB2_RELEASE_RESET() WRITE_REG(RCC->AHB2RSTR, 0x00000000U)
  2332. #define __HAL_RCC_GPIOA_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOARST)
  2333. #define __HAL_RCC_GPIOB_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOBRST)
  2334. #define __HAL_RCC_GPIOC_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOCRST)
  2335. #define __HAL_RCC_GPIOD_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIODRST)
  2336. #if defined(GPIOE)
  2337. #define __HAL_RCC_GPIOE_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOERST)
  2338. #endif /* GPIOE */
  2339. #if defined(GPIOF)
  2340. #define __HAL_RCC_GPIOF_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOFRST)
  2341. #endif /* GPIOF */
  2342. #if defined(GPIOG)
  2343. #define __HAL_RCC_GPIOG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOGRST)
  2344. #endif /* GPIOG */
  2345. #define __HAL_RCC_GPIOH_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOHRST)
  2346. #if defined(GPIOG)
  2347. #define __HAL_RCC_GPIOI_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_GPIOIRST)
  2348. #endif /* GPIOI */
  2349. #define __HAL_RCC_ADC_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_ADCRST)
  2350. #define __HAL_RCC_DAC1_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DAC1RST)
  2351. #if defined(DCMI)
  2352. #define __HAL_RCC_DCMI_PSSI_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_DCMI_PSSIRST)
  2353. #define __HAL_RCC_DCMI_RELEASE_RESET() __HAL_RCC_DCMI_PSSI_RELEASE_RESET() /* for API backward compatibility */
  2354. #endif /* DCMI */
  2355. #if defined(AES)
  2356. #define __HAL_RCC_AES_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_AESRST)
  2357. #endif /* AES */
  2358. #if defined(HASH)
  2359. #define __HAL_RCC_HASH_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_HASHRST)
  2360. #endif /* HASH */
  2361. #define __HAL_RCC_RNG_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_RNGRST)
  2362. #if defined(PKA)
  2363. #define __HAL_RCC_PKA_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_PKARST)
  2364. #endif /* PKA */
  2365. #if defined(SAES)
  2366. #define __HAL_RCC_SAES_RELEASE_RESET() CLEAR_BIT(RCC->AHB2RSTR, RCC_AHB2RSTR_SAESRST)
  2367. #endif /* SAES*/
  2368. /**
  2369. * @}
  2370. */
  2371. /** @defgroup RCC_AHB4_Force_Release_Reset AHB4 Peripheral Force Release Reset
  2372. * @brief Force or release AHB4 peripheral reset.
  2373. * @{
  2374. */
  2375. #if defined(FMC_BASE)
  2376. #define __HAL_RCC_AHB4_FORCE_RESET() WRITE_REG(RCC->AHB4RSTR, 0x00111880U)
  2377. #endif /* FMC_BASE */
  2378. #if defined(OTFDEC1)
  2379. #define __HAL_RCC_OTFDEC1_FORCE_RESET() SET_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_OTFDEC1RST)
  2380. #endif /* OTFDEC1 */
  2381. #if defined(SDMMC1)
  2382. #define __HAL_RCC_SDMMC1_FORCE_RESET() SET_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_SDMMC1RST)
  2383. #endif /* SDMMC1 */
  2384. #if defined(SDMMC2)
  2385. #define __HAL_RCC_SDMMC2_FORCE_RESET() SET_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_SDMMC2RST)
  2386. #endif /* SDMMC2 */
  2387. #if defined(FMC_BASE)
  2388. #define __HAL_RCC_FMC_FORCE_RESET() SET_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_FMCRST)
  2389. #endif /* FMC_BASE */
  2390. #if defined(OCTOSPI1)
  2391. #define __HAL_RCC_OSPI1_FORCE_RESET() SET_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_OCTOSPI1RST)
  2392. #endif /* OCTOSPI1 */
  2393. #if defined(FMC_BASE)
  2394. #define __HAL_RCC_AHB4_RELEASE_RESET() WRITE_REG(RCC->AHB4RSTR, 0x00000000U)
  2395. #endif /* FMC_BASE */
  2396. #if defined(OTFDEC1)
  2397. #define __HAL_RCC_OTFDEC1_RELEASE_RESET() CLEAR_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_OTFDEC1RST)
  2398. #endif /* OTFDEC1 */
  2399. #if defined(SDMMC1)
  2400. #define __HAL_RCC_SDMMC1_RELEASE_RESET() CLEAR_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_SDMMC1RST)
  2401. #endif /* SDMMC1 */
  2402. #if defined(SDMMC2)
  2403. #define __HAL_RCC_SDMMC2_RELEASE_RESET() CLEAR_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_SDMMC2RST)
  2404. #endif /* SDMMC2 */
  2405. #if defined(FMC_BASE)
  2406. #define __HAL_RCC_FMC_RELEASE_RESET() CLEAR_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_FMCRST)
  2407. #endif /* FMC_BASE */
  2408. #if defined(OCTOSPI1)
  2409. #define __HAL_RCC_OSPI1_RELEASE_RESET() CLEAR_BIT(RCC->AHB4RSTR, RCC_AHB4RSTR_OCTOSPI1RST)
  2410. #endif /* OCTOSPI1 */
  2411. /**
  2412. * @}
  2413. */
  2414. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Peripheral Force Release Reset
  2415. * @brief Force or release APB1 peripheral reset.
  2416. * @{
  2417. */
  2418. #define __HAL_RCC_APB1_FORCE_RESET() do { \
  2419. WRITE_REG(RCC->APB1LRSTR, 0xDFFEC1FFU); \
  2420. WRITE_REG(RCC->APB1HRSTR, 0x4080062BU); \
  2421. } while(0)
  2422. #define __HAL_RCC_TIM2_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM2RST)
  2423. #define __HAL_RCC_TIM3_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM3RST)
  2424. #if defined(TIM4)
  2425. #define __HAL_RCC_TIM4_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM4RST)
  2426. #endif /* TIM4 */
  2427. #if defined(TIM5)
  2428. #define __HAL_RCC_TIM5_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM5RST)
  2429. #endif /* TIM5 */
  2430. #define __HAL_RCC_TIM6_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM6RST)
  2431. #define __HAL_RCC_TIM7_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM7RST)
  2432. #if defined(TIM12)
  2433. #define __HAL_RCC_TIM12_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM12RST)
  2434. #endif /* TIM12 */
  2435. #if defined(TIM13)
  2436. #define __HAL_RCC_TIM13_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM13RST)
  2437. #endif /* TIM13 */
  2438. #if defined(TIM14)
  2439. #define __HAL_RCC_TIM14_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM14RST)
  2440. #endif /* TIM14 */
  2441. #if defined(OPAMP1)
  2442. #define __HAL_RCC_OPAMP_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_OPAMPRST)
  2443. #endif /* OPAMP1 */
  2444. #define __HAL_RCC_SPI2_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_SPI2RST)
  2445. #define __HAL_RCC_SPI3_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_SPI3RST)
  2446. #if defined(COMP1)
  2447. #define __HAL_RCC_COMP_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_COMPRST)
  2448. #endif /* COMP1 */
  2449. #define __HAL_RCC_USART2_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART2RST)
  2450. #define __HAL_RCC_USART3_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART3RST)
  2451. #if defined(UART4)
  2452. #define __HAL_RCC_UART4_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART4RST)
  2453. #endif /* UART4 */
  2454. #if defined(UART5)
  2455. #define __HAL_RCC_UART5_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART5RST)
  2456. #endif /* UART5 */
  2457. #define __HAL_RCC_I2C1_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_I2C1RST)
  2458. #define __HAL_RCC_I2C2_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_I2C2RST)
  2459. #define __HAL_RCC_I3C1_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_I3C1RST)
  2460. #define __HAL_RCC_CRS_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_CRSRST)
  2461. #if defined(USART6)
  2462. #define __HAL_RCC_USART6_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART6RST)
  2463. #endif /* USART6 */
  2464. #if defined(USART10)
  2465. #define __HAL_RCC_USART10_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART10RST)
  2466. #endif /* USART10 */
  2467. #if defined(USART11)
  2468. #define __HAL_RCC_USART11_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART11RST)
  2469. #endif /* USART11 */
  2470. #if defined(CEC)
  2471. #define __HAL_RCC_CEC_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_CECRST)
  2472. #endif /* CEC */
  2473. #if defined(UART7)
  2474. #define __HAL_RCC_UART7_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART7RST)
  2475. #endif /* UART7 */
  2476. #if defined(UART8)
  2477. #define __HAL_RCC_UART8_FORCE_RESET() SET_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART8RST)
  2478. #endif /* UART8 */
  2479. #if defined(UART9)
  2480. #define __HAL_RCC_UART9_FORCE_RESET() SET_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_UART9RST)
  2481. #endif /* UART9 */
  2482. #if defined(UART12)
  2483. #define __HAL_RCC_UART12_FORCE_RESET() SET_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_UART12RST)
  2484. #endif /* UART12 */
  2485. #define __HAL_RCC_DTS_FORCE_RESET() SET_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_DTSRST)
  2486. #define __HAL_RCC_LPTIM2_FORCE_RESET() SET_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_LPTIM2RST)
  2487. #define __HAL_RCC_FDCAN_FORCE_RESET() SET_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_FDCANRST)
  2488. #if defined(UCPD1)
  2489. #define __HAL_RCC_UCPD1_FORCE_RESET() SET_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_UCPD1RST)
  2490. #endif /* UCPD1 */
  2491. #define __HAL_RCC_APB1_RELEASE_RESET() do { \
  2492. WRITE_REG(RCC->APB1LRSTR, 0x00000000U); \
  2493. WRITE_REG(RCC->APB1HRSTR, 0x00000000U); \
  2494. } while(0)
  2495. #define __HAL_RCC_TIM2_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM2RST)
  2496. #define __HAL_RCC_TIM3_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM3RST)
  2497. #if defined(TIM4)
  2498. #define __HAL_RCC_TIM4_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM4RST)
  2499. #endif /* TIM4 */
  2500. #if defined(TIM5)
  2501. #define __HAL_RCC_TIM5_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM5RST)
  2502. #endif /* TIM5 */
  2503. #define __HAL_RCC_TIM6_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM6RST)
  2504. #define __HAL_RCC_TIM7_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM7RST)
  2505. #if defined(TIM12)
  2506. #define __HAL_RCC_TIM12_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM12RST)
  2507. #endif /* TIM12 */
  2508. #if defined(TIM13)
  2509. #define __HAL_RCC_TIM13_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM13RST)
  2510. #endif /* TIM13 */
  2511. #if defined(TIM14)
  2512. #define __HAL_RCC_TIM14_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_TIM14RST)
  2513. #endif /* TIM14 */
  2514. #if defined(OPAMP1)
  2515. #define __HAL_RCC_OPAMP_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_OPAMPRST)
  2516. #endif /* OPAMP1 */
  2517. #define __HAL_RCC_SPI2_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_SPI2RST)
  2518. #define __HAL_RCC_SPI3_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_SPI3RST)
  2519. #if defined(COMP1)
  2520. #define __HAL_RCC_COMP_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_COMPRST)
  2521. #endif /* COMP1 */
  2522. #define __HAL_RCC_USART2_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART2RST)
  2523. #define __HAL_RCC_USART3_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART3RST)
  2524. #if defined(UART4)
  2525. #define __HAL_RCC_UART4_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART4RST)
  2526. #endif /* UART4 */
  2527. #if defined(UART5)
  2528. #define __HAL_RCC_UART5_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART5RST)
  2529. #endif /* UART5 */
  2530. #define __HAL_RCC_I2C1_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_I2C1RST)
  2531. #define __HAL_RCC_I2C2_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_I2C2RST)
  2532. #define __HAL_RCC_I3C1_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_I3C1RST)
  2533. #define __HAL_RCC_CRS_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_CRSRST)
  2534. #if defined(USART6)
  2535. #define __HAL_RCC_USART6_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART6RST)
  2536. #endif /* USART6 */
  2537. #if defined(USART10)
  2538. #define __HAL_RCC_USART10_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART10RST)
  2539. #endif /* USART10 */
  2540. #if defined(USART11)
  2541. #define __HAL_RCC_USART11_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_USART11RST)
  2542. #endif /* USART11 */
  2543. #if defined(CEC)
  2544. #define __HAL_RCC_CEC_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_CECRST)
  2545. #endif /* CEC */
  2546. #if defined(UART7)
  2547. #define __HAL_RCC_UART7_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART7RST)
  2548. #endif /* UART7 */
  2549. #if defined(UART8)
  2550. #define __HAL_RCC_UART8_RELEASE_RESET() CLEAR_BIT(RCC->APB1LRSTR, RCC_APB1LRSTR_UART8RST)
  2551. #endif /* UART8 */
  2552. #if defined(UART9)
  2553. #define __HAL_RCC_UART9_RELEASE_RESET() CLEAR_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_UART9RST)
  2554. #endif /* UART9 */
  2555. #if defined(UART12)
  2556. #define __HAL_RCC_UART12_RELEASE_RESET() CLEAR_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_UART12RST)
  2557. #endif /* UART12 */
  2558. #define __HAL_RCC_DTS_RELEASE_RESET() CLEAR_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_DTSRST)
  2559. #define __HAL_RCC_LPTIM2_RELEASE_RESET() CLEAR_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_LPTIM2RST)
  2560. #define __HAL_RCC_FDCAN_RELEASE_RESET() CLEAR_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_FDCANRST)
  2561. #if defined(UCPD1)
  2562. #define __HAL_RCC_UCPD1_RELEASE_RESET() CLEAR_BIT(RCC->APB1HRSTR, RCC_APB1HRSTR_UCPD1RST)
  2563. #endif /* UCPD1 */
  2564. /**
  2565. * @}
  2566. */
  2567. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Peripheral Force Release Reset
  2568. * @brief Force or release APB2 peripheral reset.
  2569. * @{
  2570. */
  2571. #define __HAL_RCC_APB2_FORCE_RESET() WRITE_REG(RCC->APB2RSTR, 0x017F7800U)
  2572. #define __HAL_RCC_TIM1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  2573. #define __HAL_RCC_SPI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  2574. #if defined(TIM8)
  2575. #define __HAL_RCC_TIM8_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  2576. #endif /* TIM8 */
  2577. #define __HAL_RCC_USART1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  2578. #if defined(TIM15)
  2579. #define __HAL_RCC_TIM15_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  2580. #endif /* TIM15 */
  2581. #if defined(TIM16)
  2582. #define __HAL_RCC_TIM16_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  2583. #endif /* TIM16 */
  2584. #if defined(TIM17)
  2585. #define __HAL_RCC_TIM17_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  2586. #endif /* TIM17 */
  2587. #if defined(SPI4)
  2588. #define __HAL_RCC_SPI4_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI4RST)
  2589. #endif /* SPI4 */
  2590. #if defined(SPI6)
  2591. #define __HAL_RCC_SPI6_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI6RST)
  2592. #endif /* SPI6 */
  2593. #if defined(SAI1)
  2594. #define __HAL_RCC_SAI1_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  2595. #endif /* SAI1 */
  2596. #if defined(SAI2)
  2597. #define __HAL_RCC_SAI2_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI2RST)
  2598. #endif /* SAI2 */
  2599. #if defined(USB_DRD_FS)
  2600. #define __HAL_RCC_USB_FORCE_RESET() SET_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USBRST)
  2601. #endif /* USB_DRD_FS */
  2602. #define __HAL_RCC_APB2_RELEASE_RESET() WRITE_REG(RCC->APB2RSTR, 0x00000000U)
  2603. #define __HAL_RCC_TIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM1RST)
  2604. #define __HAL_RCC_SPI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI1RST)
  2605. #if defined(TIM8)
  2606. #define __HAL_RCC_TIM8_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM8RST)
  2607. #endif /* TIM8 */
  2608. #define __HAL_RCC_USART1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USART1RST)
  2609. #if defined(TIM15)
  2610. #define __HAL_RCC_TIM15_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM15RST)
  2611. #endif /* TIM15 */
  2612. #if defined(TIM16)
  2613. #define __HAL_RCC_TIM16_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM16RST)
  2614. #endif /* TIM16 */
  2615. #if defined(TIM17)
  2616. #define __HAL_RCC_TIM17_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_TIM17RST)
  2617. #endif /* TIM17 */
  2618. #if defined(SPI4)
  2619. #define __HAL_RCC_SPI4_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI4RST)
  2620. #endif /* SPI4 */
  2621. #if defined(SPI6)
  2622. #define __HAL_RCC_SPI6_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SPI6RST)
  2623. #endif /* SPI6 */
  2624. #if defined(SAI1)
  2625. #define __HAL_RCC_SAI1_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI1RST)
  2626. #endif /* SAI1 */
  2627. #if defined(SAI2)
  2628. #define __HAL_RCC_SAI2_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_SAI2RST)
  2629. #endif /* SAI2 */
  2630. #if defined(USB_DRD_FS)
  2631. #define __HAL_RCC_USB_RELEASE_RESET() CLEAR_BIT(RCC->APB2RSTR, RCC_APB2RSTR_USBRST)
  2632. #endif /* USB_DRD_FS */
  2633. /**
  2634. * @}
  2635. */
  2636. /** @defgroup RCC_APB3_Force_Release_Reset APB3 Peripheral Force Release Reset
  2637. * @brief Force or release APB3 peripheral reset.
  2638. * @{
  2639. */
  2640. #define __HAL_RCC_APB3_FORCE_RESET() WRITE_REG(RCC->APB3RSTR, 0x001008E0U)
  2641. #if defined(SPI5)
  2642. #define __HAL_RCC_SPI5_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_SPI5RST)
  2643. #endif /* SPI5 */
  2644. #define __HAL_RCC_LPUART1_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPUART1RST)
  2645. #if defined(I2C3)
  2646. #define __HAL_RCC_I2C3_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_I2C3RST)
  2647. #endif /* I2C3 */
  2648. #if defined(I2C4)
  2649. #define __HAL_RCC_I2C4_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_I2C4RST)
  2650. #endif /* I2C4 */
  2651. #if defined(I3C2)
  2652. #define __HAL_RCC_I3C2_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_I3C2RST)
  2653. #endif /* I3C2 */
  2654. #define __HAL_RCC_LPTIM1_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM1RST)
  2655. #if defined(LPTIM3)
  2656. #define __HAL_RCC_LPTIM3_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM3RST)
  2657. #endif /* LPTIM3 */
  2658. #if defined(LPTIM4)
  2659. #define __HAL_RCC_LPTIM4_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM4RST)
  2660. #endif /* LPTIM4 */
  2661. #if defined(LPTIM5)
  2662. #define __HAL_RCC_LPTIM5_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM5RST)
  2663. #endif /* LPTIM5 */
  2664. #if defined(LPTIM6)
  2665. #define __HAL_RCC_LPTIM6_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM6RST)
  2666. #endif /* LPTIM6 */
  2667. #if defined(VREFBUF)
  2668. #define __HAL_RCC_VREF_FORCE_RESET() SET_BIT(RCC->APB3RSTR, RCC_APB3RSTR_VREFRST)
  2669. #endif /* VREFBUF */
  2670. #define __HAL_RCC_APB3_RELEASE_RESET() WRITE_REG(RCC->APB3RSTR, 0x00000000U)
  2671. #if defined(SPI5)
  2672. #define __HAL_RCC_SPI5_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_SPI5RST)
  2673. #endif /* SPI5 */
  2674. #define __HAL_RCC_LPUART1_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPUART1RST)
  2675. #if defined(I2C3)
  2676. #define __HAL_RCC_I2C3_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_I2C3RST)
  2677. #endif /* I2C3 */
  2678. #if defined(I2C4)
  2679. #define __HAL_RCC_I2C4_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_I2C4RST)
  2680. #endif /* I2C4 */
  2681. #if defined(I3C2)
  2682. #define __HAL_RCC_I3C2_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_I3C2RST)
  2683. #endif /* I3C2 */
  2684. #define __HAL_RCC_LPTIM1_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM1RST)
  2685. #if defined(LPTIM3)
  2686. #define __HAL_RCC_LPTIM3_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM3RST)
  2687. #endif /* LPTIM3 */
  2688. #if defined(LPTIM4)
  2689. #define __HAL_RCC_LPTIM4_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM4RST)
  2690. #endif /* LPTIM4 */
  2691. #if defined(LPTIM5)
  2692. #define __HAL_RCC_LPTIM5_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM5RST)
  2693. #endif /* LPTIM5 */
  2694. #if defined(LPTIM6)
  2695. #define __HAL_RCC_LPTIM6_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_LPTIM6RST)
  2696. #endif /* LPTIM6 */
  2697. #if defined(VREFBUF)
  2698. #define __HAL_RCC_VREF_RELEASE_RESET() CLEAR_BIT(RCC->APB3RSTR, RCC_APB3RSTR_VREFRST)
  2699. #endif /* VREFBUF */
  2700. /**
  2701. * @}
  2702. */
  2703. /** @defgroup RCC_AHB1_Peripheral_Clock_Sleep_Enable_Disable AHB1 Peripheral Clock Sleep Enable Disable
  2704. * @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  2705. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2706. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2707. * @{
  2708. */
  2709. #define __HAL_RCC_GPDMA1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_GPDMA1LPEN)
  2710. #define __HAL_RCC_GPDMA2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_GPDMA2LPEN)
  2711. #define __HAL_RCC_FLASH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_FLITFLPEN)
  2712. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_CRCLPEN)
  2713. #if defined(CORDIC)
  2714. #define __HAL_RCC_CORDIC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_CORDICLPEN)
  2715. #endif /* CORDIC */
  2716. #if defined(FMAC)
  2717. #define __HAL_RCC_FMAC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_FMACLPEN)
  2718. #endif /* FMAC */
  2719. #define __HAL_RCC_RAMCFG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_RAMCFGLPEN)
  2720. #if defined(ETH)
  2721. #define __HAL_RCC_ETH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ETHLPEN)
  2722. #define __HAL_RCC_ETHTX_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ETHTXLPEN)
  2723. #define __HAL_RCC_ETHRX_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ETHRXLPEN)
  2724. #endif /* ETH */
  2725. #define __HAL_RCC_GTZC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_TZSC1LPEN)
  2726. #define __HAL_RCC_BKPRAM_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_BKPRAMLPEN)
  2727. #define __HAL_RCC_ICACHE_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ICACHELPEN)
  2728. #if defined(DCACHE1)
  2729. #define __HAL_RCC_DCACHE1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_DCACHE1LPEN)
  2730. #endif /* DCACHE1 */
  2731. #define __HAL_RCC_SRAM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_SRAM1LPEN)
  2732. #define __HAL_RCC_GPDMA1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_GPDMA1LPEN)
  2733. #define __HAL_RCC_GPDMA2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_GPDMA2LPEN)
  2734. #define __HAL_RCC_FLASH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_FLITFLPEN)
  2735. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_CRCLPEN)
  2736. #if defined(CORDIC)
  2737. #define __HAL_RCC_CORDIC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_CORDICLPEN)
  2738. #endif /* CORDIC */
  2739. #if defined(FMAC)
  2740. #define __HAL_RCC_FMAC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_FMACLPEN)
  2741. #endif /* FMAC */
  2742. #define __HAL_RCC_RAMCFG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_RAMCFGLPEN)
  2743. #if defined(ETH)
  2744. #define __HAL_RCC_ETH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ETHLPEN)
  2745. #define __HAL_RCC_ETHTX_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ETHTXLPEN)
  2746. #define __HAL_RCC_ETHRX_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ETHRXLPEN)
  2747. #endif /* ETH */
  2748. #define __HAL_RCC_GTZC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_TZSC1LPEN)
  2749. #define __HAL_RCC_BKPRAM_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_BKPRAMLPEN)
  2750. #define __HAL_RCC_ICACHE_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_ICACHELPEN)
  2751. #if defined(DCACHE1)
  2752. #define __HAL_RCC_DCACHE1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_DCACHE1LPEN)
  2753. #endif /* DCACHE1 */
  2754. #define __HAL_RCC_SRAM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB1LPENR, RCC_AHB1LPENR_SRAM1LPEN)
  2755. /**
  2756. * @}
  2757. */
  2758. /** @defgroup RCC_AHB2_Peripheral_Clock_Sleep_Enable_Disable AHB2 Peripheral Clock Sleep Enable Disable
  2759. * @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  2760. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2761. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2762. * @{
  2763. */
  2764. #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOALPEN)
  2765. #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOBLPEN)
  2766. #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOCLPEN)
  2767. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIODLPEN)
  2768. #if defined(GPIOE)
  2769. #define __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOELPEN)
  2770. #endif /* GPIOE */
  2771. #if defined(GPIOF)
  2772. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOFLPEN)
  2773. #endif /* GPIOF */
  2774. #if defined(GPIOG)
  2775. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOGLPEN)
  2776. #endif /* GPIOG */
  2777. #define __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOHLPEN)
  2778. #if defined(GPIOI)
  2779. #define __HAL_RCC_GPIOI_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOILPEN)
  2780. #endif /* GPIOI */
  2781. #define __HAL_RCC_ADC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_ADCLPEN)
  2782. #define __HAL_RCC_DAC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_DAC1LPEN)
  2783. #if defined(DCMI)
  2784. #define __HAL_RCC_DCMI_PSSI_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_DCMI_PSSILPEN)
  2785. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() __HAL_RCC_DCMI_PSSI_CLK_SLEEP_ENABLE() /* for API backward compatibility */
  2786. #endif /* DCMI */
  2787. #if defined(AES)
  2788. #define __HAL_RCC_AES_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_AESLPEN);
  2789. #endif /* AES */
  2790. #if defined(HASH)
  2791. #define __HAL_RCC_HASH_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_HASHLPEN)
  2792. #endif /* HASH */
  2793. #define __HAL_RCC_RNG_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_RNGLPEN)
  2794. #if defined(PKA)
  2795. #define __HAL_RCC_PKA_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_PKALPEN)
  2796. #endif /*PKA*/
  2797. #if defined(SAES)
  2798. #define __HAL_RCC_SAES_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_SAESLPEN)
  2799. #endif /* AES */
  2800. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_SRAM2LPEN)
  2801. #if defined(SRAM3_BASE)
  2802. #define __HAL_RCC_SRAM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_SRAM3LPEN)
  2803. #endif /* SRAM3_BASE */
  2804. #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOALPEN)
  2805. #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOBLPEN)
  2806. #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOCLPEN)
  2807. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIODLPEN)
  2808. #if defined(GPIOE)
  2809. #define __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOELPEN)
  2810. #endif /* GPIOE */
  2811. #if defined(GPIOF)
  2812. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOFLPEN)
  2813. #endif /* GPIOF */
  2814. #if defined(GPIOG)
  2815. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOGLPEN)
  2816. #endif /* GPIOG */
  2817. #define __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOHLPEN)
  2818. #if defined(GPIOI)
  2819. #define __HAL_RCC_GPIOI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_GPIOILPEN)
  2820. #endif /* GPIOI */
  2821. #define __HAL_RCC_ADC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_ADCLPEN)
  2822. #define __HAL_RCC_DAC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_DAC1LPEN)
  2823. #if defined(DCMI)
  2824. #define __HAL_RCC_DCMI_PSSI_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_DCMI_PSSILPEN)
  2825. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() __HAL_RCC_DCMI_PSSI_CLK_SLEEP_DISABLE() /* for API backward compatibility */
  2826. #endif /* DCMI */
  2827. #if defined(AES)
  2828. #define __HAL_RCC_AES_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_AESLPEN);
  2829. #endif /* AES */
  2830. #if defined(HASH)
  2831. #define __HAL_RCC_HASH_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_HASHLPEN)
  2832. #endif /* HASH */
  2833. #define __HAL_RCC_RNG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_RNGLPEN)
  2834. #if defined(PKA)
  2835. #define __HAL_RCC_PKA_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_PKALPEN)
  2836. #endif /*PKA*/
  2837. #define __HAL_RCC_SAES_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_SAESLPEN)
  2838. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_SRAM2LPEN)
  2839. #if defined(SRAM3_BASE)
  2840. #define __HAL_RCC_SRAM3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB2LPENR, RCC_AHB2LPENR_SRAM3LPEN)
  2841. #endif /* SRAM3_BASE */
  2842. /**
  2843. * @}
  2844. */
  2845. /** @defgroup RCC_AHB4_Clock_Sleep_Enable_Disable AHB4 Peripheral Clock Sleep Enable Disable
  2846. * @brief Enable or disable the AHB4 peripheral clock during Low Power (Sleep) mode.
  2847. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2848. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2849. * @{
  2850. */
  2851. #if defined(OTFDEC1)
  2852. #define __HAL_RCC_OTFDEC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_OTFDEC1LPEN)
  2853. #endif /* OTFDEC1 */
  2854. #if defined(SDMMC1)
  2855. #define __HAL_RCC_SDMMC1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_SDMMC1LPEN)
  2856. #endif /* SDMMC1*/
  2857. #if defined(SDMMC2)
  2858. #define __HAL_RCC_SDMMC2_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_SDMMC2LPEN)
  2859. #endif /* SDMMC2*/
  2860. #if defined(FMC_BASE)
  2861. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_FMCLPEN)
  2862. #endif /* FMC_BASE */
  2863. #if defined(OCTOSPI1)
  2864. #define __HAL_RCC_OSPI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_OCTOSPI1LPEN)
  2865. #endif /* OCTOSPI1 */
  2866. #if defined(OTFDEC1)
  2867. #define __HAL_RCC_OTFDEC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_OTFDEC1LPEN)
  2868. #endif /* OTFDEC1 */
  2869. #if defined(SDMMC1)
  2870. #define __HAL_RCC_SDMMC1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_SDMMC1LPEN)
  2871. #endif /* SDMMC1*/
  2872. #if defined(SDMMC2)
  2873. #define __HAL_RCC_SDMMC2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_SDMMC2LPEN)
  2874. #endif /* SDMMC2*/
  2875. #if defined(FMC_BASE)
  2876. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_FMCLPEN)
  2877. #endif /* FMC_BASE */
  2878. #if defined(OCTOSPI1)
  2879. #define __HAL_RCC_OSPI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->AHB4LPENR, RCC_AHB4LPENR_OCTOSPI1LPEN)
  2880. #endif /* OCTOSPI1 */
  2881. /**
  2882. * @}
  2883. */
  2884. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable APB1 Peripheral Clock Sleep Enable Disable
  2885. * @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  2886. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  2887. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  2888. * @{
  2889. */
  2890. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM2LPEN)
  2891. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM3LPEN)
  2892. #if defined(TIM4)
  2893. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM4LPEN)
  2894. #endif /* TIM4 */
  2895. #if defined(TIM5)
  2896. #define __HAL_RCC_TIM5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM5LPEN)
  2897. #endif /* TIM5 */
  2898. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM6LPEN)
  2899. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM7LPEN)
  2900. #if defined(TIM12)
  2901. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM12LPEN)
  2902. #endif /* TIM12 */
  2903. #if defined(TIM13)
  2904. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM13LPEN)
  2905. #endif /* TIM13 */
  2906. #if defined(TIM14)
  2907. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM14LPEN)
  2908. #endif /* TIM14 */
  2909. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_WWDGLPEN)
  2910. #if defined(OPAMP1)
  2911. #define __HAL_RCC_OPAMP_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_OPAMPLPEN)
  2912. #endif /* OPAMP1 */
  2913. #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_SPI2LPEN)
  2914. #define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_SPI3LPEN)
  2915. #if defined(COMP1)
  2916. #define __HAL_RCC_COMP_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_COMPLPEN)
  2917. #endif /* COMP1 */
  2918. #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART2LPEN)
  2919. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART3LPEN)
  2920. #if defined(UART4)
  2921. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART4LPEN)
  2922. #endif /* UART4 */
  2923. #if defined(UART5)
  2924. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART5LPEN)
  2925. #endif /* UART5 */
  2926. #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_I2C1LPEN)
  2927. #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_I2C2LPEN)
  2928. #define __HAL_RCC_I3C1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_I3C1LPEN)
  2929. #define __HAL_RCC_CRS_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_CRSLPEN)
  2930. #if defined(USART6)
  2931. #define __HAL_RCC_USART6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART6LPEN)
  2932. #endif /* USART6 */
  2933. #if defined(USART10)
  2934. #define __HAL_RCC_USART10_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART10LPEN)
  2935. #endif /* USART10 */
  2936. #if defined(USART11)
  2937. #define __HAL_RCC_USART11_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART11LPEN)
  2938. #endif /* USART11 */
  2939. #if defined(CEC)
  2940. #define __HAL_RCC_CEC_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_CECLPEN)
  2941. #endif /* CEC */
  2942. #if defined(UART7)
  2943. #define __HAL_RCC_UART7_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART7LPEN)
  2944. #endif /* UART7 */
  2945. #if defined(UART8)
  2946. #define __HAL_RCC_UART8_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART8LPEN)
  2947. #endif /* UART8 */
  2948. #if defined(UART9)
  2949. #define __HAL_RCC_UART9_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_UART9LPEN)
  2950. #endif /* UART9 */
  2951. #if defined(UART12)
  2952. #define __HAL_RCC_UART12_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_UART12LPEN)
  2953. #endif /* UART12 */
  2954. #define __HAL_RCC_DTS_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_DTSLPEN)
  2955. #define __HAL_RCC_LPTIM2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_LPTIM2LPEN)
  2956. #define __HAL_RCC_FDCAN_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_FDCANLPEN)
  2957. #if defined(UCPD1)
  2958. #define __HAL_RCC_UCPD1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_UCPD1LPEN)
  2959. #endif /* UCPD1 */
  2960. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM2LPEN)
  2961. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM3LPEN)
  2962. #if defined(TIM4)
  2963. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM4LPEN)
  2964. #endif /* TIM4 */
  2965. #if defined(TIM5)
  2966. #define __HAL_RCC_TIM5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM5LPEN)
  2967. #endif /* TIM5 */
  2968. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM6LPEN)
  2969. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM7LPEN)
  2970. #if defined(TIM12)
  2971. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM12LPEN)
  2972. #endif /* TIM12 */
  2973. #if defined(TIM13)
  2974. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM13LPEN)
  2975. #endif /* TIM12 */
  2976. #if defined(TIM14)
  2977. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_TIM14LPEN)
  2978. #endif /* TIM14 */
  2979. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_WWDGLPEN)
  2980. #if defined(OPAMP1)
  2981. #define __HAL_RCC_OPAMP_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_OPAMPLPEN)
  2982. #endif /* OPAMP1 */
  2983. #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_SPI2LPEN)
  2984. #define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_SPI3LPEN)
  2985. #if defined(COMP1)
  2986. #define __HAL_RCC_COMP_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_COMPLPEN)
  2987. #endif /* COMP1 */
  2988. #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART2LPEN)
  2989. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART3LPEN)
  2990. #if defined(UART4)
  2991. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART4LPEN)
  2992. #endif /* UART4 */
  2993. #if defined(UART5)
  2994. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART5LPEN)
  2995. #endif /* UART5 */
  2996. #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_I2C1LPEN)
  2997. #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_I2C2LPEN)
  2998. #define __HAL_RCC_I3C1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_I3C1LPEN)
  2999. #define __HAL_RCC_CRS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_CRSLPEN)
  3000. #if defined(USART6)
  3001. #define __HAL_RCC_USART6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART6LPEN)
  3002. #endif /* USART6 */
  3003. #if defined(USART10)
  3004. #define __HAL_RCC_USART10_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART10LPEN)
  3005. #endif /* USART10 */
  3006. #if defined(USART11)
  3007. #define __HAL_RCC_USART11_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_USART11LPEN)
  3008. #endif /* USART11 */
  3009. #if defined(CEC)
  3010. #define __HAL_RCC_CEC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_CECLPEN)
  3011. #endif /* CEC */
  3012. #if defined(UART7)
  3013. #define __HAL_RCC_UART7_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART7LPEN)
  3014. #endif /* UART7 */
  3015. #if defined(UART8)
  3016. #define __HAL_RCC_UART8_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1LLPENR, RCC_APB1LLPENR_UART8LPEN)
  3017. #endif /* UART8 */
  3018. #if defined(UART9)
  3019. #define __HAL_RCC_UART9_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_UART9LPEN)
  3020. #endif /* UART9 */
  3021. #if defined(UART12)
  3022. #define __HAL_RCC_UART12_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_UART12LPEN)
  3023. #endif /* UART12 */
  3024. #define __HAL_RCC_DTS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_DTSLPEN)
  3025. #define __HAL_RCC_LPTIM2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_LPTIM2LPEN)
  3026. #define __HAL_RCC_FDCAN_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_FDCANLPEN)
  3027. #if defined(UCPD1)
  3028. #define __HAL_RCC_UCPD1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB1HLPENR, RCC_APB1HLPENR_UCPD1LPEN)
  3029. #endif /* UCPD1 */
  3030. /**
  3031. * @}
  3032. */
  3033. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable APB2 Peripheral Clock Sleep Enable Disable
  3034. * @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  3035. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  3036. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  3037. * @{
  3038. */
  3039. #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM1LPEN)
  3040. #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SPI1LPEN)
  3041. #if defined(TIM8)
  3042. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM8LPEN)
  3043. #endif /* TIM8 */
  3044. #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_USART1LPEN)
  3045. #if defined(TIM15)
  3046. #define __HAL_RCC_TIM15_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM15LPEN)
  3047. #endif /* TIM15 */
  3048. #if defined(TIM16)
  3049. #define __HAL_RCC_TIM16_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM16LPEN)
  3050. #endif /* TIM16 */
  3051. #if defined(TIM17)
  3052. #define __HAL_RCC_TIM17_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM17LPEN)
  3053. #endif /* TIM17 */
  3054. #if defined(SPI4)
  3055. #define __HAL_RCC_SPI4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SPI4LPEN)
  3056. #endif /* SPI4 */
  3057. #if defined(SPI6)
  3058. #define __HAL_RCC_SPI6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SPI6LPEN)
  3059. #endif /* SPI6 */
  3060. #if defined(SAI1)
  3061. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SAI1LPEN)
  3062. #endif /* SAI1 */
  3063. #if defined(SAI2)
  3064. #define __HAL_RCC_SAI2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SAI2LPEN)
  3065. #endif /* SAI2 */
  3066. #if defined(USB_DRD_FS)
  3067. #define __HAL_RCC_USB_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB2LPENR, RCC_APB2LPENR_USBLPEN)
  3068. #endif /* USB_DRD_FS */
  3069. #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM1LPEN)
  3070. #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SPI1LPEN)
  3071. #if defined(TIM8)
  3072. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM8LPEN)
  3073. #endif /* TIM8 */
  3074. #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_USART1LPEN)
  3075. #if defined(TIM15)
  3076. #define __HAL_RCC_TIM15_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM15LPEN)
  3077. #endif /* TIM15 */
  3078. #if defined(TIM16)
  3079. #define __HAL_RCC_TIM16_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM16LPEN)
  3080. #endif /* TIM16 */
  3081. #if defined(TIM17)
  3082. #define __HAL_RCC_TIM17_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_TIM17LPEN)
  3083. #endif /* TIM17 */
  3084. #if defined(SPI4)
  3085. #define __HAL_RCC_SPI4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SPI4LPEN)
  3086. #endif /* SPI4 */
  3087. #if defined(SPI6)
  3088. #define __HAL_RCC_SPI6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SPI6LPEN)
  3089. #endif /* SPI6 */
  3090. #if defined(SAI1)
  3091. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SAI1LPEN)
  3092. #endif /* SAI1 */
  3093. #if defined(SAI2)
  3094. #define __HAL_RCC_SAI2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_SAI2LPEN)
  3095. #endif /* SAI2 */
  3096. #if defined(USB_DRD_FS)
  3097. #define __HAL_RCC_USB_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB2LPENR, RCC_APB2LPENR_USBLPEN)
  3098. #endif /* USB_DRD_FS */
  3099. /**
  3100. * @}
  3101. */
  3102. /** @defgroup RCC_APB3_Clock_Sleep_Enable_Disable APB3 Peripheral Clock Sleep Enable Disable
  3103. * @brief Enable or disable the APB3 peripheral clock during Low Power (Sleep) mode.
  3104. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  3105. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  3106. * @{
  3107. */
  3108. #define __HAL_RCC_SBS_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_SBSLPEN)
  3109. #if defined(SPI5)
  3110. #define __HAL_RCC_SPI5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_SPI5LPEN)
  3111. #endif /* SPI5 */
  3112. #define __HAL_RCC_LPUART1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPUART1LPEN)
  3113. #if defined(I2C3)
  3114. #define __HAL_RCC_I2C3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_I2C3LPEN)
  3115. #endif /* I2C3 */
  3116. #if defined(I2C4)
  3117. #define __HAL_RCC_I2C4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_I2C4LPEN)
  3118. #endif /* I2C4 */
  3119. #if defined(I3C2)
  3120. #define __HAL_RCC_I3C2_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_I3C2LPEN)
  3121. #endif /* I3C2 */
  3122. #define __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM1LPEN)
  3123. #if defined(LPTIM3)
  3124. #define __HAL_RCC_LPTIM3_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM3LPEN)
  3125. #endif /* LPTIM3 */
  3126. #if defined(LPTIM4)
  3127. #define __HAL_RCC_LPTIM4_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM4LPEN)
  3128. #endif /* LPTIM4 */
  3129. #if defined(LPTIM5)
  3130. #define __HAL_RCC_LPTIM5_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM5LPEN)
  3131. #endif /* LPTIM5 */
  3132. #if defined(LPTIM6)
  3133. #define __HAL_RCC_LPTIM6_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM6LPEN)
  3134. #endif /* LPTIM6 */
  3135. #if defined(VREFBUF)
  3136. #define __HAL_RCC_VREF_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_VREFLPEN)
  3137. #endif /* VREFBUF */
  3138. #define __HAL_RCC_RTC_CLK_SLEEP_ENABLE() SET_BIT(RCC->APB3LPENR, RCC_APB3LPENR_RTCAPBLPEN)
  3139. #define __HAL_RCC_SBS_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_SBSLPEN)
  3140. #if defined(SPI5)
  3141. #define __HAL_RCC_SPI5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_SPI5LPEN)
  3142. #endif /* SPI5 */
  3143. #define __HAL_RCC_LPUART1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPUART1LPEN)
  3144. #if defined(I2C3)
  3145. #define __HAL_RCC_I2C3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_I2C3LPEN)
  3146. #endif /* I2C3 */
  3147. #if defined(I2C4)
  3148. #define __HAL_RCC_I2C4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_I2C4LPEN)
  3149. #endif /* I2C4 */
  3150. #if defined(I3C2)
  3151. #define __HAL_RCC_I3C2_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_I3C2LPEN)
  3152. #endif /* I3C2 */
  3153. #define __HAL_RCC_LPTIM1_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM1LPEN)
  3154. #if defined(LPTIM3)
  3155. #define __HAL_RCC_LPTIM3_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM3LPEN)
  3156. #endif /* LPTIM3 */
  3157. #if defined(LPTIM4)
  3158. #define __HAL_RCC_LPTIM4_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM4LPEN)
  3159. #endif /* LPTIM4 */
  3160. #if defined(LPTIM5)
  3161. #define __HAL_RCC_LPTIM5_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM5LPEN)
  3162. #endif /* LPTIM5 */
  3163. #if defined(LPTIM6)
  3164. #define __HAL_RCC_LPTIM6_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_LPTIM6LPEN)
  3165. #endif /* LPTIM6 */
  3166. #if defined(VREFBUF)
  3167. #define __HAL_RCC_VREF_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_VREFLPEN)
  3168. #endif /* VREFBUF */
  3169. #define __HAL_RCC_RTC_CLK_SLEEP_DISABLE() CLEAR_BIT(RCC->APB3LPENR, RCC_APB3LPENR_RTCAPBLPEN)
  3170. /**
  3171. * @}
  3172. */
  3173. /** @defgroup RCC_Backup_Domain_Reset RCC Backup Domain Reset
  3174. * @{
  3175. */
  3176. /** @brief Macros to force or release the Backup domain reset.
  3177. * @note This function resets the RTC peripheral (including the backup registers)
  3178. * and the RTC clock source selection in RCC_BDCR register.
  3179. * @note The BKPSRAM is not affected by this reset.
  3180. * @retval None
  3181. */
  3182. #define __HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->BDCR, RCC_BDCR_VSWRST)
  3183. #define __HAL_RCC_BACKUPRESET_RELEASE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_VSWRST)
  3184. /**
  3185. * @}
  3186. */
  3187. /** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
  3188. * @{
  3189. */
  3190. /** @brief Macros to enable or disable the RTC clock.
  3191. * @note As the RTC is in the Backup domain and write access is denied to
  3192. * this domain after reset, you have to enable write access using
  3193. * HAL_PWR_EnableBkUpAccess() function before to configure the RTC
  3194. * (to be done once after reset).
  3195. * @note These macros must be used after the RTC clock source was selected.
  3196. * @retval None
  3197. */
  3198. #define __HAL_RCC_RTC_ENABLE() SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  3199. #define __HAL_RCC_RTC_DISABLE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
  3200. /**
  3201. * @}
  3202. */
  3203. /** @brief Macro to configure the Internal High Speed oscillator (HSI).
  3204. * @param __HSIDIV__ specifies the HSI division factor.
  3205. * This parameter can be one of the following values:
  3206. * @arg RCC_HSI_DIV1 Divide the HSI oscillator clock by 1 (default after reset)
  3207. * @arg RCC_HSI_DIV2 Divide the HSI oscillator clock by 2
  3208. * @arg RCC_HSI_DIV4 Divide the HSI oscillator clock by 4
  3209. * @arg RCC_HSI_DIV8 Divide the HSI oscillator clock by 8
  3210. */
  3211. #define __HAL_RCC_HSI_DIVIDER_CONFIG(__HSIDIV__) \
  3212. MODIFY_REG(RCC->CR, RCC_CR_HSIDIV , (uint32_t)(__HSIDIV__))
  3213. /** @brief Macro to get the HSI divider.
  3214. * @retval The HSI divider. The returned value can be one
  3215. * of the following:
  3216. * - RCC_HSI_DIV1 HSI oscillator divided by 1
  3217. * - RCC_HSI_DIV2 HSI oscillator divided by 2
  3218. * - RCC_HSI_DIV4 HSI oscillator divided by 4
  3219. * - RCC_HSI_DIV8 HSI oscillator divided by 8
  3220. */
  3221. #define __HAL_RCC_GET_HSI_DIVIDER() ((uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSIDIV)))
  3222. /** @brief Macros to enable or disable the Internal High Speed 64MHz oscillator (HSI).
  3223. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  3224. * It is used (enabled by hardware) as system clock source after startup
  3225. * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
  3226. * of the HSE used directly or indirectly as system clock (if the HSE Clock
  3227. * Security System HSECSS is enabled).
  3228. * @note HSI can not be stopped if it is used as system clock source. In this case,
  3229. * you have to select another source of the system clock then stop the HSI.
  3230. * @note After enabling the HSI, the application software should wait on HSIRDY
  3231. * flag to be set indicating that HSI clock is stable and can be used as
  3232. * system clock source.
  3233. * This parameter can be: ENABLE or DISABLE.
  3234. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  3235. * clock cycles.
  3236. * @retval None
  3237. */
  3238. #define __HAL_RCC_HSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSION)
  3239. #define __HAL_RCC_HSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSION)
  3240. /** @brief Macro to adjust the Internal High Speed 64MHz oscillator (HSI) calibration value.
  3241. * @note The calibration is used to compensate for the variations in voltage
  3242. * and temperature that influence the frequency of the internal HSI RC.
  3243. * @param __HSICALIBRATIONVALUE__: specifies the calibration trimming value
  3244. * (default is RCC_HSICALIBRATION_DEFAULT).
  3245. * This parameter must be a number between 0 and 0x7F.
  3246. * @retval None
  3247. */
  3248. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICALIBRATIONVALUE__) \
  3249. MODIFY_REG(RCC->HSICFGR, RCC_HSICFGR_HSITRIM, (uint32_t)(__HSICALIBRATIONVALUE__) << RCC_HSICFGR_HSITRIM_Pos)
  3250. /**
  3251. * @brief Macros to enable or disable the force of the Internal High Speed oscillator (HSI)
  3252. * in STOP mode to be quickly available as kernel clock for USARTs, LPUART and I2Cs.
  3253. * @note Keeping the HSI ON in STOP mode allows to avoid slowing down the communication
  3254. * speed because of the HSI startup time.
  3255. * @note The enable of this function has not effect on the HSION bit.
  3256. * This parameter can be: ENABLE or DISABLE.
  3257. * @retval None
  3258. */
  3259. #define __HAL_RCC_HSISTOP_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSIKERON)
  3260. #define __HAL_RCC_HSISTOP_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSIKERON)
  3261. /**
  3262. * @brief Macros to enable or disable the Internal Low-power oscillator (CSI).
  3263. * @note The CSI is stopped by hardware when entering STOP and STANDBY modes.
  3264. * It is used (enabled by hardware) as system clock source after
  3265. * startup from Reset, wakeup from STOP and STANDBY mode, or in case
  3266. * of failure of the HSE used directly or indirectly as system clock
  3267. * (if the HSE Clock Security System HSECSS is enabled and CSI is selected
  3268. * as system clock after wake up from system stop).
  3269. * @note CSI can not be stopped if it is used as system clock source.
  3270. * In this case, you have to select another source of the system
  3271. * clock then stop the CSI.
  3272. * @note After enabling the CSI, the application software should wait on
  3273. * CSIRDY flag to be set indicating that CSI clock is stable and can
  3274. * be used as system clock source.
  3275. * @note When the CSI is stopped, CSIRDY flag goes low after 6 CSI oscillator
  3276. * clock cycles.
  3277. * @retval None
  3278. */
  3279. #define __HAL_RCC_CSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_CSION)
  3280. #define __HAL_RCC_CSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_CSION)
  3281. /** @brief Macro Adjusts the Internal oscillator (CSI) calibration value.
  3282. * @note The calibration is used to compensate for the variations in voltage
  3283. * and temperature that influence the frequency of the internal CSI RC.
  3284. * @param __CSICalibrationValue__: specifies the calibration trimming value.
  3285. * This parameter must be a number between 0 and 0x3F.
  3286. */
  3287. #define __HAL_RCC_CSI_CALIBRATIONVALUE_ADJUST(__CSICalibrationValue__) \
  3288. do { \
  3289. MODIFY_REG(RCC->CSICFGR, RCC_CSICFGR_CSITRIM, (uint32_t)(__CSICalibrationValue__) << RCC_CSICFGR_CSITRIM_Pos); \
  3290. } while(0)
  3291. /**
  3292. * @brief Macros to enable or disable the force of the Low-power Internal oscillator (CSI)
  3293. * in STOP mode to be quickly available as kernel clock for USARTs and I2Cs.
  3294. * @note Keeping the CSI ON in STOP mode allows to avoid slowing down the communication
  3295. * speed because of the CSI start-up time.
  3296. * @note The enable of this function has not effect on the CSION bit.
  3297. * This parameter can be: ENABLE or DISABLE.
  3298. * @retval None
  3299. */
  3300. #define __HAL_RCC_CSISTOP_ENABLE() SET_BIT(RCC->CR, RCC_CR_CSIKERON)
  3301. #define __HAL_RCC_CSISTOP_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_CSIKERON)
  3302. /** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
  3303. * @note After enabling the LSI, the application software should wait on
  3304. * LSIRDY flag to be set indicating that LSI clock is stable and can
  3305. * be used to clock the IWDG and/or the RTC.
  3306. * @note LSI can not be disabled if the IWDG is running.
  3307. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  3308. * clock cycles.
  3309. * @retval None
  3310. */
  3311. #define __HAL_RCC_LSI_ENABLE() SET_BIT(RCC->BDCR, RCC_BDCR_LSION)
  3312. #define __HAL_RCC_LSI_DISABLE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSION)
  3313. /**
  3314. * @brief Macro to configure the External High Speed oscillator (HSE).
  3315. * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
  3316. * supported by this macro. User should request a transition to HSE Off
  3317. * first and then HSE On or HSE Bypass.
  3318. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  3319. * software should wait on HSERDY flag to be set indicating that HSE clock
  3320. * is stable and can be used to clock the PLLs and/or system clock.
  3321. * @note HSE state can not be changed if it is used directly or through the
  3322. * PLL1 as system clock. In this case, you have to select another source
  3323. * of the system clock then change the HSE state (ex. disable it).
  3324. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  3325. * @param __STATE__: specifies the new state of the HSE.
  3326. * This parameter can be one of the following values:
  3327. * @arg @ref RCC_HSE_OFF Turn OFF the HSE oscillator, HSERDY flag goes low after
  3328. * 6 HSE oscillator clock cycles.
  3329. * @arg @ref RCC_HSE_ON Turn ON the HSE oscillator.
  3330. * @arg @ref RCC_HSE_BYPASS HSE oscillator bypassed with external clock.
  3331. * @arg @ref RCC_HSE_BYPASS_DIGITAL HSE oscillator bypassed with digital external clock.
  3332. * @retval None
  3333. */
  3334. #define __HAL_RCC_HSE_CONFIG(__STATE__) \
  3335. do { \
  3336. if ((__STATE__) == RCC_HSE_ON) \
  3337. { \
  3338. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  3339. } \
  3340. else if ((__STATE__) == RCC_HSE_OFF) \
  3341. { \
  3342. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  3343. CLEAR_BIT(RCC->CR, RCC_CR_HSEEXT); \
  3344. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  3345. } \
  3346. else if ((__STATE__) == RCC_HSE_BYPASS) \
  3347. { \
  3348. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  3349. CLEAR_BIT(RCC->CR, RCC_CR_HSEEXT); \
  3350. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  3351. } \
  3352. else if((__STATE__) == RCC_HSE_BYPASS_DIGITAL) \
  3353. { \
  3354. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  3355. SET_BIT(RCC->CR, RCC_CR_HSEEXT); \
  3356. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  3357. } \
  3358. else \
  3359. { \
  3360. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  3361. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  3362. CLEAR_BIT(RCC->CR, RCC_CR_HSEEXT); \
  3363. } \
  3364. } while(0)
  3365. /**
  3366. * @brief Macro to configure the External Low Speed oscillator (LSE).
  3367. * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
  3368. * supported by this macro. User should request a transition to LSE Off
  3369. * first and then LSE On or LSE Bypass.
  3370. * @note As the LSE is in the Backup domain and write access is denied to
  3371. * this domain after reset, you have to enable write access using
  3372. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  3373. * (to be done once after reset).
  3374. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  3375. * software should wait on LSERDY flag to be set indicating that LSE clock
  3376. * is stable and can be used to clock the RTC.
  3377. * @param __STATE__: specifies the new state of the LSE.
  3378. * This parameter can be one of the following values:
  3379. * @arg @ref RCC_LSE_OFF Turn OFF the LSE oscillator, LSERDY flag goes low after
  3380. * 6 LSE oscillator clock cycles.
  3381. * @arg @ref RCC_LSE_ON Turn ON the LSE oscillator.
  3382. * @arg @ref RCC_LSE_BYPASS LSE oscillator bypassed with external clock.
  3383. * @arg @ref RCC_LSE_BYPASS_DIGITAL LSE oscillator bypassed with external digital clock.
  3384. * @retval None
  3385. */
  3386. #define __HAL_RCC_LSE_CONFIG(__STATE__) \
  3387. do { \
  3388. if((__STATE__) == RCC_LSE_ON) \
  3389. { \
  3390. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3391. } \
  3392. else if((__STATE__) == RCC_LSE_OFF) \
  3393. { \
  3394. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3395. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEEXT); \
  3396. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  3397. } \
  3398. else if((__STATE__) == RCC_LSE_BYPASS) \
  3399. { \
  3400. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  3401. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEEXT); \
  3402. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3403. } \
  3404. else if((__STATE__) == RCC_LSE_BYPASS_DIGITAL) \
  3405. { \
  3406. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  3407. SET_BIT(RCC->BDCR, RCC_BDCR_LSEEXT); \
  3408. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3409. } \
  3410. else \
  3411. { \
  3412. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
  3413. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
  3414. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEEXT); \
  3415. } \
  3416. } while(0)
  3417. /** @brief Macros to enable or disable the Internal High Speed 48MHz oscillator (HSI48).
  3418. * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes.
  3419. * @note After enabling the HSI48, the application software should wait on HSI48RDY
  3420. * flag to be set indicating that HSI48 clock is stable.
  3421. * This parameter can be: ENABLE or DISABLE.
  3422. * @retval None
  3423. */
  3424. #define __HAL_RCC_HSI48_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSI48ON)
  3425. #define __HAL_RCC_HSI48_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSI48ON)
  3426. /** @brief Macros to configure the RTC clock (RTCCLK).
  3427. * @note As the RTC clock configuration bits are in the Backup domain and write
  3428. * access is denied to this domain after reset, you have to enable write
  3429. * access using the Power Backup Access macro before to configure
  3430. * the RTC clock source (to be done once after reset).
  3431. * @note Once the RTC clock is configured it cannot be changed unless the
  3432. * Backup domain is reset using __HAL_RCC_BackupReset_RELEASE() macro, or by
  3433. * a Power On Reset (POR).
  3434. * @param __RTCCLKSource__: specifies the RTC clock source.
  3435. * This parameter can be one of the following values:
  3436. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  3437. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  3438. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIVx HSE clock divided by x selected
  3439. * as RTC clock, where x can be between 2 and 63
  3440. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  3441. * work in STOP and STANDBY modes, and can be used as wakeup source.
  3442. * However, when the HSE clock is used as RTC clock source, the RTC
  3443. * cannot be used in STOP and STANDBY modes.
  3444. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  3445. * RTC clock source).
  3446. */
  3447. #define __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__) (((__RTCCLKSource__) & RCC_BDCR_RTCSEL) == RCC_BDCR_RTCSEL) ? \
  3448. MODIFY_REG(RCC->CFGR1, RCC_CFGR1_RTCPRE, \
  3449. (((__RTCCLKSource__) & 0xFFFFCFFU) >> 4)) : CLEAR_BIT(RCC->CFGR1, RCC_CFGR1_RTCPRE)
  3450. #define __HAL_RCC_RTC_CONFIG(__RTCCLKSource__) do { __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__); \
  3451. RCC->BDCR &= ~RCC_BDCR_RTCSEL; \
  3452. RCC->BDCR |= ((__RTCCLKSource__) & 0x00000FFFU); \
  3453. } while (0)
  3454. /** @brief Macro to get the RTC clock source.
  3455. * @retval The returned value can be one of the following:
  3456. * @arg @ref RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock.
  3457. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
  3458. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
  3459. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIVx HSE clock divided by x selected as
  3460. * RTC clock, where x can be between 2 and 63
  3461. (x can be retrieved with @ref __HAL_RCC_GET_RTC_HSE_PRESCALER())
  3462. */
  3463. #define __HAL_RCC_GET_RTC_SOURCE() ((uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL)))
  3464. /** @brief Macro to get the HSE division factor for RTC clock.
  3465. *
  3466. * @retval The HSE division factor for RTC clock. The returned value can be one
  3467. * of the following:
  3468. * @arg @ref RCC_RTC_HSE_NOCLOCK : No HSE Clock selected as RTC clock
  3469. * @arg @ref RCC_RTC_HSE_DIV2 : HSE Divided by 2 selected as RTC clock
  3470. * @arg @ref RCC_RTC_HSE_DIV3 : HSE Divided by 3 selected as RTC clock
  3471. * @arg @ref RCC_RTC_HSE_DIV4 : HSE Divided by 4 selected as RTC clock
  3472. * @arg @ref RCC_RTC_HSE_DIV5 : HSE Divided by 5 selected as RTC clock
  3473. * @arg @ref RCC_RTC_HSE_DIV6 : HSE Divided by 6 selected as RTC clock
  3474. * @arg @ref RCC_RTC_HSE_DIV7 : HSE Divided by 7 selected as RTC clock
  3475. * @arg @ref RCC_RTC_HSE_DIV8 : HSE Divided by 8 selected as RTC clock
  3476. * @arg @ref RCC_RTC_HSE_DIV9 : HSE Divided by 9 selected as RTC clock
  3477. * @arg @ref RCC_RTC_HSE_DIV10 : HSE Divided by 10 selected as RTC clock
  3478. * @arg @ref RCC_RTC_HSE_DIV11 : HSE Divided by 11 selected as RTC clock
  3479. * @arg @ref RCC_RTC_HSE_DIV12 : HSE Divided by 12 selected as RTC clock
  3480. * @arg @ref RCC_RTC_HSE_DIV13 : HSE Divided by 13 selected as RTC clock
  3481. * @arg @ref RCC_RTC_HSE_DIV14 : HSE Divided by 14 selected as RTC clock
  3482. * @arg @ref RCC_RTC_HSE_DIV15 : HSE Divided by 15 selected as RTC clock
  3483. * @arg @ref RCC_RTC_HSE_DIV16 : HSE Divided by 16 selected as RTC clock
  3484. * @arg @ref RCC_RTC_HSE_DIV17 : HSE Divided by 17 selected as RTC clock
  3485. * @arg @ref RCC_RTC_HSE_DIV18 : HSE Divided by 18 selected as RTC clock
  3486. * @arg @ref RCC_RTC_HSE_DIV19 : HSE Divided by 19 selected as RTC clock
  3487. * @arg @ref RCC_RTC_HSE_DIV20 : HSE Divided by 20 selected as RTC clock
  3488. * @arg @ref RCC_RTC_HSE_DIV21 : HSE Divided by 21 selected as RTC clock
  3489. * @arg @ref RCC_RTC_HSE_DIV22 : HSE Divided by 22 selected as RTC clock
  3490. * @arg @ref RCC_RTC_HSE_DIV23 : HSE Divided by 23 selected as RTC clock
  3491. * @arg @ref RCC_RTC_HSE_DIV24 : HSE Divided by 24 selected as RTC clock
  3492. * @arg @ref RCC_RTC_HSE_DIV25 : HSE Divided by 25 selected as RTC clock
  3493. * @arg @ref RCC_RTC_HSE_DIV26 : HSE Divided by 26 selected as RTC clock
  3494. * @arg @ref RCC_RTC_HSE_DIV27 : HSE Divided by 27 selected as RTC clock
  3495. * @arg @ref RCC_RTC_HSE_DIV28 : HSE Divided by 28 selected as RTC clock
  3496. * @arg @ref RCC_RTC_HSE_DIV29 : HSE Divided by 29 selected as RTC clock
  3497. * @arg @ref RCC_RTC_HSE_DIV30 : HSE Divided by 30 selected as RTC clock
  3498. * @arg @ref RCC_RTC_HSE_DIV31 : HSE Divided by 31 selected as RTC clock
  3499. * @arg @ref RCC_RTC_HSE_DIV32 : HSE Divided by 32 selected as RTC clock
  3500. * @arg @ref RCC_RTC_HSE_DIV33 : HSE Divided by 33 selected as RTC clock
  3501. * @arg @ref RCC_RTC_HSE_DIV34 : HSE Divided by 34 selected as RTC clock
  3502. * @arg @ref RCC_RTC_HSE_DIV35 : HSE Divided by 35 selected as RTC clock
  3503. * @arg @ref RCC_RTC_HSE_DIV36 : HSE Divided by 36 selected as RTC clock
  3504. * @arg @ref RCC_RTC_HSE_DIV37 : HSE Divided by 37 selected as RTC clock
  3505. * @arg @ref RCC_RTC_HSE_DIV38 : HSE Divided by 38 selected as RTC clock
  3506. * @arg @ref RCC_RTC_HSE_DIV39 : HSE Divided by 39 selected as RTC clock
  3507. * @arg @ref RCC_RTC_HSE_DIV40 : HSE Divided by 40 selected as RTC clock
  3508. * @arg @ref RCC_RTC_HSE_DIV41 : HSE Divided by 41 selected as RTC clock
  3509. * @arg @ref RCC_RTC_HSE_DIV42 : HSE Divided by 42 selected as RTC clock
  3510. * @arg @ref RCC_RTC_HSE_DIV43 : HSE Divided by 43 selected as RTC clock
  3511. * @arg @ref RCC_RTC_HSE_DIV44 : HSE Divided by 44 selected as RTC clock
  3512. * @arg @ref RCC_RTC_HSE_DIV45 : HSE Divided by 45 selected as RTC clock
  3513. * @arg @ref RCC_RTC_HSE_DIV46 : HSE Divided by 46 selected as RTC clock
  3514. * @arg @ref RCC_RTC_HSE_DIV47 : HSE Divided by 47 selected as RTC clock
  3515. * @arg @ref RCC_RTC_HSE_DIV48 : HSE Divided by 48 selected as RTC clock
  3516. * @arg @ref RCC_RTC_HSE_DIV49 : HSE Divided by 49 selected as RTC clock
  3517. * @arg @ref RCC_RTC_HSE_DIV50 : HSE Divided by 50 selected as RTC clock
  3518. * @arg @ref RCC_RTC_HSE_DIV51 : HSE Divided by 51 selected as RTC clock
  3519. * @arg @ref RCC_RTC_HSE_DIV52 : HSE Divided by 52 selected as RTC clock
  3520. * @arg @ref RCC_RTC_HSE_DIV53 : HSE Divided by 53 selected as RTC clock
  3521. * @arg @ref RCC_RTC_HSE_DIV54 : HSE Divided by 54 selected as RTC clock
  3522. * @arg @ref RCC_RTC_HSE_DIV55 : HSE Divided by 55 selected as RTC clock
  3523. * @arg @ref RCC_RTC_HSE_DIV56 : HSE Divided by 56 selected as RTC clock
  3524. * @arg @ref RCC_RTC_HSE_DIV57 : HSE Divided by 57 selected as RTC clock
  3525. * @arg @ref RCC_RTC_HSE_DIV58 : HSE Divided by 58 selected as RTC clock
  3526. * @arg @ref RCC_RTC_HSE_DIV59 : HSE Divided by 59 selected as RTC clock
  3527. * @arg @ref RCC_RTC_HSE_DIV60 : HSE Divided by 60 selected as RTC clock
  3528. * @arg @ref RCC_RTC_HSE_DIV61 : HSE Divided by 61 selected as RTC clock
  3529. * @arg @ref RCC_RTC_HSE_DIV62 : HSE Divided by 62 selected as RTC clock
  3530. * @arg @ref RCC_RTC_HSE_DIV63 : HSE Divided by 63 selected as RTC clock
  3531. */
  3532. #define __HAL_RCC_GET_RTC_HSE_PRESCALER() ((uint32_t)(READ_BIT(RCC->CFGR1, RCC_CFGR1_RTCPRE)))
  3533. /** @brief Macros to enable or disable the main PLL.
  3534. * @note After enabling the main PLL, the application software should wait on
  3535. * PLLRDY flag to be set indicating that PLL clock is stable and can
  3536. * be used as system clock source.
  3537. * @note The main PLL can not be disabled if it is used as system clock source
  3538. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  3539. */
  3540. #define __HAL_RCC_PLL1_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLL1ON)
  3541. #define __HAL_RCC_PLL1_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLL1ON)
  3542. /**
  3543. * @brief Enables or disables each clock output (PLL1P_CLK, PLL1Q_CLK, PLL1R_CLK)
  3544. * @note Enabling/disabling Those Clocks can be any time without the need to stop the PLL1,
  3545. * (except the ck_pll_p of the System PLL that cannot be stopped if used as System
  3546. * Clock. This is mainly used to save Power.
  3547. * @param __PLL1_CLOCKOUT__: specifies the PLL clock to be outputted
  3548. * This parameter can be one of the following values:
  3549. * @arg RCC_PLL1_DIVP: This Clock is used to generate the high speed system clock (up to 250MHz)
  3550. * @arg RCC_PLL1_DIVQ: This Clock is used to generate the clock for USB (48 MHz), RNG (<=48 MHz),
  3551. * OCTOSPI, SPI, SAI and Ethernet
  3552. * @arg RCC_PLL1_DIVR: This Clock is used to generate an accurate clock
  3553. * @retval None
  3554. *
  3555. */
  3556. #define __HAL_RCC_PLL1_CLKOUT_ENABLE(__PLL1_CLOCKOUT__) SET_BIT(RCC->PLL1CFGR, (__PLL1_CLOCKOUT__))
  3557. #define __HAL_RCC_PLL1_CLKOUT_DISABLE(__PLL1_CLOCKOUT__) CLEAR_BIT(RCC->PLL1CFGR, (__PLL1_CLOCKOUT__))
  3558. /**
  3559. * @brief Macro to get the PLL clock output enable status.
  3560. * @param __PLL1_CLOCKOUT__ specifies the PLL1 clock to be output.
  3561. * This parameter can be one of the following values:
  3562. * @arg RCC_PLL1_DIVP: This Clock is used to generate the high speed system clock (up to 250MHz)
  3563. * @arg RCC_PLL1_DIVQ: This Clock is used to generate the clock for USB (48 MHz), RNG (<=48 MHz),
  3564. * OCTOSPI, SPI, SAI and Ethernet
  3565. * @arg RCC_PLL1_DIVR: This Clock is used to generate an accurate clock
  3566. * @retval SET / RESET
  3567. */
  3568. #define __HAL_RCC_GET_PLL1_CLKOUT_CONFIG(__PLL1_CLOCKOUT__) READ_BIT(RCC->PLL1CFGR, (__PLL1_CLOCKOUT__))
  3569. /**
  3570. * @brief Enables or disables Fractional Part Of The Multiplication Factor of PLL1 VCO
  3571. * @note Enabling/disabling Fractional Part can be any time without the need to stop the PLL1
  3572. * @retval None
  3573. */
  3574. #define __HAL_RCC_PLL1_FRACN_ENABLE() SET_BIT(RCC->PLL1CFGR, RCC_PLL1CFGR_PLL1FRACEN)
  3575. #define __HAL_RCC_PLL1_FRACN_DISABLE() CLEAR_BIT(RCC->PLL1CFGR, RCC_PLL1CFGR_PLL1FRACEN)
  3576. /**
  3577. * @brief Macro to configures the main PLL (PLL1) clock source, multiplication and division factors.
  3578. * @note This function must be used only when the main PLL1 is disabled.
  3579. *
  3580. * @param __PLL1SOURCE__: specifies the PLL entry clock source.
  3581. * This parameter can be one of the following values:
  3582. * @arg RCC_PLL1_SOURCE_CSI: CSI oscillator clock selected as PLL1 clock entry
  3583. * @arg RCC_PLL1_SOURCE_HSI: HSI oscillator clock selected as PLL1 clock entry
  3584. * @arg RCC_PLL1_SOURCE_HSE: HSE oscillator clock selected as PLL1 clock entry
  3585. * @note This clock source (__PLL1SOURCE__) is the clock source for PLL1 (main PLL) and is different
  3586. from PLL2 & PLL3 clock sources.
  3587. *
  3588. * @param __PLL1M__: specifies the division factor for PLL VCO input clock
  3589. * This parameter must be a number between 1 and 63.
  3590. * @note You have to set the PLL1M parameter correctly to ensure that the VCO input
  3591. * frequency ranges from 1 to 16 MHz.
  3592. *
  3593. * @param __PLL1N__: specifies the multiplication factor for PLL VCO output clock
  3594. * This parameter must be a number between 4 and 512.
  3595. * @note You have to set the PLL1N parameter correctly to ensure that the VCO
  3596. * output frequency is between 150 and 420 MHz (when in medium VCO range) or
  3597. * between 192 and 836 MHZ (when in wide VCO range)
  3598. *
  3599. * @param __PLL1P__: specifies the division factor for system clock.
  3600. * This parameter must be a number between 2 and 128 (where odd numbers not allowed)
  3601. *
  3602. * @param __PLL1Q__: specifies the division factor for peripheral kernel clocks
  3603. * This parameter must be a number between 1 and 128
  3604. *
  3605. * @param __PLL1R__: specifies the division factor for peripheral kernel clocks
  3606. * This parameter must be a number between 1 and 128
  3607. *
  3608. * @retval None
  3609. */
  3610. #define __HAL_RCC_PLL1_CONFIG(__PLL1SOURCE__, __PLL1M__, __PLL1N__, __PLL1P__, __PLL1Q__, __PLL1R__) \
  3611. do{ MODIFY_REG(RCC->PLL1CFGR, (RCC_PLL1CFGR_PLL1SRC | RCC_PLL1CFGR_PLL1M), \
  3612. ((__PLL1SOURCE__) << RCC_PLL1CFGR_PLL1SRC_Pos) | ((__PLL1M__) << RCC_PLL1CFGR_PLL1M_Pos));\
  3613. WRITE_REG(RCC->PLL1DIVR , ( (((__PLL1N__) - 1U ) & RCC_PLL1DIVR_PLL1N) | \
  3614. ((((__PLL1P__) - 1U ) << RCC_PLL1DIVR_PLL1P_Pos) & RCC_PLL1DIVR_PLL1P) | \
  3615. ((((__PLL1Q__) - 1U) << RCC_PLL1DIVR_PLL1Q_Pos) & RCC_PLL1DIVR_PLL1Q) | \
  3616. ((((__PLL1R__) - 1U) << RCC_PLL1DIVR_PLL1R_Pos) & RCC_PLL1DIVR_PLL1R))); \
  3617. } while(0)
  3618. /** @brief Macro to configure the PLL1 clock source.
  3619. * @note This function must be used only when PLL1 is disabled.
  3620. * @param __PLL1SOURCE__: specifies the PLL1 entry clock source.
  3621. * This parameter can be one of the following values:
  3622. * @arg RCC_PLL1_SOURCE_CSI: CSI oscillator clock selected as PLL1 clock entry
  3623. * @arg RCC_PLL1_SOURCE_HSI: HSI oscillator clock selected as PLL1 clock entry
  3624. * @arg RCC_PLL1_SOURCE_HSE: HSE oscillator clock selected as PLL1 clock entry
  3625. *
  3626. */
  3627. #define __HAL_RCC_PLL1_PLLSOURCE_CONFIG(__PLL1SOURCE__) \
  3628. MODIFY_REG(RCC->PLL1CFGR, RCC_PLL1CFGR_PLL1SRC, (__PLL1SOURCE__))
  3629. /** @brief Macro to configure the PLL1 input clock division factor M.
  3630. *
  3631. * @note This function must be used only when the PLL1 is disabled.
  3632. * @note PLL1 clock source is common with the main PLL (configured through
  3633. * __HAL_RCC_PLL1_CONFIG() macro)
  3634. *
  3635. * @param __PLL1M__ specifies the division factor for PLL1 clock.
  3636. * This parameter must be a number between Min_Data = 1 and Max_Data = 63.
  3637. * In order to save power when PLL1 is not used, the value of PLL1M must be set to 0.
  3638. *
  3639. * @retval None
  3640. */
  3641. #define __HAL_RCC_PLL1_DIVM_CONFIG(__PLL1M__) \
  3642. MODIFY_REG(RCC->PLL1CFGR, RCC_PLL1CFGR_PLL1M, (__PLL1M__) << RCC_PLL1CFGR_PLL1M_Pos)
  3643. /**
  3644. * @brief Macro to configures the main PLL clock Fractional Part Of The Multiplication Factor
  3645. *
  3646. * @note These bits can be written at any time, allowing dynamic fine-tuning of the PLL1 VCO
  3647. *
  3648. * @param __PLL1FRACN__: specifies Fractional Part Of The Multiplication Factor for PLL1 VCO
  3649. * It should be a value between 0 and 8191
  3650. * @note Warning: The software has to set correctly these bits to insure that the VCO
  3651. * output frequency is between its valid frequency range, which is:
  3652. * 192 to 836 MHz if PLL1VCOSEL = 0
  3653. * 150 to 420 MHz if PLL1VCOSEL = 1.
  3654. *
  3655. *
  3656. * @retval None
  3657. */
  3658. #define __HAL_RCC_PLL1_FRACN_CONFIG(__PLL1FRACN__) WRITE_REG(RCC->PLL1FRACR, \
  3659. (uint32_t)(__PLL1FRACN__) << RCC_PLL1FRACR_PLL1FRACN_Pos)
  3660. /** @brief Macro to select the PLL1 reference frequency range.
  3661. * @param __PLL1VCIRange__: specifies the PLL1 input frequency range
  3662. * This parameter can be one of the following values:
  3663. * @arg RCC_PLL1_VCIRANGE_0: Range frequency is between 1 and 2 MHz
  3664. * @arg RCC_PLL1_VCIRANGE_1: Range frequency is between 2 and 4 MHz
  3665. * @arg RCC_PLL1_VCIRANGE_2: Range frequency is between 4 and 8 MHz
  3666. * @arg RCC_PLL1_VCIRANGE_3: Range frequency is between 8 and 16 MHz
  3667. * @retval None
  3668. */
  3669. #define __HAL_RCC_PLL1_VCIRANGE(__PLL1VCIRange__) \
  3670. MODIFY_REG(RCC->PLL1CFGR, RCC_PLL1CFGR_PLL1RGE, (__PLL1VCIRange__))
  3671. /** @brief Macro to select the PLL1 reference frequency range.
  3672. * @param __RCC_PLL1VCORange__: specifies the PLL1 input frequency range
  3673. * This parameter can be one of the following values:
  3674. * @arg RCC_PLL1_VCORANGE_WIDE: Range frequency is between 192 and 836 MHz
  3675. * @arg RCC_PLL1_VCORANGE_MEDIUM: Range frequency is between 150 and 420 MHz
  3676. *
  3677. *
  3678. * @retval None
  3679. */
  3680. #define __HAL_RCC_PLL1_VCORANGE(__RCC_PLL1VCORange__) \
  3681. MODIFY_REG(RCC->PLL1CFGR, RCC_PLL1CFGR_PLL1VCOSEL, (__RCC_PLL1VCORange__))
  3682. /** @brief Macro to get the oscillator used as PLL1 clock source.
  3683. * @retval The oscillator used as PLL1 clock source. The returned value can be one
  3684. * of the following:
  3685. * - RCC_PLL1_SOURCE_NONE: No oscillator is used as PLL clock source.
  3686. * - RCC_PLL1_SOURCE_CSI: CSI oscillator is used as PLL clock source.
  3687. * - RCC_PLL1_SOURCE_HSI: HSI oscillator is used as PLL clock source.
  3688. * - RCC_PLL1_SOURCE_HSE: HSE oscillator is used as PLL clock source.
  3689. */
  3690. #define __HAL_RCC_GET_PLL1_OSCSOURCE() ((uint32_t)(RCC->PLL1CFGR & RCC_PLL1CFGR_PLL1SRC))
  3691. /**
  3692. * @brief Macro to configure the system clock source.
  3693. * @param __SYSCLKSOURCE__: specifies the system clock source.
  3694. * This parameter can be one of the following values:
  3695. * - RCC_SYSCLKSOURCE_CSI: CSI oscillator is used as system clock source.
  3696. * - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
  3697. * - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
  3698. * - RCC_SYSCLKSOURCE_PLL1CLK: PLL1P output is used as system clock source.
  3699. * @retval None
  3700. */
  3701. #define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
  3702. MODIFY_REG(RCC->CFGR1, RCC_CFGR1_SW, (__SYSCLKSOURCE__))
  3703. /** @brief Macro to get the clock source used as system clock.
  3704. * @retval The clock source used as system clock. The returned value can be one
  3705. * of the following:
  3706. * - RCC_SYSCLKSOURCE_STATUS_CSI: CSI used as system clock.
  3707. * - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
  3708. * - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
  3709. * - RCC_SYSCLKSOURCE_STATUS_PLL1CLK: PLL1P used as system clock.
  3710. */
  3711. #define __HAL_RCC_GET_SYSCLK_SOURCE() ((uint32_t)(RCC->CFGR1 & RCC_CFGR1_SWS))
  3712. /**
  3713. * @brief Macro to configure the External Low Speed oscillator (LSE) drive capability.
  3714. * @note As the LSE is in the Backup domain and write access is denied to
  3715. * this domain after reset, you have to enable the write access using
  3716. * HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  3717. * (to be done once after reset).
  3718. * @param __LSEDRIVE__: specifies the new state of the LSE drive capability.
  3719. * This parameter can be one of the following values:
  3720. * @arg @ref RCC_LSEDRIVE_LOW LSE oscillator low drive capability.
  3721. * @arg @ref RCC_LSEDRIVE_MEDIUMLOW LSE oscillator medium low drive capability.
  3722. * @arg @ref RCC_LSEDRIVE_MEDIUMHIGH LSE oscillator medium high drive capability.
  3723. * @arg @ref RCC_LSEDRIVE_HIGH LSE oscillator high drive capability.
  3724. * @retval None
  3725. */
  3726. #define __HAL_RCC_LSEDRIVE_CONFIG(__LSEDRIVE__) \
  3727. MODIFY_REG(RCC->BDCR, RCC_BDCR_LSEDRV, (uint32_t)(__LSEDRIVE__))
  3728. /**
  3729. * @brief Macro to configure the wake up from stop clock.
  3730. * @note The configured clock is also used as emergency clock for the Clock Security System on HSE (HSECSS).
  3731. * @param __STOPWUCLK__: specifies the clock source used after wake up from stop.
  3732. * This parameter can be one of the following values:
  3733. * @arg @ref RCC_STOP_WAKEUPCLOCK_HSI HSI selected as system clock source
  3734. * @arg @ref RCC_STOP_WAKEUPCLOCK_CSI CSI selected as system clock source
  3735. * @retval None
  3736. */
  3737. #define __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(__STOPWUCLK__) \
  3738. MODIFY_REG(RCC->CFGR1, RCC_CFGR1_STOPWUCK, (__STOPWUCLK__))
  3739. #define __HAL_RCC_HSECSS_RECOVCLK_CONFIG __HAL_RCC_WAKEUPSTOP_CLK_CONFIG
  3740. /**
  3741. * @brief Macro to configure the Kernel wake up from stop clock.
  3742. * @param __RCC_STOPKERWUCLK__: specifies the Kernel clock source used after wake up from stop
  3743. * This parameter can be one of the following values:
  3744. * @arg RCC_STOP_KERWAKEUPCLOCK_CSI: CSI selected as Kernel clock source
  3745. * @arg RCC_STOP_KERWAKEUPCLOCK_HSI: HSI selected as Kernel clock source
  3746. * @retval None
  3747. */
  3748. #define __HAL_RCC_KERWAKEUPSTOP_CLK_CONFIG(__RCC_STOPKERWUCLK__) \
  3749. MODIFY_REG(RCC->CFGR1, RCC_CFGR1_STOPKERWUCK, (__RCC_STOPKERWUCLK__))
  3750. /** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
  3751. * @{
  3752. */
  3753. /** @brief Macro to configure the MCO1 clock.
  3754. * @param __MCOCLKSOURCE__ specifies the MCO1 clock source.
  3755. * This parameter can be one of the following values:
  3756. * @arg RCC_MCO1SOURCE_HSI: HSI clock selected as MCO1 source
  3757. * @arg RCC_MCO1SOURCE_LSE: LSE clock selected as MCO1 source
  3758. * @arg RCC_MCO1SOURCE_HSE: HSE clock selected as MCO1 source
  3759. * @arg RCC_MCO1SOURCE_PLL1QCLK: PLL1Q clock selected as MCO1 source
  3760. * @arg RCC_MCO1SOURCE_HSI48: HSI48 (48MHZ) selected as MCO1 source
  3761. * @param __MCODIV__ specifies the MCO clock prescaler.
  3762. * This parameter can be one of the following values:
  3763. * @arg RCC_MCODIV_1 up to RCC_MCODIV_15 : divider applied to MCO1 clock
  3764. */
  3765. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  3766. MODIFY_REG(RCC->CFGR1, (RCC_CFGR1_MCO1SEL | RCC_CFGR1_MCO1PRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  3767. /** @brief Macro to configure the MCO2 clock.
  3768. * @param __MCOCLKSOURCE__ specifies the MCO2 clock source.
  3769. * This parameter can be one of the following values:
  3770. * @arg RCC_MCO2SOURCE_SYSCLK: System clock (SYSCLK) selected as MCO2 source
  3771. * @arg RCC_MCO2SOURCE_PLL2PCLK: PLL2P clock selected as MCO2 source
  3772. * @arg RCC_MCO2SOURCE_HSE: HSE clock selected as MCO2 source
  3773. * @arg RCC_MCO2SOURCE_PLL1PCLK: PLL1P clock selected as MCO2 source
  3774. * @arg RCC_MCO2SOURCE_CSI: CSI clock selected as MCO2 source
  3775. * @arg RCC_MCO2SOURCE_LSI: LSI clock selected as MCO2 source
  3776. * @param __MCODIV__ specifies the MCO clock prescaler.
  3777. * This parameter can be one of the following values:
  3778. * @arg RCC_MCODIV_1 up to RCC_MCODIV_15 : divider applied to MCO2 clock
  3779. */
  3780. #define __HAL_RCC_MCO2_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  3781. MODIFY_REG(RCC->CFGR1, (RCC_CFGR1_MCO2SEL | RCC_CFGR1_MCO2PRE), ((__MCOCLKSOURCE__) | ((__MCODIV__) << 7)));
  3782. /**
  3783. * @}
  3784. */
  3785. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  3786. * @brief macros to manage the specified RCC Flags and interrupts.
  3787. * @{
  3788. */
  3789. /** @brief Enable RCC interrupt (Perform access to RCC_CIER[8:0] bits to enable
  3790. * the selected interrupts).
  3791. * @param __INTERRUPT__: specifies the RCC interrupt sources to be enabled.
  3792. * This parameter can be any combination of the following values:
  3793. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3794. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3795. * @arg @ref RCC_IT_CSIRDY CSI ready interrupt
  3796. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3797. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3798. * @arg @ref RCC_IT_PLL1RDY Main PLL ready interrupt
  3799. * @arg @ref RCC_IT_PLL2RDY PLL2 ready interrupt
  3800. * @arg @ref RCC_IT_PLL3RDY PLL3 ready interrupt (*)
  3801. * @arg @ref RCC_IT_HSECSS HSE Clock security system interrupt
  3802. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt
  3803. * @retval None
  3804. *
  3805. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  3806. */
  3807. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) SET_BIT(RCC->CIER, (__INTERRUPT__))
  3808. /** @brief Disable RCC interrupt (Perform access to RCC_CIER[8:0] bits to disable
  3809. * the selected interrupts).
  3810. * @param __INTERRUPT__: specifies the RCC interrupt sources to be disabled.
  3811. * This parameter can be any combination of the following values:
  3812. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3813. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3814. * @arg @ref RCC_IT_CSIRDY CSI ready interrupt
  3815. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3816. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3817. * @arg @ref RCC_IT_PLL1RDY Main PLL ready interrupt
  3818. * @arg @ref RCC_IT_PLL2RDY PLL2 ready interrupt
  3819. * @arg @ref RCC_IT_PLL3RDY PLL3 ready interrupt (*)
  3820. * @arg @ref RCC_IT_HSECSS HSE Clock security system interrupt
  3821. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt
  3822. * @retval None
  3823. *
  3824. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  3825. */
  3826. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(RCC->CIER, (__INTERRUPT__))
  3827. /** @brief Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CICR[10:0]
  3828. * bits to clear the selected interrupt pending bits.
  3829. * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
  3830. * This parameter can be any combination of the following values:
  3831. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3832. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3833. * @arg @ref RCC_IT_CSIRDY CSI ready interrupt
  3834. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3835. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3836. * @arg @ref RCC_IT_PLL1RDY Main PLL ready interrupt
  3837. * @arg @ref RCC_IT_PLL2RDY PLL2 ready interrupt
  3838. * @arg @ref RCC_IT_PLL3RDY PLL3 ready interrupt (*)
  3839. * @arg @ref RCC_IT_HSECSS HSE Clock security system interrupt
  3840. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt
  3841. * @retval None
  3842. *
  3843. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  3844. */
  3845. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) WRITE_REG(RCC->CICR, (__INTERRUPT__))
  3846. /** @brief Check whether the RCC interrupt has occurred or not.
  3847. * @param __INTERRUPT__: specifies the RCC interrupt source to check.
  3848. * This parameter can be one of the following values:
  3849. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  3850. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  3851. * @arg @ref RCC_IT_CSIRDY CSI ready interrupt
  3852. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  3853. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  3854. * @arg @ref RCC_IT_PLL1RDY Main PLL ready interrupt
  3855. * @arg @ref RCC_IT_PLL2RDY PLL2 ready interrupt
  3856. * @arg @ref RCC_IT_PLL3RDY PLL3 ready interrupt (*)
  3857. * @arg @ref RCC_IT_HSECSS HSE Clock security system interrupt
  3858. * @arg @ref RCC_IT_HSI48RDY HSI48 ready interrupt
  3859. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  3860. *
  3861. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  3862. */
  3863. #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIFR & (__INTERRUPT__)) == (__INTERRUPT__))
  3864. /** @brief Set RMVF bit to clear the reset flags.
  3865. * The reset flags are: RCC_FLAG_SFTRST, RCC_FLAG_PINRST, RCC_FLAG_BORRST,
  3866. * RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
  3867. * @retval None
  3868. */
  3869. #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->RSR |= RCC_RSR_RMVF)
  3870. /** @brief Check whether the selected RCC flag is set or not.
  3871. * @param __FLAG__: specifies the flag to check.
  3872. * This parameter can be one of the following values:
  3873. * @arg @ref RCC_FLAG_CSIRDY CSI oscillator clock ready
  3874. * @arg @ref RCC_FLAG_HSIRDY HSI oscillator clock ready
  3875. * @arg @ref RCC_FLAG_HSERDY HSE oscillator clock ready
  3876. * @arg @ref RCC_FLAG_PLL1RDY Main PLL1 clock ready
  3877. * @arg @ref RCC_FLAG_PLL2RDY PLL2 clock ready
  3878. * @arg @ref RCC_FLAG_PLL3RDY PLL3 clock ready (*)
  3879. * @arg @ref RCC_FLAG_HSI48RDY HSI48 clock ready
  3880. * @arg @ref RCC_FLAG_LSERDY LSE oscillator clock ready
  3881. * @arg @ref RCC_FLAG_LSECSSD Clock security system failure on LSE oscillator detection
  3882. * @arg @ref RCC_FLAG_LSIRDY LSI oscillator clock ready
  3883. * @arg @ref RCC_FLAG_HSIDIVF HSI Divider
  3884. * @arg @ref RCC_FLAG_BORRST BOR reset
  3885. * @arg @ref RCC_FLAG_PINRST Pin reset
  3886. * @arg @ref RCC_FLAG_RMVF Remove reset Flag
  3887. * @arg @ref RCC_FLAG_SFTRST Software reset
  3888. * @arg @ref RCC_FLAG_IWDGRST Independent Watchdog reset
  3889. * @arg @ref RCC_FLAG_WWDGRST Window Watchdog reset
  3890. * @arg @ref RCC_FLAG_LPWRRST Low Power reset
  3891. * @retval The new state of __FLAG__ (TRUE or FALSE).
  3892. *
  3893. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  3894. */
  3895. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U) ? RCC->CR : \
  3896. ((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR : \
  3897. ((((__FLAG__) >> 5U) == 3U) ? RCC->RSR : RCC->CIFR))) & \
  3898. (1U << ((__FLAG__) & RCC_FLAG_MASK))) != 0U) ? 1U : 0U)
  3899. /**
  3900. * @}
  3901. */
  3902. /**
  3903. * @}
  3904. */
  3905. /* Private constants ---------------------------------------------------------*/
  3906. /** @defgroup RCC_Private_Constants RCC Private Constants
  3907. * @{
  3908. */
  3909. /** @defgroup RCC_Timeout_Value Timeout Values
  3910. * @{
  3911. */
  3912. #define RCC_HSE_TIMEOUT_VALUE HSE_STARTUP_TIMEOUT
  3913. #define RCC_HSI_TIMEOUT_VALUE ((uint32_t)2U) /* 2 ms (minimum Tick + 1) */
  3914. #define RCC_CSI_TIMEOUT_VALUE ((uint32_t)2U) /* 2 ms (minimum Tick + 1) */
  3915. #define RCC_DBP_TIMEOUT_VALUE (2U) /* 2 ms (minimum Tick + 1) */
  3916. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
  3917. /**
  3918. * @}
  3919. */
  3920. /* Defines used for Flags */
  3921. #define RCC_CR_REG_INDEX (1U)
  3922. #define RCC_BDCR_REG_INDEX (2U)
  3923. #define RCC_RSR_REG_INDEX (3U)
  3924. #define RCC_FLAG_MASK (0x1FU)
  3925. /* Defines Oscillator Masks */
  3926. #define RCC_OSCILLATORTYPE_ALL (RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48 | \
  3927. RCC_OSCILLATORTYPE_CSI | RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE)
  3928. /*!< All Oscillator to configure */
  3929. /**
  3930. * @}
  3931. */
  3932. /* Private macros ------------------------------------------------------------*/
  3933. /** @addtogroup RCC_Private_Macros
  3934. * @{
  3935. */
  3936. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  3937. (((__OSCILLATOR__) & ~RCC_OSCILLATORTYPE_ALL) == 0x00U))
  3938. #define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
  3939. ((__HSE__) == RCC_HSE_BYPASS) || ((__HSE__) == RCC_HSE_BYPASS_DIGITAL))
  3940. #define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
  3941. ((__LSE__) == RCC_LSE_BYPASS) || ((__LSE__) == RCC_LSE_BYPASS_DIGITAL))
  3942. #define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
  3943. #define IS_RCC_HSIDIV(__DIV__) (((__DIV__) == RCC_HSI_DIV1) || ((__DIV__) == RCC_HSI_DIV2) || \
  3944. ((__DIV__) == RCC_HSI_DIV4) || ((__DIV__) == RCC_HSI_DIV8))
  3945. #define IS_RCC_HSI_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) \
  3946. <= (uint32_t)( RCC_HSICFGR_HSITRIM >> RCC_HSICFGR_HSITRIM_Pos))
  3947. #define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
  3948. #define IS_RCC_CSI(__CSI__) (((__CSI__) == RCC_CSI_OFF) || ((__CSI__) == RCC_CSI_ON))
  3949. #define IS_RCC_CSICALIBRATION_VALUE(__VALUE__) ((__VALUE__) \
  3950. <= (uint32_t)( RCC_CSICFGR_CSITRIM >> RCC_CSICFGR_CSITRIM_Pos))
  3951. #define IS_RCC_HSI48(__HSI48__) (((__HSI48__) == RCC_HSI48_OFF) || ((__HSI48__) == RCC_HSI48_ON))
  3952. #define IS_RCC_PLL(PLL) (((PLL) == RCC_PLL_NONE) ||((PLL) == RCC_PLL_OFF) || \
  3953. ((PLL) == RCC_PLL_ON))
  3954. #define IS_RCC_PLL1_SOURCE(SOURCE) (((SOURCE) == RCC_PLL1_SOURCE_CSI) || \
  3955. ((SOURCE) == RCC_PLL1_SOURCE_HSI) || \
  3956. ((SOURCE) == RCC_PLL1_SOURCE_HSE))
  3957. #define IS_RCC_PLL1_DIVM_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 63U))
  3958. #define IS_RCC_PLL1_MULN_VALUE(VALUE) ((4U <= (VALUE)) && ((VALUE) <= 512U))
  3959. #define IS_RCC_PLL1_DIVP_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 128U))
  3960. #define IS_RCC_PLL1_DIVQ_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  3961. #define IS_RCC_PLL1_DIVR_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  3962. #define IS_RCC_PLL1_CLOCKOUT_VALUE(VALUE) (((VALUE) == RCC_PLL1_DIVP) || \
  3963. ((VALUE) == RCC_PLL1_DIVQ) || \
  3964. ((VALUE) == RCC_PLL1_DIVR))
  3965. #define IS_RCC_PLL1_VCIRGE_VALUE(VALUE) (((VALUE) == RCC_PLL1_VCIRANGE_0) || \
  3966. ((VALUE) == RCC_PLL1_VCIRANGE_1) || \
  3967. ((VALUE) == RCC_PLL1_VCIRANGE_2) || \
  3968. ((VALUE) == RCC_PLL1_VCIRANGE_3))
  3969. #define IS_RCC_PLL1_VCORGE_VALUE(VALUE) (((VALUE) == RCC_PLL1_VCORANGE_WIDE) || ((VALUE) == RCC_PLL1_VCORANGE_MEDIUM))
  3970. #define IS_RCC_PLL1_FRACN_VALUE(VALUE) ((VALUE) <= 8191U)
  3971. #define IS_RCC_CLOCKTYPE(CLK) ((1U <= (CLK)) && ((CLK) <= 0x1FU))
  3972. #define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_CSI) || \
  3973. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
  3974. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
  3975. ((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
  3976. #define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
  3977. ((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
  3978. ((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
  3979. ((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
  3980. ((__HCLK__) == RCC_SYSCLK_DIV512))
  3981. #define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
  3982. ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
  3983. ((__PCLK__) == RCC_HCLK_DIV16))
  3984. #define IS_RCC_RTCCLKSOURCE(SOURCE) \
  3985. (((SOURCE) == RCC_RTCCLKSOURCE_LSE) || ((SOURCE) == RCC_RTCCLKSOURCE_LSI) || \
  3986. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV2) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV3) || \
  3987. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV4) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV5) || \
  3988. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV6) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV7) || \
  3989. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV8) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV9) || \
  3990. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV10) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV11) || \
  3991. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV12) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV13) || \
  3992. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV14) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV15) || \
  3993. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV16) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV17) || \
  3994. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV18) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV19) || \
  3995. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV20) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV21) || \
  3996. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV22) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV23) || \
  3997. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV24) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV25) || \
  3998. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV26) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV27) || \
  3999. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV28) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV29) || \
  4000. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV30) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV31) || \
  4001. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV32) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV33) || \
  4002. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV34) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV35) || \
  4003. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV36) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV37) || \
  4004. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV38) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV39) || \
  4005. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV40) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV41) || \
  4006. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV42) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV43) || \
  4007. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV44) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV45) || \
  4008. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV46) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV47) || \
  4009. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV48) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV49) || \
  4010. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV50) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV51) || \
  4011. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV52) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV53) || \
  4012. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV54) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV55) || \
  4013. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV56) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV57) || \
  4014. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV58) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV59) || \
  4015. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV60) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV61) || \
  4016. ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV62) || ((SOURCE) == RCC_RTCCLKSOURCE_HSE_DIV63) || \
  4017. ((SOURCE) == RCC_RTCCLKSOURCE_NO_CLK))
  4018. #define IS_RCC_MCO(MCOx) (((MCOx) == RCC_MCO1) || ((MCOx) == RCC_MCO2))
  4019. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_HSI) || ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
  4020. ((SOURCE) == RCC_MCO1SOURCE_HSE) || ((SOURCE) == RCC_MCO1SOURCE_PLL1Q) || \
  4021. ((SOURCE) == RCC_MCO1SOURCE_HSI48))
  4022. #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2SOURCE_SYSCLK) || ((SOURCE) == RCC_MCO2SOURCE_PLL2P) || \
  4023. ((SOURCE) == RCC_MCO2SOURCE_HSE) || ((SOURCE) == RCC_MCO2SOURCE_PLL1P) || \
  4024. ((SOURCE) == RCC_MCO2SOURCE_CSI) || ((SOURCE) == RCC_MCO2SOURCE_LSI))
  4025. #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1) || ((DIV) == RCC_MCODIV_2) || \
  4026. ((DIV) == RCC_MCODIV_3) || ((DIV) == RCC_MCODIV_4) || \
  4027. ((DIV) == RCC_MCODIV_5) || ((DIV) == RCC_MCODIV_6) || \
  4028. ((DIV) == RCC_MCODIV_7) || ((DIV) == RCC_MCODIV_8) || \
  4029. ((DIV) == RCC_MCODIV_9) || ((DIV) == RCC_MCODIV_10) || \
  4030. ((DIV) == RCC_MCODIV_11) || ((DIV) == RCC_MCODIV_12) || \
  4031. ((DIV) == RCC_MCODIV_13) || ((DIV) == RCC_MCODIV_14) || \
  4032. ((DIV) == RCC_MCODIV_15))
  4033. #define IS_RCC_LSE_DRIVE(__DRIVE__) (((__DRIVE__) == RCC_LSEDRIVE_MEDIUMLOW) || \
  4034. ((__DRIVE__) == RCC_LSEDRIVE_LOW) || \
  4035. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMHIGH) || \
  4036. ((__DRIVE__) == RCC_LSEDRIVE_HIGH))
  4037. #define IS_RCC_STOP_WAKEUPCLOCK(__SOURCE__) (((__SOURCE__) == RCC_STOP_WAKEUPCLOCK_CSI) || \
  4038. ((__SOURCE__) == RCC_STOP_WAKEUPCLOCK_HSI))
  4039. #define IS_RCC_STOP_KERWAKEUPCLOCK(SOURCE) (((SOURCE) == RCC_STOP_KERWAKEUPCLOCK_CSI) || \
  4040. ((SOURCE) == RCC_STOP_KERWAKEUPCLOCK_HSI))
  4041. #if defined(RCC_SECCFGR_HSISEC)
  4042. #define IS_RCC_ITEM_ATTRIBUTES(ITEM) ((((ITEM) & RCC_ALL) != 0U) && (((ITEM) & ~RCC_ALL) == 0U))
  4043. #define IS_RCC_SINGLE_ITEM_ATTRIBUTES(ITEM) (((ITEM) == RCC_HSI) || \
  4044. ((ITEM) == RCC_HSE) || \
  4045. ((ITEM) == RCC_CSI) || \
  4046. ((ITEM) == RCC_LSI) || \
  4047. ((ITEM) == RCC_LSE) || \
  4048. ((ITEM) == RCC_SYSCLK) || \
  4049. ((ITEM) == RCC_PRESC) || \
  4050. ((ITEM) == RCC_PLL1) || \
  4051. ((ITEM) == RCC_PLL2) || \
  4052. ((ITEM) == RCC_PLL3) || \
  4053. ((ITEM) == RCC_HSI48) || \
  4054. ((ITEM) == RCC_RMVF) || \
  4055. ((ITEM) == RCC_CKPERSEL))
  4056. #endif /* RCC_SECCFGR_HSISEC */
  4057. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  4058. #define IS_RCC_ATTRIBUTES(ATTRIBUTES) (((ATTRIBUTES) == RCC_SEC_PRIV) || \
  4059. ((ATTRIBUTES) == RCC_SEC_NPRIV) || \
  4060. ((ATTRIBUTES) == RCC_NSEC_PRIV) || \
  4061. ((ATTRIBUTES) == RCC_NSEC_NPRIV))
  4062. #elif defined(RCC_PRIVCFGR_NSPRIV)
  4063. #define IS_RCC_ATTRIBUTES(ATTRIBUTES) (((ATTRIBUTES) == RCC_NSEC_NPRIV) || ((ATTRIBUTES) == RCC_NSEC_PRIV))
  4064. #else
  4065. #define IS_RCC_ATTRIBUTES(ATTRIBUTES) (((ATTRIBUTES) == RCC_NPRIV) || ((ATTRIBUTES) == RCC_PRIV))
  4066. #endif /* __ARM_FEATURE_CMSE */
  4067. /**
  4068. * @}
  4069. */
  4070. /* Include RCC HAL Extended module */
  4071. #include "stm32h5xx_hal_rcc_ex.h"
  4072. /* Exported functions --------------------------------------------------------*/
  4073. /** @addtogroup RCC_Exported_Functions
  4074. * @{
  4075. */
  4076. /** @addtogroup RCC_Exported_Functions_Group1
  4077. * @{
  4078. */
  4079. /* Initialization and de-initialization functions ******************************/
  4080. HAL_StatusTypeDef HAL_RCC_DeInit(void);
  4081. HAL_StatusTypeDef HAL_RCC_OscConfig(const RCC_OscInitTypeDef *pOscInitStruct);
  4082. HAL_StatusTypeDef HAL_RCC_ClockConfig(const RCC_ClkInitTypeDef *pClkInitStruct, uint32_t FLatency);
  4083. /**
  4084. * @}
  4085. */
  4086. /** @addtogroup RCC_Exported_Functions_Group2
  4087. * @{
  4088. */
  4089. /* Peripheral Control functions **********************************************/
  4090. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  4091. void HAL_RCC_EnableCSS(void);
  4092. uint32_t HAL_RCC_GetSysClockFreq(void);
  4093. uint32_t HAL_RCC_GetHCLKFreq(void);
  4094. uint32_t HAL_RCC_GetPCLK1Freq(void);
  4095. uint32_t HAL_RCC_GetPCLK2Freq(void);
  4096. uint32_t HAL_RCC_GetPCLK3Freq(void);
  4097. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *pOscInitStruct);
  4098. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *pClkInitStruct, uint32_t *pFLatency);
  4099. /* CSS NMI IRQ handler */
  4100. void HAL_RCC_NMI_IRQHandler(void);
  4101. /* User Callbacks in non blocking mode (IT mode) */
  4102. void HAL_RCC_CSSCallback(void);
  4103. uint32_t HAL_RCC_GetResetSource(void);
  4104. /**
  4105. * @}
  4106. */
  4107. /** @addtogroup RCC_Exported_Functions_Group3
  4108. * @{
  4109. */
  4110. /* Attributes management functions ********************************************/
  4111. void HAL_RCC_ConfigAttributes(uint32_t Item, uint32_t Attributes);
  4112. HAL_StatusTypeDef HAL_RCC_GetConfigAttributes(uint32_t Item, uint32_t *pAttributes);
  4113. /**
  4114. * @}
  4115. */
  4116. /**
  4117. * @}
  4118. */
  4119. /**
  4120. * @}
  4121. */
  4122. /**
  4123. * @}
  4124. */
  4125. #ifdef __cplusplus
  4126. }
  4127. #endif
  4128. #endif /* __STM32H5xx_HAL_RCC_H */