stm32h5xx_hal_rcc_ex.h 174 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849
  1. /**
  2. ******************************************************************************
  3. * @file stm32h5xx_hal_rcc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL Extended 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_EX_H
  20. #define __STM32H5xx_HAL_RCC_EX_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 RCCEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup RCCEx_Exported_Types RCCEx Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief PLL2 Clock structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t PLL2Source; /*!< RCC_PLL2Source: PLL2 entry clock source.
  42. This parameter must be a value of @ref RCC_PLL2_Clock_Source */
  43. uint32_t PLL2M; /*!< PLL2M: Division factor for PLL2 VCO input clock.
  44. This parameter must be a number between Min_Data = 1 and Max_Data = 63 */
  45. uint32_t PLL2N; /*!< PLL2N: Multiplication factor for PLL2 VCO output clock.
  46. This parameter must be a number between Min_Data = 4 and Max_Data = 512 */
  47. uint32_t PLL2P; /*!< PLL2P: Division factor for peripheral clock.
  48. This parameter must be a number between Min_Data = 2 and Max_Data = 128 */
  49. uint32_t PLL2Q; /*!< PLL2Q: Division factor for peripheral clocks.
  50. This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
  51. uint32_t PLL2R; /*!< PLL2R: Division factor for peripheral clocks.
  52. This parameter must be a number between Min_Data = 1 and Max_Data = 128
  53. odd division factors are not allowed */
  54. uint32_t PLL2RGE; /*!<PLL2RGE: PLL2 clock Input range
  55. This parameter must be a value of @ref RCC_PLL2_VCI_Range */
  56. uint32_t PLL2VCOSEL; /*!<PLL2VCOSEL: PLL2 clock Output range
  57. This parameter must be a value of @ref RCC_PLL2_VCO_Range */
  58. uint32_t PLL2FRACN; /*!<PLL2FRACN: Specifies Fractional Part Of The Multiplication Factor for
  59. PLL2 VCO It should be a value between 0 and 8191 */
  60. uint32_t PLL2ClockOut; /*!< PLL2ClockOut: specifies PLL2 output clock to be enabled.
  61. This parameter must be a value or a combination of @ref RCC_PLL2_Clock_Output */
  62. } RCC_PLL2InitTypeDef;
  63. #if defined(RCC_CR_PLL3ON)
  64. /**
  65. * @brief PLL3 Clock structure definition
  66. */
  67. typedef struct
  68. {
  69. uint32_t PLL3Source; /*!< RCC_PLL3Source: PLL3 entry clock source.
  70. This parameter must be a value of @ref RCC_PLL3_Clock_Source */
  71. uint32_t PLL3M; /*!< PLL3M: Division factor for PLL3 VCO input clock.
  72. This parameter must be a number between Min_Data = 1 and Max_Data = 63 */
  73. uint32_t PLL3N; /*!< PLL3N: Multiplication factor for PLL3 VCO output clock.
  74. This parameter must be a number between Min_Data = 4 and Max_Data = 512 */
  75. uint32_t PLL3P; /*!< PLL3P: Division factor for system clock.
  76. This parameter must be a number between Min_Data = 2 and Max_Data = 128 */
  77. uint32_t PLL3Q; /*!< PLL3Q: Division factor for peripheral clocks.
  78. This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
  79. uint32_t PLL3R; /*!< PLL3R: Division factor for peripheral clocks.
  80. This parameter must be a number between Min_Data = 1 and Max_Data = 128
  81. odd division factors are not allowed */
  82. uint32_t PLL3RGE; /*!<PLL3RGE: PLL3 clock Input range
  83. This parameter must be a value of @ref RCC_PLL3_VCI_Range */
  84. uint32_t PLL3VCOSEL; /*!<PLL3VCOSEL: PLL3 clock Output range
  85. This parameter must be a value of @ref RCC_PLL3_VCO_Range */
  86. uint32_t PLL3FRACN; /*!<PLL3FRACN: Specifies Fractional Part Of The Multiplication Factor for
  87. PLL3 VCO It should be a value between 0 and 8191 */
  88. uint32_t PLL3ClockOut; /*!< PLL3ClockOut: specifies PLL3 output clock to be enabled.
  89. This parameter must be a value or a combination of @ref RCC_PLL3_Clock_Output */
  90. } RCC_PLL3InitTypeDef;
  91. #endif /* RCC_CR_PLL3ON */
  92. /**
  93. * @brief RCC PLL1 Clocks structure definition
  94. */
  95. typedef struct
  96. {
  97. uint32_t PLL1_P_Frequency;
  98. uint32_t PLL1_Q_Frequency;
  99. uint32_t PLL1_R_Frequency;
  100. } PLL1_ClocksTypeDef;
  101. /**
  102. * @brief RCC PLL2 Clocks structure definition
  103. */
  104. typedef struct
  105. {
  106. uint32_t PLL2_P_Frequency;
  107. uint32_t PLL2_Q_Frequency;
  108. uint32_t PLL2_R_Frequency;
  109. } PLL2_ClocksTypeDef;
  110. #if defined(RCC_CR_PLL3ON)
  111. /**
  112. * @brief RCC PLL3 Clocks structure definition
  113. */
  114. typedef struct
  115. {
  116. uint32_t PLL3_P_Frequency;
  117. uint32_t PLL3_Q_Frequency;
  118. uint32_t PLL3_R_Frequency;
  119. } PLL3_ClocksTypeDef;
  120. #endif /* RCC_CR_PLL3ON */
  121. /**
  122. * @brief RCC extended clocks structure definition
  123. */
  124. typedef struct
  125. {
  126. uint64_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  127. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  128. RCC_PLL2InitTypeDef PLL2; /*!< PLL2structure parameters.
  129. This parameter will be used only when PLL2 is selected as kernel clock Source
  130. for some peripherals */
  131. #if defined(RCC_CR_PLL3ON)
  132. RCC_PLL3InitTypeDef PLL3; /*!< PLL3 structure parameters.
  133. This parameter will be used only when PLL2 is selected as kernel clock Source
  134. for some peripherals */
  135. #endif /* RCC_CR_PLL3ON */
  136. uint32_t CkperClockSelection; /*!< Specifies CKPER clock source
  137. This parameter can be a value of @ref RCCEx_CLKP_Clock_Source */
  138. uint32_t Usart1ClockSelection; /*!< Specifies USART1 clock source.
  139. This parameter can be a value of @ref RCCEx_USART1_Clock_Source */
  140. uint32_t Usart2ClockSelection; /*!< Specifies USART2 clock source.
  141. This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
  142. uint32_t Usart3ClockSelection; /*!< Specifies USART3 clock source.
  143. This parameter can be a value of @ref RCCEx_USART3_Clock_Source */
  144. #if defined(UART4)
  145. uint32_t Uart4ClockSelection; /*!< Specifies UART4 clock source.
  146. This parameter can be a value of @ref RCCEx_UART4_Clock_Source */
  147. #endif /* UART4 */
  148. #if defined(UART5)
  149. uint32_t Uart5ClockSelection; /*!< Specifies UART5 clock source.
  150. This parameter can be a value of @ref RCCEx_UART5_Clock_Source */
  151. #endif /* UART5 */
  152. #if defined(USART6)
  153. uint32_t Usart6ClockSelection; /*!< Specifies USART6 clock source.
  154. This parameter can be a value of @ref RCCEx_USART6_Clock_Source */
  155. #endif /* USART6 */
  156. #if defined(UART7)
  157. uint32_t Uart7ClockSelection; /*!< Specifies UART7 clock source.
  158. This parameter can be a value of @ref RCCEx_UART7_Clock_Source */
  159. #endif /* UART7 */
  160. #if defined(UART8)
  161. uint32_t Uart8ClockSelection; /*!< Specifies UART8 clock source.
  162. This parameter can be a value of @ref RCCEx_UART8_Clock_Source */
  163. #endif /* UART8 */
  164. #if defined(UART9)
  165. uint32_t Uart9ClockSelection; /*!< Specifies UART9 clock source.
  166. This parameter can be a value of @ref RCCEx_UART9_Clock_Source */
  167. #endif /* UART9 */
  168. #if defined(USART10)
  169. uint32_t Usart10ClockSelection; /*!< Specifies USART10 clock source.
  170. This parameter can be a value of @ref RCCEx_USART10_Clock_Source */
  171. #endif /* USART10 */
  172. #if defined(USART11)
  173. uint32_t Usart11ClockSelection; /*!< Specifies USART11 clock source.
  174. This parameter can be a value of @ref RCCEx_USART11_Clock_Source */
  175. #endif /* USART11 */
  176. #if defined(UART12)
  177. uint32_t Uart12ClockSelection; /*!< Specifies UART12 clock source.
  178. This parameter can be a value of @ref RCCEx_UART12_Clock_Source */
  179. #endif /* UART12 */
  180. uint32_t Lpuart1ClockSelection; /*!< Specifies LPUART1 clock source.
  181. This parameter can be a value of @ref RCCEx_LPUART1_Clock_Source */
  182. uint32_t I2c1ClockSelection; /*!< Specifies I2C1 clock source.
  183. This parameter can be a value of @ref RCCEx_I2C1_Clock_Source */
  184. uint32_t I2c2ClockSelection; /*!< Specifies I2C2 clock source.
  185. This parameter can be a value of @ref RCCEx_I2C2_Clock_Source */
  186. #if defined(I2C3)
  187. uint32_t I2c3ClockSelection; /*!< Specifies I2C3 clock source.
  188. This parameter can be a value of @ref RCCEx_I2C3_Clock_Source */
  189. #endif /* I2C3 */
  190. #if defined(I2C4)
  191. uint32_t I2c4ClockSelection; /*!< Specifies I2C4 clock source.
  192. This parameter can be a value of @ref RCCEx_I2C4_Clock_Source */
  193. #endif /* I2C4 */
  194. uint32_t I3c1ClockSelection; /*!< Specifies I3C1 clock source.
  195. This parameter can be a value of @ref RCCEx_I3C1_Clock_Source */
  196. #if defined(I3C2)
  197. uint32_t I3c2ClockSelection; /*!< Specifies I3C2 clock source.
  198. This parameter can be a value of @ref RCCEx_I3C2_Clock_Source */
  199. #endif /* I3C2*/
  200. uint32_t Lptim1ClockSelection; /*!< Specifies LPTIM1 clock source.
  201. This parameter can be a value of @ref RCCEx_LPTIM1_Clock_Source */
  202. uint32_t Lptim2ClockSelection; /*!< Specifies LPTIM2 clock source.
  203. This parameter can be a value of @ref RCCEx_LPTIM2_Clock_Source */
  204. #if defined(LPTIM3)
  205. uint32_t Lptim3ClockSelection; /*!< Specifies LPTIM3 clock source.
  206. This parameter can be a value of @ref RCCEx_LPTIM3_Clock_Source */
  207. #endif /* LPTIM3 */
  208. #if defined(LPTIM4)
  209. uint32_t Lptim4ClockSelection; /*!< Specifies LPTIM4 clock source.
  210. This parameter can be a value of @ref RCCEx_LPTIM4_Clock_Source */
  211. #endif /* LPTIM4 */
  212. #if defined(LPTIM5)
  213. uint32_t Lptim5ClockSelection; /*!< Specifies LPTIM5 clock source.
  214. This parameter can be a value of @ref RCCEx_LPTIM5_Clock_Source */
  215. #endif /* LPTIM5 */
  216. #if defined(LPTIM6)
  217. uint32_t Lptim6ClockSelection; /*!< Specifies LPTIM6 clock source.
  218. This parameter can be a value of @ref RCCEx_LPTIM6_Clock_Source */
  219. #endif /* LPTIM6 */
  220. uint32_t FdcanClockSelection; /*!< Specifies FDCAN kernel clock source.
  221. This parameter can be a value of @ref RCCEx_FDCAN_Clock_Source */
  222. #if defined(SAI1)
  223. uint32_t Sai1ClockSelection; /*!< Specifies SAI1 clock source.
  224. This parameter can be a value of @ref RCCEx_SAI1_Clock_Source */
  225. #endif /* SAI1*/
  226. #if defined(SAI2)
  227. uint32_t Sai2ClockSelection; /*!< Specifies SAI2 clock source.
  228. This parameter can be a value of @ref RCCEx_SAI2_Clock_Source */
  229. #endif /* SAI2*/
  230. uint32_t RngClockSelection; /*!< Specifies RNG clock source.
  231. This parameter can be a value of @ref RCCEx_RNG_Clock_Source */
  232. #if defined(SDMMC1)
  233. uint32_t Sdmmc1ClockSelection; /*!< Specifies SDMMC1 clock source.
  234. This parameter can be a value of @ref RCCEx_SDMMC1_Clock_Source */
  235. #endif /* SDMMC1 */
  236. #if defined(SDMMC2)
  237. uint32_t Sdmmc2ClockSelection; /*!< Specifies SDMMC2 clock source.
  238. This parameter can be a value of @ref RCCEx_SDMMC2_Clock_Source */
  239. #endif /* SDMMC2 */
  240. uint32_t AdcDacClockSelection; /*!< Specifies ADC1, ADC2 and DAC interface clock source.
  241. This parameter can be a value of @ref RCCEx_ADCDAC_Clock_Source */
  242. uint32_t DacLowPowerClockSelection; /*!< Specifies DAC low-power clock source used in Sample and hold mode.
  243. This parameter can be a value of @ref RCCEx_DAC_Low_Power_Clock_Source */
  244. #if defined(OCTOSPI1)
  245. uint32_t OspiClockSelection; /*!< Specifies OctoSPI clock source.
  246. This parameter can be a value of @ref RCCEx_OSPI_Clock_Source */
  247. #endif /* OCTOSPI1 */
  248. uint32_t Spi1ClockSelection; /*!< Specifies SPI1 clock source.
  249. This parameter can be a value of @ref RCCEx_SPI1_Clock_Source */
  250. uint32_t Spi2ClockSelection; /*!< Specifies SPI2 clock source.
  251. This parameter can be a value of @ref RCCEx_SPI2_Clock_Source */
  252. uint32_t Spi3ClockSelection; /*!< Specifies SPI3 clock source.
  253. This parameter can be a value of @ref RCCEx_SPI3_Clock_Source */
  254. #if defined(SPI4)
  255. uint32_t Spi4ClockSelection; /*!< Specifies SPI4 clock source.
  256. This parameter can be a value of @ref RCCEx_SPI4_Clock_Source */
  257. #endif /* SPI4 */
  258. #if defined(SPI5)
  259. uint32_t Spi5ClockSelection; /*!< Specifies SPI5 clock source.
  260. This parameter can be a value of @ref RCCEx_SPI5_Clock_Source */
  261. #endif /* SPI5 */
  262. #if defined(SPI6)
  263. uint32_t Spi6ClockSelection; /*!< Specifies SPI6 clock source.
  264. This parameter can be a value of @ref RCCEx_SPI6_Clock_Source */
  265. #endif /* SPI6 */
  266. uint32_t RTCClockSelection; /*!< Specifies RTC clock source.
  267. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  268. #if defined(CEC)
  269. uint32_t CecClockSelection; /*!< Specifies CEC clock source.
  270. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  271. #endif /* CEC */
  272. #if defined(USB_DRD_FS)
  273. uint32_t UsbClockSelection; /*!< Specifies USB clock source.
  274. This parameter can be a value of @ref RCCEx_USB_Clock_Source */
  275. #endif /* USB_DRD_FS */
  276. uint32_t TimPresSelection; /*!< Specifies TIM Clock Prescalers Selection.
  277. This parameter can be a value of @ref RCCEx_TIM_Prescaler_Selection */
  278. } RCC_PeriphCLKInitTypeDef;
  279. #if defined(CRS)
  280. /**
  281. * @brief RCC_CRS Init structure definition
  282. */
  283. typedef struct
  284. {
  285. uint32_t Prescaler; /*!< Specifies the division factor of the SYNC signal.
  286. This parameter can be a value of @ref RCCEx_CRS_SynchroDivider */
  287. uint32_t Source; /*!< Specifies the SYNC signal source.
  288. This parameter can be a value of @ref RCCEx_CRS_SynchroSource */
  289. uint32_t Polarity; /*!< Specifies the input polarity for the SYNC signal source.
  290. This parameter can be a value of @ref RCCEx_CRS_SynchroPolarity */
  291. uint32_t ReloadValue; /*!< Specifies the value to be loaded in the frequency error counter with each SYNC
  292. event. It can be calculated in using macro
  293. __HAL_RCC_CRS_RELOADVALUE_CALCULATE(__FTARGET__, __FSYNC__)
  294. This parameter must be a number between 0 and 0xFFFF or a value of
  295. @ref RCCEx_CRS_ReloadValueDefault .*/
  296. uint32_t ErrorLimitValue; /*!< Specifies the value to be used to evaluate the captured frequency error value.
  297. This parameter must be a number between 0 and 0xFF or a value of
  298. @ref RCCEx_CRS_ErrorLimitDefault */
  299. uint32_t HSI48CalibrationValue; /*!< Specifies a user-programmable trimming value to the HSI48 oscillator.
  300. This parameter must be a number between 0 and 0x7F or a value of
  301. @ref RCCEx_CRS_HSI48CalibrationDefault */
  302. } RCC_CRSInitTypeDef;
  303. /**
  304. * @brief RCC_CRS Synchronization structure definition
  305. */
  306. typedef struct
  307. {
  308. uint32_t ReloadValue; /*!< Specifies the value loaded in the Counter reload value.
  309. This parameter must be a number between 0 and 0xFFFF */
  310. uint32_t HSI48CalibrationValue; /*!< Specifies value loaded in HSI48 oscillator smooth trimming.
  311. This parameter must be a number between 0 and 0x3F */
  312. uint32_t FreqErrorCapture; /*!< Specifies the value loaded in the .FECAP, the frequency error counter
  313. value latched in the time of the last SYNC event.
  314. This parameter must be a number between 0 and 0xFFFF */
  315. uint32_t FreqErrorDirection; /*!< Specifies the value loaded in the .FEDIR, the counting direction of the
  316. frequency error counter latched in the time of the last SYNC event.
  317. It shows whether the actual frequency is below or above the target.
  318. This parameter must be a value of @ref RCCEx_CRS_FreqErrorDirection */
  319. } RCC_CRSSynchroInfoTypeDef;
  320. #endif /* CRS */
  321. /**
  322. * @}
  323. */
  324. /* Exported constants --------------------------------------------------------*/
  325. /** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
  326. * @{
  327. */
  328. /** @defgroup RCCEx_LSCO_Clock_Source Low Speed Microcontroller Clock Output Source
  329. * @{
  330. */
  331. #define RCC_LSCOSOURCE_LSI 0x00000000U /*!< LSI selection for low speed microcontroller clock output */
  332. #define RCC_LSCOSOURCE_LSE RCC_BDCR_LSCOSEL /*!< LSE selection for low speed microcontroller clock output */
  333. /**
  334. * @}
  335. */
  336. #if defined(PWR_USBSCR_OTGHSEN)
  337. /** @defgroup OTGHS_CLK48_VALUE OTG_HS output clock
  338. * @{
  339. */
  340. #define OTGHS_CLK48_VALUE 48000000U /*!< Value of the OTGHS_CLK48 in Hz*/
  341. /**
  342. * @}
  343. */
  344. #endif /* PWR_USBSCR_OTGHSEN */
  345. /** @defgroup RCCEx_Periph_Clock_Selection RCCEx Periph Clock Selection
  346. * @{
  347. */
  348. #define RCC_PERIPHCLK_USART1 ((uint64_t)0x00000001U)
  349. #define RCC_PERIPHCLK_USART2 ((uint64_t)0x00000002U)
  350. #define RCC_PERIPHCLK_USART3 ((uint64_t)0x00000004U)
  351. #if defined(UART4)
  352. #define RCC_PERIPHCLK_UART4 ((uint64_t)0x00000008U)
  353. #endif /* UART4 */
  354. #if defined(UART5)
  355. #define RCC_PERIPHCLK_UART5 ((uint64_t)0x00000010U)
  356. #endif /* UART5 */
  357. #if defined(USART6)
  358. #define RCC_PERIPHCLK_USART6 ((uint64_t)0x00000020U)
  359. #endif /* USART6 */
  360. #if defined(UART7)
  361. #define RCC_PERIPHCLK_UART7 ((uint64_t)0x00000040U)
  362. #endif /* UART7 */
  363. #if defined(UART8)
  364. #define RCC_PERIPHCLK_UART8 ((uint64_t)0x00000080U)
  365. #endif /* UART8 */
  366. #if defined(UART9)
  367. #define RCC_PERIPHCLK_UART9 ((uint64_t)0x00000100U)
  368. #endif /* UART9 */
  369. #if defined(USART10)
  370. #define RCC_PERIPHCLK_USART10 ((uint64_t)0x00000200U)
  371. #endif /* USART10 */
  372. #if defined(USART11)
  373. #define RCC_PERIPHCLK_USART11 ((uint64_t)0x00000400U)
  374. #endif /* USART11 */
  375. #if defined(UART12)
  376. #define RCC_PERIPHCLK_UART12 ((uint64_t)0x00000800U)
  377. #endif /* UART12 */
  378. #define RCC_PERIPHCLK_LPUART1 ((uint64_t)0x00001000U)
  379. #define RCC_PERIPHCLK_I2C1 ((uint64_t)0x00002000U)
  380. #define RCC_PERIPHCLK_I2C2 ((uint64_t)0x00004000U)
  381. #if defined(I2C3)
  382. #define RCC_PERIPHCLK_I2C3 ((uint64_t)0x00008000U)
  383. #endif /* I2C3 */
  384. #define RCC_PERIPHCLK_I3C1 ((uint64_t)0x00010000U)
  385. #define RCC_PERIPHCLK_LPTIM1 ((uint64_t)0x00020000U)
  386. #define RCC_PERIPHCLK_LPTIM2 ((uint64_t)0x00040000U)
  387. #if defined(SAI1)
  388. #define RCC_PERIPHCLK_SAI1 ((uint64_t)0x00080000U)
  389. #endif /* SAI1 */
  390. #if defined(SAI2)
  391. #define RCC_PERIPHCLK_SAI2 ((uint64_t)0x00100000U)
  392. #endif /* SAI2 */
  393. #define RCC_PERIPHCLK_ADCDAC ((uint64_t)0x00200000U)
  394. #define RCC_PERIPHCLK_ADC RCC_PERIPHCLK_ADCDAC
  395. #define RCC_PERIPHCLK_DAC RCC_PERIPHCLK_ADCDAC
  396. #if defined(SDMMC1)
  397. #define RCC_PERIPHCLK_SDMMC1 ((uint64_t)0x00400000U)
  398. #endif /* SDMMC1 */
  399. #if defined(SDMMC2)
  400. #define RCC_PERIPHCLK_SDMMC2 ((uint64_t)0x00800000U)
  401. #endif /* SDMMC2 */
  402. #define RCC_PERIPHCLK_CKPER ((uint64_t)0x01000000U)
  403. #define RCC_PERIPHCLK_RTC ((uint64_t)0x02000000U)
  404. #define RCC_PERIPHCLK_RNG ((uint64_t)0x04000000U)
  405. #define RCC_PERIPHCLK_SPI1 ((uint64_t)0x08000000U)
  406. #define RCC_PERIPHCLK_SPI2 ((uint64_t)0x10000000U)
  407. #define RCC_PERIPHCLK_SPI3 ((uint64_t)0x20000000U)
  408. #if defined(SPI4)
  409. #define RCC_PERIPHCLK_SPI4 ((uint64_t)0x40000000U)
  410. #endif /* SPI4 */
  411. #if defined(SPI5)
  412. #define RCC_PERIPHCLK_SPI5 ((uint64_t)0x80000000U)
  413. #endif /* SPI5 */
  414. #if defined(SPI6)
  415. #define RCC_PERIPHCLK_SPI6 ((uint64_t)0x100000000U)
  416. #endif /* SPI6 */
  417. #if defined(OCTOSPI1)
  418. #define RCC_PERIPHCLK_OSPI ((uint64_t)0x200000000U)
  419. #endif /* OCTOSPI1 */
  420. #define RCC_PERIPHCLK_FDCAN ((uint64_t)0x400000000U)
  421. #if defined(CEC)
  422. #define RCC_PERIPHCLK_CEC ((uint64_t)0x800000000U)
  423. #endif /* CEC */
  424. #if defined(USB_DRD_FS)
  425. #define RCC_PERIPHCLK_USB ((uint64_t)0x1000000000U)
  426. #endif /* USB_DRD_FS */
  427. #if defined(LPTIM3)
  428. #define RCC_PERIPHCLK_LPTIM3 ((uint64_t)0x2000000000U)
  429. #endif /* LPTIM3 */
  430. #if defined(LPTIM4)
  431. #define RCC_PERIPHCLK_LPTIM4 ((uint64_t)0x4000000000U)
  432. #endif /* LPTIM4 */
  433. #if defined(LPTIM5)
  434. #define RCC_PERIPHCLK_LPTIM5 ((uint64_t)0x8000000000U)
  435. #endif /* LPTIM5 */
  436. #if defined(LPTIM6)
  437. #define RCC_PERIPHCLK_LPTIM6 ((uint64_t)0x10000000000U)
  438. #endif /* LPTIM6 */
  439. #define RCC_PERIPHCLK_DAC_LP ((uint64_t)0x20000000000U)
  440. #if defined(I2C4)
  441. #define RCC_PERIPHCLK_I2C4 ((uint64_t)0x40000000000U)
  442. #endif /* I2C4 */
  443. #define RCC_PERIPHCLK_TIM ((uint64_t)0x80000000000U)
  444. #if defined(I3C2)
  445. #define RCC_PERIPHCLK_I3C2 ((uint64_t)0x100000000000U)
  446. #endif /* I3C2 */
  447. /**
  448. * @}
  449. */
  450. /** @defgroup RCC_PLL2_Clock_Output RCC PLL2 Clock Output
  451. * @{
  452. */
  453. #define RCC_PLL2_DIVP RCC_PLL2CFGR_PLL2PEN
  454. #define RCC_PLL2_DIVQ RCC_PLL2CFGR_PLL2QEN
  455. #define RCC_PLL2_DIVR RCC_PLL2CFGR_PLL2REN
  456. /**
  457. * @}
  458. */
  459. #if defined(RCC_CR_PLL3ON)
  460. /** @defgroup RCC_PLL3_Clock_Output RCC PLL3 Clock Output
  461. * @{
  462. */
  463. #define RCC_PLL3_DIVP RCC_PLL3CFGR_PLL3PEN
  464. #define RCC_PLL3_DIVQ RCC_PLL3CFGR_PLL3QEN
  465. #define RCC_PLL3_DIVR RCC_PLL3CFGR_PLL3REN
  466. /**
  467. * @}
  468. */
  469. #endif /* RCC_CR_PLL3ON */
  470. /** @defgroup RCC_PLL2_VCI_Range RCC PLL2 VCI Range
  471. * @{
  472. */
  473. #define RCC_PLL2_VCIRANGE_0 (0x00000000U) /*!< Clock range frequency between 1 and 2 MHz */
  474. #define RCC_PLL2_VCIRANGE_1 RCC_PLL2CFGR_PLL2RGE_0 /*!< Clock range frequency between 2 and 4 MHz */
  475. #define RCC_PLL2_VCIRANGE_2 RCC_PLL2CFGR_PLL2RGE_1 /*!< Clock range frequency between 4 and 8 MHz */
  476. #define RCC_PLL2_VCIRANGE_3 (RCC_PLL2CFGR_PLL2RGE_0 | RCC_PLL2CFGR_PLL2RGE_1) /*!< Clock range frequency between 8 and 16 MHz */
  477. /**
  478. * @}
  479. */
  480. /** @defgroup RCC_PLL2_VCO_Range RCC PLL2 VCO Range
  481. * @{
  482. */
  483. #define RCC_PLL2_VCORANGE_WIDE (0x00000000U) /*!< Wide VCO range: 192 to 836 MHz */
  484. #define RCC_PLL2_VCORANGE_MEDIUM RCC_PLL2CFGR_PLL2VCOSEL /*!< Medium VCO range: 150 to 420 MHz */
  485. /**
  486. * @}
  487. */
  488. /** @defgroup RCC_PLL2_Clock_Source RCC PLL2 Clock Source
  489. * @{
  490. */
  491. #define RCC_PLL2_SOURCE_NONE (0x00000000U)
  492. #define RCC_PLL2_SOURCE_HSI RCC_PLL2CFGR_PLL2SRC_0
  493. #define RCC_PLL2_SOURCE_CSI RCC_PLL2CFGR_PLL2SRC_1
  494. #define RCC_PLL2_SOURCE_HSE (RCC_PLL2CFGR_PLL2SRC_0 | RCC_PLL2CFGR_PLL2SRC_1)
  495. /**
  496. * @}
  497. */
  498. #if defined(RCC_CR_PLL3ON)
  499. /** @defgroup RCC_PLL3_VCI_Range RCC PLL3 VCI Range
  500. * @{
  501. */
  502. #define RCC_PLL3_VCIRANGE_0 (0x00000000U) /*!< Clock range frequency between 1 and 2 MHz */
  503. #define RCC_PLL3_VCIRANGE_1 RCC_PLL3CFGR_PLL3RGE_0 /*!< Clock range frequency between 2 and 4 MHz */
  504. #define RCC_PLL3_VCIRANGE_2 RCC_PLL3CFGR_PLL3RGE_1 /*!< Clock range frequency between 4 and 8 MHz */
  505. #define RCC_PLL3_VCIRANGE_3 (RCC_PLL3CFGR_PLL3RGE_0 | RCC_PLL3CFGR_PLL3RGE_1) /*!< Clock range frequency between 8 and 16 MHz */
  506. /**
  507. * @}
  508. */
  509. /** @defgroup RCC_PLL3_VCO_Range RCC PLL3 VCO Range
  510. * @{
  511. */
  512. #define RCC_PLL3_VCORANGE_WIDE (0x00000000U) /*!< Wide VCO range: 192 to 836 MHz */
  513. #define RCC_PLL3_VCORANGE_MEDIUM RCC_PLL3CFGR_PLL3VCOSEL /*!< Medium VCO range: 150 to 420 MHz */
  514. /**
  515. * @}
  516. */
  517. /** @defgroup RCC_PLL3_Clock_Source RCC PLL3 Clock Source
  518. * @{
  519. */
  520. #define RCC_PLL3_SOURCE_NONE (0x00000000U)
  521. #define RCC_PLL3_SOURCE_HSI RCC_PLL3CFGR_PLL3SRC_0
  522. #define RCC_PLL3_SOURCE_CSI RCC_PLL3CFGR_PLL3SRC_1
  523. #define RCC_PLL3_SOURCE_HSE (RCC_PLL3CFGR_PLL3SRC_0 | RCC_PLL3CFGR_PLL3SRC_1)
  524. /**
  525. * @}
  526. */
  527. #endif /* RCC_CR_PLL3ON */
  528. /** @defgroup RCCEx_USART1_Clock_Source USART1 Clock Source
  529. * @{
  530. */
  531. #define RCC_USART1CLKSOURCE_PCLK2 ((uint32_t)0x00000000U)
  532. #define RCC_USART1CLKSOURCE_PLL2Q RCC_CCIPR1_USART1SEL_0
  533. #if defined(RCC_CR_PLL3ON)
  534. #define RCC_USART1CLKSOURCE_PLL3Q RCC_CCIPR1_USART1SEL_1
  535. #endif /* RCC_CR_PLL3ON */
  536. #define RCC_USART1CLKSOURCE_HSI (RCC_CCIPR1_USART1SEL_0 | RCC_CCIPR1_USART1SEL_1)
  537. #define RCC_USART1CLKSOURCE_CSI RCC_CCIPR1_USART1SEL_2
  538. #define RCC_USART1CLKSOURCE_LSE (RCC_CCIPR1_USART1SEL_0 | RCC_CCIPR1_USART1SEL_2)
  539. /**
  540. * @}
  541. */
  542. /** @defgroup RCCEx_USART2_Clock_Source USART2 Clock Source
  543. * @{
  544. */
  545. #define RCC_USART2CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  546. #define RCC_USART2CLKSOURCE_PLL2Q RCC_CCIPR1_USART2SEL_0
  547. #if defined(RCC_CR_PLL3ON)
  548. #define RCC_USART2CLKSOURCE_PLL3Q RCC_CCIPR1_USART2SEL_1
  549. #endif /* RCC_CR_PLL3ON */
  550. #define RCC_USART2CLKSOURCE_HSI (RCC_CCIPR1_USART2SEL_0 | RCC_CCIPR1_USART2SEL_1)
  551. #define RCC_USART2CLKSOURCE_CSI RCC_CCIPR1_USART2SEL_2
  552. #define RCC_USART2CLKSOURCE_LSE (RCC_CCIPR1_USART2SEL_0 | RCC_CCIPR1_USART2SEL_2)
  553. /**
  554. * @}
  555. */
  556. /** @defgroup RCCEx_USART3_Clock_Source USART3 Clock Source
  557. * @{
  558. */
  559. #define RCC_USART3CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  560. #define RCC_USART3CLKSOURCE_PLL2Q RCC_CCIPR1_USART3SEL_0
  561. #if defined(RCC_CR_PLL3ON)
  562. #define RCC_USART3CLKSOURCE_PLL3Q RCC_CCIPR1_USART3SEL_1
  563. #endif /* RCC_CR_PLL3ON */
  564. #define RCC_USART3CLKSOURCE_HSI (RCC_CCIPR1_USART3SEL_0 | RCC_CCIPR1_USART3SEL_1)
  565. #define RCC_USART3CLKSOURCE_CSI RCC_CCIPR1_USART3SEL_2
  566. #define RCC_USART3CLKSOURCE_LSE (RCC_CCIPR1_USART3SEL_0 | RCC_CCIPR1_USART3SEL_2)
  567. /**
  568. * @}
  569. */
  570. #if defined(UART4)
  571. /** @defgroup RCCEx_UART4_Clock_Source UART4 Clock Source
  572. * @{
  573. */
  574. #define RCC_UART4CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  575. #define RCC_UART4CLKSOURCE_PLL2Q RCC_CCIPR1_UART4SEL_0
  576. #define RCC_UART4CLKSOURCE_PLL3Q RCC_CCIPR1_UART4SEL_1
  577. #define RCC_UART4CLKSOURCE_HSI (RCC_CCIPR1_UART4SEL_0 | RCC_CCIPR1_UART4SEL_1)
  578. #define RCC_UART4CLKSOURCE_CSI RCC_CCIPR1_UART4SEL_2
  579. #define RCC_UART4CLKSOURCE_LSE (RCC_CCIPR1_UART4SEL_0 | RCC_CCIPR1_UART4SEL_2)
  580. /**
  581. * @}
  582. */
  583. #endif /* UART4 */
  584. #if defined(UART5)
  585. /** @defgroup RCCEx_UART5_Clock_Source UART5 Clock Source
  586. * @{
  587. */
  588. #define RCC_UART5CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  589. #define RCC_UART5CLKSOURCE_PLL2Q RCC_CCIPR1_UART5SEL_0
  590. #define RCC_UART5CLKSOURCE_PLL3Q RCC_CCIPR1_UART5SEL_1
  591. #define RCC_UART5CLKSOURCE_HSI (RCC_CCIPR1_UART5SEL_0 | RCC_CCIPR1_UART5SEL_1)
  592. #define RCC_UART5CLKSOURCE_CSI RCC_CCIPR1_UART5SEL_2
  593. #define RCC_UART5CLKSOURCE_LSE (RCC_CCIPR1_UART5SEL_0 | RCC_CCIPR1_UART5SEL_2)
  594. /**
  595. * @}
  596. */
  597. #endif /* UART5 */
  598. #if defined(USART6)
  599. /** @defgroup RCCEx_USART6_Clock_Source USART6 Clock Source
  600. * @{
  601. */
  602. #define RCC_USART6CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  603. #define RCC_USART6CLKSOURCE_PLL2Q RCC_CCIPR1_USART6SEL_0
  604. #define RCC_USART6CLKSOURCE_PLL3Q RCC_CCIPR1_USART6SEL_1
  605. #define RCC_USART6CLKSOURCE_HSI (RCC_CCIPR1_USART6SEL_0 | RCC_CCIPR1_USART6SEL_1)
  606. #define RCC_USART6CLKSOURCE_CSI RCC_CCIPR1_USART6SEL_2
  607. #define RCC_USART6CLKSOURCE_LSE (RCC_CCIPR1_USART6SEL_0 | RCC_CCIPR1_USART6SEL_2)
  608. /**
  609. * @}
  610. */
  611. #endif /* USART6 */
  612. #if defined(UART7)
  613. /** @defgroup RCCEx_UART7_Clock_Source UART7 Clock Source
  614. * @{
  615. */
  616. #define RCC_UART7CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  617. #define RCC_UART7CLKSOURCE_PLL2Q RCC_CCIPR1_UART7SEL_0
  618. #define RCC_UART7CLKSOURCE_PLL3Q RCC_CCIPR1_UART7SEL_1
  619. #define RCC_UART7CLKSOURCE_HSI (RCC_CCIPR1_UART7SEL_0 | RCC_CCIPR1_UART7SEL_1)
  620. #define RCC_UART7CLKSOURCE_CSI RCC_CCIPR1_UART7SEL_2
  621. #define RCC_UART7CLKSOURCE_LSE (RCC_CCIPR1_UART7SEL_0 | RCC_CCIPR1_UART7SEL_2)
  622. /**
  623. * @}
  624. */
  625. #endif /* UART7 */
  626. #if defined(UART8)
  627. /** @defgroup RCCEx_UART8_Clock_Source UART8 Clock Source
  628. * @{
  629. */
  630. #define RCC_UART8CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  631. #define RCC_UART8CLKSOURCE_PLL2Q RCC_CCIPR1_UART8SEL_0
  632. #define RCC_UART8CLKSOURCE_PLL3Q RCC_CCIPR1_UART8SEL_1
  633. #define RCC_UART8CLKSOURCE_HSI (RCC_CCIPR1_UART8SEL_0 | RCC_CCIPR1_UART8SEL_1)
  634. #define RCC_UART8CLKSOURCE_CSI RCC_CCIPR1_UART8SEL_2
  635. #define RCC_UART8CLKSOURCE_LSE (RCC_CCIPR1_UART8SEL_0 | RCC_CCIPR1_UART8SEL_2)
  636. /**
  637. * @}
  638. */
  639. #endif /* UART8 */
  640. #if defined(UART9)
  641. /** @defgroup RCCEx_UART9_Clock_Source UART9 Clock Source
  642. * @{
  643. */
  644. #define RCC_UART9CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  645. #define RCC_UART9CLKSOURCE_PLL2Q RCC_CCIPR1_UART9SEL_0
  646. #define RCC_UART9CLKSOURCE_PLL3Q RCC_CCIPR1_UART9SEL_1
  647. #define RCC_UART9CLKSOURCE_HSI (RCC_CCIPR1_UART9SEL_0 | RCC_CCIPR1_UART9SEL_1)
  648. #define RCC_UART9CLKSOURCE_CSI RCC_CCIPR1_UART9SEL_2
  649. #define RCC_UART9CLKSOURCE_LSE (RCC_CCIPR1_UART9SEL_0 | RCC_CCIPR1_UART9SEL_2)
  650. /**
  651. * @}
  652. */
  653. #endif /* UART9 */
  654. #if defined(USART10)
  655. /** @defgroup RCCEx_USART10_Clock_Source USART10 Clock Source
  656. * @{
  657. */
  658. #define RCC_USART10CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  659. #define RCC_USART10CLKSOURCE_PLL2Q RCC_CCIPR1_USART10SEL_0
  660. #define RCC_USART10CLKSOURCE_PLL3Q RCC_CCIPR1_USART10SEL_1
  661. #define RCC_USART10CLKSOURCE_HSI (RCC_CCIPR1_USART10SEL_0 | RCC_CCIPR1_USART10SEL_1)
  662. #define RCC_USART10CLKSOURCE_CSI RCC_CCIPR1_USART10SEL_2
  663. #define RCC_USART10CLKSOURCE_LSE (RCC_CCIPR1_USART10SEL_0 | RCC_CCIPR1_USART10SEL_2)
  664. /**
  665. * @}
  666. */
  667. #endif /* USART10 */
  668. #if defined(USART11)
  669. /** @defgroup RCCEx_USART11_Clock_Source USART11 Clock Source
  670. * @{
  671. */
  672. #define RCC_USART11CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  673. #define RCC_USART11CLKSOURCE_PLL2Q RCC_CCIPR2_USART11SEL_0
  674. #define RCC_USART11CLKSOURCE_PLL3Q RCC_CCIPR2_USART11SEL_1
  675. #define RCC_USART11CLKSOURCE_HSI (RCC_CCIPR2_USART11SEL_0 | RCC_CCIPR2_USART11SEL_1)
  676. #define RCC_USART11CLKSOURCE_CSI RCC_CCIPR2_USART11SEL_2
  677. #define RCC_USART11CLKSOURCE_LSE (RCC_CCIPR2_USART11SEL_0 | RCC_CCIPR2_USART11SEL_2)
  678. /**
  679. * @}
  680. */
  681. #endif /* USART11 */
  682. #if defined(UART12)
  683. /** @defgroup RCCEx_UART12_Clock_Source UART12 Clock Source
  684. * @{
  685. */
  686. #define RCC_UART12CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  687. #define RCC_UART12CLKSOURCE_PLL2Q RCC_CCIPR2_UART12SEL_0
  688. #define RCC_UART12CLKSOURCE_PLL3Q RCC_CCIPR2_UART12SEL_1
  689. #define RCC_UART12CLKSOURCE_HSI (RCC_CCIPR2_UART12SEL_0 | RCC_CCIPR2_UART12SEL_1)
  690. #define RCC_UART12CLKSOURCE_CSI RCC_CCIPR2_UART12SEL_2
  691. #define RCC_UART12CLKSOURCE_LSE (RCC_CCIPR2_UART12SEL_0 | RCC_CCIPR2_UART12SEL_2)
  692. /**
  693. * @}
  694. */
  695. #endif /* UART12 */
  696. /** @defgroup RCCEx_LPUART1_Clock_Source LPUART1 Clock Source
  697. * @{
  698. */
  699. #define RCC_LPUART1CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  700. #define RCC_LPUART1CLKSOURCE_PLL2Q RCC_CCIPR3_LPUART1SEL_0
  701. #if defined(RCC_CR_PLL3ON)
  702. #define RCC_LPUART1CLKSOURCE_PLL3Q RCC_CCIPR3_LPUART1SEL_1
  703. #endif /* RCC_CR_PLL3ON */
  704. #define RCC_LPUART1CLKSOURCE_HSI (RCC_CCIPR3_LPUART1SEL_0 | RCC_CCIPR3_LPUART1SEL_1)
  705. #define RCC_LPUART1CLKSOURCE_CSI RCC_CCIPR3_LPUART1SEL_2
  706. #define RCC_LPUART1CLKSOURCE_LSE (RCC_CCIPR3_LPUART1SEL_0 | RCC_CCIPR3_LPUART1SEL_2)
  707. /**
  708. * @}
  709. */
  710. /** @defgroup RCCEx_I2C1_Clock_Source I2C1 Clock Source
  711. * @{
  712. */
  713. #define RCC_I2C1CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  714. #if defined(RCC_CR_PLL3ON)
  715. #define RCC_I2C1CLKSOURCE_PLL3R RCC_CCIPR4_I2C1SEL_0
  716. #else
  717. #define RCC_I2C1CLKSOURCE_PLL2R RCC_CCIPR4_I2C1SEL_0
  718. #endif /* RCC_CR_PLL3ON */
  719. #define RCC_I2C1CLKSOURCE_HSI RCC_CCIPR4_I2C1SEL_1
  720. #define RCC_I2C1CLKSOURCE_CSI (RCC_CCIPR4_I2C1SEL_1 | RCC_CCIPR4_I2C1SEL_0)
  721. /**
  722. * @}
  723. */
  724. /** @defgroup RCCEx_I2C2_Clock_Source I2C2 Clock Source
  725. * @{
  726. */
  727. #define RCC_I2C2CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  728. #if defined(RCC_CR_PLL3ON)
  729. #define RCC_I2C2CLKSOURCE_PLL3R RCC_CCIPR4_I2C2SEL_0
  730. #else
  731. #define RCC_I2C2CLKSOURCE_PLL2R RCC_CCIPR4_I2C2SEL_0
  732. #endif /* RCC_CR_PLL3ON */
  733. #define RCC_I2C2CLKSOURCE_HSI RCC_CCIPR4_I2C2SEL_1
  734. #define RCC_I2C2CLKSOURCE_CSI (RCC_CCIPR4_I2C2SEL_1 | RCC_CCIPR4_I2C2SEL_0)
  735. /**
  736. * @}
  737. */
  738. #if defined(I2C3)
  739. /** @defgroup RCCEx_I2C3_Clock_Source I2C3 Clock Source
  740. * @{
  741. */
  742. #define RCC_I2C3CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  743. #define RCC_I2C3CLKSOURCE_PLL3R RCC_CCIPR4_I2C3SEL_0
  744. #define RCC_I2C3CLKSOURCE_HSI RCC_CCIPR4_I2C3SEL_1
  745. #define RCC_I2C3CLKSOURCE_CSI (RCC_CCIPR4_I2C3SEL_0 | RCC_CCIPR4_I2C3SEL_1)
  746. /**
  747. * @}
  748. */
  749. #endif /* I2C3 */
  750. #if defined(I2C4)
  751. /** @defgroup RCCEx_I2C4_Clock_Source I2C4 Clock Source
  752. * @{
  753. */
  754. #define RCC_I2C4CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  755. #define RCC_I2C4CLKSOURCE_PLL3R RCC_CCIPR4_I2C4SEL_0
  756. #define RCC_I2C4CLKSOURCE_HSI RCC_CCIPR4_I2C4SEL_1
  757. #define RCC_I2C4CLKSOURCE_CSI (RCC_CCIPR4_I2C4SEL_0 | RCC_CCIPR4_I2C4SEL_1)
  758. /**
  759. * @}
  760. */
  761. #endif /* I2C4 */
  762. /** @defgroup RCCEx_I3C1_Clock_Source I3C1 Clock Source
  763. * @{
  764. */
  765. #define RCC_I3C1CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  766. #if defined(RCC_CR_PLL3ON)
  767. #define RCC_I3C1CLKSOURCE_PLL3R RCC_CCIPR4_I3C1SEL_0
  768. #else
  769. #define RCC_I3C1CLKSOURCE_PLL2R RCC_CCIPR4_I3C1SEL_0
  770. #endif /* RCC_CR_PLL3ON */
  771. #define RCC_I3C1CLKSOURCE_HSI RCC_CCIPR4_I3C1SEL_1
  772. /**
  773. * @}
  774. */
  775. #if defined(I3C2)
  776. /** @defgroup RCCEx_I3C2_Clock_Source I3C2 Clock Source
  777. * @{
  778. */
  779. #define RCC_I3C2CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  780. #if defined(RCC_CR_PLL3ON)
  781. #define RCC_I3C2CLKSOURCE_PLL3R RCC_CCIPR4_I3C2SEL_0
  782. #else
  783. #define RCC_I3C2CLKSOURCE_PLL2R RCC_CCIPR4_I3C2SEL_0
  784. #endif /* RCC_CR_PLL3ON */
  785. #define RCC_I3C2CLKSOURCE_HSI RCC_CCIPR4_I3C2SEL_1
  786. /**
  787. * @}
  788. */
  789. #endif /* I3C2 */
  790. /** @defgroup RCCEx_RNG_Clock_Source RCCEx RNG Clock Source
  791. * @{
  792. */
  793. #define RCC_RNGCLKSOURCE_HSI48 ((uint32_t)0x00000000U)
  794. #define RCC_RNGCLKSOURCE_PLL1Q RCC_CCIPR5_RNGSEL_0
  795. #define RCC_RNGCLKSOURCE_LSE RCC_CCIPR5_RNGSEL_1
  796. #define RCC_RNGCLKSOURCE_LSI (RCC_CCIPR5_RNGSEL_0 | RCC_CCIPR5_RNGSEL_1)
  797. /**
  798. * @}
  799. */
  800. /** @defgroup RCCEx_SPI1_Clock_Source SPI1 Clock Source
  801. * @{
  802. */
  803. #define RCC_SPI1CLKSOURCE_PLL1Q ((uint32_t)0x00000000U)
  804. #define RCC_SPI1CLKSOURCE_PLL2P RCC_CCIPR3_SPI1SEL_0
  805. #if defined(RCC_CR_PLL3ON)
  806. #define RCC_SPI1CLKSOURCE_PLL3P RCC_CCIPR3_SPI1SEL_1
  807. #endif /* RCC_CR_PLL3ON */
  808. #define RCC_SPI1CLKSOURCE_PIN (RCC_CCIPR3_SPI1SEL_0 | RCC_CCIPR3_SPI1SEL_1)
  809. #define RCC_SPI1CLKSOURCE_CLKP RCC_CCIPR3_SPI1SEL_2
  810. /**
  811. * @}
  812. */
  813. /** @defgroup RCCEx_SPI2_Clock_Source SPI2 Clock Source
  814. * @{
  815. */
  816. #define RCC_SPI2CLKSOURCE_PLL1Q ((uint32_t)0x00000000U)
  817. #define RCC_SPI2CLKSOURCE_PLL2P RCC_CCIPR3_SPI2SEL_0
  818. #if defined(RCC_CR_PLL3ON)
  819. #define RCC_SPI2CLKSOURCE_PLL3P RCC_CCIPR3_SPI2SEL_1
  820. #endif /* RCC_CR_PLL3ON */
  821. #define RCC_SPI2CLKSOURCE_PIN (RCC_CCIPR3_SPI2SEL_0 | RCC_CCIPR3_SPI2SEL_1)
  822. #define RCC_SPI2CLKSOURCE_CLKP RCC_CCIPR3_SPI2SEL_2
  823. /**
  824. * @}
  825. */
  826. /** @defgroup RCCEx_SPI3_Clock_Source SPI3 Clock Source
  827. * @{
  828. */
  829. #define RCC_SPI3CLKSOURCE_PLL1Q ((uint32_t)0x00000000U)
  830. #define RCC_SPI3CLKSOURCE_PLL2P RCC_CCIPR3_SPI3SEL_0
  831. #if defined(RCC_CR_PLL3ON)
  832. #define RCC_SPI3CLKSOURCE_PLL3P RCC_CCIPR3_SPI3SEL_1
  833. #endif /* RCC_CR_PLL3ON */
  834. #define RCC_SPI3CLKSOURCE_PIN (RCC_CCIPR3_SPI3SEL_0 | RCC_CCIPR3_SPI3SEL_1)
  835. #define RCC_SPI3CLKSOURCE_CLKP RCC_CCIPR3_SPI3SEL_2
  836. /**
  837. * @}
  838. */
  839. #if defined(SPI4)
  840. /** @defgroup RCCEx_SPI4_Clock_Source SPI4 Clock Source
  841. * @{
  842. */
  843. #define RCC_SPI4CLKSOURCE_PCLK2 ((uint32_t)0x00000000U)
  844. #define RCC_SPI4CLKSOURCE_PLL2Q RCC_CCIPR3_SPI4SEL_0
  845. #define RCC_SPI4CLKSOURCE_PLL3Q RCC_CCIPR3_SPI4SEL_1
  846. #define RCC_SPI4CLKSOURCE_HSI (RCC_CCIPR3_SPI4SEL_0 | RCC_CCIPR3_SPI4SEL_1)
  847. #define RCC_SPI4CLKSOURCE_CSI RCC_CCIPR3_SPI4SEL_2
  848. #define RCC_SPI4CLKSOURCE_HSE (RCC_CCIPR3_SPI4SEL_0 | RCC_CCIPR3_SPI4SEL_2)
  849. /**
  850. * @}
  851. */
  852. #endif /* SPI4 */
  853. #if defined(SPI5)
  854. /** @defgroup RCCEx_SPI5_Clock_Source SPI5 Clock Source
  855. * @{
  856. */
  857. #define RCC_SPI5CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  858. #define RCC_SPI5CLKSOURCE_PLL2Q RCC_CCIPR3_SPI5SEL_0
  859. #define RCC_SPI5CLKSOURCE_PLL3Q RCC_CCIPR3_SPI5SEL_1
  860. #define RCC_SPI5CLKSOURCE_HSI (RCC_CCIPR3_SPI5SEL_0 | RCC_CCIPR3_SPI5SEL_1)
  861. #define RCC_SPI5CLKSOURCE_CSI RCC_CCIPR3_SPI5SEL_2
  862. #define RCC_SPI5CLKSOURCE_HSE (RCC_CCIPR3_SPI5SEL_0 | RCC_CCIPR3_SPI5SEL_2)
  863. /**
  864. * @}
  865. */
  866. #endif /* SPI5 */
  867. #if defined(SPI6)
  868. /** @defgroup RCCEx_SPI6_Clock_Source SPI6 Clock Source
  869. * @{
  870. */
  871. #define RCC_SPI6CLKSOURCE_PCLK2 ((uint32_t)0x00000000U)
  872. #define RCC_SPI6CLKSOURCE_PLL2Q RCC_CCIPR3_SPI6SEL_0
  873. #define RCC_SPI6CLKSOURCE_PLL3Q RCC_CCIPR3_SPI6SEL_1
  874. #define RCC_SPI6CLKSOURCE_HSI (RCC_CCIPR3_SPI6SEL_0 | RCC_CCIPR3_SPI6SEL_1)
  875. #define RCC_SPI6CLKSOURCE_CSI RCC_CCIPR3_SPI6SEL_2
  876. #define RCC_SPI6CLKSOURCE_HSE (RCC_CCIPR3_SPI6SEL_0 | RCC_CCIPR3_SPI6SEL_2)
  877. /**
  878. * @}
  879. */
  880. #endif /* SPI6 */
  881. /** @defgroup RCCEx_LPTIM1_Clock_Source LPTIM1 Clock Source
  882. * @{
  883. */
  884. #define RCC_LPTIM1CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  885. #define RCC_LPTIM1CLKSOURCE_PLL2P RCC_CCIPR2_LPTIM1SEL_0
  886. #if defined(RCC_CR_PLL3ON)
  887. #define RCC_LPTIM1CLKSOURCE_PLL3R RCC_CCIPR2_LPTIM1SEL_1
  888. #endif /* RCC_CR_PLL3ON */
  889. #define RCC_LPTIM1CLKSOURCE_LSE (RCC_CCIPR2_LPTIM1SEL_0 | RCC_CCIPR2_LPTIM1SEL_1)
  890. #define RCC_LPTIM1CLKSOURCE_LSI RCC_CCIPR2_LPTIM1SEL_2
  891. #define RCC_LPTIM1CLKSOURCE_CLKP (RCC_CCIPR2_LPTIM1SEL_0 | RCC_CCIPR2_LPTIM1SEL_2)
  892. /**
  893. * @}
  894. */
  895. /** @defgroup RCCEx_LPTIM2_Clock_Source LPTIM2 Clock Source
  896. * @{
  897. */
  898. #define RCC_LPTIM2CLKSOURCE_PCLK1 ((uint32_t)0x00000000U)
  899. #define RCC_LPTIM2CLKSOURCE_PLL2P RCC_CCIPR2_LPTIM2SEL_0
  900. #if defined(RCC_CR_PLL3ON)
  901. #define RCC_LPTIM2CLKSOURCE_PLL3R RCC_CCIPR2_LPTIM2SEL_1
  902. #endif /* RCC_CR_PLL3ON */
  903. #define RCC_LPTIM2CLKSOURCE_LSE (RCC_CCIPR2_LPTIM2SEL_0 | RCC_CCIPR2_LPTIM2SEL_1)
  904. #define RCC_LPTIM2CLKSOURCE_LSI RCC_CCIPR2_LPTIM2SEL_2
  905. #define RCC_LPTIM2CLKSOURCE_CLKP (RCC_CCIPR2_LPTIM2SEL_0 | RCC_CCIPR2_LPTIM2SEL_2)
  906. /**
  907. * @}
  908. */
  909. #if defined(LPTIM3)
  910. /** @defgroup RCCEx_LPTIM3_Clock_Source LPTIM3 Clock Source
  911. * @{
  912. */
  913. #define RCC_LPTIM3CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  914. #define RCC_LPTIM3CLKSOURCE_PLL2P RCC_CCIPR2_LPTIM3SEL_0
  915. #define RCC_LPTIM3CLKSOURCE_PLL3R RCC_CCIPR2_LPTIM3SEL_1
  916. #define RCC_LPTIM3CLKSOURCE_LSE (RCC_CCIPR2_LPTIM3SEL_0 | RCC_CCIPR2_LPTIM3SEL_1)
  917. #define RCC_LPTIM3CLKSOURCE_LSI RCC_CCIPR2_LPTIM3SEL_2
  918. #define RCC_LPTIM3CLKSOURCE_CLKP (RCC_CCIPR2_LPTIM3SEL_0 | RCC_CCIPR2_LPTIM3SEL_2)
  919. /**
  920. * @}
  921. */
  922. #endif /* LPTIM3 */
  923. #if defined(LPTIM4)
  924. /** @defgroup RCCEx_LPTIM4_Clock_Source LPTIM4 Clock Source
  925. * @{
  926. */
  927. #define RCC_LPTIM4CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  928. #define RCC_LPTIM4CLKSOURCE_PLL2P RCC_CCIPR2_LPTIM4SEL_0
  929. #define RCC_LPTIM4CLKSOURCE_PLL3R RCC_CCIPR2_LPTIM4SEL_1
  930. #define RCC_LPTIM4CLKSOURCE_LSE (RCC_CCIPR2_LPTIM4SEL_0 | RCC_CCIPR2_LPTIM4SEL_1)
  931. #define RCC_LPTIM4CLKSOURCE_LSI RCC_CCIPR2_LPTIM4SEL_2
  932. #define RCC_LPTIM4CLKSOURCE_CLKP (RCC_CCIPR2_LPTIM4SEL_0 | RCC_CCIPR2_LPTIM4SEL_2)
  933. /**
  934. * @}
  935. */
  936. #endif /* LPTIM4 */
  937. #if defined(LPTIM5)
  938. /** @defgroup RCCEx_LPTIM5_Clock_Source LPTIM5 Clock Source
  939. * @{
  940. */
  941. #define RCC_LPTIM5CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  942. #define RCC_LPTIM5CLKSOURCE_PLL2P RCC_CCIPR2_LPTIM5SEL_0
  943. #define RCC_LPTIM5CLKSOURCE_PLL3R RCC_CCIPR2_LPTIM5SEL_1
  944. #define RCC_LPTIM5CLKSOURCE_LSE (RCC_CCIPR2_LPTIM5SEL_0 | RCC_CCIPR2_LPTIM5SEL_1)
  945. #define RCC_LPTIM5CLKSOURCE_LSI RCC_CCIPR2_LPTIM5SEL_2
  946. #define RCC_LPTIM5CLKSOURCE_CLKP (RCC_CCIPR2_LPTIM5SEL_0 | RCC_CCIPR2_LPTIM5SEL_2)
  947. /**
  948. * @}
  949. */
  950. #endif /* LPTIM5 */
  951. #if defined(LPTIM6)
  952. /** @defgroup RCCEx_LPTIM6_Clock_Source LPTIM6 Clock Source
  953. * @{
  954. */
  955. #define RCC_LPTIM6CLKSOURCE_PCLK3 ((uint32_t)0x00000000U)
  956. #define RCC_LPTIM6CLKSOURCE_PLL2P RCC_CCIPR2_LPTIM6SEL_0
  957. #define RCC_LPTIM6CLKSOURCE_PLL3R RCC_CCIPR2_LPTIM6SEL_1
  958. #define RCC_LPTIM6CLKSOURCE_LSE (RCC_CCIPR2_LPTIM6SEL_0 | RCC_CCIPR2_LPTIM6SEL_1)
  959. #define RCC_LPTIM6CLKSOURCE_LSI RCC_CCIPR2_LPTIM6SEL_2
  960. #define RCC_LPTIM6CLKSOURCE_CLKP (RCC_CCIPR2_LPTIM6SEL_0 | RCC_CCIPR2_LPTIM6SEL_2)
  961. /**
  962. * @}
  963. */
  964. #endif /* LPTIM6 */
  965. /** @defgroup RCCEx_FDCAN_Clock_Source FDCAN Kernel Clock Source
  966. * @{
  967. */
  968. #define RCC_FDCANCLKSOURCE_HSE ((uint32_t)0x00000000U)
  969. #define RCC_FDCANCLKSOURCE_PLL1Q RCC_CCIPR5_FDCANSEL_0
  970. #define RCC_FDCANCLKSOURCE_PLL2Q RCC_CCIPR5_FDCANSEL_1
  971. /**
  972. * @}
  973. */
  974. /** @defgroup RCCEx_ADCDAC_Clock_Source ADCDAC Kernel Clock Source
  975. * @{
  976. */
  977. #define RCC_ADCDACCLKSOURCE_HCLK ((uint32_t)0x00000000U)
  978. #define RCC_ADCDACCLKSOURCE_SYSCLK RCC_CCIPR5_ADCDACSEL_0
  979. #define RCC_ADCDACCLKSOURCE_PLL2R RCC_CCIPR5_ADCDACSEL_1
  980. #define RCC_ADCDACCLKSOURCE_HSE (RCC_CCIPR5_ADCDACSEL_1 | RCC_CCIPR5_ADCDACSEL_0)
  981. #define RCC_ADCDACCLKSOURCE_HSI RCC_CCIPR5_ADCDACSEL_2
  982. #define RCC_ADCDACCLKSOURCE_CSI (RCC_CCIPR5_ADCDACSEL_2 | RCC_CCIPR5_ADCDACSEL_0)
  983. /**
  984. * @}
  985. */
  986. /** @defgroup RCCEx_DAC_Low_Power_Clock_Source DAC Low Power Kernel Clock Source
  987. * @{
  988. */
  989. #define RCC_DACLPCLKSOURCE_LSE ((uint32_t)0x00000000U)
  990. #define RCC_DACLPCLKSOURCE_LSI RCC_CCIPR5_DACSEL
  991. /**
  992. * @}
  993. */
  994. #if defined(SAI1)
  995. /** @defgroup RCCEx_SAI1_Clock_Source SAI1 Clock Source
  996. * @{
  997. */
  998. #define RCC_SAI1CLKSOURCE_PLL1Q ((uint32_t)0x00000000U)
  999. #define RCC_SAI1CLKSOURCE_PLL2P RCC_CCIPR5_SAI1SEL_0
  1000. #define RCC_SAI1CLKSOURCE_PLL3P RCC_CCIPR5_SAI1SEL_1
  1001. #define RCC_SAI1CLKSOURCE_PIN (RCC_CCIPR5_SAI1SEL_1 | RCC_CCIPR5_SAI1SEL_0)
  1002. #define RCC_SAI1CLKSOURCE_CLKP RCC_CCIPR5_SAI1SEL_2
  1003. /**
  1004. * @}
  1005. */
  1006. #endif /* SAI1 */
  1007. #if defined(SAI2)
  1008. /** @defgroup RCCEx_SAI2_Clock_Source SAI2 Clock Source
  1009. * @{
  1010. */
  1011. #define RCC_SAI2CLKSOURCE_PLL1Q ((uint32_t)0x00000000U)
  1012. #define RCC_SAI2CLKSOURCE_PLL2P RCC_CCIPR5_SAI2SEL_0
  1013. #define RCC_SAI2CLKSOURCE_PLL3P RCC_CCIPR5_SAI2SEL_1
  1014. #define RCC_SAI2CLKSOURCE_PIN (RCC_CCIPR5_SAI2SEL_1 | RCC_CCIPR5_SAI2SEL_0)
  1015. #define RCC_SAI2CLKSOURCE_CLKP RCC_CCIPR5_SAI2SEL_2
  1016. /**
  1017. * @}
  1018. */
  1019. #endif /* SAI2 */
  1020. /** @defgroup RCCEx_CLKP_Clock_Source RCCEx CLKP Clock Source
  1021. * @{
  1022. */
  1023. #define RCC_CLKPSOURCE_HSI (0x00000000U)
  1024. #define RCC_CLKPSOURCE_CSI RCC_CCIPR5_CKERPSEL_0
  1025. #define RCC_CLKPSOURCE_HSE RCC_CCIPR5_CKERPSEL_1
  1026. /**
  1027. * @}
  1028. */
  1029. #if defined(SDMMC1)
  1030. /** @defgroup RCCEx_SDMMC1_Clock_Source SDMMC1 Clock Source
  1031. * @{
  1032. */
  1033. #define RCC_SDMMC1CLKSOURCE_PLL1Q ((uint32_t)0x00000000U)
  1034. #define RCC_SDMMC1CLKSOURCE_PLL2R RCC_CCIPR4_SDMMC1SEL
  1035. /**
  1036. * @}
  1037. */
  1038. #endif /* SDMMC1 */
  1039. #if defined(SDMMC2)
  1040. /** @defgroup RCCEx_SDMMC2_Clock_Source SDMMC2 Clock Source
  1041. * @{
  1042. */
  1043. #define RCC_SDMMC2CLKSOURCE_PLL1Q ((uint32_t)0x00000000U)
  1044. #define RCC_SDMMC2CLKSOURCE_PLL2R RCC_CCIPR4_SDMMC2SEL
  1045. /**
  1046. * @}
  1047. */
  1048. #endif /* SDMMC2 */
  1049. #if defined(OCTOSPI1)
  1050. /** @defgroup RCCEx_OSPI_Clock_Source OctoSPI Clock Source
  1051. * @{
  1052. */
  1053. #define RCC_OSPICLKSOURCE_HCLK ((uint32_t)0x00000000U)
  1054. #define RCC_OSPICLKSOURCE_PLL1Q RCC_CCIPR4_OCTOSPISEL_0
  1055. #define RCC_OSPICLKSOURCE_PLL2R RCC_CCIPR4_OCTOSPISEL_1
  1056. #define RCC_OSPICLKSOURCE_CLKP (RCC_CCIPR4_OCTOSPISEL_0 | RCC_CCIPR4_OCTOSPISEL_1)
  1057. /**
  1058. * @}
  1059. */
  1060. #endif /* OCTOSPI1 */
  1061. #if defined(CEC)
  1062. /** @defgroup RCCEx_CEC_Clock_Source CEC Clock Source
  1063. * @{
  1064. */
  1065. #define RCC_CECCLKSOURCE_LSE ((uint32_t)0x00000000U)
  1066. #define RCC_CECCLKSOURCE_LSI RCC_CCIPR5_CECSEL_0
  1067. #define RCC_CECCLKSOURCE_CSI_DIV122 RCC_CCIPR5_CECSEL_1
  1068. /**
  1069. * @}
  1070. */
  1071. #endif /* CEC */
  1072. #if defined(USB_DRD_FS)
  1073. /** @defgroup RCCEx_USB_Clock_Source RCCEx USB Clock Source
  1074. * @{
  1075. */
  1076. #define RCC_USBCLKSOURCE_PLL1Q RCC_CCIPR4_USBSEL_0
  1077. #if defined(RCC_CR_PLL3ON)
  1078. #define RCC_USBCLKSOURCE_PLL3Q RCC_CCIPR4_USBSEL_1
  1079. #else
  1080. #define RCC_USBCLKSOURCE_PLL2Q RCC_CCIPR4_USBSEL_1
  1081. #endif /* RCC_CR_PLL3ON */
  1082. #define RCC_USBCLKSOURCE_HSI48 RCC_CCIPR4_USBSEL
  1083. /**
  1084. * @}
  1085. */
  1086. #endif /* USB_DRD_FS */
  1087. /** @defgroup RCCEx_TIM_Prescaler_Selection RCCEx TIM Prescaler Selection
  1088. * @{
  1089. */
  1090. #define RCC_TIMPRES_DEACTIVATED (0x00000000U)
  1091. #define RCC_TIMPRES_ACTIVATED RCC_CFGR1_TIMPRE
  1092. /**
  1093. * @}
  1094. */
  1095. #if defined(CRS)
  1096. /** @defgroup RCCEx_CRS_Status RCCEx CRS Status
  1097. * @{
  1098. */
  1099. #define RCC_CRS_NONE ((uint32_t)0x00000000U)
  1100. #define RCC_CRS_TIMEOUT ((uint32_t)0x00000001U)
  1101. #define RCC_CRS_SYNCOK ((uint32_t)0x00000002U)
  1102. #define RCC_CRS_SYNCWARN ((uint32_t)0x00000004U)
  1103. #define RCC_CRS_SYNCERR ((uint32_t)0x00000008U)
  1104. #define RCC_CRS_SYNCMISS ((uint32_t)0x00000010U)
  1105. #define RCC_CRS_TRIMOVF ((uint32_t)0x00000020U)
  1106. /**
  1107. * @}
  1108. */
  1109. /** @defgroup RCCEx_CRS_SynchroSource RCCEx CRS SynchroSource
  1110. * @{
  1111. */
  1112. #define RCC_CRS_SYNC_SOURCE_GPIO ((uint32_t)0x00000000U) /*!< Synchro Signal source GPIO */
  1113. #define RCC_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */
  1114. #if defined(USB_DRD_FS)
  1115. #define RCC_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/
  1116. #endif /* USB_DRD_FS */
  1117. /**
  1118. * @}
  1119. */
  1120. /** @defgroup RCCEx_CRS_SynchroDivider RCCEx CRS SynchroDivider
  1121. * @{
  1122. */
  1123. #define RCC_CRS_SYNC_DIV1 ((uint32_t)0x00000000U) /*!< Synchro Signal not divided (default) */
  1124. #define RCC_CRS_SYNC_DIV2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */
  1125. #define RCC_CRS_SYNC_DIV4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */
  1126. #define RCC_CRS_SYNC_DIV8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
  1127. #define RCC_CRS_SYNC_DIV16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */
  1128. #define RCC_CRS_SYNC_DIV32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
  1129. #define RCC_CRS_SYNC_DIV64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
  1130. #define RCC_CRS_SYNC_DIV128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */
  1131. /**
  1132. * @}
  1133. */
  1134. /** @defgroup RCCEx_CRS_SynchroPolarity RCCEx CRS SynchroPolarity
  1135. * @{
  1136. */
  1137. #define RCC_CRS_SYNC_POLARITY_RISING ((uint32_t)0x00000000U) /*!< Synchro Active on rising edge (default) */
  1138. #define RCC_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */
  1139. /**
  1140. * @}
  1141. */
  1142. /** @defgroup RCCEx_CRS_ReloadValueDefault RCCEx CRS ReloadValueDefault
  1143. * @{
  1144. */
  1145. #define RCC_CRS_RELOADVALUE_DEFAULT ((uint32_t)0x0000BB7FU) /*!< The reset value of the RELOAD field corresponds
  1146. to a target frequency of 48 MHz and a synchronization
  1147. signal frequency of 1 kHz (SOF signal from USB). */
  1148. /**
  1149. * @}
  1150. */
  1151. /** @defgroup RCCEx_CRS_ErrorLimitDefault RCCEx CRS ErrorLimitDefault
  1152. * @{
  1153. */
  1154. #define RCC_CRS_ERRORLIMIT_DEFAULT ((uint32_t)0x00000022U) /*!< Default Frequency error limit */
  1155. /**
  1156. * @}
  1157. */
  1158. /** @defgroup RCCEx_CRS_HSI48CalibrationDefault RCCEx CRS HSI48CalibrationDefault
  1159. * @{
  1160. */
  1161. #define RCC_CRS_HSI48CALIBRATION_DEFAULT ((uint32_t)0x00000020U) /*!< The default value is 32, which corresponds to the
  1162. middle of the trimming interval. The trimming step
  1163. is around 67 kHz between two consecutive TRIM
  1164. steps. A higher TRIM value corresponds to a higher
  1165. output frequency */
  1166. /**
  1167. * @}
  1168. */
  1169. /** @defgroup RCCEx_CRS_FreqErrorDirection RCCEx CRS FreqErrorDirection
  1170. * @{
  1171. */
  1172. #define RCC_CRS_FREQERRORDIR_UP ((uint32_t)0x00000000U) /*!< Upcounting direction, the actual frequency is above the target */
  1173. #define RCC_CRS_FREQERRORDIR_DOWN ((uint32_t)CRS_ISR_FEDIR) /*!< Downcounting direction, the actual frequency is below the target */
  1174. /**
  1175. * @}
  1176. */
  1177. /** @defgroup RCCEx_CRS_Interrupt_Sources RCCEx CRS Interrupt Sources
  1178. * @{
  1179. */
  1180. #define RCC_CRS_IT_SYNCOK CRS_CR_SYNCOKIE /*!< SYNC event OK */
  1181. #define RCC_CRS_IT_SYNCWARN CRS_CR_SYNCWARNIE /*!< SYNC warning */
  1182. #define RCC_CRS_IT_ERR CRS_CR_ERRIE /*!< Error */
  1183. #define RCC_CRS_IT_ESYNC CRS_CR_ESYNCIE /*!< Expected SYNC */
  1184. #define RCC_CRS_IT_SYNCERR CRS_CR_ERRIE /*!< SYNC error */
  1185. #define RCC_CRS_IT_SYNCMISS CRS_CR_ERRIE /*!< SYNC missed */
  1186. #define RCC_CRS_IT_TRIMOVF CRS_CR_ERRIE /*!< Trimming overflow or underflow */
  1187. /**
  1188. * @}
  1189. */
  1190. /** @defgroup RCCEx_CRS_Flags RCCEx CRS Flags
  1191. * @{
  1192. */
  1193. #define RCC_CRS_FLAG_SYNCOK CRS_ISR_SYNCOKF /*!< SYNC event OK flag */
  1194. #define RCC_CRS_FLAG_SYNCWARN CRS_ISR_SYNCWARNF /*!< SYNC warning flag */
  1195. #define RCC_CRS_FLAG_ERR CRS_ISR_ERRF /*!< Error flag */
  1196. #define RCC_CRS_FLAG_ESYNC CRS_ISR_ESYNCF /*!< Expected SYNC flag */
  1197. #define RCC_CRS_FLAG_SYNCERR CRS_ISR_SYNCERR /*!< SYNC error */
  1198. #define RCC_CRS_FLAG_SYNCMISS CRS_ISR_SYNCMISS /*!< SYNC missed*/
  1199. #define RCC_CRS_FLAG_TRIMOVF CRS_ISR_TRIMOVF /*!< Trimming overflow or underflow */
  1200. /**
  1201. * @}
  1202. */
  1203. #endif /* CRS */
  1204. /**
  1205. * @}
  1206. */
  1207. /* Exported macros -----------------------------------------------------------*/
  1208. /** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
  1209. * @{
  1210. */
  1211. /** @brief Macros to enable or disable the HSI and CSI divided clock for Timers 12, 15 and LPTimer2 input capture.
  1212. * @note HSI and CSI clocks without division are available when TIMIC is enabled
  1213. * @retval None
  1214. */
  1215. #define __HAL_RCC_TIMIC_ENABLE() SET_BIT(RCC->CCIPR1, RCC_CCIPR1_TIMICSEL) /*!< HSI/1024, CSI/128 and HSI/8 generation for Timers 12,15 and LPTimer2 Input capture */
  1216. #define __HAL_RCC_TIMIC_DISABLE() CLEAR_BIT(RCC->CCIPR1, RCC_CCIPR1_TIMICSEL) /*!< No clock available for Timers Input capture */
  1217. /** @brief Macro to configure the PLL2 clock source.
  1218. * @note This function must be used only when all PLL2 is disabled.
  1219. * @param __PLL2SOURCE__: specifies the PLL2 entry clock source.
  1220. * This parameter can be one of the following values:
  1221. * @arg RCC_PLL2_SOURCE_NONE: No oscillator clock selected as PLL2 clock entry
  1222. * @arg RCC_PLL2_SOURCE_CSI: CSI oscillator clock selected as PLL2 clock entry
  1223. * @arg RCC_PLL2_SOURCE_HSI: HSI oscillator clock selected as PLL2 clock entry
  1224. * @arg RCC_PLL2_SOURCE_HSE: HSE oscillator clock selected as PLL2 clock entry
  1225. *
  1226. */
  1227. #define __HAL_RCC_PLL2_PLLSOURCE_CONFIG(__PLL2SOURCE__) MODIFY_REG(RCC->PLL2CFGR, RCC_PLL2CFGR_PLL2SRC, \
  1228. (__PLL2SOURCE__))
  1229. /** @brief Macro to get the oscillator used as PLL2 clock source.
  1230. * @retval The oscillator used as PLL2 clock source. The returned value can be one
  1231. * of the following:
  1232. * - RCC_PLL2_SOURCE_NONE: No oscillator is used as PLL clock source.
  1233. * - RCC_PLL2_SOURCE_CSI: CSI oscillator is used as PLL clock source.
  1234. * - RCC_PLL2_SOURCE_HSI: HSI oscillator is used as PLL clock source.
  1235. * - RCC_PLL2_SOURCE_HSE: HSE oscillator is used as PLL clock source.
  1236. */
  1237. #define __HAL_RCC_GET_PLL2_OSCSOURCE() ((uint32_t)(RCC->PLL2CFGR & RCC_PLL2CFGR_PLL2SRC))
  1238. /**
  1239. * @brief Macro to configures the PLL2 source, multiplication and division factors.
  1240. * @note This function must be used only when PLL2 is disabled.
  1241. *
  1242. * @param __PLL2SOURCE__: specifies the PLL2 entry clock source.
  1243. * This parameter can be one of the following values:
  1244. * @arg @ref RCC_PLL2_SOURCE_NONE No clock selected as PLL2 clock entry
  1245. * @arg @ref RCC_PLL2_SOURCE_CSI CSI oscillator clock selected as PLL2 clock entry
  1246. * @arg @ref RCC_PLL2_SOURCE_HSI HSI oscillator clock selected as PLL2 clock entry
  1247. * @arg @ref RCC_PLL2_SOURCE_HSE HSE oscillator clock selected as PLL2 clock entry
  1248. *
  1249. * @param __PLL2M__ specifies the division factor of PLL2 input clock.
  1250. * This parameter must be a number between Min_Data = 1 and Max_Data = 63.
  1251. *
  1252. * @param __PLL2N__: specifies the multiplication factor for PLL2 VCO output clock
  1253. * This parameter must be a number between 4 and 512.
  1254. * @note You have to set the PLL2N parameter correctly to ensure that the VCO
  1255. * output frequency is between 192 and 836 MHz (Wide range) or 150 and 420 Mhz (Medium range).
  1256. * PLL2 clock frequency = f(PLL2) multiplied by PLL2N
  1257. *
  1258. * @param __PLL2P__: specifies the division factor for peripheral kernel clocks
  1259. * This parameter must be a number between 1 and 128
  1260. *
  1261. * @param __PLL2Q__: specifies the division factor for peripheral kernel clocks
  1262. * This parameter must be a number between 1 and 128
  1263. *
  1264. * @param __PLL2R__: specifies the division factor for peripheral kernel clocks
  1265. * This parameter must be a number between 1 and 128
  1266. *
  1267. * @retval None
  1268. */
  1269. #define __HAL_RCC_PLL2_CONFIG(__PLL2SOURCE__, __PLL2M__, __PLL2N__, __PLL2P__, __PLL2Q__, __PLL2R__) \
  1270. do{ \
  1271. MODIFY_REG(RCC->PLL2CFGR, (RCC_PLL2CFGR_PLL2SRC | RCC_PLL2CFGR_PLL2M), \
  1272. ((__PLL2SOURCE__) << RCC_PLL2CFGR_PLL2SRC_Pos) | ((__PLL2M__) << RCC_PLL2CFGR_PLL2M_Pos)); \
  1273. WRITE_REG(RCC->PLL2DIVR , ((((__PLL2N__) - 1U) & RCC_PLL2DIVR_PLL2N) | \
  1274. ((((__PLL2P__) - 1U) << RCC_PLL2DIVR_PLL2P_Pos) & RCC_PLL2DIVR_PLL2P) | \
  1275. ((((__PLL2Q__) - 1U) << RCC_PLL2DIVR_PLL2Q_Pos) & RCC_PLL2DIVR_PLL2Q) | \
  1276. ((((__PLL2R__) - 1U) << RCC_PLL2DIVR_PLL2R_Pos) & RCC_PLL2DIVR_PLL2R))); \
  1277. } while(0)
  1278. /**
  1279. * @brief Macro to configure the PLL2 clock multiplication factor N.
  1280. *
  1281. * @note This function must be used only when the PLL2 is disabled.
  1282. * @note PLL2 clock source is independent from the main PLL and is configured through
  1283. * __HAL_RCC_PLL2_CONFIG() macro.
  1284. *
  1285. * @param __PLL2N__ specifies the multiplication factor for PLL2 VCO output clock.
  1286. * This parameter must be a number between 4 and 512.
  1287. * @note You have to set the PLL2N parameter correctly to ensure that the VCO
  1288. * output frequency is between 192 and 836 MHz (Wide range) or 150 and 420 Mhz (Medium range).
  1289. * PLL2 clock frequency = f(PLL2) multiplied by PLL2N
  1290. *
  1291. * @retval None
  1292. */
  1293. #define __HAL_RCC_PLL2_MULN_CONFIG(__PLL2N__) \
  1294. MODIFY_REG(RCC->PLL2DIVR, RCC_PLL2DIVR_N2, ((__PLL2N__) - 1U) << RCC_PLL2DIVR_N2_Pos)
  1295. /** @brief Macro to configure the PLL2 input clock division factor M.
  1296. *
  1297. * @note This function must be used only when the PLL2 is disabled.
  1298. * @note PLL2 clock source is independent from the main PLL and is configured through
  1299. * __HAL_RCC_PLL2_CONFIG() macro.
  1300. *
  1301. * @param __PLL2M__ specifies the division factor for PLL2 clock.
  1302. * This parameter must be a number between Min_Data = 1 and Max_Data = 63.
  1303. * In order to save power when PLL2 is not used, the value of PLL2M must be set to 0.
  1304. *
  1305. * @retval None
  1306. */
  1307. #define __HAL_RCC_PLL2_DIVM_CONFIG(__PLL2M__) \
  1308. MODIFY_REG(RCC->PLL2CFGR, RCC_PLL2CFGR_DIVM2, (__PLL2M__) << RCC_PLL2CFGR_DIVM2_Pos)
  1309. /** @brief Macro to configure the PLL2 clock division factor P.
  1310. *
  1311. * @note This function must be used only when the PLL2 is disabled.
  1312. * @note PLL2 clock source is independent from the main PLL and is configured through
  1313. * __HAL_RCC_PLL2_CONFIG() macro.
  1314. *
  1315. * @param __PLL2P__ specifies the division factor for PLL2 output P clock.
  1316. * This parameter must be a number in the range (1 to 128).
  1317. * Use to set PLL2 output P clock frequency = f(PLL2) / PLL2P
  1318. *
  1319. * @retval None
  1320. */
  1321. #define __HAL_RCC_PLL2_DIVP_CONFIG(__PLL2P__) \
  1322. MODIFY_REG(RCC->PLL2DIVR, RCC_PLL2DIVR_P2, ((__PLL2P__) - 1U) << RCC_PLL2DIVR_P2_Pos)
  1323. /** @brief Macro to configure the PLL2 clock division factor Q.
  1324. *
  1325. * @note This function must be used only when the PLL2 is disabled.
  1326. * @note PLL2 clock source is independent from the main PLL and is configured through
  1327. * __HAL_RCC_PLL2_CONFIG() macro.
  1328. *
  1329. * @param __PLL2Q__ specifies the division factor for PLL2 output Q clock.
  1330. * This parameter must be a number in the range (1 to 128).
  1331. * Use to set PLL2 output Q clock frequency = f(PLL2) / PLL2Q
  1332. *
  1333. * @retval None
  1334. */
  1335. #define __HAL_RCC_PLL2_DIVQ_CONFIG(__PLL2Q__) \
  1336. MODIFY_REG(RCC->PLL2DIVR, RCC_PLL2DIVR_Q2, ((__PLL2Q__) - 1U) << RCC_PLL2DIVR_Q2_Pos)
  1337. /** @brief Macro to configure the PLL2 clock division factor R.
  1338. *
  1339. * @note This function must be used only when the PLL2 is disabled.
  1340. * @note PLL2 clock source is independent from the main PLL and is configured through
  1341. * __HAL_RCC_PLL2_CONFIG() macro.
  1342. *
  1343. * @param __PLL2R__ specifies the division factor for PLL2 output R clock.
  1344. * This parameter must be a number in the range (1 to 128).
  1345. * Use to set PLL2 output R clock frequency = f(PLL2) / PLL2R
  1346. *
  1347. * @retval None
  1348. */
  1349. #define __HAL_RCC_PLL2_DIVR_CONFIG(__PLL2R__) \
  1350. MODIFY_REG(RCC->PLL2DIVR, RCC_PLL2DIVR_R2, ((__PLL2R__) - 1U) << RCC_PLL2DIVR_R2_Pos)
  1351. /** @brief Macros to enable or disable the PLL2.
  1352. * @note After enabling PLL2, the application software should wait on
  1353. * PLL2RDY flag to be set indicating that PLL2 clock is stable and can
  1354. * be used as kernel clock source.
  1355. * @note The PLL2 is disabled by hardware when entering STOP and STANDBY modes.
  1356. * @retval None
  1357. */
  1358. #define __HAL_RCC_PLL2_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLL2ON)
  1359. #define __HAL_RCC_PLL2_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLL2ON)
  1360. /**
  1361. * @brief Enables or disables each clock output (PLL2_P_CLK, PLL2_Q_CLK, PLL2_R_CLK)
  1362. * @note Enabling/disabling those clocks can be done at any time without the need to stop the PLL2,
  1363. * This is mainly used to save Power.
  1364. * @param __PLL2_CLOCKOUT__ specifies the PLL2 clock to be output.
  1365. * This parameter can be one or a combination of the following values:
  1366. * @arg RCC_PLL2_DIVP: This clock is used to generate an accurate kernel clock to achieve
  1367. * high-quality audio performance on SAI interface, SPI/I2S and LPTIM peripherals.
  1368. * @arg RCC_PLL2_DIVQ: This clock is used to generate kernel clock for the random number generator RNG
  1369. * (<=48 MHz), SPI, FDCAN and UART/USART peripherals.
  1370. * @arg RCC_PLL2_DIVR: This clock is used to generate kernel clock for ADC and DAC peripherals.
  1371. * @retval None
  1372. */
  1373. #define __HAL_RCC_PLL2_CLKOUT_ENABLE(__PLL2_CLOCKOUT__) SET_BIT(RCC->PLL2CFGR, (__PLL2_CLOCKOUT__))
  1374. #define __HAL_RCC_PLL2_CLKOUT_DISABLE(__PLL2_CLOCKOUT__) CLEAR_BIT(RCC->PLL2CFGR, (__PLL2_CLOCKOUT__))
  1375. /**
  1376. * @brief Macro to get the PLL2 clock output enable status.
  1377. * @param __PLL2_CLOCKOUT__ specifies the PLL2 clock to be output.
  1378. * This parameter can be one or a combination of the following values:
  1379. * @arg RCC_PLL2_DIVP: This clock is used to generate an accurate kernel clock to achieve
  1380. * high-quality audio performance on SAI interface, SPI/I2S and LPTIM peripherals.
  1381. * @arg RCC_PLL2_DIVQ: This clock is used to generate kernel clock for the random number generator RNG
  1382. * (<=48 MHz), SPI, FDCAN and UART/USART peripherals.
  1383. * @arg RCC_PLL2_DIVR: This clock is used to generate kernel clock for ADC and DAC peripherals.
  1384. * @retval SET / RESET
  1385. */
  1386. #define __HAL_RCC_GET_PLL2_CLKOUT_CONFIG(__PLL2_CLOCKOUT__) READ_BIT(RCC->PLL2CFGR, (__PLL2_CLOCKOUT__))
  1387. /**
  1388. * @brief Enables or disables Fractional Part Of The Multiplication Factor of PLL2 VCO
  1389. * @note Enabling/disabling Fractional Part can be done at any time without the need to stop the PLL2
  1390. * @retval None
  1391. */
  1392. #define __HAL_RCC_PLL2_FRACN_ENABLE() SET_BIT(RCC->PLL2CFGR, RCC_PLL2CFGR_PLL2FRACEN)
  1393. #define __HAL_RCC_PLL2_FRACN_DISABLE() CLEAR_BIT(RCC->PLL2CFGR, RCC_PLL2CFGR_PLL2FRACEN)
  1394. /**
  1395. * @brief Macro to configures PLL2 clock Fractional Part Of The Multiplication Factor
  1396. *
  1397. * @note These bits can be written at any time, allowing dynamic fine-tuning of the PLL2 VCO
  1398. *
  1399. * @param __PLL2FRACN__: Specifies Fractional Part Of The Multiplication factor for PLL2 VCO
  1400. * It should be a value between 0 and 8191
  1401. * @note Warning: the software has to set correctly these bits to insure that the VCO
  1402. * output frequency is between its valid frequency range, which is:
  1403. * 192 to 836 MHz if PLL2VCOSEL = 0
  1404. * 150 to 420 MHz if PLL2VCOSEL = 1.
  1405. *
  1406. * @retval None
  1407. */
  1408. #define __HAL_RCC_PLL2_FRACN_CONFIG(__PLL2FRACN__) MODIFY_REG(RCC->PLL2FRACR, RCC_PLL2FRACR_PLL2FRACN, \
  1409. (uint32_t)(__PLL2FRACN__) << RCC_PLL2FRACR_PLL2FRACN_Pos)
  1410. /** @brief Macro to select the PLL2 reference frequency range.
  1411. * @param __PLL2VCIRange__: specifies the PLL2 input frequency range
  1412. * This parameter can be one of the following values:
  1413. * @arg RCC_PLL2_VCIRANGE_0: Range frequency is between 1 and 2 MHz
  1414. * @arg RCC_PLL2_VCIRANGE_1: Range frequency is between 2 and 4 MHz
  1415. * @arg RCC_PLL2_VCIRANGE_2: Range frequency is between 4 and 8 MHz
  1416. * @arg RCC_PLL2_VCIRANGE_3: Range frequency is between 8 and 16 MHz
  1417. * @retval None
  1418. */
  1419. #define __HAL_RCC_PLL2_VCIRANGE(__PLL2VCIRange__) \
  1420. MODIFY_REG(RCC->PLL2CFGR, RCC_PLL2CFGR_PLL2RGE, (__PLL2VCIRange__))
  1421. /** @brief Macro to select the PLL2 reference frequency range.
  1422. * @param __RCC_PLL2VCORange__: specifies the PLL2 output frequency range
  1423. * This parameter can be one of the following values:
  1424. * @arg RCC_PLL2_VCORANGE_WIDE: Range frequency is between 192 and 836 MHz
  1425. * @arg RCC_PLL2_VCORANGE_MEDIUM: Range frequency is between 150 and 420 MHz
  1426. *
  1427. * @retval None
  1428. */
  1429. #define __HAL_RCC_PLL2_VCORANGE(__RCC_PLL2VCORange__) \
  1430. MODIFY_REG(RCC->PLL2CFGR, RCC_PLL2CFGR_PLL2VCOSEL, (__RCC_PLL2VCORange__))
  1431. #if defined(RCC_CR_PLL3ON)
  1432. /** @brief Macro to configure the PLL3 clock source.
  1433. * @note This function must be used only when all PLL3 is disabled.
  1434. * @param __PLL3SOURCE__: specifies the PLL3 entry clock source.
  1435. * This parameter can be one of the following values:
  1436. * @arg RCC_PLL3_SOURCE_NONE: No oscillator clock selected as PLL3 clock entry
  1437. * @arg RCC_PLL3_SOURCE_CSI: CSI oscillator clock selected as PLL3 clock entry
  1438. * @arg RCC_PLL3_SOURCE_HSI: HSI oscillator clock selected as PLL3 clock entry
  1439. * @arg RCC_PLL3_SOURCE_HSE: HSE oscillator clock selected as PLL3 clock entry
  1440. *
  1441. */
  1442. #define __HAL_RCC_PLL3_PLLSOURCE_CONFIG(__PLL3SOURCE__) MODIFY_REG(RCC->PLL3CFGR, RCC_PLL3CFGR_PLL3SRC, \
  1443. (__PLL3SOURCE__))
  1444. /** @brief Macro to get the oscillator used as PLL3 clock source.
  1445. * @retval The oscillator used as PLL3 clock source. The returned value can be one
  1446. * of the following:
  1447. * - RCC_PLL3_SOURCE_NONE: No oscillator is used as PLL3 clock source.
  1448. * - RCC_PLL3_SOURCE_CSI: CSI oscillator is used as PLL3 clock source.
  1449. * - RCC_PLL3_SOURCE_HSI: HSI oscillator is used as PLL3 clock source.
  1450. * - RCC_PLL3_SOURCE_HSE: HSE oscillator is used as PLL3 clock source.
  1451. */
  1452. #define __HAL_RCC_GET_PLL3_OSCSOURCE() ((uint32_t)(RCC->PLL3CFGR & RCC_PLL3CFGR_PLL3SRC))
  1453. /**
  1454. * @brief Macro to configures the PLL3 source, multiplication and division factors.
  1455. * @note This function must be used only when PLL3 is disabled.
  1456. *
  1457. * @param __PLL3SOURCE__: specifies the PLL3 entry clock source.
  1458. * This parameter can be one of the following values:
  1459. * @arg @ref RCC_PLL3_SOURCE_NONE No clock selected as PLL3 clock entry
  1460. * @arg @ref RCC_PLL3_SOURCE_CSI CSI oscillator clock selected as PLL3 clock entry
  1461. * @arg @ref RCC_PLL3_SOURCE_HSI HSI oscillator clock selected as PLL3 clock entry
  1462. * @arg @ref RCC_PLL3_SOURCE_HSE HSE oscillator clock selected as PLL3 clock entry
  1463. *
  1464. * @param __PLL3M__ specifies the division factor of PLL3 input clock.
  1465. * This parameter must be a number between Min_Data = 1 and Max_Data = 63.
  1466. *
  1467. * @param __PLL3N__: specifies the multiplication factor for PLL3 VCO output clock
  1468. * This parameter must be a number between 4 and 512.
  1469. * @note You have to set the PLL3N parameter correctly to ensure that the VCO
  1470. * output frequency is between 150 and 420 MHz (when in medium VCO range)
  1471. * or between 192 and 836 MHZ (when in wide VCO range)
  1472. *
  1473. * @param __PLL3P__: specifies the division factor for peripheral kernel clocks
  1474. * This parameter must be a number between 1 and 128
  1475. *
  1476. * @param __PLL3Q__: specifies the division factor for peripheral kernel clocks
  1477. * This parameter must be a number between 1 and 128
  1478. *
  1479. * @param __PLL3R__: specifies the division factor for peripheral kernel clocks
  1480. * This parameter must be a number between 1 and 128
  1481. *
  1482. * @retval None
  1483. */
  1484. #define __HAL_RCC_PLL3_CONFIG(__PLL3SOURCE__, __PLL3M__, __PLL3N__, __PLL3P__, __PLL3Q__, __PLL3R__) \
  1485. do{\
  1486. MODIFY_REG(RCC->PLL3CFGR, (RCC_PLL3CFGR_PLL3SRC | RCC_PLL3CFGR_PLL3M), \
  1487. ((__PLL3SOURCE__) << RCC_PLL3CFGR_PLL3SRC_Pos) | ((__PLL3M__) << RCC_PLL3CFGR_PLL3M_Pos)); \
  1488. WRITE_REG(RCC->PLL3DIVR , ( (((__PLL3N__) - 1U) & RCC_PLL3DIVR_PLL3N) | \
  1489. ((((__PLL3P__) - 1U) << RCC_PLL3DIVR_PLL3P_Pos) & RCC_PLL3DIVR_PLL3P) | \
  1490. ((((__PLL3Q__) - 1U) << RCC_PLL3DIVR_PLL3Q_Pos) & RCC_PLL3DIVR_PLL3Q) | \
  1491. ((((__PLL3R__) - 1U) << RCC_PLL3DIVR_PLL3R_Pos) & RCC_PLL3DIVR_PLL3R))); \
  1492. } while(0)
  1493. /**
  1494. * @brief Macro to configure the PLL3 clock multiplication factor N.
  1495. *
  1496. * @note This function must be used only when the PLL3 is disabled.
  1497. * @note PLL3 clock source is independent from the main PLL and is configured through
  1498. * __HAL_RCC_PLL3_CONFIG() macro.
  1499. *
  1500. * @param __PLL3N__ specifies the multiplication factor for PLL3 VCO output clock.
  1501. * This parameter must be a number between 8 and 86.
  1502. * @note You have to set the PLL3N parameter correctly to ensure that the VCO
  1503. * output frequency is between 192 and 836 MHz (Wide range) or 150 and 420 Mhz (Medium range).
  1504. * PLL3 clock frequency = f(PLL3) multiplied by PLL3N
  1505. *
  1506. * @retval None
  1507. */
  1508. #define __HAL_RCC_PLL3_MULN_CONFIG(__PLL3N__) \
  1509. MODIFY_REG(RCC->PLL3DIVR, RCC_PLL3DIVR_N3, ((__PLL3N__) - 1U) << RCC_PLL3DIVR_N3_Pos)
  1510. /** @brief Macro to configure the PLL3 input clock division factor M.
  1511. *
  1512. * @note This function must be used only when the PLL3 is disabled.
  1513. * @note PLL3 clock source is independent from the main PLL and is configured through
  1514. * __HAL_RCC_PLL3_CONFIG() macro.
  1515. *
  1516. * @param __PLL3M__ specifies the division factor for PLL3 clock.
  1517. * This parameter must be a number between Min_Data = 1 and Max_Data = 63.
  1518. * In order to save power when PLL3 is not used, the value of PLL3M must be set to 0.
  1519. *
  1520. * @retval None
  1521. */
  1522. #define __HAL_RCC_PLL3_DIVM_CONFIG(__PLL3M__) \
  1523. MODIFY_REG(RCC->PLL3CFGR, RCC_PLL3CFGR_DIVM3, (__PLL3M__) << RCC_PLL3CFGR_DIVM3_Pos)
  1524. /** @brief Macro to configure the PLL3 clock division factor P.
  1525. *
  1526. * @note This function must be used only when the PLL3 is disabled.
  1527. * @note PLL3 clock source is independent from the main PLL and is configured through
  1528. * __HAL_RCC_PLL3_CONFIG() macro.
  1529. *
  1530. * @param __PLL3P__ specifies the division factor for PLL3 output P clock.
  1531. * This parameter must be a number in the range (1 to 128).
  1532. * Use to set PLL3 output P clock frequency = f(PLL3) / PLL3P
  1533. *
  1534. * @retval None
  1535. */
  1536. #define __HAL_RCC_PLL3_DIVP_CONFIG(__PLL3P__) \
  1537. MODIFY_REG(RCC->PLL3DIVR, RCC_PLL3DIVR_P3, ((__PLL3P__) - 1U) << RCC_PLL3DIVR_P3_Pos)
  1538. /** @brief Macro to configure the PLL3 clock division factor Q.
  1539. *
  1540. * @note This function must be used only when the PLL3 is disabled.
  1541. * @note PLL3 clock source is independent from the main PLL and is configured through
  1542. * __HAL_RCC_PLL3_CONFIG() macro.
  1543. *
  1544. * @param __PLL3Q__ specifies the division factor for PLL3 output Q clock.
  1545. * This parameter must be a number in the range (1 to 128).
  1546. * Use to set PLL3 output Q clock frequency = f(PLL3) / PLL3Q
  1547. *
  1548. * @retval None
  1549. */
  1550. #define __HAL_RCC_PLL3_DIVQ_CONFIG(__PLL3Q__) \
  1551. MODIFY_REG(RCC->PLL3DIVR, RCC_PLL3DIVR_Q3, ((__PLL3Q__) - 1U) << RCC_PLL3DIVR_Q3_Pos)
  1552. /** @brief Macro to configure the PLL3 clock division factor R.
  1553. *
  1554. * @note This function must be used only when the PLL3 is disabled.
  1555. * @note PLL3 clock source is independent from the main PLL and is configured through
  1556. * __HAL_RCC_PLL3_CONFIG() macro.
  1557. *
  1558. * @param __PLL3R__ specifies the division factor for PLL3 output R clock.
  1559. * This parameter must be a number in the range (1 to 128).
  1560. * Use to set PLL3 output R clock frequency = f(PLL3) / PLL3R
  1561. *
  1562. * @retval None
  1563. */
  1564. #define __HAL_RCC_PLL3_DIVR_CONFIG(__PLL3R__) \
  1565. MODIFY_REG(RCC->PLL3DIVR, RCC_PLL3DIVR_R3, ((__PLL3R__) - 1U) << RCC_PLL3DIVR_R3_Pos)
  1566. /**
  1567. * @brief Macro to configures PLL3 clock Fractional Part of The Multiplication Factor
  1568. *
  1569. * @note These bits can be written at any time, allowing dynamic fine-tuning of the PLL3 VCO
  1570. *
  1571. * @param __PLL3FRACN__: specifies Fractional Part Of The Multiplication Factor for PLL3 VCO
  1572. * It should be a value between 0 and 8191
  1573. * @note Warning: the software has to set correctly these bits to insure that the VCO
  1574. * output frequency is between its valid frequency range, which is:
  1575. * 192 to 836 MHz if PLL3VCOSEL = 0
  1576. * 150 to 420 MHz if PLL3VCOSEL = 1.
  1577. *
  1578. * @retval None
  1579. */
  1580. #define __HAL_RCC_PLL3_FRACN_CONFIG(__PLL3FRACN__) MODIFY_REG(RCC->PLL3FRACR, RCC_PLL3FRACR_PLL3FRACN, \
  1581. (uint32_t)(__PLL3FRACN__) << RCC_PLL3FRACR_PLL3FRACN_Pos)
  1582. /** @brief Macro to select the PLL3 reference frequency range.
  1583. * @param __PLL3VCIRange__: specifies the PLL3 input frequency range
  1584. * This parameter can be one of the following values:
  1585. * @arg RCC_PLL3_VCIRANGE_0: Range frequency is between 1 and 2 MHz
  1586. * @arg RCC_PLL3_VCIRANGE_1: Range frequency is between 2 and 4 MHz
  1587. * @arg RCC_PLL3_VCIRANGE_2: Range frequency is between 4 and 8 MHz
  1588. * @arg RCC_PLL3_VCIRANGE_3: Range frequency is between 8 and 16 MHz
  1589. *
  1590. * @retval None
  1591. */
  1592. #define __HAL_RCC_PLL3_VCIRANGE(__PLL3VCIRange__) \
  1593. MODIFY_REG(RCC->PLL3CFGR, RCC_PLL3CFGR_PLL3RGE, (__PLL3VCIRange__))
  1594. /** @brief Macro to select the PLL3 reference frequency range.
  1595. * @param __RCC_PLL3VCORange__: specifies the PLL3 input frequency range
  1596. * This parameter can be one of the following values:
  1597. * @arg RCC_PLL3VCOWIDE: Range frequency is between 192 and 836 MHz
  1598. * @arg RCC_PLL3VCOMEDIUM: Range frequency is between 150 and 420 MHz
  1599. *
  1600. * @retval None
  1601. */
  1602. #define __HAL_RCC_PLL3_VCORANGE(__RCC_PLL3VCORange__) \
  1603. MODIFY_REG(RCC->PLL3CFGR, RCC_PLL3CFGR_PLL3VCOSEL, (__RCC_PLL3VCORange__))
  1604. /**
  1605. * @brief Macros to enable or disable the PLL3.
  1606. * @note The PLL3 is disabled by hardware when entering STOP and STANDBY modes.
  1607. * @retval None
  1608. */
  1609. /** @brief Macros to enable or disable the main PLL3.
  1610. * @note After enabling PLL3, the application software should wait on
  1611. * PLL3RDY flag to be set indicating that PLL3 clock is stable and can
  1612. * be used as kernel clock source.
  1613. * @note PLL3 is disabled by hardware when entering STOP and STANDBY modes.
  1614. */
  1615. #define __HAL_RCC_PLL3_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLL3ON)
  1616. #define __HAL_RCC_PLL3_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLL3ON)
  1617. /**
  1618. * @brief Enables or disables Fractional Part Of The Multiplication Factor of PLL3 VCO
  1619. * @note Enabling/disabling Fractional Part can be done at any time without the need to stop the PLL3
  1620. * @retval None
  1621. */
  1622. #define __HAL_RCC_PLL3_FRACN_ENABLE() SET_BIT(RCC->PLL3CFGR, RCC_PLL3CFGR_PLL3FRACEN)
  1623. #define __HAL_RCC_PLL3_FRACN_DISABLE() CLEAR_BIT(RCC->PLL3CFGR, RCC_PLL3CFGR_PLL3FRACEN)
  1624. /**
  1625. * @brief Enables or disables each clock output (PLL3_P_CLK, PLL3_Q_CLK, PLL3_R_CLK)
  1626. * @note Enabling/disabling Those Clocks can be any time without the need to stop the PLL3,
  1627. * This is mainly used to save Power.
  1628. * @param __PLL3_CLOCKOUT__: specifies the PLL3 clock to be outputted
  1629. * This parameter can be one of the following values:
  1630. * @arg RCC_PLL3_DIVP: This clock is used to generate an accurate clock to achieve
  1631. * high-quality audio performance on SAI and SPI/I2S interfaces.
  1632. * @arg RCC_PLL3_DIVQ: This clock is used to generate kernel clock for SPI, LPUART, UART/USART
  1633. * and USB peripherals.
  1634. * @arg RCC_PLL3_DIVR: This clock is used to generate kernel clock for I2C, I3C and LPTIM peripherals.
  1635. *
  1636. * @retval None
  1637. */
  1638. #define __HAL_RCC_PLL3_CLKOUT_ENABLE(__PLL3_CLOCKOUT__) SET_BIT(RCC->PLL3CFGR, (__PLL3_CLOCKOUT__))
  1639. #define __HAL_RCC_PLL3_CLKOUT_DISABLE(__PLL3_CLOCKOUT__) CLEAR_BIT(RCC->PLL3CFGR, (__PLL3_CLOCKOUT__))
  1640. /**
  1641. * @brief Macro to get clock output enable status (PLL3_SAI2).
  1642. * @param __PLL3_CLOCKOUT__ specifies the PLL3 clock to be output.
  1643. * This parameter can be one or a combination of the following values:
  1644. * @arg RCC_PLL3_DIVP: This clock is used to generate an accurate clock to achieve
  1645. * high-quality audio performance on SAI and SPI/I2S interfaces.
  1646. * @arg RCC_PLL3_DIVQ: This clock is used to generate kernel clock for SPI, LPUART, UART/USART
  1647. * and USB peripherals.
  1648. * @arg RCC_PLL3_DIVR: This clock is used to generate kernel clock for I2C, I3C and LPTIM peripherals.
  1649. *
  1650. * @retval SET / RESET
  1651. */
  1652. #define __HAL_RCC_GET_PLL3_CLKOUT_CONFIG(__PLL3_CLOCKOUT__) READ_BIT(RCC->PLL3CFGR, (__PLL3_CLOCKOUT__))
  1653. #endif /* RCC_CR_PLL3ON */
  1654. /** @brief Macro to configure the ADC and DAC kernel clock source.
  1655. * @param __ADCDAC_CLKSOURCE__ specifies the ADC and DAC kernel clock source.
  1656. * This parameter can be one of the following values:
  1657. * @arg @ref RCC_ADCDACCLKSOURCE_HCLK AHB bus clock selected as ADC and DAC kernel clock
  1658. * @arg @ref RCC_ADCDACCLKSOURCE_SYSCLK System clock selected as ADC and DAC kernel clock
  1659. * @arg @ref RCC_ADCDACCLKSOURCE_PLL2R PLL2R clock selected as ADC and DAC kernel clock
  1660. * @arg @ref RCC_ADCDACCLKSOURCE_HSE HSE clock selected as ADC and DAC kernel clock
  1661. * @arg @ref RCC_ADCDACCLKSOURCE_HSI HSI clock selected as ADC and DAC kernel clock
  1662. * @arg @ref RCC_ADCDACCLKSOURCE_CSI CSI clock selected as ADC and DAC kernel clock
  1663. * @retval None
  1664. */
  1665. #define __HAL_RCC_ADCDAC_CONFIG(__ADCDAC_CLKSOURCE__) \
  1666. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_ADCDACSEL, (uint32_t)(__ADCDAC_CLKSOURCE__))
  1667. /** @brief Macro to get the ADC and DAC kernel clock source.
  1668. * @retval The clock source can be one of the following values:
  1669. * @arg @ref RCC_ADCDACCLKSOURCE_HCLK AHB Bus clock used as ADC and DAC kernel clock
  1670. * @arg @ref RCC_ADCDACCLKSOURCE_SYSCLK System clock used as ADC and DAC kernel clock
  1671. * @arg @ref RCC_ADCDACCLKSOURCE_PLL2R PLL2R clock used as ADC and DAC kernel clock
  1672. * @arg @ref RCC_ADCDACCLKSOURCE_HSE HSE oscillator used as ADC and DAC kernel clock
  1673. * @arg @ref RCC_ADCDACCLKSOURCE_HSI HSI oscillator used as ADC and DAC kernel clock
  1674. * @arg @ref RCC_ADCDACCLKSOURCE_CSI CSI oscillator used as ADC and DAC kernel clock
  1675. */
  1676. #define __HAL_RCC_GET_ADCDAC_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_ADCDACSEL)))
  1677. /** @brief Macro to configure the DAC kernel clock source in low-power mode.
  1678. * @param __DACLPCLKSOURCE__ specifies the DAC kernel clock source in low-power mode.
  1679. * This parameter can be one of the following values:
  1680. * @arg @ref RCC_DACLPCLKSOURCE_LSE LSE oscillator selected as DAC kernel clock in low-power mode
  1681. * @arg @ref RCC_DACLPCLKSOURCE_LSI LSI oscillator selected as DAC kernel clock in low-power mode
  1682. * @retval None
  1683. */
  1684. #define __HAL_RCC_DAC_LP_CONFIG(__DACLPCLKSOURCE__) \
  1685. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_DACSEL, (uint32_t)(__DACLPCLKSOURCE__))
  1686. /** @brief Macro to get the DAC kernel clock source in low-power mode.
  1687. * @retval The clock source can be one of the following values:
  1688. * @arg @ref RCC_DACLPCLKSOURCE_LSE LSE oscillator used as DAC kernel clock in low-power mode
  1689. * @arg @ref RCC_DACLPCLKSOURCE_LSI LSI oscillator used as DAC kernel clock in low-power mode
  1690. */
  1691. #define __HAL_RCC_GET_DAC_LP_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_DACSEL)))
  1692. /** @brief Macro to configure the FDCAN kernel clock (FDCANCLK).
  1693. *
  1694. * @param __FDCAN_CLKSOURCE__ specifies the FDCAN kernel clock source.
  1695. * This parameter can be one of the following values:
  1696. * @arg @ref RCC_FDCANCLKSOURCE_HSE HSE oscillator selected as FDCAN kernel clock
  1697. * @arg @ref RCC_FDCANCLKSOURCE_PLL1Q PLL1Q Clock selected as FDCAN kernel clock
  1698. * @arg @ref RCC_FDCANCLKSOURCE_PLL2Q PLL2Q Clock selected as FDCAN kernel clock
  1699. * @retval None
  1700. */
  1701. #define __HAL_RCC_FDCAN_CONFIG(__FDCAN_CLKSOURCE__) \
  1702. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_FDCANSEL, (uint32_t)(__FDCAN_CLKSOURCE__))
  1703. /** @brief Macro to get the FDCAN clock source.
  1704. * @retval The clock source can be one of the following values:
  1705. * @arg @ref RCC_FDCANCLKSOURCE_HSE HSE oscillator selected as FDCAN kernel clock
  1706. * @arg @ref RCC_FDCANCLKSOURCE_PLL1Q PLL1Q Clock selected as FDCAN kernel clock
  1707. * @arg @ref RCC_FDCANCLKSOURCE_PLL2Q PLL2Q Clock selected as FDCAN kernel clock
  1708. */
  1709. #define __HAL_RCC_GET_FDCAN_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_FDCANSEL)))
  1710. /** @brief Macro to configure the LPTIM1 clock (LPTIM1CLK).
  1711. *
  1712. * @param __LPTIM1_CLKSOURCE__ specifies the LPTIM1 clock source.
  1713. * This parameter can be one of the following values:
  1714. * @arg @ref RCC_LPTIM1CLKSOURCE_PCLK3 PCLK3 selected as LPTIM1 clock
  1715. * @arg @ref RCC_LPTIM1CLKSOURCE_PLL2P PLL2P selected as LPTIM1 clock
  1716. * @arg @ref RCC_LPTIM1CLKSOURCE_PLL3R PLL3R selected as LPTIM1 clock (*)
  1717. * @arg @ref RCC_LPTIM1CLKSOURCE_LSE LSE selected as LPTIM1 clock
  1718. * @arg @ref RCC_LPTIM1CLKSOURCE_LSI LSI selected as LPTIM1 clock
  1719. * @arg @ref RCC_LPTIM1CLKSOURCE_CLKP CLKP selected as LPTIM1 clock
  1720. * @retval None
  1721. *
  1722. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1723. */
  1724. #define __HAL_RCC_LPTIM1_CONFIG(__LPTIM1_CLKSOURCE__) \
  1725. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_LPTIM1SEL, (uint32_t)(__LPTIM1_CLKSOURCE__))
  1726. /** @brief Macro to get the LPTIM1 clock source.
  1727. * @retval The clock source can be one of the following values:
  1728. * @arg @ref RCC_LPTIM1CLKSOURCE_PCLK3 PCLK3 selected as LPTIM1 clock
  1729. * @arg @ref RCC_LPTIM1CLKSOURCE_PLL2P PLL2P selected as LPTIM1 clock
  1730. * @arg @ref RCC_LPTIM1CLKSOURCE_PLL3R PLL3R selected as LPTIM1 clock (*)
  1731. * @arg @ref RCC_LPTIM1CLKSOURCE_LSE LSE selected as LPTIM1 clock
  1732. * @arg @ref RCC_LPTIM1CLKSOURCE_LSI LSI selected as LPTIM1 clock
  1733. * @arg @ref RCC_LPTIM1CLKSOURCE_CLKP CLKP selected as LPTIM1 clock
  1734. *
  1735. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1736. */
  1737. #define __HAL_RCC_GET_LPTIM1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_LPTIM1SEL)))
  1738. /** @brief Macro to configure the LPTIM2 clock (LPTIM2CLK).
  1739. *
  1740. * @param __LPTIM2_CLKSOURCE__ specifies the LPTIM2 clock source.
  1741. * This parameter can be one of the following values:
  1742. * @arg @ref RCC_LPTIM2CLKSOURCE_PCLK1 PCLK1 selected as LPTIM2 clock
  1743. * @arg @ref RCC_LPTIM2CLKSOURCE_PLL2P PLL2P selected as LPTIM2 clock
  1744. * @arg @ref RCC_LPTIM2CLKSOURCE_PLL3R PLL3R selected as LPTIM2 clock (*)
  1745. * @arg @ref RCC_LPTIM2CLKSOURCE_LSE LSE selected as LPTIM2 clock
  1746. * @arg @ref RCC_LPTIM2CLKSOURCE_LSI LSI selected as LPTIM2 clock
  1747. * @arg @ref RCC_LPTIM2CLKSOURCE_CLKP CLKP selected as LPTIM2 clock
  1748. * @retval None
  1749. *
  1750. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1751. */
  1752. #define __HAL_RCC_LPTIM2_CONFIG(__LPTIM2_CLKSOURCE__) \
  1753. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_LPTIM2SEL, (uint32_t)(__LPTIM2_CLKSOURCE__))
  1754. /** @brief Macro to get the LPTIM2 clock source.
  1755. * @retval The clock source can be one of the following values:
  1756. * @arg @ref RCC_LPTIM2CLKSOURCE_PCLK1 PCLK1 selected as LPTIM2 clock
  1757. * @arg @ref RCC_LPTIM2CLKSOURCE_PLL2P PLL2P selected as LPTIM2 clock
  1758. * @arg @ref RCC_LPTIM2CLKSOURCE_PLL3R PLL3R selected as LPTIM2 clock (*)
  1759. * @arg @ref RCC_LPTIM2CLKSOURCE_LSE LSE selected as LPTIM2 clock
  1760. * @arg @ref RCC_LPTIM2CLKSOURCE_LSI LSI selected as LPTIM2 clock
  1761. * @arg @ref RCC_LPTIM2CLKSOURCE_CLKP CLKP selected as LPTIM2 clock
  1762. *
  1763. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1764. */
  1765. #define __HAL_RCC_GET_LPTIM2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_LPTIM2SEL)))
  1766. #if defined(LPTIM3)
  1767. /** @brief Macro to configure the LPTIM3 clock (LPTIM3CLK).
  1768. *
  1769. * @param __LPTIM3_CLKSOURCE__ specifies the LPTIM3 clock source.
  1770. * This parameter can be one of the following values:
  1771. * @arg @ref RCC_LPTIM3CLKSOURCE_PCLK3 PCLK3 selected as LPTIM3 clock
  1772. * @arg @ref RCC_LPTIM3CLKSOURCE_PLL2P PLL2P selected as LPTIM3 clock
  1773. * @arg @ref RCC_LPTIM3CLKSOURCE_PLL3R PLL3R selected as LPTIM3 clock
  1774. * @arg @ref RCC_LPTIM3CLKSOURCE_LSE LSE selected as LPTIM3 clock
  1775. * @arg @ref RCC_LPTIM3CLKSOURCE_LSI LSI selected as LPTIM3 clock
  1776. * @arg @ref RCC_LPTIM3CLKSOURCE_CLKP CLKP selected as LPTIM3 clock
  1777. * @retval None
  1778. */
  1779. #define __HAL_RCC_LPTIM3_CONFIG(__LPTIM3_CLKSOURCE__) \
  1780. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_LPTIM3SEL, (uint32_t)(__LPTIM3_CLKSOURCE__))
  1781. /** @brief Macro to get the LPTIM3 clock source.
  1782. * @retval The clock source can be one of the following values:
  1783. * @arg @ref RCC_LPTIM3CLKSOURCE_PCLK3 PCLK3 selected as LPTIM3 clock
  1784. * @arg @ref RCC_LPTIM3CLKSOURCE_PLL2P PLL2P selected as LPTIM3 clock
  1785. * @arg @ref RCC_LPTIM3CLKSOURCE_PLL3R PLL3R selected as LPTIM3 clock
  1786. * @arg @ref RCC_LPTIM3CLKSOURCE_LSE LSE selected as LPTIM3 clock
  1787. * @arg @ref RCC_LPTIM3CLKSOURCE_LSI LSI selected as LPTIM3 clock
  1788. * @arg @ref RCC_LPTIM3CLKSOURCE_CLKP CLKP selected as LPTIM3 clock
  1789. */
  1790. #define __HAL_RCC_GET_LPTIM3_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_LPTIM3SEL)))
  1791. #endif /* LPTIM3 */
  1792. #if defined(LPTIM4)
  1793. /** @brief Macro to configure the LPTIM4 clock (LPTIM4CLK).
  1794. *
  1795. * @param __LPTIM4_CLKSOURCE__ specifies the LPTIM4 clock source.
  1796. * This parameter can be one of the following values:
  1797. * @arg @ref RCC_LPTIM4CLKSOURCE_PCLK3 PCLK3 selected as LPTIM4 clock
  1798. * @arg @ref RCC_LPTIM4CLKSOURCE_PLL2P PLL2P selected as LPTIM4 clock
  1799. * @arg @ref RCC_LPTIM4CLKSOURCE_PLL3R PLL3R selected as LPTIM4 clock
  1800. * @arg @ref RCC_LPTIM4CLKSOURCE_LSE LSE selected as LPTIM4 clock
  1801. * @arg @ref RCC_LPTIM4CLKSOURCE_LSI LSI selected as LPTIM4 clock
  1802. * @arg @ref RCC_LPTIM4CLKSOURCE_CLKP CLKP selected as LPTIM4 clock
  1803. * @retval None
  1804. */
  1805. #define __HAL_RCC_LPTIM4_CONFIG(__LPTIM4_CLKSOURCE__) \
  1806. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_LPTIM4SEL, (uint32_t)(__LPTIM4_CLKSOURCE__))
  1807. /** @brief Macro to get the LPTIM4 clock source.
  1808. * @retval The clock source can be one of the following values:
  1809. * @arg @ref RCC_LPTIM4CLKSOURCE_PCLK3 PCLK3 selected as LPTIM4 clock
  1810. * @arg @ref RCC_LPTIM4CLKSOURCE_PLL2P PLL2P selected as LPTIM4 clock
  1811. * @arg @ref RCC_LPTIM4CLKSOURCE_PLL3R PLL3R selected as LPTIM4 clock
  1812. * @arg @ref RCC_LPTIM4CLKSOURCE_LSE LSE selected as LPTIM4 clock
  1813. * @arg @ref RCC_LPTIM4CLKSOURCE_LSI LSI selected as LPTIM4 clock
  1814. * @arg @ref RCC_LPTIM4CLKSOURCE_CLKP CLKP selected as LPTIM4 clock
  1815. */
  1816. #define __HAL_RCC_GET_LPTIM4_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_LPTIM4SEL)))
  1817. #endif /* LPTIM4 */
  1818. #if defined(LPTIM5)
  1819. /** @brief Macro to configure the LPTIM5 clock (LPTIM5CLK).
  1820. *
  1821. * @param __LPTIM5_CLKSOURCE__ specifies the LPTIM5 clock source.
  1822. * This parameter can be one of the following values:
  1823. * @arg @ref RCC_LPTIM5CLKSOURCE_PCLK3 PCLK3 selected as LPTIM5 clock
  1824. * @arg @ref RCC_LPTIM5CLKSOURCE_PLL2P PLL2P selected as LPTIM5 clock
  1825. * @arg @ref RCC_LPTIM5CLKSOURCE_PLL3R PLL3R selected as LPTIM5 clock
  1826. * @arg @ref RCC_LPTIM5CLKSOURCE_LSE LSE selected as LPTIM5 clock
  1827. * @arg @ref RCC_LPTIM5CLKSOURCE_LSI LSI selected as LPTIM5 clock
  1828. * @arg @ref RCC_LPTIM5CLKSOURCE_CLKP CLKP selected as LPTIM5 clock
  1829. * @retval None
  1830. */
  1831. #define __HAL_RCC_LPTIM5_CONFIG(__LPTIM5_CLKSOURCE__) \
  1832. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_LPTIM5SEL, (uint32_t)(__LPTIM5_CLKSOURCE__))
  1833. /** @brief Macro to get the LPTIM5 clock source.
  1834. * @retval The clock source can be one of the following values:
  1835. * @arg @ref RCC_LPTIM5CLKSOURCE_PCLK3 PCLK3 selected as LPTIM5 clock
  1836. * @arg @ref RCC_LPTIM5CLKSOURCE_PLL2P PLL2P selected as LPTIM5 clock
  1837. * @arg @ref RCC_LPTIM5CLKSOURCE_PLL3R PLL3R selected as LPTIM5 clock
  1838. * @arg @ref RCC_LPTIM5CLKSOURCE_LSE LSE selected as LPTIM5 clock
  1839. * @arg @ref RCC_LPTIM5CLKSOURCE_LSI LSI selected as LPTIM5 clock
  1840. * @arg @ref RCC_LPTIM5CLKSOURCE_CLKP CLKP selected as LPTIM5 clock
  1841. */
  1842. #define __HAL_RCC_GET_LPTIM5_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_LPTIM5SEL)))
  1843. #endif /* LPTIM5 */
  1844. #if defined(LPTIM6)
  1845. /** @brief Macro to configure the LPTIM6 clock (LPTIM6CLK).
  1846. *
  1847. * @param __LPTIM6_CLKSOURCE__ specifies the LPTIM6 clock source.
  1848. * This parameter can be one of the following values:
  1849. * @arg @ref RCC_LPTIM6CLKSOURCE_PCLK3 PCLK3 selected as LPTIM6 clock
  1850. * @arg @ref RCC_LPTIM6CLKSOURCE_PLL2P PLL2P selected as LPTIM6 clock
  1851. * @arg @ref RCC_LPTIM6CLKSOURCE_PLL3R PLL3R selected as LPTIM6 clock
  1852. * @arg @ref RCC_LPTIM6CLKSOURCE_LSE LSE selected as LPTIM6 clock
  1853. * @arg @ref RCC_LPTIM6CLKSOURCE_LSI LSI selected as LPTIM6 clock
  1854. * @arg @ref RCC_LPTIM6CLKSOURCE_CLKP CLKP selected as LPTIM6 clock
  1855. * @retval None
  1856. */
  1857. #define __HAL_RCC_LPTIM6_CONFIG(__LPTIM6_CLKSOURCE__) \
  1858. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_LPTIM6SEL, (uint32_t)(__LPTIM6_CLKSOURCE__))
  1859. /** @brief Macro to get the LPTIM6 clock source.
  1860. * @retval The clock source can be one of the following values:
  1861. * @arg @ref RCC_LPTIM6CLKSOURCE_PCLK3 PCLK3 selected as LPTIM6 clock
  1862. * @arg @ref RCC_LPTIM6CLKSOURCE_PLL2P PLL2P selected as LPTIM6 clock
  1863. * @arg @ref RCC_LPTIM6CLKSOURCE_PLL3R PLL3R selected as LPTIM6 clock
  1864. * @arg @ref RCC_LPTIM6CLKSOURCE_LSE LSE selected as LPTIM6 clock
  1865. * @arg @ref RCC_LPTIM6CLKSOURCE_LSI LSI selected as LPTIM6 clock
  1866. * @arg @ref RCC_LPTIM6CLKSOURCE_CLKP CLKP selected as LPTIM6 clock
  1867. */
  1868. #define __HAL_RCC_GET_LPTIM6_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_LPTIM6SEL)))
  1869. #endif /* LPTIM6 */
  1870. /** @brief macro to configure the SPI1 clock source.
  1871. * @retval The clock source can be one of the following values:
  1872. * @arg RCC_SPI1CLKSOURCE_PLL1Q PLL1Q selected as SPI1 clock
  1873. * @arg RCC_SPI1CLKSOURCE_PLL2P PLL2P selected as SPI1 clock
  1874. * @arg RCC_SPI1CLKSOURCE_PLL3P PLL3P selected as SPI1 clock (*)
  1875. * @arg RCC_SPI1CLKSOURCE_PIN External Clock selected as SPI1 clock
  1876. * @arg RCC_SPI1CLKSOURCE_CLKP CLKP selected as SPI1 clock
  1877. *
  1878. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1879. */
  1880. #define __HAL_RCC_SPI1_CONFIG(__SPI1CLKSource__) \
  1881. MODIFY_REG(RCC->CCIPR3, RCC_CCIPR3_SPI1SEL, (uint32_t)(__SPI1CLKSource__))
  1882. /** @brief macro to get the SPI1 clock source.
  1883. * @retval The clock source can be one of the following values:
  1884. * @arg RCC_SPI1CLKSOURCE_PLL1Q PLL1Q selected as SPI1 clock
  1885. * @arg RCC_SPI1CLKSOURCE_PLL2P PLL2P selected as SPI1 clock
  1886. * @arg RCC_SPI1CLKSOURCE_PLL3P PLL3P selected as SPI1 clock (*)
  1887. * @arg RCC_SPI1CLKSOURCE_PIN External Clock selected as SPI1 clock
  1888. * @arg RCC_SPI1CLKSOURCE_CLKP CLKP selected as SPI1 clock
  1889. *
  1890. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1891. */
  1892. #define __HAL_RCC_GET_SPI1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR3, RCC_CCIPR3_SPI1SEL)))
  1893. /** @brief macro to configure the SPI2 clock source.
  1894. * @retval The clock source can be one of the following values:
  1895. * @arg RCC_SPI2CLKSOURCE_PLL1Q PLL1Q selected as SPI2 clock
  1896. * @arg RCC_SPI2CLKSOURCE_PLL2P PLL2P selected as SPI2 clock
  1897. * @arg RCC_SPI2CLKSOURCE_PLL3P PLL3P selected as SPI2 clock (*)
  1898. * @arg RCC_SPI2CLKSOURCE_PIN External Clock selected as SPI2 clock
  1899. * @arg RCC_SPI2CLKSOURCE_CLKP CLKP selected as SPI2 clock
  1900. *
  1901. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1902. */
  1903. #define __HAL_RCC_SPI2_CONFIG(__SPI2CLKSource__) \
  1904. MODIFY_REG(RCC->CCIPR3, RCC_CCIPR3_SPI2SEL, (uint32_t)(__SPI2CLKSource__))
  1905. /** @brief macro to get the SPI2 clock source.
  1906. * @retval The clock source can be one of the following values:
  1907. * @arg RCC_SPI2CLKSOURCE_PLL1Q PLL1Q selected as SPI2 clock
  1908. * @arg RCC_SPI2CLKSOURCE_PLL2P PLL2P selected as SPI2 clock
  1909. * @arg RCC_SPI2CLKSOURCE_PLL3P PLL3P selected as SPI2 clock (*)
  1910. * @arg RCC_SPI2CLKSOURCE_PIN External Clock selected as SPI2 clock
  1911. * @arg RCC_SPI2CLKSOURCE_CLKP CLKP selected as SPI2 clock
  1912. *
  1913. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1914. */
  1915. #define __HAL_RCC_GET_SPI2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR3, RCC_CCIPR3_SPI2SEL)))
  1916. /** @brief macro to configure the SPI3 clock source.
  1917. * @retval The clock source can be one of the following values:
  1918. * @arg RCC_SPI3CLKSOURCE_PLL1Q PLL1Q used as SPI3 clock
  1919. * @arg RCC_SPI3CLKSOURCE_PLL2P PLL2P used as SPI3 clock
  1920. * @arg RCC_SPI3CLKSOURCE_PLL3P PLL3P used as SPI3 clock (*)
  1921. * @arg RCC_SPI3CLKSOURCE_PIN External Clock used as SPI3 clock
  1922. * @arg RCC_SPI3CLKSOURCE_CLKP CLKP used as SPI3 clock
  1923. *
  1924. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1925. */
  1926. #define __HAL_RCC_SPI3_CONFIG(__SPI3CLKSource__) \
  1927. MODIFY_REG(RCC->CCIPR3, RCC_CCIPR3_SPI3SEL, (uint32_t)(__SPI3CLKSource__))
  1928. /** @brief macro to get the SPI3 clock source.
  1929. * @retval The clock source can be one of the following values:
  1930. * @arg RCC_SPI3CLKSOURCE_PLL1Q PLL1Q used as SPI3 clock
  1931. * @arg RCC_SPI3CLKSOURCE_PLL2P PLL2P used as SPI3 clock
  1932. * @arg RCC_SPI3CLKSOURCE_PLL3P PLL3P used as SPI3 clock (*)
  1933. * @arg RCC_SPI3CLKSOURCE_PIN External Clock used as SPI3 clock
  1934. * @arg RCC_SPI3CLKSOURCE_CLKP CLKP used as SPI3 clock
  1935. *
  1936. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  1937. */
  1938. #define __HAL_RCC_GET_SPI3_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR3, RCC_CCIPR3_SPI3SEL)))
  1939. #if defined(SPI4)
  1940. /** @brief macro to configure the SPI4 clock source.
  1941. * @retval The clock source can be one of the following values:
  1942. * @arg RCC_SPI4CLKSOURCE_PCLK2 PCLK2 used as SPI4 clock
  1943. * @arg RCC_SPI4CLKSOURCE_PLL2Q PLL2Q used as SPI4 clock
  1944. * @arg RCC_SPI4CLKSOURCE_PLL3Q PLL3Q used as SPI4 clock
  1945. * @arg RCC_SPI4CLKSOURCE_HSI HSI used as SPI4 clock
  1946. * @arg RCC_SPI4CLKSOURCE_CSI CSI Clock used as SPI4 clock
  1947. * @arg RCC_SPI4CLKSOURCE_HSE HSE Clock used as SPI4 clock
  1948. */
  1949. #define __HAL_RCC_SPI4_CONFIG(__SPI4CLKSource__) \
  1950. MODIFY_REG(RCC->CCIPR3, RCC_CCIPR3_SPI4SEL, (uint32_t)(__SPI4CLKSource__))
  1951. /** @brief macro to get the SPI4 clock source.
  1952. * @retval The clock source can be one of the following values:
  1953. * @arg RCC_SPI4CLKSOURCE_PCLK2 PCLK2 used as SPI4 clock
  1954. * @arg RCC_SPI4CLKSOURCE_PLL2Q PLL2Q used as SPI4 clock
  1955. * @arg RCC_SPI4CLKSOURCE_PLL3Q PLL3Q used as SPI4 clock
  1956. * @arg RCC_SPI4CLKSOURCE_HSI HSI used as SPI4 clock
  1957. * @arg RCC_SPI4CLKSOURCE_CSI CSI used as SPI4 clock
  1958. * @arg RCC_SPI4CLKSOURCE_HSE HSE used as SPI4 clock
  1959. */
  1960. #define __HAL_RCC_GET_SPI4_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR3, RCC_CCIPR3_SPI4SEL)))
  1961. #endif /* SPI4 */
  1962. #if defined(SPI5)
  1963. /** @brief macro to configure the SPI5 clock source.
  1964. * @retval The clock source can be one of the following values:
  1965. * @arg RCC_SPI5CLKSOURCE_PCLK3 PCLK3 used as SPI5 clock
  1966. * @arg RCC_SPI5CLKSOURCE_PLL2Q PLL2Q used as SPI5 clock
  1967. * @arg RCC_SPI5CLKSOURCE_PLL3Q PLL3Q used as SPI5 clock
  1968. * @arg RCC_SPI5CLKSOURCE_HSI HSI used as SPI5 clock
  1969. * @arg RCC_SPI5CLKSOURCE_CSI CSI Clock used as SPI5 clock
  1970. * @arg RCC_SPI5CLKSOURCE_HSE HSE Clock used as SPI5 clock
  1971. */
  1972. #define __HAL_RCC_SPI5_CONFIG(__SPI5CLKSource__) \
  1973. MODIFY_REG(RCC->CCIPR3, RCC_CCIPR3_SPI5SEL, (uint32_t)(__SPI5CLKSource__))
  1974. /** @brief macro to get the SPI5 clock source.
  1975. * @retval The clock source can be one of the following values:
  1976. * @arg RCC_SPI5CLKSOURCE_PCLK3 PCLK3 used as SPI5 clock
  1977. * @arg RCC_SPI5CLKSOURCE_PLL2Q PLL2Q used as SPI5 clock
  1978. * @arg RCC_SPI5CLKSOURCE_PLL3Q PLL3Q used as SPI5 clock
  1979. * @arg RCC_SPI5CLKSOURCE_HSI HSI used as SPI5 clock
  1980. * @arg RCC_SPI5CLKSOURCE_CSI CSI used as SPI5 clock
  1981. * @arg RCC_SPI5CLKSOURCE_HSE HSE used as SPI5 clock
  1982. */
  1983. #define __HAL_RCC_GET_SPI5_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR3, RCC_CCIPR3_SPI5SEL)))
  1984. #endif /* SPI5 */
  1985. #if defined(SPI6)
  1986. /** @brief macro to configure the SPI6 clock source.
  1987. * @retval The clock source can be one of the following values:
  1988. * @arg RCC_SPI6CLKSOURCE_PCLK2 PCLK2 used as SPI6 clock
  1989. * @arg RCC_SPI6CLKSOURCE_PLL2Q PLL2Q used as SPI6 clock
  1990. * @arg RCC_SPI6CLKSOURCE_PLL3Q PLL3Q used as SPI6 clock
  1991. * @arg RCC_SPI6CLKSOURCE_HSI HSI used as SPI6 clock
  1992. * @arg RCC_SPI6CLKSOURCE_CSI CSI used as SPI6 clock
  1993. * @arg RCC_SPI6CLKSOURCE_HSE HSE used as SPI6 clock
  1994. */
  1995. #define __HAL_RCC_SPI6_CONFIG(__SPI6CLKSource__) \
  1996. MODIFY_REG(RCC->CCIPR3, RCC_CCIPR3_SPI6SEL, (uint32_t)(__SPI6CLKSource__))
  1997. /** @brief macro to get the SPI6 clock source.
  1998. * @retval The clock source can be one of the following values:
  1999. * @arg RCC_SPI6CLKSOURCE_PCLK2 PCLK2 used as SPI6 clock
  2000. * @arg RCC_SPI6CLKSOURCE_PLL2Q PLL2Q used as SPI6 clock
  2001. * @arg RCC_SPI6CLKSOURCE_PLL3Q PLL3Q used as SPI6 clock
  2002. * @arg RCC_SPI6CLKSOURCE_HSI HSI used as SPI6 clock
  2003. * @arg RCC_SPI6CLKSOURCE_CSI CSI used as SPI6 clock
  2004. * @arg RCC_SPI6CLKSOURCE_HSE HSE used as SPI6 clock
  2005. */
  2006. #define __HAL_RCC_GET_SPI6_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR3, RCC_CCIPR3_SPI6SEL)))
  2007. #endif /* SPI6 */
  2008. /** @brief Macro to configure the I2C1 clock (I2C1CLK).
  2009. *
  2010. * @param __I2C1_CLKSOURCE__ specifies the I2C1 clock source.
  2011. * This parameter can be one of the following values:
  2012. * @arg @ref RCC_I2C1CLKSOURCE_PCLK1 PCLK1 selected as I2C1 clock
  2013. * @arg @ref RCC_I2C1CLKSOURCE_PLL3R PLL3R selected as I2C1 clock (*)
  2014. * @arg @ref RCC_I2C1CLKSOURCE_PLL2R PLL2R selected as I2C1 clock (**)
  2015. * @arg @ref RCC_I2C1CLKSOURCE_HSI HSI selected as I2C1 clock
  2016. * @arg @ref RCC_I2C1CLKSOURCE_CSI CSI selected as I2C1 clock
  2017. * @retval None
  2018. *
  2019. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2020. * (**) : For stm32h503xx family line.
  2021. */
  2022. #define __HAL_RCC_I2C1_CONFIG(__I2C1_CLKSOURCE__) \
  2023. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_I2C1SEL, (uint32_t)(__I2C1_CLKSOURCE__))
  2024. /** @brief Macro to get the I2C1 clock source.
  2025. * @retval The clock source can be one of the following values:
  2026. * @arg @ref RCC_I2C1CLKSOURCE_PCLK1 PCLK1 selected as I2C1 clock
  2027. * @arg @ref RCC_I2C1CLKSOURCE_PLL3R PLL3R selected as I2C1 clock (*)
  2028. * @arg @ref RCC_I2C1CLKSOURCE_PLL2R PLL2R selected as I2C1 clock (**)
  2029. * @arg @ref RCC_I2C1CLKSOURCE_HSI HSI selected as I2C1 clock
  2030. * @arg @ref RCC_I2C1CLKSOURCE_CSI CSI selected as I2C1 clock
  2031. *
  2032. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2033. * (**) : For stm32h503xx family line.
  2034. */
  2035. #define __HAL_RCC_GET_I2C1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_I2C1SEL)))
  2036. /** @brief Macro to configure the I2C2 clock (I2C2CLK).
  2037. *
  2038. * @param __I2C2_CLKSOURCE__ specifies the I2C2 clock source.
  2039. * This parameter can be one of the following values:
  2040. * @arg @ref RCC_I2C2CLKSOURCE_PCLK1 PCLK1 selected as I2C2 clock
  2041. * @arg @ref RCC_I2C2CLKSOURCE_PLL3R PLL3R selected as I2C2 clock (*)
  2042. * @arg @ref RCC_I2C2CLKSOURCE_PLL2R PLL2R selected as I2C2 clock (**)
  2043. * @arg @ref RCC_I2C2CLKSOURCE_HSI HSI selected as I2C2 clock
  2044. * @arg @ref RCC_I2C2CLKSOURCE_CSI CSI selected as I2C2 clock
  2045. * @retval None
  2046. *
  2047. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2048. * (**) : For stm32h503xx family line.
  2049. */
  2050. #define __HAL_RCC_I2C2_CONFIG(__I2C2_CLKSOURCE__) \
  2051. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_I2C2SEL, (uint32_t)(__I2C2_CLKSOURCE__))
  2052. /** @brief Macro to get the I2C2 clock source.
  2053. * @retval The clock source can be one of the following values:
  2054. * @arg @ref RCC_I2C2CLKSOURCE_PCLK1 PCLK1 selected as I2C2 clock
  2055. * @arg @ref RCC_I2C2CLKSOURCE_PLL3R PLL3R selected as I2C2 clock (*)
  2056. * @arg @ref RCC_I2C2CLKSOURCE_PLL2R PLL2R selected as I2C2 clock (**)
  2057. * @arg @ref RCC_I2C2CLKSOURCE_HSI HSI selected as I2C2 clock
  2058. * @arg @ref RCC_I2C2CLKSOURCE_CSI CSI selected as I2C2 clock
  2059. *
  2060. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2061. * (**) : For stm32h503xx family line.
  2062. */
  2063. #define __HAL_RCC_GET_I2C2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_I2C2SEL)))
  2064. #if defined(I2C3)
  2065. /** @brief Macro to configure the I2C3 clock (I2C3CLK).
  2066. *
  2067. * @param __I2C3_CLKSOURCE__ specifies the I2C3 clock source.
  2068. * This parameter can be one of the following values:
  2069. * @arg @ref RCC_I2C3CLKSOURCE_PCLK3 PCLK3 selected as I2C3 clock
  2070. * @arg @ref RCC_I2C3CLKSOURCE_PLL3R PLL3R selected as I2C3 clock
  2071. * @arg @ref RCC_I2C3CLKSOURCE_HSI HSI selected as I2C3 clock
  2072. * @arg @ref RCC_I2C3CLKSOURCE_CSI CSI selected as I2C3 clock
  2073. * @retval None
  2074. */
  2075. #define __HAL_RCC_I2C3_CONFIG(__I2C3_CLKSOURCE__) \
  2076. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_I2C3SEL, (uint32_t)(__I2C3_CLKSOURCE__))
  2077. /** @brief Macro to get the I2C3 clock source.
  2078. * @retval The clock source can be one of the following values:
  2079. * @arg @ref RCC_I2C3CLKSOURCE_PCLK3 PCLK3 selected as I2C3 clock
  2080. * @arg @ref RCC_I2C3CLKSOURCE_PLL3R PLL3R selected as I2C3 clock
  2081. * @arg @ref RCC_I2C3CLKSOURCE_HSI HSI selected as I2C3 clock
  2082. * @arg @ref RCC_I2C3CLKSOURCE_CSI CSI selected as I2C3 clock
  2083. */
  2084. #define __HAL_RCC_GET_I2C3_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_I2C3SEL)))
  2085. #endif /* I2C3 */
  2086. #if defined(I2C4)
  2087. /** @brief Macro to configure the I2C4 clock (I2C4CLK).
  2088. *
  2089. * @param __I2C4_CLKSOURCE__ specifies the I2C4 clock source.
  2090. * This parameter can be one of the following values:
  2091. * @arg @ref RCC_I2C4CLKSOURCE_PCLK3 PCLK3 selected as I2C4 clock
  2092. * @arg @ref RCC_I2C4CLKSOURCE_PLL3R PLL3R selected as I2C4 clock
  2093. * @arg @ref RCC_I2C4CLKSOURCE_HSI HSI selected as I2C4 clock
  2094. * @arg @ref RCC_I2C4CLKSOURCE_CSI CSI selected as I2C4 clock
  2095. * @retval None
  2096. */
  2097. #define __HAL_RCC_I2C4_CONFIG(__I2C4_CLKSOURCE__) \
  2098. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_I2C4SEL, (uint32_t)(__I2C4_CLKSOURCE__))
  2099. /** @brief Macro to get the I2C4 clock source.
  2100. * @retval The clock source can be one of the following values:
  2101. * @arg @ref RCC_I2C4CLKSOURCE_PCLK3 PCLK3 selected as I2C4 clock
  2102. * @arg @ref RCC_I2C4CLKSOURCE_PLL3R PLL3R selected as I2C4 clock
  2103. * @arg @ref RCC_I2C4CLKSOURCE_HSI HSI selected as I2C4 clock
  2104. * @arg @ref RCC_I2C4CLKSOURCE_CSI CSI selected as I2C4 clock
  2105. */
  2106. #define __HAL_RCC_GET_I2C4_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_I2C4SEL)))
  2107. #endif /* I2C4 */
  2108. /** @brief Macro to configure the I3C1 clock (I3C1CLK).
  2109. *
  2110. * @param __I3C1_CLKSOURCE__ specifies the I3C1 clock source.
  2111. * This parameter can be one of the following values:
  2112. * @arg @ref RCC_I3C1CLKSOURCE_PCLK1 PCLK1 selected as I3C1 clock
  2113. * @arg @ref RCC_I3C1CLKSOURCE_PLL3R PLL3R selected as I3C1 clock (*)
  2114. * @arg @ref RCC_I3C1CLKSOURCE_PLL2R PLL2R selected as I3C1 clock (**)
  2115. * @arg @ref RCC_I3C1CLKSOURCE_HSI HSI selected as I3C1 clock
  2116. * @retval None
  2117. *
  2118. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2119. * (**) : For stm32h503xx family line.
  2120. */
  2121. #define __HAL_RCC_I3C1_CONFIG(__I3C1_CLKSOURCE__) \
  2122. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_I3C1SEL, (uint32_t)(__I3C1_CLKSOURCE__))
  2123. /** @brief Macro to get the I3C1 clock source.
  2124. * @retval The clock source can be one of the following values:
  2125. * @arg @ref RCC_I3C1CLKSOURCE_PCLK1 PCLK1 selected as I3C1 clock
  2126. * @arg @ref RCC_I3C1CLKSOURCE_PLL3R PLL3R selected as I3C1 clock (*)
  2127. * @arg @ref RCC_I3C1CLKSOURCE_PLL2R PLL2R selected as I3C1 clock (**)
  2128. * @arg @ref RCC_I3C1CLKSOURCE_HSI HSI selected as I3C1 clock
  2129. *
  2130. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2131. * (**) : For stm32h503xx family line.
  2132. */
  2133. #define __HAL_RCC_GET_I3C1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_I3C1SEL)))
  2134. #if defined(I3C2)
  2135. /** @brief Macro to configure the I3C2 clock (I3C2CLK).
  2136. *
  2137. * @param __I3C2_CLKSOURCE__ specifies the I3C2 clock source.
  2138. * This parameter can be one of the following values:
  2139. * @arg @ref RCC_I3C2CLKSOURCE_PCLK3 PCLK3 selected as I3C2 clock
  2140. * @arg @ref RCC_I3C2CLKSOURCE_PLL3R PLL3R selected as I3C2 clock (*)
  2141. * @arg @ref RCC_I3C2CLKSOURCE_PLL2R PLL2R selected as I3C2 clock
  2142. * @arg @ref RCC_I3C2CLKSOURCE_HSI HSI selected as I3C2 clock
  2143. *
  2144. * @retval None
  2145. *
  2146. * (*) : Not available for all stm32h5xxxx family lines.
  2147. */
  2148. #define __HAL_RCC_I3C2_CONFIG(__I3C2_CLKSOURCE__) \
  2149. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_I3C2SEL, (uint32_t)(__I3C2_CLKSOURCE__))
  2150. /** @brief Macro to get the I3C2 clock source.
  2151. * @retval The clock source can be one of the following values:
  2152. * @arg @ref RCC_I3C2CLKSOURCE_PCLK3 PCLK3 selected as I3C2 clock
  2153. * @arg @ref RCC_I3C2CLKSOURCE_PLL3R PLL3R selected as I3C2 clock (*)
  2154. * @arg @ref RCC_I3C2CLKSOURCE_PLL2R PLL2R selected as I3C2 clock
  2155. * @arg @ref RCC_I3C2CLKSOURCE_HSI HSI selected as I3C2 clock
  2156. *
  2157. * (*) : Not available for all stm32h5xxxx family lines.
  2158. */
  2159. #define __HAL_RCC_GET_I3C2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_I3C2SEL)))
  2160. #endif /* I3C2 */
  2161. /** @brief Macro to configure the USART1 clock (USART1CLK).
  2162. *
  2163. * @param __USART1_CLKSOURCE__ specifies the USART1 clock source.
  2164. * This parameter can be one of the following values:
  2165. * @arg @ref RCC_USART1CLKSOURCE_PCLK2 PCLK2 selected as USART1 clock
  2166. * @arg @ref RCC_USART1CLKSOURCE_PLL2Q PLL2Q selected as USART1 clock
  2167. * @arg @ref RCC_USART1CLKSOURCE_PLL3Q PLL3Q selected as USART1 clock (*)
  2168. * @arg @ref RCC_USART1CLKSOURCE_HSI HSI selected as USART1 clock
  2169. * @arg @ref RCC_USART1CLKSOURCE_CSI CSI selected as USART1 clock
  2170. * @arg @ref RCC_USART1CLKSOURCE_LSE LSE selected as USART1 clock
  2171. * @retval None
  2172. *
  2173. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2174. */
  2175. #define __HAL_RCC_USART1_CONFIG(__USART1_CLKSOURCE__) \
  2176. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_USART1SEL, (uint32_t)(__USART1_CLKSOURCE__))
  2177. /** @brief Macro to get the USART1 clock source.
  2178. * @retval The clock source can be one of the following values:
  2179. * @arg @ref RCC_USART1CLKSOURCE_PCLK2 PCLK2 selected as USART1 clock
  2180. * @arg @ref RCC_USART1CLKSOURCE_PLL2Q PLL2Q selected as USART1 clock
  2181. * @arg @ref RCC_USART1CLKSOURCE_PLL3Q PLL3Q selected as USART1 clock (*)
  2182. * @arg @ref RCC_USART1CLKSOURCE_HSI HSI selected as USART1 clock
  2183. * @arg @ref RCC_USART1CLKSOURCE_CSI CSI selected as USART1 clock
  2184. * @arg @ref RCC_USART1CLKSOURCE_LSE LSE selected as USART1 clock
  2185. *
  2186. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2187. */
  2188. #define __HAL_RCC_GET_USART1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_USART1SEL)))
  2189. /** @brief Macro to configure the USART2 clock (USART2CLK).
  2190. *
  2191. * @param __USART2_CLKSOURCE__ specifies the USART2 clock source.
  2192. * This parameter can be one of the following values:
  2193. * @arg @ref RCC_USART2CLKSOURCE_PCLK1 PCLK2 selected as USART2 clock
  2194. * @arg @ref RCC_USART2CLKSOURCE_PLL2Q PLL2Q selected as USART2 clock
  2195. * @arg @ref RCC_USART2CLKSOURCE_PLL3Q PLL3Q selected as USART2 clock (*)
  2196. * @arg @ref RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock
  2197. * @arg @ref RCC_USART2CLKSOURCE_CSI CSI selected as USART2 clock
  2198. * @arg @ref RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock
  2199. * @retval None
  2200. *
  2201. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2202. */
  2203. #define __HAL_RCC_USART2_CONFIG(__USART2_CLKSOURCE__) \
  2204. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_USART2SEL, (uint32_t)(__USART2_CLKSOURCE__))
  2205. /** @brief Macro to get the USART2 clock source.
  2206. * @retval The clock source can be one of the following values:
  2207. * @arg @ref RCC_USART2CLKSOURCE_PCLK1 PCLK2 selected as USART2 clock
  2208. * @arg @ref RCC_USART2CLKSOURCE_PLL2Q PLL2Q selected as USART2 clock
  2209. * @arg @ref RCC_USART2CLKSOURCE_PLL3Q PLL3Q selected as USART2 clock (*)
  2210. * @arg @ref RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock
  2211. * @arg @ref RCC_USART2CLKSOURCE_CSI CSI selected as USART2 clock
  2212. * @arg @ref RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock
  2213. *
  2214. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2215. */
  2216. #define __HAL_RCC_GET_USART2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_USART2SEL)))
  2217. /** @brief Macro to configure the USART3 clock (USART3CLK).
  2218. *
  2219. * @param __USART3_CLKSOURCE__ specifies the USART3 clock source.
  2220. * This parameter can be one of the following values:
  2221. * @arg @ref RCC_USART3CLKSOURCE_PCLK1 PCLK2 selected as USART3 clock
  2222. * @arg @ref RCC_USART3CLKSOURCE_PLL2Q PLL2Q selected as USART3 clock
  2223. * @arg @ref RCC_USART3CLKSOURCE_PLL3Q PLL3Q selected as USART3 clock (*)
  2224. * @arg @ref RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock
  2225. * @arg @ref RCC_USART3CLKSOURCE_CSI CSI selected as USART3 clock
  2226. * @arg @ref RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock
  2227. * @retval None
  2228. *
  2229. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2230. */
  2231. #define __HAL_RCC_USART3_CONFIG(__USART3_CLKSOURCE__) \
  2232. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_USART3SEL, (uint32_t)(__USART3_CLKSOURCE__))
  2233. /** @brief Macro to get the USART3 clock source.
  2234. * @retval The clock source can be one of the following values:
  2235. * @arg @ref RCC_USART3CLKSOURCE_PCLK1 PCLK2 selected as USART3 clock
  2236. * @arg @ref RCC_USART3CLKSOURCE_PLL2Q PLL2Q selected as USART3 clock
  2237. * @arg @ref RCC_USART3CLKSOURCE_PLL3Q PLL3Q selected as USART3 clock (*)
  2238. * @arg @ref RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock
  2239. * @arg @ref RCC_USART3CLKSOURCE_CSI CSI selected as USART3 clock
  2240. * @arg @ref RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock
  2241. *
  2242. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2243. */
  2244. #define __HAL_RCC_GET_USART3_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_USART3SEL)))
  2245. #if defined(UART4)
  2246. /** @brief Macro to configure the UART4 clock (UART4CLK).
  2247. *
  2248. * @param __UART4_CLKSOURCE__ specifies the UART4 clock source.
  2249. * This parameter can be one of the following values:
  2250. * @arg @ref RCC_UART4CLKSOURCE_PCLK1 PCLK1 selected as UART4 clock
  2251. * @arg @ref RCC_UART4CLKSOURCE_PLL2Q PLL2Q Clock selected as UART4 clock
  2252. * @arg @ref RCC_UART4CLKSOURCE_PLL3Q PLL3Q Clock selected as UART4 clock
  2253. * @arg @ref RCC_UART4CLKSOURCE_HSI HSI selected as UART4 clock
  2254. * @arg @ref RCC_UART4CLKSOURCE_CSI CSI selected as UART4 clock
  2255. * @arg @ref RCC_UART4CLKSOURCE_LSE LSE selected as UART4 clock
  2256. * @retval None
  2257. */
  2258. #define __HAL_RCC_UART4_CONFIG(__UART4_CLKSOURCE__) \
  2259. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_UART4SEL, (uint32_t)(__UART4_CLKSOURCE__))
  2260. /** @brief Macro to get the UART4 clock source.
  2261. * @retval The clock source can be one of the following values:
  2262. * @arg @ref RCC_UART4CLKSOURCE_PCLK1 PCLK1 selected as UART4 clock
  2263. * @arg @ref RCC_UART4CLKSOURCE_PLL2Q PLL2Q Clock selected as UART4 clock
  2264. * @arg @ref RCC_UART4CLKSOURCE_PLL3Q PLL3Q Clock selected as UART4 clock
  2265. * @arg @ref RCC_UART4CLKSOURCE_HSI HSI selected as UART4 clock
  2266. * @arg @ref RCC_UART4CLKSOURCE_CSI CSI selected as UART4 clock
  2267. * @arg @ref RCC_UART4CLKSOURCE_LSE LSE selected as UART4 clock
  2268. */
  2269. #define __HAL_RCC_GET_UART4_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_UART4SEL)))
  2270. #endif /* UART4 */
  2271. #if defined(UART5)
  2272. /** @brief Macro to configure the UART5 clock (UART5CLK).
  2273. *
  2274. * @param __UART5_CLKSOURCE__ specifies the UART5 clock source.
  2275. * This parameter can be one of the following values:
  2276. * @arg @ref RCC_UART5CLKSOURCE_PCLK1 PCLK1 selected as UART5 clock
  2277. * @arg @ref RCC_UART5CLKSOURCE_PLL2Q PLL2Q Clock selected as UART5 clock
  2278. * @arg @ref RCC_UART5CLKSOURCE_PLL3Q PLL3Q Clock selected as UART5 clock
  2279. * @arg @ref RCC_UART5CLKSOURCE_HSI HSI selected as UART5 clock
  2280. * @arg @ref RCC_UART5CLKSOURCE_CSI CSI selected as UART5 clock
  2281. * @arg @ref RCC_UART5CLKSOURCE_LSE LSE selected as UART5 clock
  2282. * @retval None
  2283. */
  2284. #define __HAL_RCC_UART5_CONFIG(__UART5_CLKSOURCE__) \
  2285. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_UART5SEL, (uint32_t)(__UART5_CLKSOURCE__))
  2286. /** @brief Macro to get the UART5 clock source.
  2287. * @retval The clock source can be one of the following values:
  2288. * @arg @ref RCC_UART5CLKSOURCE_PCLK1 PCLK1 selected as UART5 clock
  2289. * @arg @ref RCC_UART5CLKSOURCE_PLL2Q PLL2Q Clock selected as UART5 clock
  2290. * @arg @ref RCC_UART5CLKSOURCE_PLL3Q PLL3Q Clock selected as UART5 clock
  2291. * @arg @ref RCC_UART5CLKSOURCE_HSI HSI selected as UART5 clock
  2292. * @arg @ref RCC_UART5CLKSOURCE_CSI CSI selected as UART5 clock
  2293. * @arg @ref RCC_UART5CLKSOURCE_LSE LSE selected as UART5 clock
  2294. */
  2295. #define __HAL_RCC_GET_UART5_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_UART5SEL)))
  2296. #endif /* UART5 */
  2297. #if defined(USART6)
  2298. /** @brief Macro to configure the USART6 clock (USART6CLK).
  2299. *
  2300. * @param __USART6_CLKSOURCE__ specifies the USART6 clock source.
  2301. * This parameter can be one of the following values:
  2302. * @arg @ref RCC_USART6CLKSOURCE_PCLK1 PCLK2 selected as USART6 clock
  2303. * @arg @ref RCC_USART6CLKSOURCE_PLL2Q PLL2Q selected as USART6 clock
  2304. * @arg @ref RCC_USART6CLKSOURCE_PLL3Q PLL3Q selected as USART6 clock
  2305. * @arg @ref RCC_USART6CLKSOURCE_HSI HSI selected as USART6 clock
  2306. * @arg @ref RCC_USART6CLKSOURCE_CSI CSI selected as USART6 clock
  2307. * @arg @ref RCC_USART6CLKSOURCE_LSE LSE selected as USART6 clock
  2308. * @retval None
  2309. */
  2310. #define __HAL_RCC_USART6_CONFIG(__USART6_CLKSOURCE__) \
  2311. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_USART6SEL, (uint32_t)(__USART6_CLKSOURCE__))
  2312. /** @brief Macro to get the USART6 clock source.
  2313. * @retval The clock source can be one of the following values:
  2314. * @arg @ref RCC_USART6CLKSOURCE_PCLK1 PCLK1 selected as USART6 clock
  2315. * @arg @ref RCC_USART6CLKSOURCE_PLL2Q PLL2Q selected as USART6 clock
  2316. * @arg @ref RCC_USART6CLKSOURCE_PLL3Q PLL3Q selected as USART6 clock
  2317. * @arg @ref RCC_USART6CLKSOURCE_HSI HSI selected as USART6 clock
  2318. * @arg @ref RCC_USART6CLKSOURCE_CSI CSI selected as USART6 clock
  2319. * @arg @ref RCC_USART6CLKSOURCE_LSE LSE selected as USART6 clock
  2320. */
  2321. #define __HAL_RCC_GET_USART6_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_USART6SEL)))
  2322. #endif /* USART6 */
  2323. #if defined(UART7)
  2324. /** @brief Macro to configure the UART7 clock (UART7CLK).
  2325. *
  2326. * @param __UART7_CLKSOURCE__ specifies the UART7 clock source.
  2327. * This parameter can be one of the following values:
  2328. * @arg @ref RCC_UART7CLKSOURCE_PCLK1 PCLK1 selected as UART7 clock
  2329. * @arg @ref RCC_UART7CLKSOURCE_PLL2Q PLL2Q selected as UART7 clock
  2330. * @arg @ref RCC_UART7CLKSOURCE_PLL3Q PLL3Q selected as UART7 clock
  2331. * @arg @ref RCC_UART7CLKSOURCE_HSI HSI selected as UART7 clock
  2332. * @arg @ref RCC_UART7CLKSOURCE_CSI CSI selected as UART7 clock
  2333. * @arg @ref RCC_UART7CLKSOURCE_LSE LSE selected as UART7 clock
  2334. * @retval None
  2335. */
  2336. #define __HAL_RCC_UART7_CONFIG(__UART7_CLKSOURCE__) \
  2337. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_UART7SEL, (uint32_t)(__UART7_CLKSOURCE__))
  2338. /** @brief Macro to get the UART7 clock source.
  2339. * @retval The clock source can be one of the following values:
  2340. * @arg @ref RCC_UART7CLKSOURCE_PCLK1 PCLK1 selected as UART7 clock
  2341. * @arg @ref RCC_UART7CLKSOURCE_PLL2Q PLL2Q selected as UART7 clock
  2342. * @arg @ref RCC_UART7CLKSOURCE_PLL3Q PLL3Q selected as UART7 clock
  2343. * @arg @ref RCC_UART7CLKSOURCE_HSI HSI selected as UART7 clock
  2344. * @arg @ref RCC_UART7CLKSOURCE_CSI CSI selected as UART7 clock
  2345. * @arg @ref RCC_UART7CLKSOURCE_LSE LSE selected as UART7 clock
  2346. */
  2347. #define __HAL_RCC_GET_UART7_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_UART7SEL)))
  2348. #endif /* UART5 */
  2349. #if defined(UART8)
  2350. /** @brief Macro to configure the UART8 clock (UART8CLK).
  2351. *
  2352. * @param __UART8_CLKSOURCE__ specifies the UART8 clock source.
  2353. * This parameter can be one of the following values:
  2354. * @arg @ref RCC_UART8CLKSOURCE_PCLK1 PCLK1 selected as UART8 clock
  2355. * @arg @ref RCC_UART8CLKSOURCE_PLL2Q PLL2Q selected as UART8 clock
  2356. * @arg @ref RCC_UART8CLKSOURCE_PLL3Q PLL3Q selected as UART8 clock
  2357. * @arg @ref RCC_UART8CLKSOURCE_HSI HSI selected as UART8 clock
  2358. * @arg @ref RCC_UART8CLKSOURCE_CSI CSI selected as UART8 clock
  2359. * @arg @ref RCC_UART8CLKSOURCE_LSE LSE selected as UART8 clock
  2360. * @retval None
  2361. */
  2362. #define __HAL_RCC_UART8_CONFIG(__UART8_CLKSOURCE__) \
  2363. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_UART8SEL, (uint32_t)(__UART8_CLKSOURCE__))
  2364. /** @brief Macro to get the UART8 clock source.
  2365. * @retval The clock source can be one of the following values:
  2366. * @arg @ref RCC_UART8CLKSOURCE_PCLK1 PCLK1 selected as UART8 clock
  2367. * @arg @ref RCC_UART8CLKSOURCE_PLL2Q PLL2Q selected as UART8 clock
  2368. * @arg @ref RCC_UART8CLKSOURCE_PLL3Q PLL3Q selected as UART8 clock
  2369. * @arg @ref RCC_UART8CLKSOURCE_HSI HSI selected as UART8 clock
  2370. * @arg @ref RCC_UART8CLKSOURCE_CSI CSI selected as UART8 clock
  2371. * @arg @ref RCC_UART8CLKSOURCE_LSE LSE selected as UART8 clock
  2372. */
  2373. #define __HAL_RCC_GET_UART8_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_UART8SEL)))
  2374. #endif /* UART8 */
  2375. #if defined(UART9)
  2376. /** @brief Macro to configure the UART9 clock (UART9CLK).
  2377. *
  2378. * @param __UART9_CLKSOURCE__ specifies the UART9 clock source.
  2379. * This parameter can be one of the following values:
  2380. * @arg @ref RCC_UART9CLKSOURCE_PCLK1 PCLK1 selected as UART9 clock
  2381. * @arg @ref RCC_UART9CLKSOURCE_PLL2Q PLL2Q selected as UART9 clock
  2382. * @arg @ref RCC_UART9CLKSOURCE_PLL3Q PLL3Q selected as UART9 clock
  2383. * @arg @ref RCC_UART9CLKSOURCE_HSI HSI selected as UART9 clock
  2384. * @arg @ref RCC_UART9CLKSOURCE_CSI CSI selected as UART9 clock
  2385. * @arg @ref RCC_UART9CLKSOURCE_LSE LSE selected as UART9 clock
  2386. * @retval None
  2387. */
  2388. #define __HAL_RCC_UART9_CONFIG(__UART9_CLKSOURCE__) \
  2389. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_UART9SEL, (uint32_t)(__UART9_CLKSOURCE__))
  2390. /** @brief Macro to get the UART9 clock source.
  2391. * @retval The clock source can be one of the following values:
  2392. * @arg @ref RCC_UART9CLKSOURCE_PCLK1 PCLK1 selected as UART9 clock
  2393. * @arg @ref RCC_UART9CLKSOURCE_PLL2Q PLL2Q selected as UART9 clock
  2394. * @arg @ref RCC_UART9CLKSOURCE_PLL3Q PLL3Q selected as UART9 clock
  2395. * @arg @ref RCC_UART9CLKSOURCE_HSI HSI selected as UART9 clock
  2396. * @arg @ref RCC_UART9CLKSOURCE_CSI CSI selected as UART9 clock
  2397. * @arg @ref RCC_UART9CLKSOURCE_LSE LSE selected as UART9 clock
  2398. */
  2399. #define __HAL_RCC_GET_UART9_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_UART9SEL)))
  2400. #endif /* UART9 */
  2401. #if defined(USART10)
  2402. /** @brief Macro to configure the USART10 clock (USART10CLK).
  2403. *
  2404. * @param __USART10_CLKSOURCE__ specifies the USART10 clock source.
  2405. * This parameter can be one of the following values:
  2406. * @arg @ref RCC_USART10CLKSOURCE_PCLK1 PCLK1 selected as USART10 clock
  2407. * @arg @ref RCC_USART10CLKSOURCE_PLL2Q PLL2Q selected as USART10 clock
  2408. * @arg @ref RCC_USART10CLKSOURCE_PLL3Q PLL3Q selected as USART10 clock
  2409. * @arg @ref RCC_USART10CLKSOURCE_HSI HSI selected as USART10 clock
  2410. * @arg @ref RCC_USART10CLKSOURCE_CSI CSI selected as USART10 clock
  2411. * @arg @ref RCC_USART10CLKSOURCE_LSE LSE selected as USART10 clock
  2412. * @retval None
  2413. */
  2414. #define __HAL_RCC_USART10_CONFIG(__USART10_CLKSOURCE__) \
  2415. MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_USART10SEL, (uint32_t)(__USART10_CLKSOURCE__))
  2416. /** @brief Macro to get the USART10 clock source.
  2417. * @retval The clock source can be one of the following values:
  2418. * @arg @ref RCC_USART10CLKSOURCE_PCLK1 PCLK1 selected as USART10 clock
  2419. * @arg @ref RCC_USART10CLKSOURCE_PLL2Q PLL2Q selected as USART10 clock
  2420. * @arg @ref RCC_USART10CLKSOURCE_PLL3Q PLL3Q selected as USART10 clock
  2421. * @arg @ref RCC_USART10CLKSOURCE_HSI HSI selected as USART10 clock
  2422. * @arg @ref RCC_USART10CLKSOURCE_CSI CSI selected as USART10 clock
  2423. * @arg @ref RCC_USART10CLKSOURCE_LSE LSE selected as USART10 clock
  2424. */
  2425. #define __HAL_RCC_GET_USART10_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_USART10SEL)))
  2426. #endif /* USART10 */
  2427. #if defined(USART11)
  2428. /** @brief Macro to configure the USART11 clock (USART11CLK).
  2429. *
  2430. * @param __USART11_CLKSOURCE__ specifies the USART11 clock source.
  2431. * This parameter can be one of the following values:
  2432. * @arg @ref RCC_USART11CLKSOURCE_PCLK1 PCLK1 selected as USART11 clock
  2433. * @arg @ref RCC_USART11CLKSOURCE_PLL2Q PLL2Q selected as USART11 clock
  2434. * @arg @ref RCC_USART11CLKSOURCE_PLL3Q PLL3Q selected as USART11 clock
  2435. * @arg @ref RCC_USART11CLKSOURCE_HSI HSI selected as USART11 clock
  2436. * @arg @ref RCC_USART11CLKSOURCE_CSI CSI selected as USART11 clock
  2437. * @arg @ref RCC_USART11CLKSOURCE_LSE LSE selected as USART11 clock
  2438. * @retval None
  2439. */
  2440. #define __HAL_RCC_USART11_CONFIG(__USART11_CLKSOURCE__) \
  2441. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_USART11SEL, (uint32_t)(__USART11_CLKSOURCE__))
  2442. /** @brief Macro to get the USART11 clock source.
  2443. * @retval The clock source can be one of the following values:
  2444. * @arg @ref RCC_USART11CLKSOURCE_PCLK1 PCLK1 selected as USART11 clock
  2445. * @arg @ref RCC_USART11CLKSOURCE_PLL2Q PLL2Q selected as USART11 clock
  2446. * @arg @ref RCC_USART11CLKSOURCE_PLL3Q PLL3Q selected as USART11 clock
  2447. * @arg @ref RCC_USART11CLKSOURCE_HSI HSI selected as USART11 clock
  2448. * @arg @ref RCC_USART11CLKSOURCE_CSI CSI selected as USART11 clock
  2449. * @arg @ref RCC_USART11CLKSOURCE_LSE LSE selected as USART11 clock
  2450. */
  2451. #define __HAL_RCC_GET_USART11_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_USART11SEL)))
  2452. #endif /* USART11 */
  2453. #if defined(UART12)
  2454. /** @brief Macro to configure the UART12 clock (UART12CLK).
  2455. *
  2456. * @param __UART12_CLKSOURCE__ specifies the UART12 clock source.
  2457. * This parameter can be one of the following values:
  2458. * @arg @ref RCC_UART12CLKSOURCE_PCLK1 PCLK1 selected as UART12 clock
  2459. * @arg @ref RCC_UART12CLKSOURCE_PLL2Q PLL2Q selected as UART12 clock
  2460. * @arg @ref RCC_UART12CLKSOURCE_PLL3Q PLL3Q selected as UART12 clock
  2461. * @arg @ref RCC_UART12CLKSOURCE_HSI HSI selected as UART12 clock
  2462. * @arg @ref RCC_UART12CLKSOURCE_CSI CSI selected as UART12 clock
  2463. * @arg @ref RCC_UART12CLKSOURCE_LSE LSE selected as UART12 clock
  2464. * @retval None
  2465. */
  2466. #define __HAL_RCC_UART12_CONFIG(__UART12_CLKSOURCE__) \
  2467. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_UART12SEL, (uint32_t)(__UART12_CLKSOURCE__))
  2468. /** @brief Macro to get the UART12 clock source.
  2469. * @retval The clock source can be one of the following values:
  2470. * @arg @ref RCC_UART12CLKSOURCE_PCLK1 PCLK1 selected as UART12 clock
  2471. * @arg @ref RCC_UART12CLKSOURCE_PLL2Q PLL2Q selected as UART12 clock
  2472. * @arg @ref RCC_UART12CLKSOURCE_PLL3Q PLL3Q selected as UART12 clock
  2473. * @arg @ref RCC_UART12CLKSOURCE_HSI HSI selected as UART12 clock
  2474. * @arg @ref RCC_UART12CLKSOURCE_CSI CSI selected as UART12 clock
  2475. * @arg @ref RCC_UART12CLKSOURCE_LSE LSE selected as UART12 clock
  2476. */
  2477. #define __HAL_RCC_GET_UART12_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR2, RCC_CCIPR2_UART12SEL)))
  2478. #endif /* UART12 */
  2479. /** @brief Macro to configure the LPUART1 clock (LPUART1CLK).
  2480. *
  2481. * @param __LPUART1_CLKSOURCE__ specifies the LPUART1 clock source.
  2482. * This parameter can be one of the following values:
  2483. * @arg @ref RCC_LPUART1CLKSOURCE_PCLK3 PCLK3 selected as LPUART1 clock
  2484. * @arg @ref RCC_LPUART1CLKSOURCE_PLL2Q PLL2Q selected as LPUART1 clock
  2485. * @arg @ref RCC_LPUART1CLKSOURCE_PLL3Q PLL3Q selected as LPUART1 clock (*)
  2486. * @arg @ref RCC_LPUART1CLKSOURCE_HSI HSI selected as LPUART1 clock
  2487. * @arg @ref RCC_LPUART1CLKSOURCE_CSI CSI selected as LPUART1 clock
  2488. * @arg @ref RCC_LPUART1CLKSOURCE_LSE LSE selected as LPUART1 clock
  2489. *
  2490. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2491. * @retval None
  2492. */
  2493. #define __HAL_RCC_LPUART1_CONFIG(__LPUART1_CLKSOURCE__) \
  2494. MODIFY_REG(RCC->CCIPR3, RCC_CCIPR3_LPUART1SEL, (uint32_t)(__LPUART1_CLKSOURCE__))
  2495. /** @brief Macro to get the LPUART1 clock source.
  2496. * @retval The clock source can be one of the following values:
  2497. * @arg @ref RCC_LPUART1CLKSOURCE_PCLK3 PCLK3 selected as LPUART1 clock
  2498. * @arg @ref RCC_LPUART1CLKSOURCE_PLL2Q PLL2Q selected as LPUART1 clock
  2499. * @arg @ref RCC_LPUART1CLKSOURCE_PLL3Q PLL3Q selected as LPUART1 clock (*)
  2500. * @arg @ref RCC_LPUART1CLKSOURCE_HSI HSI selected as LPUART1 clock
  2501. * @arg @ref RCC_LPUART1CLKSOURCE_CSI CSI selected as LPUART1 clock
  2502. * @arg @ref RCC_LPUART1CLKSOURCE_LSE LSE selected as LPUART1 clock
  2503. *
  2504. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2505. */
  2506. #define __HAL_RCC_GET_LPUART1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR3, RCC_CCIPR3_LPUART1SEL)))
  2507. #if defined(OCTOSPI1)
  2508. /** @brief Macro to configure the OctoSPI clock.
  2509. * @param __OSPI_CLKSOURCE__ specifies the OctoSPI clock source.
  2510. * This parameter can be one of the following values:
  2511. * @arg @ref RCC_OSPICLKSOURCE_HCLK HCLK selected as OctoSPI clock
  2512. * @arg @ref RCC_OSPICLKSOURCE_PLL1Q PLL1Q divider clock selected as OctoSPI clock
  2513. * @arg @ref RCC_OSPICLKSOURCE_PLL2R PLL2R divider clock selected as OctoSPI clock
  2514. * @arg @ref RCC_OSPICLKSOURCE_CLKP CLKP selected as OctoSPI clock
  2515. * @retval None
  2516. */
  2517. #define __HAL_RCC_OSPI_CONFIG(__OSPI_CLKSOURCE__) \
  2518. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_OCTOSPISEL, (uint32_t)(__OSPI_CLKSOURCE__))
  2519. /** @brief Macro to get the OctoSPI clock source.
  2520. * @retval The clock source can be one of the following values:
  2521. * @arg @ref RCC_OSPICLKSOURCE_HCLK HCLK selected as OctoSPI clock
  2522. * @arg @ref RCC_OSPICLKSOURCE_PLL1Q PLL1Q divider clock selected as OctoSPI clock
  2523. * @arg @ref RCC_OSPICLKSOURCE_PLL2R PLL2R divider clock selected as OctoSPI clock
  2524. * @arg @ref RCC_OSPICLKSOURCE_CLKP CLKP selected as OctoSPI clock
  2525. */
  2526. #define __HAL_RCC_GET_OSPI_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_OCTOSPISEL)))
  2527. #endif /* OCTOSPI1 */
  2528. #if defined(SDMMC1)
  2529. /** @brief Macro to configure the SDMMC1 clock (SDMMCCLK).
  2530. *
  2531. * @param __SDMMC1_CLKSOURCE__: specifies the SDMMC1 clock source.
  2532. * This parameter can be one of the following values:
  2533. * @arg RCC_SDMMC1CLKSOURCE_PLL1Q PLL1Q selected as SDMMC1 clock
  2534. * @arg RCC_SDMMC1CLKSOURCE_PLL2R PLL2R selected as SDMMC1 clock
  2535. */
  2536. #define __HAL_RCC_SDMMC1_CONFIG(__SDMMC1_CLKSOURCE__) \
  2537. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_SDMMC1SEL, (uint32_t)(__SDMMC1_CLKSOURCE__))
  2538. /** @brief macro to get the SDMMC1 clock source.
  2539. * @retval The clock source can be one of the following values:
  2540. * @arg RCC_SDMMC1CLKSOURCE_PLL1Q PLL1Q selected as SDMMC1 clock
  2541. * @arg RCC_SDMMC1CLKSOURCE_PLL2R PLL2R selected as SDMMC1 clock
  2542. */
  2543. #define __HAL_RCC_GET_SDMMC1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_SDMMC1SEL)))
  2544. #endif /* SDMMC1 */
  2545. #if defined(SDMMC2)
  2546. /** @brief Macro to configure the SDMMC2 clock (SDMMCCLK).
  2547. *
  2548. * @param __SDMMC2_CLKSOURCE__: specifies the SDMMC2 clock source.
  2549. * This parameter can be one of the following values:
  2550. * @arg RCC_SDMMC2CLKSOURCE_PLL1Q PLL1Q selected as SDMMC2 clock
  2551. * @arg RCC_SDMMC2CLKSOURCE_PLL2R PLL2R selected as SDMMC2 clock
  2552. */
  2553. #define __HAL_RCC_SDMMC2_CONFIG(__SDMMC2_CLKSOURCE__) \
  2554. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_SDMMC2SEL, (uint32_t)(__SDMMC2_CLKSOURCE__))
  2555. /** @brief macro to get the SDMMC2 clock source.
  2556. * @retval The clock source can be one of the following values:
  2557. * @arg RCC_SDMMC2CLKSOURCE_PLL1Q PLL1Q selected as SDMMC2 clock
  2558. * @arg RCC_SDMMC2CLKSOURCE_PLL2R PLL2R selected as SDMMC2 clock
  2559. */
  2560. #define __HAL_RCC_GET_SDMMC2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_SDMMC2SEL)))
  2561. #endif /*SDMMC2*/
  2562. /** @brief macro to configure the RNG clock (RNGCLK).
  2563. *
  2564. * @param __RNGCLKSource__: specifies the RNG clock source.
  2565. * This parameter can be one of the following values:
  2566. * @arg RCC_RNGCLKSOURCE_HSI48: HSI48 selected as RNG clock
  2567. * @arg RCC_RNGCLKSOURCE_PLL1Q: PLL1Q selected as RNG clock
  2568. * @arg RCC_RNGCLKSOURCE_LSE: LSE selected as RNG clock
  2569. * @arg RCC_RNGCLKSOURCE_LSI: LSI selected as RNG clock
  2570. */
  2571. #define __HAL_RCC_RNG_CONFIG(__RNGCLKSource__) \
  2572. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_RNGSEL, (uint32_t)(__RNGCLKSource__))
  2573. /** @brief macro to get the RNG clock source.
  2574. * @retval The clock source can be one of the following values:
  2575. * @arg RCC_RNGCLKSOURCE_HSI48: HSI48 selected as RNG clock
  2576. * @arg RCC_RNGCLKSOURCE_PLL1Q: PLL1Q selected as RNG clock
  2577. * @arg RCC_RNGCLKSOURCE_LSE: LSE selected as RNG clock
  2578. * @arg RCC_RNGCLKSOURCE_LSI: LSI selected as RNG clock
  2579. */
  2580. #define __HAL_RCC_GET_RNG_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_RNGSEL)))
  2581. #if defined(SAI1)
  2582. /**
  2583. * @brief Macro to configure the SAI1 clock source.
  2584. * @param __SAI1_CLKSOURCE__ defines the SAI1 clock source.
  2585. * This parameter can be one of the following values:
  2586. * @arg @ref RCC_SAI1CLKSOURCE_PLL1Q PLL1Q selected as SAI1 clock
  2587. * @arg @ref RCC_SAI1CLKSOURCE_PLL2P PLL2Pselected as SAI1 clock
  2588. * @arg @ref RCC_SAI1CLKSOURCE_PLL3P PLL3P selected as SAI1 clock
  2589. * @arg @ref RCC_SAI1CLKSOURCE_PIN External clock selected as SAI1 clock
  2590. * @arg @ref RCC_SAI1CLKSOURCE_CLKP CLKP selected as SAI1 clock
  2591. * @retval None
  2592. */
  2593. #define __HAL_RCC_SAI1_CONFIG(__SAI1_CLKSOURCE__)\
  2594. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_SAI1SEL, (uint32_t)(__SAI1_CLKSOURCE__))
  2595. /** @brief Macro to get the SAI1 clock source.
  2596. * @retval The clock source can be one of the following values:
  2597. * @arg @ref RCC_SAI1CLKSOURCE_PLL1Q PLL1Q selected as SAI1 clock
  2598. * @arg @ref RCC_SAI1CLKSOURCE_PLL2P PLL2P selected as SAI1 clock
  2599. * @arg @ref RCC_SAI1CLKSOURCE_PLL3P PLL3P selected as SAI1 clock
  2600. * @arg @ref RCC_SAI1CLKSOURCE_PIN External clock selected as SAI1 clock
  2601. * @arg @ref RCC_SAI1CLKSOURCE_CLKP CLKP selected as SAI1 clock
  2602. */
  2603. #define __HAL_RCC_GET_SAI1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_SAI1SEL)))
  2604. #endif /* SAI1 */
  2605. #if defined(SAI2)
  2606. /**
  2607. * @brief Macro to configure the SAI2 clock source.
  2608. * @param __SAI2_CLKSOURCE__ defines the SAI2 clock source.
  2609. * This parameter can be one of the following values:
  2610. * @arg @ref RCC_SAI2CLKSOURCE_PLL1Q PLL1Q selected as SAI2 clock
  2611. * @arg @ref RCC_SAI2CLKSOURCE_PLL2P PLL2P selected as SAI2 clock
  2612. * @arg @ref RCC_SAI2CLKSOURCE_PLL3P PLL3P selected as SAI2 clock
  2613. * @arg @ref RCC_SAI2CLKSOURCE_PIN External clock selected as SAI2 clock
  2614. * @arg @ref RCC_SAI2CLKSOURCE_CLKP CLKP selected as SAI2 clock
  2615. * @retval None
  2616. */
  2617. #define __HAL_RCC_SAI2_CONFIG(__SAI2_CLKSOURCE__ )\
  2618. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_SAI2SEL, (uint32_t)(__SAI2_CLKSOURCE__))
  2619. /** @brief Macro to get the SAI2 clock source.
  2620. * @retval The clock source can be one of the following values:
  2621. * @arg @ref RCC_SAI2CLKSOURCE_PLL1Q PLL1Q selected as SAI2 clock
  2622. * @arg @ref RCC_SAI2CLKSOURCE_PLL2P PLL2P selected as SAI2 clock
  2623. * @arg @ref RCC_SAI2CLKSOURCE_PLL3P PLL3P selected as SAI2 clock
  2624. * @arg @ref RCC_SAI2CLKSOURCE_PIN External clock selected as SAI2 clock
  2625. * @arg @ref RCC_SAI2CLKSOURCE_CLKP CLKP selected as SAI2 clock
  2626. */
  2627. #define __HAL_RCC_GET_SAI2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_SAI2SEL)))
  2628. #endif /* SAI2 */
  2629. /** @brief Macro to configure the CLKP : Oscillator clock for peripheral
  2630. * @param __CLKPSource__ specifies Oscillator clock for peripheral
  2631. * This parameter can be one of the following values:
  2632. * @arg RCC_CLKPSOURCE_HSI HSI oscillator selected as clock for peripheral
  2633. * @arg RCC_CLKPSOURCE_CSI CSI oscillator selected as clock for peripheral
  2634. * @arg RCC_CLKPSOURCE_HSE HSE oscillator selected as clock for peripheral
  2635. */
  2636. #define __HAL_RCC_CLKP_CONFIG(__CLKPSource__) \
  2637. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_CKERPSEL, (uint32_t)(__CLKPSource__))
  2638. /** @brief Macro to get the oscillator clock for peripheral clock source.
  2639. * @retval The clock source can be one of the following values:
  2640. * @arg RCC_CLKPSOURCE_HSI HSI selected Oscillator clock for peripheral
  2641. * @arg RCC_CLKPSOURCE_CSI CSI selected Oscillator clock for peripheral
  2642. * @arg RCC_CLKPSOURCE_HSE HSE selected Oscillator clock for peripheral
  2643. */
  2644. #define __HAL_RCC_GET_CLKP_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_CKERPSEL)))
  2645. #if defined(CEC)
  2646. /** @brief Macro to configure the CEC clock (CECCLK)
  2647. * @param __CECCLKSource__ specifies the CEC clock source.
  2648. * This parameter can be one of the following values:
  2649. * @arg RCC_CECCLKSOURCE_LSE LSE selected as CEC clock
  2650. * @arg RCC_CECCLKSOURCE_LSI LSI selected as CEC clock
  2651. * @arg RCC_CECCLKSOURCE_CSI_DIV122 CSI Divided by 122 selected as CEC clock
  2652. */
  2653. #define __HAL_RCC_CEC_CONFIG(__CECCLKSource__) \
  2654. MODIFY_REG(RCC->CCIPR5, RCC_CCIPR5_CECSEL, (uint32_t)(__CECCLKSource__))
  2655. /** @brief Macro to get the CEC clock source.
  2656. * @retval The clock source can be one of the following values:
  2657. * @arg RCC_CECCLKSOURCE_LSE: LSE selected as CEC clock
  2658. * @arg RCC_CECCLKSOURCE_LSI: LSI selected as CEC clock
  2659. * @arg RCC_CECCLKSOURCE_CSI_DIV122: CSI Divided by 122 selected as CEC clock
  2660. */
  2661. #define __HAL_RCC_GET_CEC_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR5, RCC_CCIPR5_CECSEL)))
  2662. #endif /* CEC */
  2663. #if defined(USB_DRD_FS)
  2664. /** @brief Macro to configure the USB clock (USBCLK).
  2665. * @param __USBCLKSource__ specifies the USB clock source.
  2666. * This parameter can be one of the following values:
  2667. * @arg RCC_USBCLKSOURCE_PLL1Q PLL1Q selected as USB clock
  2668. * @arg RCC_USBCLKSOURCE_PLL3Q PLL3Q selected as USB clock (*)
  2669. * @arg RCC_USBCLKSOURCE_PLL2Q PLL2Q selected as USB clock (**)
  2670. * @arg RCC_USBCLKSOURCE_HSI48 HSI48 selected as USB clock
  2671. *
  2672. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2673. * (**) : For stm32h503xx family line.
  2674. */
  2675. #define __HAL_RCC_USB_CONFIG(__USBCLKSource__) \
  2676. MODIFY_REG(RCC->CCIPR4, RCC_CCIPR4_USBSEL, (uint32_t)(__USBCLKSource__))
  2677. /** @brief Macro to get the USB clock source.
  2678. * @retval The clock source can be one of the following values:
  2679. * @arg RCC_USBCLKSOURCE_PLL1Q PLL1Q selected as USB clock
  2680. * @arg RCC_USBCLKSOURCE_PLL3Q PLL3Q selected as USB clock (*)
  2681. * @arg RCC_USBCLKSOURCE_PLL2Q PLL2Q selected as USB clock (**)
  2682. * @arg RCC_USBCLKSOURCE_HSI48 HSI48 selected as USB clock
  2683. *
  2684. * (*) : For stm32h56xxx and stm32h57xxx family lines.
  2685. * (**) : For stm32h503xx family line.
  2686. */
  2687. #define __HAL_RCC_GET_USB_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR4, RCC_CCIPR4_USBSEL)))
  2688. #endif /* USB_DRD_FS */
  2689. /** @brief Macro to configure the Timers clocks prescalers
  2690. * @param __PRESC__ specifies the Timers clocks prescalers selection
  2691. * This parameter can be one of the following values:
  2692. * @arg RCC_TIMPRES_DEACTIVATED: The Timers kernels clocks prescaler is
  2693. * equal to rcc_hclk1 if PPREx is corresponding to division by 1 or 2,
  2694. * else it is equal to 2 x Frcc_pclkx (default after reset)
  2695. * @arg RCC_TIMPRES_ACTIVATED: The Timers kernels clocks prescaler is
  2696. * equal to rcc_hclk1 if PPREx is corresponding to division by 1, 2 or 4,
  2697. * else it is equal to 4 x Frcc_pclkx
  2698. */
  2699. #define __HAL_RCC_TIMCLKPRESCALER(__PRESC__) do {RCC->CFGR1 &= ~(RCC_CFGR1_TIMPRE);\
  2700. RCC->CFGR1 |= (__PRESC__); \
  2701. }while(0)
  2702. #if defined(CRS)
  2703. /**
  2704. * @brief Enable the specified CRS interrupts.
  2705. * @param __INTERRUPT__ specifies the CRS interrupt sources to be enabled.
  2706. * This parameter can be any combination of the following values:
  2707. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  2708. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  2709. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  2710. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  2711. * @retval None
  2712. */
  2713. #define __HAL_RCC_CRS_ENABLE_IT(__INTERRUPT__) SET_BIT(CRS->CR, (__INTERRUPT__))
  2714. /**
  2715. * @brief Disable the specified CRS interrupts.
  2716. * @param __INTERRUPT__ specifies the CRS interrupt sources to be disabled.
  2717. * This parameter can be any combination of the following values:
  2718. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  2719. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  2720. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  2721. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  2722. * @retval None
  2723. */
  2724. #define __HAL_RCC_CRS_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(CRS->CR, (__INTERRUPT__))
  2725. /** @brief Check whether the CRS interrupt has occurred or not.
  2726. * @param __INTERRUPT__ specifies the CRS interrupt source to check.
  2727. * This parameter can be one of the following values:
  2728. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  2729. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  2730. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  2731. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  2732. * @retval The new state of __INTERRUPT__ (0 or 1).
  2733. */
  2734. #define __HAL_RCC_CRS_GET_IT_SOURCE(__INTERRUPT__) ((READ_BIT(CRS->CR, (__INTERRUPT__)) != 0U) ? 1U : 0U)
  2735. /** @brief Clear the CRS interrupt pending bits
  2736. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  2737. * This parameter can be any combination of the following values:
  2738. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  2739. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  2740. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  2741. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  2742. * @arg @ref RCC_CRS_IT_TRIMOVF Trimming overflow or underflow interrupt
  2743. * @arg @ref RCC_CRS_IT_SYNCERR SYNC error interrupt
  2744. * @arg @ref RCC_CRS_IT_SYNCMISS SYNC missed interrupt
  2745. */
  2746. /* CRS IT Error Mask */
  2747. #define RCC_CRS_IT_ERROR_MASK ((uint32_t)(RCC_CRS_IT_TRIMOVF |\
  2748. RCC_CRS_IT_SYNCERR | RCC_CRS_IT_SYNCMISS))
  2749. #define __HAL_RCC_CRS_CLEAR_IT(__INTERRUPT__) do { \
  2750. if(((__INTERRUPT__) & RCC_CRS_IT_ERROR_MASK) != 0U) \
  2751. { \
  2752. WRITE_REG(CRS->ICR, CRS_ICR_ERRC | \
  2753. ((__INTERRUPT__) & ~RCC_CRS_IT_ERROR_MASK)); \
  2754. } \
  2755. else \
  2756. { \
  2757. WRITE_REG(CRS->ICR, (__INTERRUPT__)); \
  2758. } \
  2759. } while(0)
  2760. /**
  2761. * @brief Check whether the specified CRS flag is set or not.
  2762. * @param __FLAG__ specifies the flag to check.
  2763. * This parameter can be one of the following values:
  2764. * @arg @ref RCC_CRS_FLAG_SYNCOK SYNC event OK
  2765. * @arg @ref RCC_CRS_FLAG_SYNCWARN SYNC warning
  2766. * @arg @ref RCC_CRS_FLAG_ERR Error
  2767. * @arg @ref RCC_CRS_FLAG_ESYNC Expected SYNC
  2768. * @arg @ref RCC_CRS_FLAG_TRIMOVF Trimming overflow or underflow
  2769. * @arg @ref RCC_CRS_FLAG_SYNCERR SYNC error
  2770. * @arg @ref RCC_CRS_FLAG_SYNCMISS SYNC missed
  2771. * @retval The new state of _FLAG_ (TRUE or FALSE).
  2772. */
  2773. #define __HAL_RCC_CRS_GET_FLAG(__FLAG__) (READ_BIT(CRS->ISR, (__FLAG__)) == (__FLAG__))
  2774. /**
  2775. * @brief Clear the CRS specified FLAG.
  2776. * @param __FLAG__ specifies the flag to clear.
  2777. * This parameter can be any combination of the following values:
  2778. * @arg @ref RCC_CRS_FLAG_SYNCOK SYNC event OK
  2779. * @arg @ref RCC_CRS_FLAG_SYNCWARN SYNC warning
  2780. * @arg @ref RCC_CRS_FLAG_ERR Error
  2781. * @arg @ref RCC_CRS_FLAG_ESYNC Expected SYNC
  2782. * @arg @ref RCC_CRS_FLAG_TRIMOVF Trimming overflow or underflow
  2783. * @arg @ref RCC_CRS_FLAG_SYNCERR SYNC error
  2784. * @arg @ref RCC_CRS_FLAG_SYNCMISS SYNC missed
  2785. * @note RCC_CRS_FLAG_ERR clears RCC_CRS_FLAG_TRIMOVF, RCC_CRS_FLAG_SYNCERR, RCC_CRS_FLAG_SYNCMISS
  2786. and consequently RCC_CRS_FLAG_ERR
  2787. * @retval None
  2788. */
  2789. /* CRS Flag Error Mask */
  2790. #define RCC_CRS_FLAG_ERROR_MASK ((uint32_t)(RCC_CRS_FLAG_TRIMOVF |\
  2791. RCC_CRS_FLAG_SYNCERR | RCC_CRS_FLAG_SYNCMISS))
  2792. #define __HAL_RCC_CRS_CLEAR_FLAG(__FLAG__) do { \
  2793. if(((__FLAG__) & RCC_CRS_FLAG_ERROR_MASK) != 0U) \
  2794. { \
  2795. WRITE_REG(CRS->ICR, CRS_ICR_ERRC | \
  2796. ((__FLAG__) & ~RCC_CRS_FLAG_ERROR_MASK)); \
  2797. } \
  2798. else \
  2799. { \
  2800. WRITE_REG(CRS->ICR, (__FLAG__)); \
  2801. } \
  2802. } while(0)
  2803. /**
  2804. * @}
  2805. */
  2806. /** @defgroup RCCEx_CRS_Extended_Features RCCEx CRS Extended Features
  2807. * @{
  2808. */
  2809. /**
  2810. * @brief Enable the oscillator clock for frequency error counter.
  2811. * @note when the CEN bit is set the CRS_CFGR register becomes write-protected.
  2812. * @retval None
  2813. */
  2814. #define __HAL_RCC_CRS_FREQ_ERROR_COUNTER_ENABLE() SET_BIT(CRS->CR, CRS_CR_CEN)
  2815. /**
  2816. * @brief Disable the oscillator clock for frequency error counter.
  2817. * @retval None
  2818. */
  2819. #define __HAL_RCC_CRS_FREQ_ERROR_COUNTER_DISABLE() CLEAR_BIT(CRS->CR, CRS_CR_CEN)
  2820. /**
  2821. * @brief Enable the automatic hardware adjustment of TRIM bits.
  2822. * @note When the AUTOTRIMEN bit is set the CRS_CFGR register becomes write-protected.
  2823. * @retval None
  2824. */
  2825. #define __HAL_RCC_CRS_AUTOMATIC_CALIB_ENABLE() SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN)
  2826. /**
  2827. * @brief Enable or disable the automatic hardware adjustment of TRIM bits.
  2828. * @retval None
  2829. */
  2830. #define __HAL_RCC_CRS_AUTOMATIC_CALIB_DISABLE() CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN)
  2831. /**
  2832. * @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies
  2833. * @note The RELOAD value should be selected according to the ratio between the target frequency and the frequency
  2834. * of the synchronization source after prescaling. It is then decreased by one in order to
  2835. * reach the expected synchronization on the zero value. The formula is the following:
  2836. * RELOAD = (fTARGET / fSYNC) -1
  2837. * @param __FTARGET__ Target frequency (value in Hz)
  2838. * @param __FSYNC__ Synchronization signal frequency (value in Hz)
  2839. * @retval None
  2840. */
  2841. #define __HAL_RCC_CRS_RELOADVALUE_CALCULATE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
  2842. /**
  2843. * @}
  2844. */
  2845. #endif /* CRS */
  2846. /* Private constants ---------------------------------------------------------*/
  2847. /** @addtogroup RCCEx_Private_Constants
  2848. * @{
  2849. */
  2850. /* Define used for IS_RCC_* macros below */
  2851. #if defined(SDMMC2)
  2852. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2853. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | RCC_PERIPHCLK_USART6 | \
  2854. RCC_PERIPHCLK_UART7 | RCC_PERIPHCLK_UART8 | RCC_PERIPHCLK_UART9 | \
  2855. RCC_PERIPHCLK_USART10 | RCC_PERIPHCLK_USART11 | RCC_PERIPHCLK_UART12 | \
  2856. RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | \
  2857. RCC_PERIPHCLK_I2C3 | RCC_PERIPHCLK_I2C4 | RCC_PERIPHCLK_I3C1 | \
  2858. RCC_PERIPHCLK_TIM | RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2859. RCC_PERIPHCLK_LPTIM3 | RCC_PERIPHCLK_LPTIM4 | RCC_PERIPHCLK_LPTIM5 | \
  2860. RCC_PERIPHCLK_LPTIM6 | RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2861. RCC_PERIPHCLK_ADCDAC | RCC_PERIPHCLK_DAC_LP | RCC_PERIPHCLK_RNG | \
  2862. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_SDMMC1 | RCC_PERIPHCLK_SDMMC2 | \
  2863. RCC_PERIPHCLK_SPI1 | RCC_PERIPHCLK_SPI2 | \
  2864. RCC_PERIPHCLK_SPI3 | RCC_PERIPHCLK_SPI4 | RCC_PERIPHCLK_SPI5 | \
  2865. RCC_PERIPHCLK_SPI6 | RCC_PERIPHCLK_OSPI | RCC_PERIPHCLK_FDCAN | \
  2866. RCC_PERIPHCLK_CEC | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_CKPER)
  2867. #elif defined(UART7)
  2868. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2869. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | RCC_PERIPHCLK_USART6 | \
  2870. RCC_PERIPHCLK_UART7 | RCC_PERIPHCLK_UART8 | RCC_PERIPHCLK_UART9 | \
  2871. RCC_PERIPHCLK_USART10 | RCC_PERIPHCLK_USART11 | RCC_PERIPHCLK_UART12 | \
  2872. RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | \
  2873. RCC_PERIPHCLK_I2C3 | RCC_PERIPHCLK_I2C4 | RCC_PERIPHCLK_I3C1 | \
  2874. RCC_PERIPHCLK_TIM | RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2875. RCC_PERIPHCLK_LPTIM3 | RCC_PERIPHCLK_LPTIM4 | RCC_PERIPHCLK_LPTIM5 | \
  2876. RCC_PERIPHCLK_LPTIM6 | RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2877. RCC_PERIPHCLK_ADCDAC | RCC_PERIPHCLK_DAC_LP | RCC_PERIPHCLK_RNG | \
  2878. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_SDMMC1 | RCC_PERIPHCLK_SPI1 | \
  2879. RCC_PERIPHCLK_SPI2 | RCC_PERIPHCLK_SPI3 | RCC_PERIPHCLK_SPI4 | \
  2880. RCC_PERIPHCLK_SPI5 | RCC_PERIPHCLK_SPI6 | RCC_PERIPHCLK_OSPI | \
  2881. RCC_PERIPHCLK_FDCAN | RCC_PERIPHCLK_CEC | RCC_PERIPHCLK_USB | \
  2882. RCC_PERIPHCLK_CKPER)
  2883. #elif defined(USART6)
  2884. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2885. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | RCC_PERIPHCLK_USART6 | \
  2886. RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | \
  2887. RCC_PERIPHCLK_I2C3 | RCC_PERIPHCLK_I3C1 | RCC_PERIPHCLK_I3C2 | \
  2888. RCC_PERIPHCLK_TIM | RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2889. RCC_PERIPHCLK_ADCDAC | RCC_PERIPHCLK_DAC_LP | RCC_PERIPHCLK_RNG | \
  2890. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_SDMMC1 | RCC_PERIPHCLK_SPI1 | \
  2891. RCC_PERIPHCLK_SPI2 | RCC_PERIPHCLK_SPI3 | RCC_PERIPHCLK_SPI4 | \
  2892. RCC_PERIPHCLK_OSPI | RCC_PERIPHCLK_FDCAN | RCC_PERIPHCLK_CEC | \
  2893. RCC_PERIPHCLK_USB | RCC_PERIPHCLK_CKPER)
  2894. #else
  2895. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2896. RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | \
  2897. RCC_PERIPHCLK_I3C1 | RCC_PERIPHCLK_I3C2 | RCC_PERIPHCLK_TIM | \
  2898. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | RCC_PERIPHCLK_ADCDAC | \
  2899. RCC_PERIPHCLK_DAC_LP | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_RTC | \
  2900. RCC_PERIPHCLK_SPI1 | RCC_PERIPHCLK_SPI2 | RCC_PERIPHCLK_SPI3 | \
  2901. RCC_PERIPHCLK_FDCAN | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_CKPER)
  2902. #endif /*FDCAN2 && SDMMC2 */
  2903. /**
  2904. * @}
  2905. */
  2906. /* Private macros ------------------------------------------------------------*/
  2907. /** @addtogroup RCCEx_Private_Macros
  2908. * @{
  2909. */
  2910. #define IS_RCC_PLL2_SOURCE(SOURCE) (((SOURCE) == RCC_PLL2_SOURCE_CSI) || \
  2911. ((SOURCE) == RCC_PLL2_SOURCE_HSI) || \
  2912. ((SOURCE) == RCC_PLL2_SOURCE_HSE))
  2913. #define IS_RCC_PLL2_DIVM_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 63U))
  2914. #define IS_RCC_PLL2_MULN_VALUE(VALUE) ((4U <= (VALUE)) && ((VALUE) <= 512U))
  2915. #define IS_RCC_PLL2_DIVP_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  2916. #define IS_RCC_PLL2_DIVQ_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  2917. #define IS_RCC_PLL2_DIVR_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  2918. #define IS_RCC_PLL2_FRACN_VALUE(VALUE) ((VALUE) <= 8191U)
  2919. #define IS_RCC_PLL2_VCIRGE_VALUE(VALUE) (((VALUE) == RCC_PLL2_VCIRANGE_0) || \
  2920. ((VALUE) == RCC_PLL2_VCIRANGE_1) || \
  2921. ((VALUE) == RCC_PLL2_VCIRANGE_2) || \
  2922. ((VALUE) == RCC_PLL2_VCIRANGE_3))
  2923. #define IS_RCC_PLL2_VCORGE_VALUE(VALUE) (((VALUE) == RCC_PLL2_VCORANGE_WIDE) || ((VALUE) == RCC_PLL2_VCORANGE_MEDIUM))
  2924. #define IS_RCC_PLL2_CLOCKOUT_VALUE(VALUE) ((0x00010000U <= (VALUE)) && ((VALUE) <= 0x00070000U))
  2925. #if defined(RCC_CR_PLL3ON)
  2926. #define IS_RCC_PLL3_SOURCE(SOURCE) (((SOURCE) == RCC_PLL3_SOURCE_CSI) || \
  2927. ((SOURCE) == RCC_PLL3_SOURCE_HSI) || \
  2928. ((SOURCE) == RCC_PLL3_SOURCE_HSE))
  2929. #define IS_RCC_PLL3_VCIRGE_VALUE(VALUE) (((VALUE) == RCC_PLL3_VCIRANGE_0) || \
  2930. ((VALUE) == RCC_PLL3_VCIRANGE_1) || \
  2931. ((VALUE) == RCC_PLL3_VCIRANGE_2) || \
  2932. ((VALUE) == RCC_PLL3_VCIRANGE_3))
  2933. #define IS_RCC_PLL3_DIVM_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 63U))
  2934. #define IS_RCC_PLL3_MULN_VALUE(VALUE) ((4U <= (VALUE)) && ((VALUE) <= 512U))
  2935. #define IS_RCC_PLL3_DIVP_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  2936. #define IS_RCC_PLL3_DIVQ_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  2937. #define IS_RCC_PLL3_DIVR_VALUE(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 128U))
  2938. #define IS_RCC_PLL3_FRACN_VALUE(VALUE) ((VALUE) <= 8191U)
  2939. #define IS_RCC_PLL3_VCORGE_VALUE(VALUE) (((VALUE) == RCC_PLL3_VCORANGE_WIDE) || ((VALUE) == RCC_PLL3_VCORANGE_MEDIUM))
  2940. #define IS_RCC_PLL3_CLOCKOUT_VALUE(VALUE) ((0x00010000U <= (VALUE)) && ((VALUE) <= 0x00070000U))
  2941. #endif /* RCC_CR_PLL3ON */
  2942. #define IS_RCC_LSCOSOURCE(__SOURCE__) (((__SOURCE__) == RCC_LSCOSOURCE_LSI) || \
  2943. ((__SOURCE__) == RCC_LSCOSOURCE_LSE))
  2944. #define IS_RCC_CLKPSOURCE(SOURCE) (((SOURCE) == RCC_CLKPSOURCE_HSI) || \
  2945. ((SOURCE) == RCC_CLKPSOURCE_CSI) || \
  2946. ((SOURCE) == RCC_CLKPSOURCE_HSE))
  2947. #define IS_RCC_PERIPHCLOCK(__SELECTION__) ((((__SELECTION__) & RCC_PERIPHCLOCK_ALL) != ((uint64_t)0x00)) && \
  2948. (((__SELECTION__) & ~RCC_PERIPHCLOCK_ALL) == ((uint64_t)0x00)))
  2949. #if defined(RCC_CR_PLL3ON)
  2950. #define IS_RCC_USART1CLKSOURCE(__SOURCE__) \
  2951. (((__SOURCE__) == RCC_USART1CLKSOURCE_PCLK2) || \
  2952. ((__SOURCE__) == RCC_USART1CLKSOURCE_PLL2Q) || \
  2953. ((__SOURCE__) == RCC_USART1CLKSOURCE_PLL3Q) || \
  2954. ((__SOURCE__) == RCC_USART1CLKSOURCE_HSI) || \
  2955. ((__SOURCE__) == RCC_USART1CLKSOURCE_CSI) || \
  2956. ((__SOURCE__) == RCC_USART1CLKSOURCE_LSE))
  2957. #define IS_RCC_USART2CLKSOURCE(__SOURCE__) \
  2958. (((__SOURCE__) == RCC_USART2CLKSOURCE_PCLK1) || \
  2959. ((__SOURCE__) == RCC_USART2CLKSOURCE_PLL2Q) || \
  2960. ((__SOURCE__) == RCC_USART2CLKSOURCE_PLL3Q) || \
  2961. ((__SOURCE__) == RCC_USART2CLKSOURCE_HSI) || \
  2962. ((__SOURCE__) == RCC_USART2CLKSOURCE_CSI) || \
  2963. ((__SOURCE__) == RCC_USART2CLKSOURCE_LSE))
  2964. #define IS_RCC_USART3CLKSOURCE(__SOURCE__) \
  2965. (((__SOURCE__) == RCC_USART3CLKSOURCE_PCLK1) || \
  2966. ((__SOURCE__) == RCC_USART3CLKSOURCE_PLL2Q) || \
  2967. ((__SOURCE__) == RCC_USART3CLKSOURCE_PLL3Q) || \
  2968. ((__SOURCE__) == RCC_USART3CLKSOURCE_HSI) || \
  2969. ((__SOURCE__) == RCC_USART3CLKSOURCE_CSI) || \
  2970. ((__SOURCE__) == RCC_USART3CLKSOURCE_LSE))
  2971. #else
  2972. #define IS_RCC_USART1CLKSOURCE(__SOURCE__) \
  2973. (((__SOURCE__) == RCC_USART1CLKSOURCE_PCLK2) || \
  2974. ((__SOURCE__) == RCC_USART1CLKSOURCE_PLL2Q) || \
  2975. ((__SOURCE__) == RCC_USART1CLKSOURCE_HSI) || \
  2976. ((__SOURCE__) == RCC_USART1CLKSOURCE_CSI) || \
  2977. ((__SOURCE__) == RCC_USART1CLKSOURCE_LSE))
  2978. #define IS_RCC_USART2CLKSOURCE(__SOURCE__) \
  2979. (((__SOURCE__) == RCC_USART2CLKSOURCE_PCLK1) || \
  2980. ((__SOURCE__) == RCC_USART2CLKSOURCE_PLL2Q) || \
  2981. ((__SOURCE__) == RCC_USART2CLKSOURCE_HSI) || \
  2982. ((__SOURCE__) == RCC_USART2CLKSOURCE_CSI) || \
  2983. ((__SOURCE__) == RCC_USART2CLKSOURCE_LSE))
  2984. #define IS_RCC_USART3CLKSOURCE(__SOURCE__) \
  2985. (((__SOURCE__) == RCC_USART3CLKSOURCE_PCLK1) || \
  2986. ((__SOURCE__) == RCC_USART3CLKSOURCE_PLL2Q) || \
  2987. ((__SOURCE__) == RCC_USART3CLKSOURCE_HSI) || \
  2988. ((__SOURCE__) == RCC_USART3CLKSOURCE_CSI) || \
  2989. ((__SOURCE__) == RCC_USART3CLKSOURCE_LSE))
  2990. #endif /* RCC_CR_PLL3ON */
  2991. #if defined(UART4)
  2992. #define IS_RCC_UART4CLKSOURCE(__SOURCE__) \
  2993. (((__SOURCE__) == RCC_UART4CLKSOURCE_PCLK1) || \
  2994. ((__SOURCE__) == RCC_UART4CLKSOURCE_PLL2Q) || \
  2995. ((__SOURCE__) == RCC_UART4CLKSOURCE_PLL3Q) || \
  2996. ((__SOURCE__) == RCC_UART4CLKSOURCE_HSI) || \
  2997. ((__SOURCE__) == RCC_UART4CLKSOURCE_CSI) || \
  2998. ((__SOURCE__) == RCC_UART4CLKSOURCE_LSE))
  2999. #endif /* UART4 */
  3000. #if defined(UART5)
  3001. #define IS_RCC_UART5CLKSOURCE(__SOURCE__) \
  3002. (((__SOURCE__) == RCC_UART5CLKSOURCE_PCLK1) || \
  3003. ((__SOURCE__) == RCC_UART5CLKSOURCE_PLL2Q) || \
  3004. ((__SOURCE__) == RCC_UART5CLKSOURCE_PLL3Q) || \
  3005. ((__SOURCE__) == RCC_UART5CLKSOURCE_HSI) || \
  3006. ((__SOURCE__) == RCC_UART5CLKSOURCE_CSI) || \
  3007. ((__SOURCE__) == RCC_UART5CLKSOURCE_LSE))
  3008. #endif /* UART5 */
  3009. #if defined(USART6)
  3010. #define IS_RCC_USART6CLKSOURCE(__SOURCE__) \
  3011. (((__SOURCE__) == RCC_USART6CLKSOURCE_PCLK1) || \
  3012. ((__SOURCE__) == RCC_USART6CLKSOURCE_PLL2Q) || \
  3013. ((__SOURCE__) == RCC_USART6CLKSOURCE_PLL3Q) || \
  3014. ((__SOURCE__) == RCC_USART6CLKSOURCE_HSI) || \
  3015. ((__SOURCE__) == RCC_USART6CLKSOURCE_CSI) || \
  3016. ((__SOURCE__) == RCC_USART6CLKSOURCE_LSE))
  3017. #endif /* USART6 */
  3018. #if defined(UART7)
  3019. #define IS_RCC_UART7CLKSOURCE(__SOURCE__) \
  3020. (((__SOURCE__) == RCC_UART7CLKSOURCE_PCLK1) || \
  3021. ((__SOURCE__) == RCC_UART7CLKSOURCE_PLL2Q) || \
  3022. ((__SOURCE__) == RCC_UART7CLKSOURCE_PLL3Q) || \
  3023. ((__SOURCE__) == RCC_UART7CLKSOURCE_HSI) || \
  3024. ((__SOURCE__) == RCC_UART7CLKSOURCE_CSI) || \
  3025. ((__SOURCE__) == RCC_UART7CLKSOURCE_LSE))
  3026. #endif /* UART7 */
  3027. #if defined(UART8)
  3028. #define IS_RCC_UART8CLKSOURCE(__SOURCE__) \
  3029. (((__SOURCE__) == RCC_UART8CLKSOURCE_PCLK1) || \
  3030. ((__SOURCE__) == RCC_UART8CLKSOURCE_PLL2Q) || \
  3031. ((__SOURCE__) == RCC_UART8CLKSOURCE_PLL3Q) || \
  3032. ((__SOURCE__) == RCC_UART8CLKSOURCE_HSI) || \
  3033. ((__SOURCE__) == RCC_UART8CLKSOURCE_CSI) || \
  3034. ((__SOURCE__) == RCC_UART8CLKSOURCE_LSE))
  3035. #endif /* UART8 */
  3036. #if defined(UART9)
  3037. #define IS_RCC_UART9CLKSOURCE(__SOURCE__) \
  3038. (((__SOURCE__) == RCC_UART9CLKSOURCE_PCLK1) || \
  3039. ((__SOURCE__) == RCC_UART9CLKSOURCE_PLL2Q) || \
  3040. ((__SOURCE__) == RCC_UART9CLKSOURCE_PLL3Q) || \
  3041. ((__SOURCE__) == RCC_UART9CLKSOURCE_HSI) || \
  3042. ((__SOURCE__) == RCC_UART9CLKSOURCE_CSI) || \
  3043. ((__SOURCE__) == RCC_UART9CLKSOURCE_LSE))
  3044. #endif /* UART9 */
  3045. #if defined(USART10)
  3046. #define IS_RCC_USART10CLKSOURCE(__SOURCE__) \
  3047. (((__SOURCE__) == RCC_USART10CLKSOURCE_PCLK1) || \
  3048. ((__SOURCE__) == RCC_USART10CLKSOURCE_PLL2Q) || \
  3049. ((__SOURCE__) == RCC_USART10CLKSOURCE_PLL3Q) || \
  3050. ((__SOURCE__) == RCC_USART10CLKSOURCE_HSI) || \
  3051. ((__SOURCE__) == RCC_USART10CLKSOURCE_CSI) || \
  3052. ((__SOURCE__) == RCC_USART10CLKSOURCE_LSE))
  3053. #endif /* USART10 */
  3054. #if defined(USART11)
  3055. #define IS_RCC_USART11CLKSOURCE(__SOURCE__) \
  3056. (((__SOURCE__) == RCC_USART11CLKSOURCE_PCLK1) || \
  3057. ((__SOURCE__) == RCC_USART11CLKSOURCE_PLL2Q) || \
  3058. ((__SOURCE__) == RCC_USART11CLKSOURCE_PLL3Q) || \
  3059. ((__SOURCE__) == RCC_USART11CLKSOURCE_HSI) || \
  3060. ((__SOURCE__) == RCC_USART11CLKSOURCE_CSI) || \
  3061. ((__SOURCE__) == RCC_USART11CLKSOURCE_LSE))
  3062. #endif /* USART11 */
  3063. #if defined(UART12)
  3064. #define IS_RCC_UART12CLKSOURCE(__SOURCE__) \
  3065. (((__SOURCE__) == RCC_UART12CLKSOURCE_PCLK1) || \
  3066. ((__SOURCE__) == RCC_UART12CLKSOURCE_PLL2Q) || \
  3067. ((__SOURCE__) == RCC_UART12CLKSOURCE_PLL3Q) || \
  3068. ((__SOURCE__) == RCC_UART12CLKSOURCE_HSI) || \
  3069. ((__SOURCE__) == RCC_UART12CLKSOURCE_CSI) || \
  3070. ((__SOURCE__) == RCC_UART12CLKSOURCE_LSE))
  3071. #endif /* UART12 */
  3072. #if defined(RCC_CR_PLL3ON)
  3073. #define IS_RCC_LPUART1CLKSOURCE(__SOURCE__) \
  3074. (((__SOURCE__) == RCC_LPUART1CLKSOURCE_PCLK3) || \
  3075. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_PLL2Q) || \
  3076. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_PLL3Q) || \
  3077. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_HSI) || \
  3078. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_LSE) || \
  3079. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_CSI))
  3080. #else
  3081. #define IS_RCC_LPUART1CLKSOURCE(__SOURCE__) \
  3082. (((__SOURCE__) == RCC_LPUART1CLKSOURCE_PCLK3) || \
  3083. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_PLL2Q) || \
  3084. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_HSI) || \
  3085. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_LSE) || \
  3086. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_CSI))
  3087. #endif /* RCC_CR_PLL3ON */
  3088. #if defined(RCC_CR_PLL3ON)
  3089. #define IS_RCC_I2C1CLKSOURCE(__SOURCE__) \
  3090. (((__SOURCE__) == RCC_I2C1CLKSOURCE_PCLK1) || \
  3091. ((__SOURCE__) == RCC_I2C1CLKSOURCE_PLL3R) || \
  3092. ((__SOURCE__) == RCC_I2C1CLKSOURCE_HSI) || \
  3093. ((__SOURCE__) == RCC_I2C1CLKSOURCE_CSI))
  3094. #define IS_RCC_I2C2CLKSOURCE(__SOURCE__) \
  3095. (((__SOURCE__) == RCC_I2C2CLKSOURCE_PCLK1) || \
  3096. ((__SOURCE__) == RCC_I2C2CLKSOURCE_PLL3R) || \
  3097. ((__SOURCE__) == RCC_I2C2CLKSOURCE_HSI) || \
  3098. ((__SOURCE__) == RCC_I2C2CLKSOURCE_CSI))
  3099. #else
  3100. #define IS_RCC_I2C1CLKSOURCE(__SOURCE__) \
  3101. (((__SOURCE__) == RCC_I2C1CLKSOURCE_PCLK1) || \
  3102. ((__SOURCE__) == RCC_I2C1CLKSOURCE_PLL2R) || \
  3103. ((__SOURCE__) == RCC_I2C1CLKSOURCE_HSI) || \
  3104. ((__SOURCE__) == RCC_I2C1CLKSOURCE_CSI))
  3105. #define IS_RCC_I2C2CLKSOURCE(__SOURCE__) \
  3106. (((__SOURCE__) == RCC_I2C2CLKSOURCE_PCLK1) || \
  3107. ((__SOURCE__) == RCC_I2C2CLKSOURCE_PLL2R) || \
  3108. ((__SOURCE__) == RCC_I2C2CLKSOURCE_HSI) || \
  3109. ((__SOURCE__) == RCC_I2C2CLKSOURCE_CSI))
  3110. #endif /* RCC_CR_PLL3ON */
  3111. #if defined(I2C3)
  3112. #define IS_RCC_I2C3CLKSOURCE(__SOURCE__) \
  3113. (((__SOURCE__) == RCC_I2C3CLKSOURCE_PCLK3) || \
  3114. ((__SOURCE__) == RCC_I2C3CLKSOURCE_PLL3R) || \
  3115. ((__SOURCE__) == RCC_I2C3CLKSOURCE_HSI ) || \
  3116. ((__SOURCE__) == RCC_I2C3CLKSOURCE_CSI))
  3117. #endif /* I2C3 */
  3118. #if defined(I2C4)
  3119. #define IS_RCC_I2C4CLKSOURCE(__SOURCE__) \
  3120. (((__SOURCE__) == RCC_I2C4CLKSOURCE_PCLK3) || \
  3121. ((__SOURCE__) == RCC_I2C4CLKSOURCE_PLL3R) || \
  3122. ((__SOURCE__) == RCC_I2C4CLKSOURCE_HSI ) || \
  3123. ((__SOURCE__) == RCC_I2C4CLKSOURCE_CSI))
  3124. #endif /* I2C4 */
  3125. #if defined(RCC_CR_PLL3ON)
  3126. #define IS_RCC_I3C1CLKSOURCE(__SOURCE__) \
  3127. (((__SOURCE__) == RCC_I3C1CLKSOURCE_PCLK1) || \
  3128. ((__SOURCE__) == RCC_I3C1CLKSOURCE_PLL3R) || \
  3129. ((__SOURCE__) == RCC_I3C1CLKSOURCE_HSI))
  3130. #else
  3131. #define IS_RCC_I3C1CLKSOURCE(__SOURCE__) \
  3132. (((__SOURCE__) == RCC_I3C1CLKSOURCE_PCLK1) || \
  3133. ((__SOURCE__) == RCC_I3C1CLKSOURCE_PLL2R) || \
  3134. ((__SOURCE__) == RCC_I3C1CLKSOURCE_HSI))
  3135. #endif /* RCC_CR_PLL3ON */
  3136. #if defined(I3C2)
  3137. #if defined(RCC_CR_PLL3ON)
  3138. #define IS_RCC_I3C2CLKSOURCE(__SOURCE__) \
  3139. (((__SOURCE__) == RCC_I3C2CLKSOURCE_PCLK3) || \
  3140. ((__SOURCE__) == RCC_I3C2CLKSOURCE_PLL3R) || \
  3141. ((__SOURCE__) == RCC_I3C2CLKSOURCE_HSI))
  3142. #else
  3143. #define IS_RCC_I3C2CLKSOURCE(__SOURCE__) \
  3144. (((__SOURCE__) == RCC_I3C2CLKSOURCE_PCLK3) || \
  3145. ((__SOURCE__) == RCC_I3C2CLKSOURCE_PLL2R) || \
  3146. ((__SOURCE__) == RCC_I3C2CLKSOURCE_HSI))
  3147. #endif /* PLL3 */
  3148. #endif /* I3C2 */
  3149. #if defined(SAI1)
  3150. #define IS_RCC_SAI1CLK(__SOURCE__) \
  3151. (((__SOURCE__) == RCC_SAI1CLKSOURCE_PLL1Q)|| \
  3152. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PLL2P)|| \
  3153. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PLL3P)|| \
  3154. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PIN) || \
  3155. ((__SOURCE__) == RCC_SAI1CLKSOURCE_CLKP))
  3156. #endif /* SAI1 */
  3157. #if defined(SAI2)
  3158. #define IS_RCC_SAI2CLK(__SOURCE__) \
  3159. (((__SOURCE__) == RCC_SAI2CLKSOURCE_PLL1Q)|| \
  3160. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PLL2P)|| \
  3161. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PLL3P)|| \
  3162. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PIN) || \
  3163. ((__SOURCE__) == RCC_SAI2CLKSOURCE_CLKP))
  3164. #endif /* SAI2 */
  3165. #if defined(RCC_CR_PLL3ON)
  3166. #define IS_RCC_LPTIM1CLK(__SOURCE__) \
  3167. (((__SOURCE__) == RCC_LPTIM1CLKSOURCE_PCLK3) || \
  3168. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_PLL2P) || \
  3169. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_PLL3R) || \
  3170. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_LSE) || \
  3171. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_LSI) || \
  3172. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_CLKP))
  3173. #define IS_RCC_LPTIM2CLK(__SOURCE__) \
  3174. (((__SOURCE__) == RCC_LPTIM2CLKSOURCE_PCLK1) || \
  3175. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_PLL2P) || \
  3176. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_PLL3R) || \
  3177. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_LSE) || \
  3178. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_LSI) || \
  3179. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_CLKP))
  3180. #else
  3181. #define IS_RCC_LPTIM1CLK(__SOURCE__) \
  3182. (((__SOURCE__) == RCC_LPTIM1CLKSOURCE_PCLK3) || \
  3183. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_PLL2P) || \
  3184. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_LSE) || \
  3185. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_LSI) || \
  3186. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_CLKP))
  3187. #define IS_RCC_LPTIM2CLK(__SOURCE__) \
  3188. (((__SOURCE__) == RCC_LPTIM2CLKSOURCE_PCLK1) || \
  3189. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_PLL2P) || \
  3190. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_LSE) || \
  3191. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_LSI) || \
  3192. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_CLKP))
  3193. #endif /* RCC_CR_PLL3ON */
  3194. #if defined(LPTIM3)
  3195. #define IS_RCC_LPTIM3CLK(__SOURCE__) \
  3196. (((__SOURCE__) == RCC_LPTIM3CLKSOURCE_PCLK3) || \
  3197. ((__SOURCE__) == RCC_LPTIM3CLKSOURCE_PLL2P) || \
  3198. ((__SOURCE__) == RCC_LPTIM3CLKSOURCE_PLL3R) || \
  3199. ((__SOURCE__) == RCC_LPTIM3CLKSOURCE_LSE) || \
  3200. ((__SOURCE__) == RCC_LPTIM3CLKSOURCE_LSI) || \
  3201. ((__SOURCE__) == RCC_LPTIM3CLKSOURCE_CLKP))
  3202. #endif /* LPTIM3 */
  3203. #if defined(LPTIM4)
  3204. #define IS_RCC_LPTIM4CLK(__SOURCE__) \
  3205. (((__SOURCE__) == RCC_LPTIM4CLKSOURCE_PCLK3) || \
  3206. ((__SOURCE__) == RCC_LPTIM4CLKSOURCE_PLL2P) || \
  3207. ((__SOURCE__) == RCC_LPTIM4CLKSOURCE_PLL3R) || \
  3208. ((__SOURCE__) == RCC_LPTIM4CLKSOURCE_LSE) || \
  3209. ((__SOURCE__) == RCC_LPTIM4CLKSOURCE_LSI) || \
  3210. ((__SOURCE__) == RCC_LPTIM4CLKSOURCE_CLKP))
  3211. #endif /* LPTIM4 */
  3212. #if defined(LPTIM5)
  3213. #define IS_RCC_LPTIM5CLK(__SOURCE__) \
  3214. (((__SOURCE__) == RCC_LPTIM5CLKSOURCE_PCLK3) || \
  3215. ((__SOURCE__) == RCC_LPTIM5CLKSOURCE_PLL2P) || \
  3216. ((__SOURCE__) == RCC_LPTIM5CLKSOURCE_PLL3R) || \
  3217. ((__SOURCE__) == RCC_LPTIM5CLKSOURCE_LSE) || \
  3218. ((__SOURCE__) == RCC_LPTIM5CLKSOURCE_LSI) || \
  3219. ((__SOURCE__) == RCC_LPTIM5CLKSOURCE_CLKP))
  3220. #endif /* LPTIM5 */
  3221. #if defined(LPTIM6)
  3222. #define IS_RCC_LPTIM6CLK(__SOURCE__) \
  3223. (((__SOURCE__) == RCC_LPTIM6CLKSOURCE_PCLK3) || \
  3224. ((__SOURCE__) == RCC_LPTIM6CLKSOURCE_PLL2P) || \
  3225. ((__SOURCE__) == RCC_LPTIM6CLKSOURCE_PLL3R) || \
  3226. ((__SOURCE__) == RCC_LPTIM6CLKSOURCE_LSE) || \
  3227. ((__SOURCE__) == RCC_LPTIM6CLKSOURCE_LSI) || \
  3228. ((__SOURCE__) == RCC_LPTIM6CLKSOURCE_CLKP))
  3229. #endif /* LPTIM6 */
  3230. #define IS_RCC_FDCANCLK(__SOURCE__) \
  3231. (((__SOURCE__) == RCC_FDCANCLKSOURCE_HSE) || \
  3232. ((__SOURCE__) == RCC_FDCANCLKSOURCE_PLL1Q) || \
  3233. ((__SOURCE__) == RCC_FDCANCLKSOURCE_PLL2Q))
  3234. #if defined(SDMMC1)
  3235. #define IS_RCC_SDMMC1CLKSOURCE(__SOURCE__) \
  3236. (((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLL1Q) || \
  3237. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLL2R))
  3238. #endif /* SDMMC1 */
  3239. #if defined(SDMMC2)
  3240. #define IS_RCC_SDMMC2CLKSOURCE(__SOURCE__) \
  3241. (((__SOURCE__) == RCC_SDMMC2CLKSOURCE_PLL1Q) || \
  3242. ((__SOURCE__) == RCC_SDMMC2CLKSOURCE_PLL2R))
  3243. #endif /*SDMMC2*/
  3244. #define IS_RCC_RNGCLKSOURCE(__SOURCE__) \
  3245. (((__SOURCE__) == RCC_RNGCLKSOURCE_HSI48) || \
  3246. ((__SOURCE__) == RCC_RNGCLKSOURCE_PLL1Q) || \
  3247. ((__SOURCE__) == RCC_RNGCLKSOURCE_LSE) || \
  3248. ((__SOURCE__) == RCC_RNGCLKSOURCE_LSI))
  3249. #define IS_RCC_ADCDACCLKSOURCE(__SOURCE__) \
  3250. (((__SOURCE__) == RCC_ADCDACCLKSOURCE_HCLK) || \
  3251. ((__SOURCE__) == RCC_ADCDACCLKSOURCE_SYSCLK) || \
  3252. ((__SOURCE__) == RCC_ADCDACCLKSOURCE_PLL2R) || \
  3253. ((__SOURCE__) == RCC_ADCDACCLKSOURCE_HSE) || \
  3254. ((__SOURCE__) == RCC_ADCDACCLKSOURCE_HSI) || \
  3255. ((__SOURCE__) == RCC_ADCDACCLKSOURCE_CSI))
  3256. #define IS_RCC_DACLPCLKSOURCE(__SOURCE__) \
  3257. (((__SOURCE__) == RCC_DACLPCLKSOURCE_LSI) || \
  3258. ((__SOURCE__) == RCC_DACLPCLKSOURCE_LSE))
  3259. #if defined(OCTOSPI1)
  3260. #define IS_RCC_OSPICLKSOURCE(__SOURCE__) \
  3261. (((__SOURCE__) == RCC_OSPICLKSOURCE_HCLK) || \
  3262. ((__SOURCE__) == RCC_OSPICLKSOURCE_PLL1Q) || \
  3263. ((__SOURCE__) == RCC_OSPICLKSOURCE_PLL2R) || \
  3264. ((__SOURCE__) == RCC_OSPICLKSOURCE_CLKP))
  3265. #endif /* OCTOSPI1 */
  3266. #if defined(RCC_CR_PLL3ON)
  3267. #define IS_RCC_SPI1CLKSOURCE(__SOURCE__) \
  3268. (((__SOURCE__) == RCC_SPI1CLKSOURCE_PLL1Q) || \
  3269. ((__SOURCE__) == RCC_SPI1CLKSOURCE_PLL2P) || \
  3270. ((__SOURCE__) == RCC_SPI1CLKSOURCE_PLL3P) || \
  3271. ((__SOURCE__) == RCC_SPI1CLKSOURCE_PIN) || \
  3272. ((__SOURCE__) == RCC_SPI1CLKSOURCE_CLKP))
  3273. #define IS_RCC_SPI2CLKSOURCE(__SOURCE__) \
  3274. (((__SOURCE__) == RCC_SPI2CLKSOURCE_PLL1Q) || \
  3275. ((__SOURCE__) == RCC_SPI2CLKSOURCE_PLL2P) || \
  3276. ((__SOURCE__) == RCC_SPI2CLKSOURCE_PLL3P) || \
  3277. ((__SOURCE__) == RCC_SPI2CLKSOURCE_PIN) || \
  3278. ((__SOURCE__) == RCC_SPI2CLKSOURCE_CLKP))
  3279. #define IS_RCC_SPI3CLKSOURCE(__SOURCE__) \
  3280. (((__SOURCE__) == RCC_SPI3CLKSOURCE_PLL1Q) || \
  3281. ((__SOURCE__) == RCC_SPI3CLKSOURCE_PLL2P) || \
  3282. ((__SOURCE__) == RCC_SPI3CLKSOURCE_PLL3P) || \
  3283. ((__SOURCE__) == RCC_SPI3CLKSOURCE_PIN) || \
  3284. ((__SOURCE__) == RCC_SPI3CLKSOURCE_CLKP))
  3285. #else
  3286. #define IS_RCC_SPI1CLKSOURCE(__SOURCE__) \
  3287. (((__SOURCE__) == RCC_SPI1CLKSOURCE_PLL1Q) || \
  3288. ((__SOURCE__) == RCC_SPI1CLKSOURCE_PLL2P) || \
  3289. ((__SOURCE__) == RCC_SPI1CLKSOURCE_PIN) || \
  3290. ((__SOURCE__) == RCC_SPI1CLKSOURCE_CLKP))
  3291. #define IS_RCC_SPI2CLKSOURCE(__SOURCE__) \
  3292. (((__SOURCE__) == RCC_SPI2CLKSOURCE_PLL1Q) || \
  3293. ((__SOURCE__) == RCC_SPI2CLKSOURCE_PLL2P) || \
  3294. ((__SOURCE__) == RCC_SPI2CLKSOURCE_PIN) || \
  3295. ((__SOURCE__) == RCC_SPI2CLKSOURCE_CLKP))
  3296. #define IS_RCC_SPI3CLKSOURCE(__SOURCE__) \
  3297. (((__SOURCE__) == RCC_SPI3CLKSOURCE_PLL1Q) || \
  3298. ((__SOURCE__) == RCC_SPI3CLKSOURCE_PLL2P) || \
  3299. ((__SOURCE__) == RCC_SPI3CLKSOURCE_PIN) || \
  3300. ((__SOURCE__) == RCC_SPI3CLKSOURCE_CLKP))
  3301. #endif /* RCC_CR_PLL3ON */
  3302. #if defined(SPI4)
  3303. #define IS_RCC_SPI4CLKSOURCE(__SOURCE__) \
  3304. (((__SOURCE__) == RCC_SPI4CLKSOURCE_PCLK2) || \
  3305. ((__SOURCE__) == RCC_SPI4CLKSOURCE_PLL2Q) || \
  3306. ((__SOURCE__) == RCC_SPI4CLKSOURCE_PLL3Q) || \
  3307. ((__SOURCE__) == RCC_SPI4CLKSOURCE_HSI) || \
  3308. ((__SOURCE__) == RCC_SPI4CLKSOURCE_CSI) || \
  3309. ((__SOURCE__) == RCC_SPI4CLKSOURCE_HSE))
  3310. #endif /* SPI4 */
  3311. #if defined(SPI5)
  3312. #define IS_RCC_SPI5CLKSOURCE(__SOURCE__) \
  3313. (((__SOURCE__) == RCC_SPI5CLKSOURCE_PCLK3) || \
  3314. ((__SOURCE__) == RCC_SPI5CLKSOURCE_PLL2Q) || \
  3315. ((__SOURCE__) == RCC_SPI5CLKSOURCE_PLL3Q) || \
  3316. ((__SOURCE__) == RCC_SPI5CLKSOURCE_HSI) || \
  3317. ((__SOURCE__) == RCC_SPI5CLKSOURCE_CSI) || \
  3318. ((__SOURCE__) == RCC_SPI5CLKSOURCE_HSE))
  3319. #endif /* SPI5 */
  3320. #if defined(SPI6)
  3321. #define IS_RCC_SPI6CLKSOURCE(__SOURCE__) \
  3322. (((__SOURCE__) == RCC_SPI6CLKSOURCE_PCLK2) || \
  3323. ((__SOURCE__) == RCC_SPI6CLKSOURCE_PLL2Q) || \
  3324. ((__SOURCE__) == RCC_SPI6CLKSOURCE_PLL3Q) || \
  3325. ((__SOURCE__) == RCC_SPI6CLKSOURCE_HSI) || \
  3326. ((__SOURCE__) == RCC_SPI6CLKSOURCE_CSI) || \
  3327. ((__SOURCE__) == RCC_SPI6CLKSOURCE_HSE))
  3328. #endif /* SPI6 */
  3329. #if defined(USB_DRD_FS)
  3330. #if defined(RCC_CR_PLL3ON)
  3331. #define IS_RCC_USBCLKSOURCE(__SOURCE__) \
  3332. (((__SOURCE__) == RCC_USBCLKSOURCE_PLL1Q) || \
  3333. ((__SOURCE__) == RCC_USBCLKSOURCE_PLL3Q) || \
  3334. ((__SOURCE__) == RCC_USBCLKSOURCE_HSI48))
  3335. #else
  3336. #define IS_RCC_USBCLKSOURCE(__SOURCE__) \
  3337. (((__SOURCE__) == RCC_USBCLKSOURCE_PLL1Q) || \
  3338. ((__SOURCE__) == RCC_USBCLKSOURCE_PLL2Q) || \
  3339. ((__SOURCE__) == RCC_USBCLKSOURCE_HSI48))
  3340. #endif /* RCC_CR_PLL3ON */
  3341. #endif /* USB_DRD_FS */
  3342. #if defined(CEC)
  3343. #define IS_RCC_CECCLKSOURCE(__SOURCE__) \
  3344. (((__SOURCE__) == RCC_CECCLKSOURCE_LSE) || \
  3345. ((__SOURCE__) == RCC_CECCLKSOURCE_LSI) || \
  3346. ((__SOURCE__) == RCC_CECCLKSOURCE_CSI_DIV122))
  3347. #endif /*CEC*/
  3348. #define IS_RCC_TIMPRES(VALUE) \
  3349. (((VALUE) == RCC_TIMPRES_DEACTIVATED) || \
  3350. ((VALUE) == RCC_TIMPRES_ACTIVATED))
  3351. #if defined(CRS)
  3352. #if defined(USB_DRD_FS)
  3353. #define IS_RCC_CRS_SYNC_SOURCE(__SOURCE__) (((__SOURCE__) == RCC_CRS_SYNC_SOURCE_GPIO) || \
  3354. ((__SOURCE__) == RCC_CRS_SYNC_SOURCE_LSE) || \
  3355. ((__SOURCE__) == RCC_CRS_SYNC_SOURCE_USB))
  3356. #endif /* USB_DRD_FS */
  3357. #define IS_RCC_CRS_SYNC_DIV(__DIV__) (((__DIV__) == RCC_CRS_SYNC_DIV1) || ((__DIV__) == RCC_CRS_SYNC_DIV2) || \
  3358. ((__DIV__) == RCC_CRS_SYNC_DIV4) || ((__DIV__) == RCC_CRS_SYNC_DIV8) || \
  3359. ((__DIV__) == RCC_CRS_SYNC_DIV16) || ((__DIV__) == RCC_CRS_SYNC_DIV32) || \
  3360. ((__DIV__) == RCC_CRS_SYNC_DIV64) || ((__DIV__) == RCC_CRS_SYNC_DIV128))
  3361. #define IS_RCC_CRS_SYNC_POLARITY(__POLARITY__) (((__POLARITY__) == RCC_CRS_SYNC_POLARITY_RISING) || \
  3362. ((__POLARITY__) == RCC_CRS_SYNC_POLARITY_FALLING))
  3363. #define IS_RCC_CRS_RELOADVALUE(__VALUE__) (((__VALUE__) <= 0xFFFFU))
  3364. #define IS_RCC_CRS_ERRORLIMIT(__VALUE__) (((__VALUE__) <= 0xFFU))
  3365. #define IS_RCC_CRS_HSI48CALIBRATION(__VALUE__) (((__VALUE__) <= 0x7FU))
  3366. #define IS_RCC_CRS_FREQERRORDIR(__DIR__) (((__DIR__) == RCC_CRS_FREQERRORDIR_UP) || \
  3367. ((__DIR__) == RCC_CRS_FREQERRORDIR_DOWN))
  3368. #endif /* CRS */
  3369. /**
  3370. * @}
  3371. */
  3372. /* Exported functions --------------------------------------------------------*/
  3373. /** @addtogroup RCCEx_Exported_Functions
  3374. * @{
  3375. */
  3376. /** @addtogroup RCCEx_Exported_Functions_Group1
  3377. * @{
  3378. */
  3379. HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(const RCC_PeriphCLKInitTypeDef *pPeriphClkInit);
  3380. void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *pPeriphClkInit);
  3381. uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint64_t PeriphClk);
  3382. void HAL_RCCEx_GetPLL1ClockFreq(PLL1_ClocksTypeDef *pPLL1_Clocks);
  3383. void HAL_RCCEx_GetPLL2ClockFreq(PLL2_ClocksTypeDef *pPLL2_Clocks);
  3384. #if defined(RCC_CR_PLL3ON)
  3385. void HAL_RCCEx_GetPLL3ClockFreq(PLL3_ClocksTypeDef *pPLL3_Clocks);
  3386. #endif /* RCC_CR_PLL3ON */
  3387. /**
  3388. * @}
  3389. */
  3390. /** @addtogroup RCCEx_Exported_Functions_Group2
  3391. * @{
  3392. */
  3393. HAL_StatusTypeDef HAL_RCCEx_EnablePLL2(RCC_PLL2InitTypeDef *pPLL2Init);
  3394. HAL_StatusTypeDef HAL_RCCEx_DisablePLL2(void);
  3395. #if defined(RCC_CR_PLL3ON)
  3396. HAL_StatusTypeDef HAL_RCCEx_EnablePLL3(RCC_PLL3InitTypeDef *pPLL3Init);
  3397. HAL_StatusTypeDef HAL_RCCEx_DisablePLL3(void);
  3398. #endif /* RCC_CR_PLL3ON */
  3399. void HAL_RCCEx_WakeUpStopCLKConfig(uint32_t WakeUpClk);
  3400. void HAL_RCCEx_KerWakeUpStopCLKConfig(uint32_t WakeUpClk);
  3401. void HAL_RCCEx_EnableLSECSS(void);
  3402. void HAL_RCCEx_DisableLSECSS(void);
  3403. void HAL_RCCEx_LSECSS_IRQHandler(void);
  3404. void HAL_RCCEx_LSECSS_Callback(void);
  3405. void HAL_RCCEx_EnableLSCO(uint32_t LSCOSource);
  3406. void HAL_RCCEx_DisableLSCO(void);
  3407. /**
  3408. * @}
  3409. */
  3410. #if defined(CRS)
  3411. /** @addtogroup RCCEx_Exported_Functions_Group3
  3412. * @{
  3413. */
  3414. void HAL_RCCEx_CRSConfig(const RCC_CRSInitTypeDef *pInit);
  3415. void HAL_RCCEx_CRSSoftwareSynchronizationGenerate(void);
  3416. void HAL_RCCEx_CRSGetSynchronizationInfo(RCC_CRSSynchroInfoTypeDef *pSynchroInfo);
  3417. uint32_t HAL_RCCEx_CRSWaitSynchronization(uint32_t Timeout);
  3418. void HAL_RCCEx_CRS_IRQHandler(void);
  3419. void HAL_RCCEx_CRS_SyncOkCallback(void);
  3420. void HAL_RCCEx_CRS_SyncWarnCallback(void);
  3421. void HAL_RCCEx_CRS_ExpectedSyncCallback(void);
  3422. void HAL_RCCEx_CRS_ErrorCallback(uint32_t Error);
  3423. /**
  3424. * @}
  3425. */
  3426. #endif /* CRS */
  3427. /**
  3428. * @}
  3429. */
  3430. /**
  3431. * @}
  3432. */
  3433. /**
  3434. * @}
  3435. */
  3436. #ifdef __cplusplus
  3437. }
  3438. #endif
  3439. #endif /* __STM32H5xx_HAL_RCC_EX_H */