stm32l4xx_hal_rcc_ex.h 136 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_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) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file in
  13. * the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. ******************************************************************************
  16. */
  17. /* Define to prevent recursive inclusion -------------------------------------*/
  18. #ifndef STM32L4xx_HAL_RCC_EX_H
  19. #define STM32L4xx_HAL_RCC_EX_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32l4xx_hal_def.h"
  25. /** @addtogroup STM32L4xx_HAL_Driver
  26. * @{
  27. */
  28. /** @addtogroup RCCEx
  29. * @{
  30. */
  31. /* Exported types ------------------------------------------------------------*/
  32. /** @defgroup RCCEx_Exported_Types RCCEx Exported Types
  33. * @{
  34. */
  35. #if defined(RCC_PLLSAI1_SUPPORT)
  36. /**
  37. * @brief PLLSAI1 Clock structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t PLLSAI1Source; /*!< PLLSAI1Source: PLLSAI1 entry clock source.
  42. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  43. #if defined(RCC_PLLSAI1M_DIV_1_16_SUPPORT)
  44. uint32_t PLLSAI1M; /*!< PLLSAI1M: specifies the division factor for PLLSAI1 input clock.
  45. This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
  46. #else
  47. uint32_t PLLSAI1M; /*!< PLLSAI1M: specifies the division factor for PLLSAI1 input clock.
  48. This parameter must be a number between Min_Data = 1 and Max_Data = 8 */
  49. #endif
  50. uint32_t PLLSAI1N; /*!< PLLSAI1N: specifies the multiplication factor for PLLSAI1 VCO output clock.
  51. This parameter must be a number between 8 and 86 or 127 depending on devices. */
  52. uint32_t PLLSAI1P; /*!< PLLSAI1P: specifies the division factor for SAI clock.
  53. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  54. uint32_t PLLSAI1Q; /*!< PLLSAI1Q: specifies the division factor for USB/RNG/SDMMC1 clock.
  55. This parameter must be a value of @ref RCC_PLLQ_Clock_Divider */
  56. uint32_t PLLSAI1R; /*!< PLLSAI1R: specifies the division factor for ADC clock.
  57. This parameter must be a value of @ref RCC_PLLR_Clock_Divider */
  58. uint32_t PLLSAI1ClockOut; /*!< PLLSAIClockOut: specifies PLLSAI1 output clock to be enabled.
  59. This parameter must be a value of @ref RCC_PLLSAI1_Clock_Output */
  60. }RCC_PLLSAI1InitTypeDef;
  61. #endif /* RCC_PLLSAI1_SUPPORT */
  62. #if defined(RCC_PLLSAI2_SUPPORT)
  63. /**
  64. * @brief PLLSAI2 Clock structure definition
  65. */
  66. typedef struct
  67. {
  68. uint32_t PLLSAI2Source; /*!< PLLSAI2Source: PLLSAI2 entry clock source.
  69. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  70. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  71. uint32_t PLLSAI2M; /*!< PLLSAI2M: specifies the division factor for PLLSAI2 input clock.
  72. This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
  73. #else
  74. uint32_t PLLSAI2M; /*!< PLLSAI2M: specifies the division factor for PLLSAI2 input clock.
  75. This parameter must be a number between Min_Data = 1 and Max_Data = 8 */
  76. #endif
  77. uint32_t PLLSAI2N; /*!< PLLSAI2N: specifies the multiplication factor for PLLSAI2 VCO output clock.
  78. This parameter must be a number between 8 and 86 or 127 depending on devices. */
  79. uint32_t PLLSAI2P; /*!< PLLSAI2P: specifies the division factor for SAI clock.
  80. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  81. #if defined(RCC_PLLSAI2Q_DIV_SUPPORT)
  82. uint32_t PLLSAI2Q; /*!< PLLSAI2Q: specifies the division factor for DSI clock.
  83. This parameter must be a value of @ref RCC_PLLQ_Clock_Divider */
  84. #endif
  85. uint32_t PLLSAI2R; /*!< PLLSAI2R: specifies the division factor for ADC clock.
  86. This parameter must be a value of @ref RCC_PLLR_Clock_Divider */
  87. uint32_t PLLSAI2ClockOut; /*!< PLLSAIClockOut: specifies PLLSAI2 output clock to be enabled.
  88. This parameter must be a value of @ref RCC_PLLSAI2_Clock_Output */
  89. }RCC_PLLSAI2InitTypeDef;
  90. #endif /* RCC_PLLSAI2_SUPPORT */
  91. /**
  92. * @brief RCC extended clocks structure definition
  93. */
  94. typedef struct
  95. {
  96. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  97. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  98. #if defined(RCC_PLLSAI1_SUPPORT)
  99. RCC_PLLSAI1InitTypeDef PLLSAI1; /*!< PLLSAI1 structure parameters.
  100. This parameter will be used only when PLLSAI1 is selected as Clock Source for SAI1, USB/RNG/SDMMC1 or ADC */
  101. #endif /* RCC_PLLSAI1_SUPPORT */
  102. #if defined(RCC_PLLSAI2_SUPPORT)
  103. RCC_PLLSAI2InitTypeDef PLLSAI2; /*!< PLLSAI2 structure parameters.
  104. This parameter will be used only when PLLSAI2 is selected as Clock Source for SAI2 or ADC */
  105. #endif /* RCC_PLLSAI2_SUPPORT */
  106. uint32_t Usart1ClockSelection; /*!< Specifies USART1 clock source.
  107. This parameter can be a value of @ref RCCEx_USART1_Clock_Source */
  108. uint32_t Usart2ClockSelection; /*!< Specifies USART2 clock source.
  109. This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
  110. #if defined(USART3)
  111. uint32_t Usart3ClockSelection; /*!< Specifies USART3 clock source.
  112. This parameter can be a value of @ref RCCEx_USART3_Clock_Source */
  113. #endif /* USART3 */
  114. #if defined(UART4)
  115. uint32_t Uart4ClockSelection; /*!< Specifies UART4 clock source.
  116. This parameter can be a value of @ref RCCEx_UART4_Clock_Source */
  117. #endif /* UART4 */
  118. #if defined(UART5)
  119. uint32_t Uart5ClockSelection; /*!< Specifies UART5 clock source.
  120. This parameter can be a value of @ref RCCEx_UART5_Clock_Source */
  121. #endif /* UART5 */
  122. uint32_t Lpuart1ClockSelection; /*!< Specifies LPUART1 clock source.
  123. This parameter can be a value of @ref RCCEx_LPUART1_Clock_Source */
  124. uint32_t I2c1ClockSelection; /*!< Specifies I2C1 clock source.
  125. This parameter can be a value of @ref RCCEx_I2C1_Clock_Source */
  126. #if defined(I2C2)
  127. uint32_t I2c2ClockSelection; /*!< Specifies I2C2 clock source.
  128. This parameter can be a value of @ref RCCEx_I2C2_Clock_Source */
  129. #endif /* I2C2 */
  130. uint32_t I2c3ClockSelection; /*!< Specifies I2C3 clock source.
  131. This parameter can be a value of @ref RCCEx_I2C3_Clock_Source */
  132. #if defined(I2C4)
  133. uint32_t I2c4ClockSelection; /*!< Specifies I2C4 clock source.
  134. This parameter can be a value of @ref RCCEx_I2C4_Clock_Source */
  135. #endif /* I2C4 */
  136. uint32_t Lptim1ClockSelection; /*!< Specifies LPTIM1 clock source.
  137. This parameter can be a value of @ref RCCEx_LPTIM1_Clock_Source */
  138. uint32_t Lptim2ClockSelection; /*!< Specifies LPTIM2 clock source.
  139. This parameter can be a value of @ref RCCEx_LPTIM2_Clock_Source */
  140. #if defined(SAI1)
  141. uint32_t Sai1ClockSelection; /*!< Specifies SAI1 clock source.
  142. This parameter can be a value of @ref RCCEx_SAI1_Clock_Source */
  143. #endif /* SAI1 */
  144. #if defined(SAI2)
  145. uint32_t Sai2ClockSelection; /*!< Specifies SAI2 clock source.
  146. This parameter can be a value of @ref RCCEx_SAI2_Clock_Source */
  147. #endif /* SAI2 */
  148. #if defined(USB_OTG_FS) || defined(USB)
  149. uint32_t UsbClockSelection; /*!< Specifies USB clock source (warning: same source for SDMMC1 and RNG).
  150. This parameter can be a value of @ref RCCEx_USB_Clock_Source */
  151. #endif /* USB_OTG_FS || USB */
  152. #if defined(SDMMC1)
  153. uint32_t Sdmmc1ClockSelection; /*!< Specifies SDMMC1 clock source (warning: same source for USB and RNG).
  154. This parameter can be a value of @ref RCCEx_SDMMC1_Clock_Source */
  155. #endif /* SDMMC1 */
  156. uint32_t RngClockSelection; /*!< Specifies RNG clock source (warning: same source for USB and SDMMC1).
  157. This parameter can be a value of @ref RCCEx_RNG_Clock_Source */
  158. #if !defined(STM32L412xx) && !defined(STM32L422xx)
  159. uint32_t AdcClockSelection; /*!< Specifies ADC interface clock source.
  160. This parameter can be a value of @ref RCCEx_ADC_Clock_Source */
  161. #endif /* !STM32L412xx && !STM32L422xx */
  162. #if defined(SWPMI1)
  163. uint32_t Swpmi1ClockSelection; /*!< Specifies SWPMI1 clock source.
  164. This parameter can be a value of @ref RCCEx_SWPMI1_Clock_Source */
  165. #endif /* SWPMI1 */
  166. #if defined(DFSDM1_Filter0)
  167. uint32_t Dfsdm1ClockSelection; /*!< Specifies DFSDM1 clock source.
  168. This parameter can be a value of @ref RCCEx_DFSDM1_Clock_Source */
  169. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  170. uint32_t Dfsdm1AudioClockSelection; /*!< Specifies DFSDM1 audio clock source.
  171. This parameter can be a value of @ref RCCEx_DFSDM1_Audio_Clock_Source */
  172. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  173. #endif /* DFSDM1_Filter0 */
  174. #if defined(LTDC)
  175. uint32_t LtdcClockSelection; /*!< Specifies LTDC clock source.
  176. This parameter can be a value of @ref RCCEx_LTDC_Clock_Source */
  177. #endif /* LTDC */
  178. #if defined(DSI)
  179. uint32_t DsiClockSelection; /*!< Specifies DSI clock source.
  180. This parameter can be a value of @ref RCCEx_DSI_Clock_Source */
  181. #endif /* DSI */
  182. #if defined(OCTOSPI1) || defined(OCTOSPI2)
  183. uint32_t OspiClockSelection; /*!< Specifies OctoSPI clock source.
  184. This parameter can be a value of @ref RCCEx_OSPI_Clock_Source */
  185. #endif
  186. uint32_t RTCClockSelection; /*!< Specifies RTC clock source.
  187. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  188. }RCC_PeriphCLKInitTypeDef;
  189. #if defined(CRS)
  190. /**
  191. * @brief RCC_CRS Init structure definition
  192. */
  193. typedef struct
  194. {
  195. uint32_t Prescaler; /*!< Specifies the division factor of the SYNC signal.
  196. This parameter can be a value of @ref RCCEx_CRS_SynchroDivider */
  197. uint32_t Source; /*!< Specifies the SYNC signal source.
  198. This parameter can be a value of @ref RCCEx_CRS_SynchroSource */
  199. uint32_t Polarity; /*!< Specifies the input polarity for the SYNC signal source.
  200. This parameter can be a value of @ref RCCEx_CRS_SynchroPolarity */
  201. uint32_t ReloadValue; /*!< Specifies the value to be loaded in the frequency error counter with each SYNC event.
  202. It can be calculated in using macro __HAL_RCC_CRS_RELOADVALUE_CALCULATE(__FTARGET__, __FSYNC__)
  203. This parameter must be a number between 0 and 0xFFFF or a value of @ref RCCEx_CRS_ReloadValueDefault .*/
  204. uint32_t ErrorLimitValue; /*!< Specifies the value to be used to evaluate the captured frequency error value.
  205. This parameter must be a number between 0 and 0xFF or a value of @ref RCCEx_CRS_ErrorLimitDefault */
  206. uint32_t HSI48CalibrationValue; /*!< Specifies a user-programmable trimming value to the HSI48 oscillator.
  207. This parameter must be a number between 0 and 0x7F for STM32L412xx/L422xx, between 0 and 0x3F otherwise,
  208. or a value of @ref RCCEx_CRS_HSI48CalibrationDefault */
  209. }RCC_CRSInitTypeDef;
  210. /**
  211. * @brief RCC_CRS Synchronization structure definition
  212. */
  213. typedef struct
  214. {
  215. uint32_t ReloadValue; /*!< Specifies the value loaded in the Counter reload value.
  216. This parameter must be a number between 0 and 0xFFFF */
  217. uint32_t HSI48CalibrationValue; /*!< Specifies value loaded in HSI48 oscillator smooth trimming.
  218. This parameter must be a number between 0 and 0x7F for STM32L412xx/L422xx, between 0 and 0x3F otherwise */
  219. uint32_t FreqErrorCapture; /*!< Specifies the value loaded in the .FECAP, the frequency error counter
  220. value latched in the time of the last SYNC event.
  221. This parameter must be a number between 0 and 0xFFFF */
  222. uint32_t FreqErrorDirection; /*!< Specifies the value loaded in the .FEDIR, the counting direction of the
  223. frequency error counter latched in the time of the last SYNC event.
  224. It shows whether the actual frequency is below or above the target.
  225. This parameter must be a value of @ref RCCEx_CRS_FreqErrorDirection*/
  226. }RCC_CRSSynchroInfoTypeDef;
  227. #endif /* CRS */
  228. /**
  229. * @}
  230. */
  231. /* Exported constants --------------------------------------------------------*/
  232. /** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
  233. * @{
  234. */
  235. /** @defgroup RCCEx_LSCO_Clock_Source Low Speed Clock Source
  236. * @{
  237. */
  238. #define RCC_LSCOSOURCE_LSI 0x00000000U /*!< LSI selection for low speed clock output */
  239. #define RCC_LSCOSOURCE_LSE RCC_BDCR_LSCOSEL /*!< LSE selection for low speed clock output */
  240. /**
  241. * @}
  242. */
  243. /** @defgroup RCCEx_Periph_Clock_Selection Periph Clock Selection
  244. * @{
  245. */
  246. #define RCC_PERIPHCLK_USART1 0x00000001U
  247. #define RCC_PERIPHCLK_USART2 0x00000002U
  248. #if defined(USART3)
  249. #define RCC_PERIPHCLK_USART3 0x00000004U
  250. #endif
  251. #if defined(UART4)
  252. #define RCC_PERIPHCLK_UART4 0x00000008U
  253. #endif
  254. #if defined(UART5)
  255. #define RCC_PERIPHCLK_UART5 0x00000010U
  256. #endif
  257. #define RCC_PERIPHCLK_LPUART1 0x00000020U
  258. #define RCC_PERIPHCLK_I2C1 0x00000040U
  259. #if defined(I2C2)
  260. #define RCC_PERIPHCLK_I2C2 0x00000080U
  261. #endif
  262. #define RCC_PERIPHCLK_I2C3 0x00000100U
  263. #define RCC_PERIPHCLK_LPTIM1 0x00000200U
  264. #define RCC_PERIPHCLK_LPTIM2 0x00000400U
  265. #if defined(SAI1)
  266. #define RCC_PERIPHCLK_SAI1 0x00000800U
  267. #endif
  268. #if defined(SAI2)
  269. #define RCC_PERIPHCLK_SAI2 0x00001000U
  270. #endif
  271. #if defined(USB_OTG_FS) || defined(USB)
  272. #define RCC_PERIPHCLK_USB 0x00002000U
  273. #endif
  274. #define RCC_PERIPHCLK_ADC 0x00004000U
  275. #if defined(SWPMI1)
  276. #define RCC_PERIPHCLK_SWPMI1 0x00008000U
  277. #endif
  278. #if defined(DFSDM1_Filter0)
  279. #define RCC_PERIPHCLK_DFSDM1 0x00010000U
  280. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  281. #define RCC_PERIPHCLK_DFSDM1AUDIO 0x00200000U
  282. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  283. #endif
  284. #define RCC_PERIPHCLK_RTC 0x00020000U
  285. #define RCC_PERIPHCLK_RNG 0x00040000U
  286. #if defined(SDMMC1)
  287. #define RCC_PERIPHCLK_SDMMC1 0x00080000U
  288. #endif
  289. #if defined(I2C4)
  290. #define RCC_PERIPHCLK_I2C4 0x00100000U
  291. #endif
  292. #if defined(LTDC)
  293. #define RCC_PERIPHCLK_LTDC 0x00400000U
  294. #endif
  295. #if defined(DSI)
  296. #define RCC_PERIPHCLK_DSI 0x00800000U
  297. #endif
  298. #if defined(OCTOSPI1) || defined(OCTOSPI2)
  299. #define RCC_PERIPHCLK_OSPI 0x01000000U
  300. #endif
  301. /**
  302. * @}
  303. */
  304. /** @defgroup RCCEx_USART1_Clock_Source USART1 Clock Source
  305. * @{
  306. */
  307. #define RCC_USART1CLKSOURCE_PCLK2 0x00000000U
  308. #define RCC_USART1CLKSOURCE_SYSCLK RCC_CCIPR_USART1SEL_0
  309. #define RCC_USART1CLKSOURCE_HSI RCC_CCIPR_USART1SEL_1
  310. #define RCC_USART1CLKSOURCE_LSE (RCC_CCIPR_USART1SEL_0 | RCC_CCIPR_USART1SEL_1)
  311. /**
  312. * @}
  313. */
  314. /** @defgroup RCCEx_USART2_Clock_Source USART2 Clock Source
  315. * @{
  316. */
  317. #define RCC_USART2CLKSOURCE_PCLK1 0x00000000U
  318. #define RCC_USART2CLKSOURCE_SYSCLK RCC_CCIPR_USART2SEL_0
  319. #define RCC_USART2CLKSOURCE_HSI RCC_CCIPR_USART2SEL_1
  320. #define RCC_USART2CLKSOURCE_LSE (RCC_CCIPR_USART2SEL_0 | RCC_CCIPR_USART2SEL_1)
  321. /**
  322. * @}
  323. */
  324. #if defined(USART3)
  325. /** @defgroup RCCEx_USART3_Clock_Source USART3 Clock Source
  326. * @{
  327. */
  328. #define RCC_USART3CLKSOURCE_PCLK1 0x00000000U
  329. #define RCC_USART3CLKSOURCE_SYSCLK RCC_CCIPR_USART3SEL_0
  330. #define RCC_USART3CLKSOURCE_HSI RCC_CCIPR_USART3SEL_1
  331. #define RCC_USART3CLKSOURCE_LSE (RCC_CCIPR_USART3SEL_0 | RCC_CCIPR_USART3SEL_1)
  332. /**
  333. * @}
  334. */
  335. #endif /* USART3 */
  336. #if defined(UART4)
  337. /** @defgroup RCCEx_UART4_Clock_Source UART4 Clock Source
  338. * @{
  339. */
  340. #define RCC_UART4CLKSOURCE_PCLK1 0x00000000U
  341. #define RCC_UART4CLKSOURCE_SYSCLK RCC_CCIPR_UART4SEL_0
  342. #define RCC_UART4CLKSOURCE_HSI RCC_CCIPR_UART4SEL_1
  343. #define RCC_UART4CLKSOURCE_LSE (RCC_CCIPR_UART4SEL_0 | RCC_CCIPR_UART4SEL_1)
  344. /**
  345. * @}
  346. */
  347. #endif /* UART4 */
  348. #if defined(UART5)
  349. /** @defgroup RCCEx_UART5_Clock_Source UART5 Clock Source
  350. * @{
  351. */
  352. #define RCC_UART5CLKSOURCE_PCLK1 0x00000000U
  353. #define RCC_UART5CLKSOURCE_SYSCLK RCC_CCIPR_UART5SEL_0
  354. #define RCC_UART5CLKSOURCE_HSI RCC_CCIPR_UART5SEL_1
  355. #define RCC_UART5CLKSOURCE_LSE (RCC_CCIPR_UART5SEL_0 | RCC_CCIPR_UART5SEL_1)
  356. /**
  357. * @}
  358. */
  359. #endif /* UART5 */
  360. /** @defgroup RCCEx_LPUART1_Clock_Source LPUART1 Clock Source
  361. * @{
  362. */
  363. #define RCC_LPUART1CLKSOURCE_PCLK1 0x00000000U
  364. #define RCC_LPUART1CLKSOURCE_SYSCLK RCC_CCIPR_LPUART1SEL_0
  365. #define RCC_LPUART1CLKSOURCE_HSI RCC_CCIPR_LPUART1SEL_1
  366. #define RCC_LPUART1CLKSOURCE_LSE (RCC_CCIPR_LPUART1SEL_0 | RCC_CCIPR_LPUART1SEL_1)
  367. /**
  368. * @}
  369. */
  370. /** @defgroup RCCEx_I2C1_Clock_Source I2C1 Clock Source
  371. * @{
  372. */
  373. #define RCC_I2C1CLKSOURCE_PCLK1 0x00000000U
  374. #define RCC_I2C1CLKSOURCE_SYSCLK RCC_CCIPR_I2C1SEL_0
  375. #define RCC_I2C1CLKSOURCE_HSI RCC_CCIPR_I2C1SEL_1
  376. /**
  377. * @}
  378. */
  379. #if defined(I2C2)
  380. /** @defgroup RCCEx_I2C2_Clock_Source I2C2 Clock Source
  381. * @{
  382. */
  383. #define RCC_I2C2CLKSOURCE_PCLK1 0x00000000U
  384. #define RCC_I2C2CLKSOURCE_SYSCLK RCC_CCIPR_I2C2SEL_0
  385. #define RCC_I2C2CLKSOURCE_HSI RCC_CCIPR_I2C2SEL_1
  386. /**
  387. * @}
  388. */
  389. #endif /* I2C2 */
  390. /** @defgroup RCCEx_I2C3_Clock_Source I2C3 Clock Source
  391. * @{
  392. */
  393. #define RCC_I2C3CLKSOURCE_PCLK1 0x00000000U
  394. #define RCC_I2C3CLKSOURCE_SYSCLK RCC_CCIPR_I2C3SEL_0
  395. #define RCC_I2C3CLKSOURCE_HSI RCC_CCIPR_I2C3SEL_1
  396. /**
  397. * @}
  398. */
  399. #if defined(I2C4)
  400. /** @defgroup RCCEx_I2C4_Clock_Source I2C4 Clock Source
  401. * @{
  402. */
  403. #define RCC_I2C4CLKSOURCE_PCLK1 0x00000000U
  404. #define RCC_I2C4CLKSOURCE_SYSCLK RCC_CCIPR2_I2C4SEL_0
  405. #define RCC_I2C4CLKSOURCE_HSI RCC_CCIPR2_I2C4SEL_1
  406. /**
  407. * @}
  408. */
  409. #endif /* I2C4 */
  410. #if defined(SAI1)
  411. /** @defgroup RCCEx_SAI1_Clock_Source SAI1 Clock Source
  412. * @{
  413. */
  414. #define RCC_SAI1CLKSOURCE_PLLSAI1 0x00000000U
  415. #if defined(RCC_PLLSAI2_SUPPORT)
  416. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  417. #define RCC_SAI1CLKSOURCE_PLLSAI2 RCC_CCIPR2_SAI1SEL_0
  418. #else
  419. #define RCC_SAI1CLKSOURCE_PLLSAI2 RCC_CCIPR_SAI1SEL_0
  420. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  421. #endif /* RCC_PLLSAI2_SUPPORT */
  422. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  423. #define RCC_SAI1CLKSOURCE_PLL RCC_CCIPR2_SAI1SEL_1
  424. #define RCC_SAI1CLKSOURCE_PIN (RCC_CCIPR2_SAI1SEL_1 | RCC_CCIPR2_SAI1SEL_0)
  425. #define RCC_SAI1CLKSOURCE_HSI RCC_CCIPR2_SAI1SEL_2
  426. #else
  427. #define RCC_SAI1CLKSOURCE_PLL RCC_CCIPR_SAI1SEL_1
  428. #define RCC_SAI1CLKSOURCE_PIN RCC_CCIPR_SAI1SEL
  429. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  430. /**
  431. * @}
  432. */
  433. #endif /* SAI1 */
  434. #if defined(SAI2)
  435. /** @defgroup RCCEx_SAI2_Clock_Source SAI2 Clock Source
  436. * @{
  437. */
  438. #define RCC_SAI2CLKSOURCE_PLLSAI1 0x00000000U
  439. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  440. #define RCC_SAI2CLKSOURCE_PLLSAI2 RCC_CCIPR2_SAI2SEL_0
  441. #define RCC_SAI2CLKSOURCE_PLL RCC_CCIPR2_SAI2SEL_1
  442. #define RCC_SAI2CLKSOURCE_PIN (RCC_CCIPR2_SAI2SEL_1 | RCC_CCIPR2_SAI2SEL_0)
  443. #define RCC_SAI2CLKSOURCE_HSI RCC_CCIPR2_SAI2SEL_2
  444. #else
  445. #define RCC_SAI2CLKSOURCE_PLLSAI2 RCC_CCIPR_SAI2SEL_0
  446. #define RCC_SAI2CLKSOURCE_PLL RCC_CCIPR_SAI2SEL_1
  447. #define RCC_SAI2CLKSOURCE_PIN RCC_CCIPR_SAI2SEL
  448. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  449. /**
  450. * @}
  451. */
  452. #endif /* SAI2 */
  453. /** @defgroup RCCEx_LPTIM1_Clock_Source LPTIM1 Clock Source
  454. * @{
  455. */
  456. #define RCC_LPTIM1CLKSOURCE_PCLK1 0x00000000U
  457. #define RCC_LPTIM1CLKSOURCE_LSI RCC_CCIPR_LPTIM1SEL_0
  458. #define RCC_LPTIM1CLKSOURCE_HSI RCC_CCIPR_LPTIM1SEL_1
  459. #define RCC_LPTIM1CLKSOURCE_LSE RCC_CCIPR_LPTIM1SEL
  460. /**
  461. * @}
  462. */
  463. /** @defgroup RCCEx_LPTIM2_Clock_Source LPTIM2 Clock Source
  464. * @{
  465. */
  466. #define RCC_LPTIM2CLKSOURCE_PCLK1 0x00000000U
  467. #define RCC_LPTIM2CLKSOURCE_LSI RCC_CCIPR_LPTIM2SEL_0
  468. #define RCC_LPTIM2CLKSOURCE_HSI RCC_CCIPR_LPTIM2SEL_1
  469. #define RCC_LPTIM2CLKSOURCE_LSE RCC_CCIPR_LPTIM2SEL
  470. /**
  471. * @}
  472. */
  473. #if defined(SDMMC1)
  474. /** @defgroup RCCEx_SDMMC1_Clock_Source SDMMC1 Clock Source
  475. * @{
  476. */
  477. #if defined(RCC_HSI48_SUPPORT)
  478. #define RCC_SDMMC1CLKSOURCE_HSI48 0x00000000U /*!< HSI48 clock selected as SDMMC1 clock */
  479. #else
  480. #define RCC_SDMMC1CLKSOURCE_NONE 0x00000000U /*!< No clock selected as SDMMC1 clock */
  481. #endif /* RCC_HSI48_SUPPORT */
  482. #define RCC_SDMMC1CLKSOURCE_PLLSAI1 RCC_CCIPR_CLK48SEL_0 /*!< PLLSAI1 "Q" clock selected as SDMMC1 clock */
  483. #define RCC_SDMMC1CLKSOURCE_PLL RCC_CCIPR_CLK48SEL_1 /*!< PLL "Q" clock selected as SDMMC1 clock */
  484. #define RCC_SDMMC1CLKSOURCE_MSI RCC_CCIPR_CLK48SEL /*!< MSI clock selected as SDMMC1 clock */
  485. #if defined(RCC_CCIPR2_SDMMCSEL)
  486. #define RCC_SDMMC1CLKSOURCE_PLLP RCC_CCIPR2_SDMMCSEL /*!< PLL "P" clock selected as SDMMC1 kernel clock */
  487. #endif /* RCC_CCIPR2_SDMMCSEL */
  488. /**
  489. * @}
  490. */
  491. #endif /* SDMMC1 */
  492. /** @defgroup RCCEx_RNG_Clock_Source RNG Clock Source
  493. * @{
  494. */
  495. #if defined(RCC_HSI48_SUPPORT)
  496. #define RCC_RNGCLKSOURCE_HSI48 0x00000000U
  497. #else
  498. #define RCC_RNGCLKSOURCE_NONE 0x00000000U
  499. #endif /* RCC_HSI48_SUPPORT */
  500. #if defined(RCC_PLLSAI1_SUPPORT)
  501. #define RCC_RNGCLKSOURCE_PLLSAI1 RCC_CCIPR_CLK48SEL_0
  502. #endif /* RCC_PLLSAI1_SUPPORT */
  503. #define RCC_RNGCLKSOURCE_PLL RCC_CCIPR_CLK48SEL_1
  504. #define RCC_RNGCLKSOURCE_MSI RCC_CCIPR_CLK48SEL
  505. /**
  506. * @}
  507. */
  508. #if defined(USB_OTG_FS) || defined(USB)
  509. /** @defgroup RCCEx_USB_Clock_Source USB Clock Source
  510. * @{
  511. */
  512. #if defined(RCC_HSI48_SUPPORT)
  513. #define RCC_USBCLKSOURCE_HSI48 0x00000000U
  514. #else
  515. #define RCC_USBCLKSOURCE_NONE 0x00000000U
  516. #endif /* RCC_HSI48_SUPPORT */
  517. #if defined(RCC_PLLSAI1_SUPPORT)
  518. #define RCC_USBCLKSOURCE_PLLSAI1 RCC_CCIPR_CLK48SEL_0
  519. #endif /* RCC_PLLSAI1_SUPPORT */
  520. #define RCC_USBCLKSOURCE_PLL RCC_CCIPR_CLK48SEL_1
  521. #define RCC_USBCLKSOURCE_MSI RCC_CCIPR_CLK48SEL
  522. /**
  523. * @}
  524. */
  525. #endif /* USB_OTG_FS || USB */
  526. /** @defgroup RCCEx_ADC_Clock_Source ADC Clock Source
  527. * @{
  528. */
  529. #define RCC_ADCCLKSOURCE_NONE 0x00000000U
  530. #if defined(RCC_PLLSAI1_SUPPORT)
  531. #define RCC_ADCCLKSOURCE_PLLSAI1 RCC_CCIPR_ADCSEL_0
  532. #endif /* RCC_PLLSAI1_SUPPORT */
  533. #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)
  534. #define RCC_ADCCLKSOURCE_PLLSAI2 RCC_CCIPR_ADCSEL_1
  535. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || STM32L496xx || STM32L4A6xx */
  536. #if defined(RCC_CCIPR_ADCSEL)
  537. #define RCC_ADCCLKSOURCE_SYSCLK RCC_CCIPR_ADCSEL
  538. #else
  539. #define RCC_ADCCLKSOURCE_SYSCLK 0x30000000U
  540. #endif /* RCC_CCIPR_ADCSEL */
  541. /**
  542. * @}
  543. */
  544. #if defined(SWPMI1)
  545. /** @defgroup RCCEx_SWPMI1_Clock_Source SWPMI1 Clock Source
  546. * @{
  547. */
  548. #define RCC_SWPMI1CLKSOURCE_PCLK1 0x00000000U
  549. #define RCC_SWPMI1CLKSOURCE_HSI RCC_CCIPR_SWPMI1SEL
  550. /**
  551. * @}
  552. */
  553. #endif /* SWPMI1 */
  554. #if defined(DFSDM1_Filter0)
  555. /** @defgroup RCCEx_DFSDM1_Clock_Source DFSDM1 Clock Source
  556. * @{
  557. */
  558. #define RCC_DFSDM1CLKSOURCE_PCLK2 0x00000000U
  559. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  560. #define RCC_DFSDM1CLKSOURCE_SYSCLK RCC_CCIPR2_DFSDM1SEL
  561. #else
  562. #define RCC_DFSDM1CLKSOURCE_SYSCLK RCC_CCIPR_DFSDM1SEL
  563. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  564. /**
  565. * @}
  566. */
  567. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  568. /** @defgroup RCCEx_DFSDM1_Audio_Clock_Source DFSDM1 Audio Clock Source
  569. * @{
  570. */
  571. #define RCC_DFSDM1AUDIOCLKSOURCE_SAI1 0x00000000U
  572. #define RCC_DFSDM1AUDIOCLKSOURCE_HSI RCC_CCIPR2_ADFSDM1SEL_0
  573. #define RCC_DFSDM1AUDIOCLKSOURCE_MSI RCC_CCIPR2_ADFSDM1SEL_1
  574. /**
  575. * @}
  576. */
  577. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  578. #endif /* DFSDM1_Filter0 */
  579. #if defined(LTDC)
  580. /** @defgroup RCCEx_LTDC_Clock_Source LTDC Clock Source
  581. * @{
  582. */
  583. #define RCC_LTDCCLKSOURCE_PLLSAI2_DIV2 0x00000000U
  584. #define RCC_LTDCCLKSOURCE_PLLSAI2_DIV4 RCC_CCIPR2_PLLSAI2DIVR_0
  585. #define RCC_LTDCCLKSOURCE_PLLSAI2_DIV8 RCC_CCIPR2_PLLSAI2DIVR_1
  586. #define RCC_LTDCCLKSOURCE_PLLSAI2_DIV16 RCC_CCIPR2_PLLSAI2DIVR
  587. /**
  588. * @}
  589. */
  590. #endif /* LTDC */
  591. #if defined(DSI)
  592. /** @defgroup RCCEx_DSI_Clock_Source DSI Clock Source
  593. * @{
  594. */
  595. #define RCC_DSICLKSOURCE_DSIPHY 0x00000000U
  596. #define RCC_DSICLKSOURCE_PLLSAI2 RCC_CCIPR2_DSISEL
  597. /**
  598. * @}
  599. */
  600. #endif /* DSI */
  601. #if defined(OCTOSPI1) || defined(OCTOSPI2)
  602. /** @defgroup RCCEx_OSPI_Clock_Source OctoSPI Clock Source
  603. * @{
  604. */
  605. #define RCC_OSPICLKSOURCE_SYSCLK 0x00000000U
  606. #define RCC_OSPICLKSOURCE_MSI RCC_CCIPR2_OSPISEL_0
  607. #define RCC_OSPICLKSOURCE_PLL RCC_CCIPR2_OSPISEL_1
  608. /**
  609. * @}
  610. */
  611. #endif /* OCTOSPI1 || OCTOSPI2 */
  612. /** @defgroup RCCEx_EXTI_LINE_LSECSS RCC LSE CSS external interrupt line
  613. * @{
  614. */
  615. #define RCC_EXTI_LINE_LSECSS EXTI_IMR1_IM19 /*!< External interrupt line 19 connected to the LSE CSS EXTI Line */
  616. /**
  617. * @}
  618. */
  619. #if defined(CRS)
  620. /** @defgroup RCCEx_CRS_Status RCCEx CRS Status
  621. * @{
  622. */
  623. #define RCC_CRS_NONE 0x00000000U
  624. #define RCC_CRS_TIMEOUT 0x00000001U
  625. #define RCC_CRS_SYNCOK 0x00000002U
  626. #define RCC_CRS_SYNCWARN 0x00000004U
  627. #define RCC_CRS_SYNCERR 0x00000008U
  628. #define RCC_CRS_SYNCMISS 0x00000010U
  629. #define RCC_CRS_TRIMOVF 0x00000020U
  630. /**
  631. * @}
  632. */
  633. /** @defgroup RCCEx_CRS_SynchroSource RCCEx CRS SynchroSource
  634. * @{
  635. */
  636. #define RCC_CRS_SYNC_SOURCE_GPIO 0x00000000U /*!< Synchro Signal source GPIO */
  637. #define RCC_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */
  638. #define RCC_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/
  639. /**
  640. * @}
  641. */
  642. /** @defgroup RCCEx_CRS_SynchroDivider RCCEx CRS SynchroDivider
  643. * @{
  644. */
  645. #define RCC_CRS_SYNC_DIV1 0x00000000U /*!< Synchro Signal not divided (default) */
  646. #define RCC_CRS_SYNC_DIV2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */
  647. #define RCC_CRS_SYNC_DIV4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */
  648. #define RCC_CRS_SYNC_DIV8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
  649. #define RCC_CRS_SYNC_DIV16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */
  650. #define RCC_CRS_SYNC_DIV32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
  651. #define RCC_CRS_SYNC_DIV64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
  652. #define RCC_CRS_SYNC_DIV128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */
  653. /**
  654. * @}
  655. */
  656. /** @defgroup RCCEx_CRS_SynchroPolarity RCCEx CRS SynchroPolarity
  657. * @{
  658. */
  659. #define RCC_CRS_SYNC_POLARITY_RISING 0x00000000U /*!< Synchro Active on rising edge (default) */
  660. #define RCC_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */
  661. /**
  662. * @}
  663. */
  664. /** @defgroup RCCEx_CRS_ReloadValueDefault RCCEx CRS ReloadValueDefault
  665. * @{
  666. */
  667. #define RCC_CRS_RELOADVALUE_DEFAULT 0x0000BB7FU /*!< The reset value of the RELOAD field corresponds
  668. to a target frequency of 48 MHz and a synchronization signal frequency of 1 kHz (SOF signal from USB). */
  669. /**
  670. * @}
  671. */
  672. /** @defgroup RCCEx_CRS_ErrorLimitDefault RCCEx CRS ErrorLimitDefault
  673. * @{
  674. */
  675. #define RCC_CRS_ERRORLIMIT_DEFAULT 0x00000022U /*!< Default Frequency error limit */
  676. /**
  677. * @}
  678. */
  679. /** @defgroup RCCEx_CRS_HSI48CalibrationDefault RCCEx CRS HSI48CalibrationDefault
  680. * @{
  681. */
  682. #if defined(STM32L412xx) || defined(STM32L422xx)
  683. #define RCC_CRS_HSI48CALIBRATION_DEFAULT 0x00000040U /*!< The default value is 64, which corresponds to the middle of the trimming interval.
  684. The trimming step is specified in the product datasheet. A higher TRIM value
  685. corresponds to a higher output frequency */
  686. #else
  687. #define RCC_CRS_HSI48CALIBRATION_DEFAULT 0x00000020U /*!< The default value is 32, which corresponds to the middle of the trimming interval.
  688. The trimming step is specified in the product datasheet. A higher TRIM value
  689. corresponds to a higher output frequency */
  690. #endif
  691. /**
  692. * @}
  693. */
  694. /** @defgroup RCCEx_CRS_FreqErrorDirection RCCEx CRS FreqErrorDirection
  695. * @{
  696. */
  697. #define RCC_CRS_FREQERRORDIR_UP 0x00000000U /*!< Upcounting direction, the actual frequency is above the target */
  698. #define RCC_CRS_FREQERRORDIR_DOWN CRS_ISR_FEDIR /*!< Downcounting direction, the actual frequency is below the target */
  699. /**
  700. * @}
  701. */
  702. /** @defgroup RCCEx_CRS_Interrupt_Sources RCCEx CRS Interrupt Sources
  703. * @{
  704. */
  705. #define RCC_CRS_IT_SYNCOK CRS_CR_SYNCOKIE /*!< SYNC event OK */
  706. #define RCC_CRS_IT_SYNCWARN CRS_CR_SYNCWARNIE /*!< SYNC warning */
  707. #define RCC_CRS_IT_ERR CRS_CR_ERRIE /*!< Error */
  708. #define RCC_CRS_IT_ESYNC CRS_CR_ESYNCIE /*!< Expected SYNC */
  709. #define RCC_CRS_IT_SYNCERR CRS_CR_ERRIE /*!< SYNC error */
  710. #define RCC_CRS_IT_SYNCMISS CRS_CR_ERRIE /*!< SYNC missed */
  711. #define RCC_CRS_IT_TRIMOVF CRS_CR_ERRIE /*!< Trimming overflow or underflow */
  712. /**
  713. * @}
  714. */
  715. /** @defgroup RCCEx_CRS_Flags RCCEx CRS Flags
  716. * @{
  717. */
  718. #define RCC_CRS_FLAG_SYNCOK CRS_ISR_SYNCOKF /*!< SYNC event OK flag */
  719. #define RCC_CRS_FLAG_SYNCWARN CRS_ISR_SYNCWARNF /*!< SYNC warning flag */
  720. #define RCC_CRS_FLAG_ERR CRS_ISR_ERRF /*!< Error flag */
  721. #define RCC_CRS_FLAG_ESYNC CRS_ISR_ESYNCF /*!< Expected SYNC flag */
  722. #define RCC_CRS_FLAG_SYNCERR CRS_ISR_SYNCERR /*!< SYNC error */
  723. #define RCC_CRS_FLAG_SYNCMISS CRS_ISR_SYNCMISS /*!< SYNC missed*/
  724. #define RCC_CRS_FLAG_TRIMOVF CRS_ISR_TRIMOVF /*!< Trimming overflow or underflow */
  725. /**
  726. * @}
  727. */
  728. #endif /* CRS */
  729. /**
  730. * @}
  731. */
  732. /* Exported macros -----------------------------------------------------------*/
  733. /** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
  734. * @{
  735. */
  736. #if defined(RCC_PLLSAI1_SUPPORT)
  737. /**
  738. * @brief Macro to configure the PLLSAI1 clock multiplication and division factors.
  739. *
  740. * @note This function must be used only when the PLLSAI1 is disabled.
  741. * @note PLLSAI1 clock source is common with the main PLL (configured through
  742. * __HAL_RCC_PLL_CONFIG() macro)
  743. *
  744. @if STM32L4S9xx
  745. * @param __PLLSAI1M__ specifies the division factor of PLLSAI1 input clock.
  746. * This parameter must be a number between Min_Data = 1 and Max_Data = 16.
  747. *
  748. @endif
  749. * @param __PLLSAI1N__ specifies the multiplication factor for PLLSAI1 VCO output clock.
  750. * This parameter must be a number between 8 and 86 or 127 depending on devices.
  751. * @note You have to set the PLLSAI1N parameter correctly to ensure that the VCO
  752. * output frequency is between 64 and 344 MHz.
  753. * PLLSAI1 clock frequency = f(PLLSAI1) multiplied by PLLSAI1N
  754. *
  755. * @param __PLLSAI1P__ specifies the division factor for SAI clock.
  756. * This parameter must be a number in the range (7 or 17) for STM32L47xxx/L48xxx
  757. * else (2 to 31).
  758. * SAI1 clock frequency = f(PLLSAI1) / PLLSAI1P
  759. *
  760. * @param __PLLSAI1Q__ specifies the division factor for USB/RNG/SDMMC1 clock.
  761. * This parameter must be in the range (2, 4, 6 or 8).
  762. * USB/RNG/SDMMC1 clock frequency = f(PLLSAI1) / PLLSAI1Q
  763. *
  764. * @param __PLLSAI1R__ specifies the division factor for SAR ADC clock.
  765. * This parameter must be in the range (2, 4, 6 or 8).
  766. * ADC clock frequency = f(PLLSAI1) / PLLSAI1R
  767. *
  768. * @retval None
  769. */
  770. #if defined(RCC_PLLSAI1M_DIV_1_16_SUPPORT)
  771. #if defined(RCC_PLLSAI1P_DIV_2_31_SUPPORT)
  772. #define __HAL_RCC_PLLSAI1_CONFIG(__PLLSAI1M__, __PLLSAI1N__, __PLLSAI1P__, __PLLSAI1Q__, __PLLSAI1R__) \
  773. MODIFY_REG(RCC->PLLSAI1CFGR, \
  774. (RCC_PLLSAI1CFGR_PLLSAI1M | RCC_PLLSAI1CFGR_PLLSAI1N | RCC_PLLSAI1CFGR_PLLSAI1P | \
  775. RCC_PLLSAI1CFGR_PLLSAI1Q | RCC_PLLSAI1CFGR_PLLSAI1R | RCC_PLLSAI1CFGR_PLLSAI1PDIV), \
  776. ((((__PLLSAI1M__) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1M_Pos) | \
  777. ((__PLLSAI1N__) << RCC_PLLSAI1CFGR_PLLSAI1N_Pos) | \
  778. ((((__PLLSAI1Q__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1Q_Pos) | \
  779. ((((__PLLSAI1R__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1R_Pos) | \
  780. ((uint32_t)(__PLLSAI1P__) << RCC_PLLSAI1CFGR_PLLSAI1PDIV_Pos)))
  781. #else
  782. #define __HAL_RCC_PLLSAI1_CONFIG(__PLLSAI1M__, __PLLSAI1N__, __PLLSAI1P__, __PLLSAI1Q__, __PLLSAI1R__) \
  783. MODIFY_REG(RCC->PLLSAI1CFGR, \
  784. (RCC_PLLSAI1CFGR_PLLSAI1M | RCC_PLLSAI1CFGR_PLLSAI1N | RCC_PLLSAI1CFGR_PLLSAI1P | \
  785. RCC_PLLSAI1CFGR_PLLSAI1Q | RCC_PLLSAI1CFGR_PLLSAI1R), \
  786. ((((__PLLSAI1M__) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1M_Pos) | \
  787. ((__PLLSAI1N__) << RCC_PLLSAI1CFGR_PLLSAI1N_Pos) | \
  788. ((((__PLLSAI1Q__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1Q_Pos) | \
  789. ((((__PLLSAI1R__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1R_Pos) | \
  790. (((__PLLSAI1P__) >> 4U) << RCC_PLLSAI1CFGR_PLLSAI1P_Pos)))
  791. #endif /* RCC_PLLSAI1P_DIV_2_31_SUPPORT */
  792. #else
  793. #if defined(RCC_PLLSAI1P_DIV_2_31_SUPPORT)
  794. #define __HAL_RCC_PLLSAI1_CONFIG(__PLLSAI1N__, __PLLSAI1P__, __PLLSAI1Q__, __PLLSAI1R__) \
  795. MODIFY_REG(RCC->PLLSAI1CFGR, \
  796. (RCC_PLLSAI1CFGR_PLLSAI1N | RCC_PLLSAI1CFGR_PLLSAI1P | \
  797. RCC_PLLSAI1CFGR_PLLSAI1Q | RCC_PLLSAI1CFGR_PLLSAI1R | RCC_PLLSAI1CFGR_PLLSAI1PDIV), \
  798. (((__PLLSAI1N__) << RCC_PLLSAI1CFGR_PLLSAI1N_Pos) | \
  799. ((((__PLLSAI1Q__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1Q_Pos) | \
  800. ((((__PLLSAI1R__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1R_Pos) | \
  801. ((uint32_t)(__PLLSAI1P__) << RCC_PLLSAI1CFGR_PLLSAI1PDIV_Pos)))
  802. #else
  803. #define __HAL_RCC_PLLSAI1_CONFIG(__PLLSAI1N__, __PLLSAI1P__, __PLLSAI1Q__, __PLLSAI1R__) \
  804. MODIFY_REG(RCC->PLLSAI1CFGR, \
  805. (RCC_PLLSAI1CFGR_PLLSAI1N | RCC_PLLSAI1CFGR_PLLSAI1P | \
  806. RCC_PLLSAI1CFGR_PLLSAI1Q | RCC_PLLSAI1CFGR_PLLSAI1R), \
  807. (((__PLLSAI1N__) << RCC_PLLSAI1CFGR_PLLSAI1N_Pos) | \
  808. ((((__PLLSAI1Q__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1Q_Pos) | \
  809. ((((__PLLSAI1R__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1R_Pos) | \
  810. (((__PLLSAI1P__) >> 4U) << RCC_PLLSAI1CFGR_PLLSAI1P_Pos)))
  811. #endif /* RCC_PLLSAI1P_DIV_2_31_SUPPORT */
  812. #endif /* RCC_PLLSAI1M_DIV_1_16_SUPPORT */
  813. /**
  814. * @brief Macro to configure the PLLSAI1 clock multiplication factor N.
  815. *
  816. * @note This function must be used only when the PLLSAI1 is disabled.
  817. * @note PLLSAI1 clock source is common with the main PLL (configured through
  818. * __HAL_RCC_PLL_CONFIG() macro)
  819. *
  820. * @param __PLLSAI1N__ specifies the multiplication factor for PLLSAI1 VCO output clock.
  821. * This parameter must be a number between 8 and 86 or 127 depending on devices.
  822. * @note You have to set the PLLSAI1N parameter correctly to ensure that the VCO
  823. * output frequency is between 64 and 344 MHz.
  824. * Use to set PLLSAI1 clock frequency = f(PLLSAI1) multiplied by PLLSAI1N
  825. *
  826. * @retval None
  827. */
  828. #define __HAL_RCC_PLLSAI1_MULN_CONFIG(__PLLSAI1N__) \
  829. MODIFY_REG(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1N, (__PLLSAI1N__) << RCC_PLLSAI1CFGR_PLLSAI1N_Pos)
  830. #if defined(RCC_PLLSAI1M_DIV_1_16_SUPPORT)
  831. /** @brief Macro to configure the PLLSAI1 input clock division factor M.
  832. *
  833. * @note This function must be used only when the PLLSAI1 is disabled.
  834. * @note PLLSAI1 clock source is common with the main PLL (configured through
  835. * __HAL_RCC_PLL_CONFIG() macro)
  836. *
  837. * @param __PLLSAI1M__ specifies the division factor for PLLSAI1 clock.
  838. * This parameter must be a number between Min_Data = 1 and Max_Data = 16.
  839. *
  840. * @retval None
  841. */
  842. #define __HAL_RCC_PLLSAI1_DIVM_CONFIG(__PLLSAI1M__) \
  843. MODIFY_REG(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1M, ((__PLLSAI1M__) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1M_Pos)
  844. #endif /* RCC_PLLSAI1M_DIV_1_16_SUPPORT */
  845. /** @brief Macro to configure the PLLSAI1 clock division factor P.
  846. *
  847. * @note This function must be used only when the PLLSAI1 is disabled.
  848. * @note PLLSAI1 clock source is common with the main PLL (configured through
  849. * __HAL_RCC_PLL_CONFIG() macro)
  850. *
  851. * @param __PLLSAI1P__ specifies the division factor for SAI clock.
  852. * This parameter must be a number in the range (7 or 17) for STM32L47xxx/L48xxx
  853. * else (2 to 31).
  854. * Use to set SAI1 clock frequency = f(PLLSAI1) / PLLSAI1P
  855. *
  856. * @retval None
  857. */
  858. #if defined(RCC_PLLSAI1P_DIV_2_31_SUPPORT)
  859. #define __HAL_RCC_PLLSAI1_DIVP_CONFIG(__PLLSAI1P__) \
  860. MODIFY_REG(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1PDIV, (__PLLSAI1P__) << RCC_PLLSAI1CFGR_PLLSAI1PDIV_Pos)
  861. #else
  862. #define __HAL_RCC_PLLSAI1_DIVP_CONFIG(__PLLSAI1P__) \
  863. MODIFY_REG(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1P, ((__PLLSAI1P__) >> 4U) << RCC_PLLSAI1CFGR_PLLSAI1P_Pos)
  864. #endif /* RCC_PLLSAI1P_DIV_2_31_SUPPORT */
  865. /** @brief Macro to configure the PLLSAI1 clock division factor Q.
  866. *
  867. * @note This function must be used only when the PLLSAI1 is disabled.
  868. * @note PLLSAI1 clock source is common with the main PLL (configured through
  869. * __HAL_RCC_PLL_CONFIG() macro)
  870. *
  871. * @param __PLLSAI1Q__ specifies the division factor for USB/RNG/SDMMC1 clock.
  872. * This parameter must be in the range (2, 4, 6 or 8).
  873. * Use to set USB/RNG/SDMMC1 clock frequency = f(PLLSAI1) / PLLSAI1Q
  874. *
  875. * @retval None
  876. */
  877. #define __HAL_RCC_PLLSAI1_DIVQ_CONFIG(__PLLSAI1Q__) \
  878. MODIFY_REG(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1Q, (((__PLLSAI1Q__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1Q_Pos)
  879. /** @brief Macro to configure the PLLSAI1 clock division factor R.
  880. *
  881. * @note This function must be used only when the PLLSAI1 is disabled.
  882. * @note PLLSAI1 clock source is common with the main PLL (configured through
  883. * __HAL_RCC_PLL_CONFIG() macro)
  884. *
  885. * @param __PLLSAI1R__ specifies the division factor for ADC clock.
  886. * This parameter must be in the range (2, 4, 6 or 8)
  887. * Use to set ADC clock frequency = f(PLLSAI1) / PLLSAI1R
  888. *
  889. * @retval None
  890. */
  891. #define __HAL_RCC_PLLSAI1_DIVR_CONFIG(__PLLSAI1R__) \
  892. MODIFY_REG(RCC->PLLSAI1CFGR, RCC_PLLSAI1CFGR_PLLSAI1R, (((__PLLSAI1R__) >> 1U) - 1U) << RCC_PLLSAI1CFGR_PLLSAI1R_Pos)
  893. /**
  894. * @brief Macros to enable or disable the PLLSAI1.
  895. * @note The PLLSAI1 is disabled by hardware when entering STOP and STANDBY modes.
  896. * @retval None
  897. */
  898. #define __HAL_RCC_PLLSAI1_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLSAI1ON)
  899. #define __HAL_RCC_PLLSAI1_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLSAI1ON)
  900. /**
  901. * @brief Macros to enable or disable each clock output (PLLSAI1_SAI1, PLLSAI1_USB2 and PLLSAI1_ADC1).
  902. * @note Enabling and disabling those clocks can be done without the need to stop the PLL.
  903. * This is mainly used to save Power.
  904. * @param __PLLSAI1_CLOCKOUT__ specifies the PLLSAI1 clock to be output.
  905. * This parameter can be one or a combination of the following values:
  906. * @arg @ref RCC_PLLSAI1_SAI1CLK This clock is used to generate an accurate clock to achieve
  907. * high-quality audio performance on SAI interface in case.
  908. * @arg @ref RCC_PLLSAI1_48M2CLK This clock is used to generate the clock for the USB OTG FS (48 MHz),
  909. * the random number generator (<=48 MHz) and the SDIO (<= 48 MHz).
  910. * @arg @ref RCC_PLLSAI1_ADC1CLK Clock used to clock ADC peripheral.
  911. * @retval None
  912. */
  913. #define __HAL_RCC_PLLSAI1CLKOUT_ENABLE(__PLLSAI1_CLOCKOUT__) SET_BIT(RCC->PLLSAI1CFGR, (__PLLSAI1_CLOCKOUT__))
  914. #define __HAL_RCC_PLLSAI1CLKOUT_DISABLE(__PLLSAI1_CLOCKOUT__) CLEAR_BIT(RCC->PLLSAI1CFGR, (__PLLSAI1_CLOCKOUT__))
  915. /**
  916. * @brief Macro to get clock output enable status (PLLSAI1_SAI1, PLLSAI1_USB2 and PLLSAI1_ADC1).
  917. * @param __PLLSAI1_CLOCKOUT__ specifies the PLLSAI1 clock to be output.
  918. * This parameter can be one of the following values:
  919. * @arg @ref RCC_PLLSAI1_SAI1CLK This clock is used to generate an accurate clock to achieve
  920. * high-quality audio performance on SAI interface in case.
  921. * @arg @ref RCC_PLLSAI1_48M2CLK This clock is used to generate the clock for the USB OTG FS (48 MHz),
  922. * the random number generator (<=48 MHz) and the SDIO (<= 48 MHz).
  923. * @arg @ref RCC_PLLSAI1_ADC1CLK Clock used to clock ADC peripheral.
  924. * @retval SET / RESET
  925. */
  926. #define __HAL_RCC_GET_PLLSAI1CLKOUT_CONFIG(__PLLSAI1_CLOCKOUT__) READ_BIT(RCC->PLLSAI1CFGR, (__PLLSAI1_CLOCKOUT__))
  927. #endif /* RCC_PLLSAI1_SUPPORT */
  928. #if defined(RCC_PLLSAI2_SUPPORT)
  929. /**
  930. * @brief Macro to configure the PLLSAI2 clock multiplication and division factors.
  931. *
  932. * @note This function must be used only when the PLLSAI2 is disabled.
  933. * @note PLLSAI2 clock source is common with the main PLL (configured through
  934. * __HAL_RCC_PLL_CONFIG() macro)
  935. *
  936. @if STM32L4S9xx
  937. * @param __PLLSAI2M__ specifies the division factor of PLLSAI2 input clock.
  938. * This parameter must be a number between Min_Data = 1 and Max_Data = 16.
  939. *
  940. @endif
  941. * @param __PLLSAI2N__ specifies the multiplication factor for PLLSAI2 VCO output clock.
  942. * This parameter must be a number between 8 and 86.
  943. * @note You have to set the PLLSAI2N parameter correctly to ensure that the VCO
  944. * output frequency is between 64 and 344 MHz.
  945. *
  946. * @param __PLLSAI2P__ specifies the division factor for SAI clock.
  947. * This parameter must be a number in the range (7 or 17) for STM32L47xxx/L48xxx
  948. * else (2 to 31).
  949. * SAI2 clock frequency = f(PLLSAI2) / PLLSAI2P
  950. *
  951. @if STM32L4S9xx
  952. * @param __PLLSAI2Q__ specifies the division factor for DSI clock.
  953. * This parameter must be in the range (2, 4, 6 or 8).
  954. * DSI clock frequency = f(PLLSAI2) / PLLSAI2Q
  955. *
  956. @endif
  957. * @param __PLLSAI2R__ specifies the division factor for SAR ADC clock.
  958. * This parameter must be in the range (2, 4, 6 or 8).
  959. *
  960. * @retval None
  961. */
  962. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  963. # if defined(RCC_PLLSAI2P_DIV_2_31_SUPPORT) && defined(RCC_PLLSAI2Q_DIV_SUPPORT)
  964. #define __HAL_RCC_PLLSAI2_CONFIG(__PLLSAI2M__, __PLLSAI2N__, __PLLSAI2P__, __PLLSAI2Q__, __PLLSAI2R__) \
  965. MODIFY_REG(RCC->PLLSAI2CFGR, \
  966. (RCC_PLLSAI2CFGR_PLLSAI2M | RCC_PLLSAI2CFGR_PLLSAI2N | RCC_PLLSAI2CFGR_PLLSAI2P | \
  967. RCC_PLLSAI2CFGR_PLLSAI2Q | RCC_PLLSAI2CFGR_PLLSAI2R | RCC_PLLSAI2CFGR_PLLSAI2PDIV), \
  968. ((((__PLLSAI2M__) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2M_Pos) | \
  969. ((__PLLSAI2N__) << RCC_PLLSAI2CFGR_PLLSAI2N_Pos) | \
  970. ((((__PLLSAI2Q__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2Q_Pos) | \
  971. ((((__PLLSAI2R__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2R_Pos) | \
  972. ((uint32_t)(__PLLSAI2P__) << RCC_PLLSAI2CFGR_PLLSAI2PDIV_Pos)))
  973. # elif defined(RCC_PLLSAI2P_DIV_2_31_SUPPORT)
  974. #define __HAL_RCC_PLLSAI2_CONFIG(__PLLSAI2M__, __PLLSAI2N__, __PLLSAI2P__, __PLLSAI2R__) \
  975. MODIFY_REG(RCC->PLLSAI2CFGR, \
  976. (RCC_PLLSAI2CFGR_PLLSAI2M | RCC_PLLSAI2CFGR_PLLSAI2N | RCC_PLLSAI2CFGR_PLLSAI2P | \
  977. RCC_PLLSAI2CFGR_PLLSAI2R | RCC_PLLSAI2CFGR_PLLSAI2PDIV), \
  978. ((((__PLLSAI2M__) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2M_Pos) | \
  979. ((__PLLSAI2N__) << RCC_PLLSAI2CFGR_PLLSAI2N_Pos) | \
  980. ((((__PLLSAI2R__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2R_Pos) | \
  981. ((uint32_t)(__PLLSAI2P__) << RCC_PLLSAI2CFGR_PLLSAI2PDIV_Pos)))
  982. # else
  983. #define __HAL_RCC_PLLSAI2_CONFIG(__PLLSAI2M__, __PLLSAI2N__, __PLLSAI2P__, __PLLSAI2R__) \
  984. MODIFY_REG(RCC->PLLSAI2CFGR, \
  985. (RCC_PLLSAI2CFGR_PLLSAI2M | RCC_PLLSAI2CFGR_PLLSAI2N | RCC_PLLSAI2CFGR_PLLSAI2P | \
  986. RCC_PLLSAI2CFGR_PLLSAI2R), \
  987. ((((__PLLSAI2M__) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2M_Pos) | \
  988. ((__PLLSAI2N__) << RCC_PLLSAI2CFGR_PLLSAI2N_Pos) | \
  989. ((((__PLLSAI2R__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2R_Pos) | \
  990. (((__PLLSAI2P__) >> 4U) << RCC_PLLSAI2CFGR_PLLSAI2P_Pos)))
  991. # endif /* RCC_PLLSAI2P_DIV_2_31_SUPPORT && RCC_PLLSAI2Q_DIV_SUPPORT */
  992. #else
  993. # if defined(RCC_PLLSAI2P_DIV_2_31_SUPPORT) && defined(RCC_PLLSAI2Q_DIV_SUPPORT)
  994. #define __HAL_RCC_PLLSAI2_CONFIG(__PLLSAI2N__, __PLLSAI2P__, __PLLSAI2Q__, __PLLSAI2R__) \
  995. MODIFY_REG(RCC->PLLSAI2CFGR, \
  996. (RCC_PLLSAI2CFGR_PLLSAI2N | RCC_PLLSAI2CFGR_PLLSAI2P | \
  997. RCC_PLLSAI2CFGR_PLLSAI2Q | RCC_PLLSAI2CFGR_PLLSAI2R | RCC_PLLSAI2CFGR_PLLSAI2PDIV), \
  998. (((__PLLSAI2N__) << RCC_PLLSAI2CFGR_PLLSAI2N_Pos) | \
  999. ((((__PLLSAI2Q__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2Q_Pos) | \
  1000. ((((__PLLSAI2R__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2R_Pos) | \
  1001. ((uint32_t)(__PLLSAI2P__) << RCC_PLLSAI2CFGR_PLLSAI2PDIV_Pos)))
  1002. # elif defined(RCC_PLLSAI2P_DIV_2_31_SUPPORT)
  1003. #define __HAL_RCC_PLLSAI2_CONFIG(__PLLSAI2N__, __PLLSAI2P__, __PLLSAI2R__) \
  1004. MODIFY_REG(RCC->PLLSAI2CFGR, \
  1005. (RCC_PLLSAI2CFGR_PLLSAI2N | RCC_PLLSAI2CFGR_PLLSAI2P | \
  1006. RCC_PLLSAI2CFGR_PLLSAI2R | RCC_PLLSAI2CFGR_PLLSAI2PDIV), \
  1007. (((__PLLSAI2N__) << RCC_PLLSAI2CFGR_PLLSAI2N_Pos) | \
  1008. ((((__PLLSAI2R__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2R_Pos) | \
  1009. ((uint32_t)(__PLLSAI2P__) << RCC_PLLSAI2CFGR_PLLSAI2PDIV_Pos)))
  1010. # else
  1011. #define __HAL_RCC_PLLSAI2_CONFIG(__PLLSAI2N__, __PLLSAI2P__, __PLLSAI2R__) \
  1012. MODIFY_REG(RCC->PLLSAI2CFGR, \
  1013. (RCC_PLLSAI2CFGR_PLLSAI2N | RCC_PLLSAI2CFGR_PLLSAI2P | \
  1014. RCC_PLLSAI2CFGR_PLLSAI2R), \
  1015. (((__PLLSAI2N__) << RCC_PLLSAI2CFGR_PLLSAI2N_Pos) | \
  1016. ((((__PLLSAI2R__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2R_Pos) | \
  1017. (((__PLLSAI2P__) >> 4U) << RCC_PLLSAI2CFGR_PLLSAI2P_Pos)))
  1018. # endif /* RCC_PLLSAI2P_DIV_2_31_SUPPORT && RCC_PLLSAI2Q_DIV_SUPPORT */
  1019. #endif /* RCC_PLLSAI2M_DIV_1_16_SUPPORT */
  1020. /**
  1021. * @brief Macro to configure the PLLSAI2 clock multiplication factor N.
  1022. *
  1023. * @note This function must be used only when the PLLSAI2 is disabled.
  1024. * @note PLLSAI2 clock source is common with the main PLL (configured through
  1025. * __HAL_RCC_PLL_CONFIG() macro)
  1026. *
  1027. * @param __PLLSAI2N__ specifies the multiplication factor for PLLSAI2 VCO output clock.
  1028. * This parameter must be a number between 8 and 86.
  1029. * @note You have to set the PLLSAI2N parameter correctly to ensure that the VCO
  1030. * output frequency is between 64 and 344 MHz.
  1031. * PLLSAI1 clock frequency = f(PLLSAI1) multiplied by PLLSAI2N
  1032. *
  1033. * @retval None
  1034. */
  1035. #define __HAL_RCC_PLLSAI2_MULN_CONFIG(__PLLSAI2N__) \
  1036. MODIFY_REG(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2N, (__PLLSAI2N__) << RCC_PLLSAI2CFGR_PLLSAI2N_Pos)
  1037. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  1038. /** @brief Macro to configure the PLLSAI2 input clock division factor M.
  1039. *
  1040. * @note This function must be used only when the PLLSAI2 is disabled.
  1041. * @note PLLSAI2 clock source is common with the main PLL (configured through
  1042. * __HAL_RCC_PLL_CONFIG() macro)
  1043. *
  1044. * @param __PLLSAI2M__ specifies the division factor for PLLSAI2 clock.
  1045. * This parameter must be a number between Min_Data = 1 and Max_Data = 16.
  1046. *
  1047. * @retval None
  1048. */
  1049. #define __HAL_RCC_PLLSAI2_DIVM_CONFIG(__PLLSAI2M__) \
  1050. MODIFY_REG(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2M, ((__PLLSAI2M__) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2M_Pos)
  1051. #endif /* RCC_PLLSAI2M_DIV_1_16_SUPPORT */
  1052. /** @brief Macro to configure the PLLSAI2 clock division factor P.
  1053. *
  1054. * @note This function must be used only when the PLLSAI2 is disabled.
  1055. * @note PLLSAI2 clock source is common with the main PLL (configured through
  1056. * __HAL_RCC_PLL_CONFIG() macro)
  1057. *
  1058. * @param __PLLSAI2P__ specifies the division factor.
  1059. * This parameter must be a number in the range (7 or 17).
  1060. * Use to set SAI2 clock frequency = f(PLLSAI2) / __PLLSAI2P__
  1061. *
  1062. * @retval None
  1063. */
  1064. #define __HAL_RCC_PLLSAI2_DIVP_CONFIG(__PLLSAI2P__) \
  1065. MODIFY_REG(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2P, ((__PLLSAI2P__) >> 4U) << RCC_PLLSAI2CFGR_PLLSAI2P_Pos)
  1066. #if defined(RCC_PLLSAI2Q_DIV_SUPPORT)
  1067. /** @brief Macro to configure the PLLSAI2 clock division factor Q.
  1068. *
  1069. * @note This function must be used only when the PLLSAI2 is disabled.
  1070. * @note PLLSAI2 clock source is common with the main PLL (configured through
  1071. * __HAL_RCC_PLL_CONFIG() macro)
  1072. *
  1073. * @param __PLLSAI2Q__ specifies the division factor for USB/RNG/SDMMC1 clock.
  1074. * This parameter must be in the range (2, 4, 6 or 8).
  1075. * Use to set USB/RNG/SDMMC1 clock frequency = f(PLLSAI2) / PLLSAI2Q
  1076. *
  1077. * @retval None
  1078. */
  1079. #define __HAL_RCC_PLLSAI2_DIVQ_CONFIG(__PLLSAI2Q__) \
  1080. MODIFY_REG(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2Q, (((__PLLSAI2Q__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2Q_Pos)
  1081. #endif /* RCC_PLLSAI2Q_DIV_SUPPORT */
  1082. /** @brief Macro to configure the PLLSAI2 clock division factor R.
  1083. *
  1084. * @note This function must be used only when the PLLSAI2 is disabled.
  1085. * @note PLLSAI2 clock source is common with the main PLL (configured through
  1086. * __HAL_RCC_PLL_CONFIG() macro)
  1087. *
  1088. * @param __PLLSAI2R__ specifies the division factor.
  1089. * This parameter must be in the range (2, 4, 6 or 8).
  1090. * Use to set ADC clock frequency = f(PLLSAI2) / __PLLSAI2R__
  1091. *
  1092. * @retval None
  1093. */
  1094. #define __HAL_RCC_PLLSAI2_DIVR_CONFIG(__PLLSAI2R__) \
  1095. MODIFY_REG(RCC->PLLSAI2CFGR, RCC_PLLSAI2CFGR_PLLSAI2R, (((__PLLSAI2R__) >> 1U) - 1U) << RCC_PLLSAI2CFGR_PLLSAI2R_Pos)
  1096. /**
  1097. * @brief Macros to enable or disable the PLLSAI2.
  1098. * @note The PLLSAI2 is disabled by hardware when entering STOP and STANDBY modes.
  1099. * @retval None
  1100. */
  1101. #define __HAL_RCC_PLLSAI2_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLSAI2ON)
  1102. #define __HAL_RCC_PLLSAI2_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLSAI2ON)
  1103. /**
  1104. * @brief Macros to enable or disable each clock output (PLLSAI2_SAI2, PLLSAI2_ADC2 and RCC_PLLSAI2_DSICLK).
  1105. * @note Enabling and disabling those clocks can be done without the need to stop the PLL.
  1106. * This is mainly used to save Power.
  1107. * @param __PLLSAI2_CLOCKOUT__ specifies the PLLSAI2 clock to be output.
  1108. * This parameter can be one or a combination of the following values:
  1109. @if STM32L486xx
  1110. * @arg @ref RCC_PLLSAI2_SAI2CLK This clock is used to generate an accurate clock to achieve
  1111. * high-quality audio performance on SAI interface in case.
  1112. * @arg @ref RCC_PLLSAI2_ADC2CLK Clock used to clock ADC peripheral.
  1113. @endif
  1114. @if STM32L4A6xx
  1115. * @arg @ref RCC_PLLSAI2_SAI2CLK This clock is used to generate an accurate clock to achieve
  1116. * high-quality audio performance on SAI interface in case.
  1117. * @arg @ref RCC_PLLSAI2_ADC2CLK Clock used to clock ADC peripheral.
  1118. @endif
  1119. @if STM32L4S9xx
  1120. * @arg @ref RCC_PLLSAI2_SAI2CLK This clock is used to generate an accurate clock to achieve
  1121. * high-quality audio performance on SAI interface in case.
  1122. * @arg @ref RCC_PLLSAI2_DSICLK Clock used to clock DSI peripheral.
  1123. @endif
  1124. * @retval None
  1125. */
  1126. #define __HAL_RCC_PLLSAI2CLKOUT_ENABLE(__PLLSAI2_CLOCKOUT__) SET_BIT(RCC->PLLSAI2CFGR, (__PLLSAI2_CLOCKOUT__))
  1127. #define __HAL_RCC_PLLSAI2CLKOUT_DISABLE(__PLLSAI2_CLOCKOUT__) CLEAR_BIT(RCC->PLLSAI2CFGR, (__PLLSAI2_CLOCKOUT__))
  1128. /**
  1129. * @brief Macro to get clock output enable status (PLLSAI2_SAI2, PLLSAI2_ADC2 and RCC_PLLSAI2_DSICLK).
  1130. * @param __PLLSAI2_CLOCKOUT__ specifies the PLLSAI2 clock to be output.
  1131. * This parameter can be one of the following values:
  1132. @if STM32L486xx
  1133. * @arg @ref RCC_PLLSAI2_SAI2CLK This clock is used to generate an accurate clock to achieve
  1134. * high-quality audio performance on SAI interface in case.
  1135. * @arg @ref RCC_PLLSAI2_ADC2CLK Clock used to clock ADC peripheral.
  1136. @endif
  1137. @if STM32L4A6xx
  1138. * @arg @ref RCC_PLLSAI2_SAI2CLK This clock is used to generate an accurate clock to achieve
  1139. * high-quality audio performance on SAI interface in case.
  1140. * @arg @ref RCC_PLLSAI2_ADC2CLK Clock used to clock ADC peripheral.
  1141. @endif
  1142. @if STM32L4S9xx
  1143. * @arg @ref RCC_PLLSAI2_SAI2CLK This clock is used to generate an accurate clock to achieve
  1144. * high-quality audio performance on SAI interface in case.
  1145. * @arg @ref RCC_PLLSAI2_DSICLK Clock used to clock DSI peripheral.
  1146. @endif
  1147. * @retval SET / RESET
  1148. */
  1149. #define __HAL_RCC_GET_PLLSAI2CLKOUT_CONFIG(__PLLSAI2_CLOCKOUT__) READ_BIT(RCC->PLLSAI2CFGR, (__PLLSAI2_CLOCKOUT__))
  1150. #endif /* RCC_PLLSAI2_SUPPORT */
  1151. #if defined(SAI1)
  1152. /**
  1153. * @brief Macro to configure the SAI1 clock source.
  1154. * @param __SAI1_CLKSOURCE__ defines the SAI1 clock source. This clock is derived
  1155. * from the PLLSAI1, system PLL or external clock (through a dedicated pin).
  1156. * This parameter can be one of the following values:
  1157. * @arg @ref RCC_SAI1CLKSOURCE_PLLSAI1 SAI1 clock = PLLSAI1 "P" clock (PLLSAI1CLK)
  1158. @if STM32L486xx
  1159. * @arg @ref RCC_SAI1CLKSOURCE_PLLSAI2 SAI1 clock = PLLSAI2 "P" clock (PLLSAI2CLK) for devices with PLLSAI2
  1160. @endif
  1161. * @arg @ref RCC_SAI1CLKSOURCE_PLL SAI1 clock = PLL "P" clock (PLLSAI3CLK if PLLSAI2 exists, else PLLSAI2CLK)
  1162. * @arg @ref RCC_SAI1CLKSOURCE_PIN SAI1 clock = External Clock (SAI1_EXTCLK)
  1163. @if STM32L4S9xx
  1164. * @arg @ref RCC_SAI1CLKSOURCE_HSI SAI1 clock = HSI16
  1165. @endif
  1166. *
  1167. @if STM32L443xx
  1168. * @note HSI16 is automatically set as SAI1 clock source when PLL are disabled for devices without PLLSAI2.
  1169. @endif
  1170. *
  1171. * @retval None
  1172. */
  1173. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  1174. #define __HAL_RCC_SAI1_CONFIG(__SAI1_CLKSOURCE__)\
  1175. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_SAI1SEL, (__SAI1_CLKSOURCE__))
  1176. #else
  1177. #define __HAL_RCC_SAI1_CONFIG(__SAI1_CLKSOURCE__)\
  1178. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_SAI1SEL, (__SAI1_CLKSOURCE__))
  1179. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  1180. /** @brief Macro to get the SAI1 clock source.
  1181. * @retval The clock source can be one of the following values:
  1182. * @arg @ref RCC_SAI1CLKSOURCE_PLLSAI1 SAI1 clock = PLLSAI1 "P" clock (PLLSAI1CLK)
  1183. @if STM32L486xx
  1184. * @arg @ref RCC_SAI1CLKSOURCE_PLLSAI2 SAI1 clock = PLLSAI2 "P" clock (PLLSAI2CLK) for devices with PLLSAI2
  1185. @endif
  1186. * @arg @ref RCC_SAI1CLKSOURCE_PLL SAI1 clock = PLL "P" clock (PLLSAI3CLK if PLLSAI2 exists, else PLLSAI2CLK)
  1187. * @arg @ref RCC_SAI1CLKSOURCE_PIN SAI1 clock = External Clock (SAI1_EXTCLK)
  1188. *
  1189. * @note Despite returned values RCC_SAI1CLKSOURCE_PLLSAI1 or RCC_SAI1CLKSOURCE_PLL, HSI16 is automatically set as SAI1
  1190. * clock source when PLLs are disabled for devices without PLLSAI2.
  1191. *
  1192. */
  1193. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  1194. #define __HAL_RCC_GET_SAI1_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_SAI1SEL))
  1195. #else
  1196. #define __HAL_RCC_GET_SAI1_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_SAI1SEL))
  1197. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  1198. #endif /* SAI1 */
  1199. #if defined(SAI2)
  1200. /**
  1201. * @brief Macro to configure the SAI2 clock source.
  1202. * @param __SAI2_CLKSOURCE__ defines the SAI2 clock source. This clock is derived
  1203. * from the PLLSAI2, system PLL or external clock (through a dedicated pin).
  1204. * This parameter can be one of the following values:
  1205. * @arg @ref RCC_SAI2CLKSOURCE_PLLSAI1 SAI2 clock = PLLSAI1 "P" clock (PLLSAI1CLK)
  1206. * @arg @ref RCC_SAI2CLKSOURCE_PLLSAI2 SAI2 clock = PLLSAI2 "P" clock (PLLSAI2CLK)
  1207. * @arg @ref RCC_SAI2CLKSOURCE_PLL SAI2 clock = PLL "P" clock (PLLSAI3CLK)
  1208. * @arg @ref RCC_SAI2CLKSOURCE_PIN SAI2 clock = External Clock (SAI2_EXTCLK)
  1209. @if STM32L4S9xx
  1210. * @arg @ref RCC_SAI2CLKSOURCE_HSI SAI2 clock = HSI16
  1211. @endif
  1212. *
  1213. * @retval None
  1214. */
  1215. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  1216. #define __HAL_RCC_SAI2_CONFIG(__SAI2_CLKSOURCE__ )\
  1217. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_SAI2SEL, (__SAI2_CLKSOURCE__))
  1218. #else
  1219. #define __HAL_RCC_SAI2_CONFIG(__SAI2_CLKSOURCE__ )\
  1220. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_SAI2SEL, (__SAI2_CLKSOURCE__))
  1221. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  1222. /** @brief Macro to get the SAI2 clock source.
  1223. * @retval The clock source can be one of the following values:
  1224. * @arg @ref RCC_SAI2CLKSOURCE_PLLSAI1 SAI2 clock = PLLSAI1 "P" clock (PLLSAI1CLK)
  1225. * @arg @ref RCC_SAI2CLKSOURCE_PLLSAI2 SAI2 clock = PLLSAI2 "P" clock (PLLSAI2CLK)
  1226. * @arg @ref RCC_SAI2CLKSOURCE_PLL SAI2 clock = PLL "P" clock (PLLSAI3CLK)
  1227. * @arg @ref RCC_SAI2CLKSOURCE_PIN SAI2 clock = External Clock (SAI2_EXTCLK)
  1228. */
  1229. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  1230. #define __HAL_RCC_GET_SAI2_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_SAI2SEL))
  1231. #else
  1232. #define __HAL_RCC_GET_SAI2_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_SAI2SEL))
  1233. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  1234. #endif /* SAI2 */
  1235. /** @brief Macro to configure the I2C1 clock (I2C1CLK).
  1236. *
  1237. * @param __I2C1_CLKSOURCE__ specifies the I2C1 clock source.
  1238. * This parameter can be one of the following values:
  1239. * @arg @ref RCC_I2C1CLKSOURCE_PCLK1 PCLK1 selected as I2C1 clock
  1240. * @arg @ref RCC_I2C1CLKSOURCE_HSI HSI selected as I2C1 clock
  1241. * @arg @ref RCC_I2C1CLKSOURCE_SYSCLK System Clock selected as I2C1 clock
  1242. * @retval None
  1243. */
  1244. #define __HAL_RCC_I2C1_CONFIG(__I2C1_CLKSOURCE__) \
  1245. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_I2C1SEL, (__I2C1_CLKSOURCE__))
  1246. /** @brief Macro to get the I2C1 clock source.
  1247. * @retval The clock source can be one of the following values:
  1248. * @arg @ref RCC_I2C1CLKSOURCE_PCLK1 PCLK1 selected as I2C1 clock
  1249. * @arg @ref RCC_I2C1CLKSOURCE_HSI HSI selected as I2C1 clock
  1250. * @arg @ref RCC_I2C1CLKSOURCE_SYSCLK System Clock selected as I2C1 clock
  1251. */
  1252. #define __HAL_RCC_GET_I2C1_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_I2C1SEL))
  1253. #if defined(I2C2)
  1254. /** @brief Macro to configure the I2C2 clock (I2C2CLK).
  1255. *
  1256. * @param __I2C2_CLKSOURCE__ specifies the I2C2 clock source.
  1257. * This parameter can be one of the following values:
  1258. * @arg @ref RCC_I2C2CLKSOURCE_PCLK1 PCLK1 selected as I2C2 clock
  1259. * @arg @ref RCC_I2C2CLKSOURCE_HSI HSI selected as I2C2 clock
  1260. * @arg @ref RCC_I2C2CLKSOURCE_SYSCLK System Clock selected as I2C2 clock
  1261. * @retval None
  1262. */
  1263. #define __HAL_RCC_I2C2_CONFIG(__I2C2_CLKSOURCE__) \
  1264. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_I2C2SEL, (__I2C2_CLKSOURCE__))
  1265. /** @brief Macro to get the I2C2 clock source.
  1266. * @retval The clock source can be one of the following values:
  1267. * @arg @ref RCC_I2C2CLKSOURCE_PCLK1 PCLK1 selected as I2C2 clock
  1268. * @arg @ref RCC_I2C2CLKSOURCE_HSI HSI selected as I2C2 clock
  1269. * @arg @ref RCC_I2C2CLKSOURCE_SYSCLK System Clock selected as I2C2 clock
  1270. */
  1271. #define __HAL_RCC_GET_I2C2_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_I2C2SEL))
  1272. #endif /* I2C2 */
  1273. /** @brief Macro to configure the I2C3 clock (I2C3CLK).
  1274. *
  1275. * @param __I2C3_CLKSOURCE__ specifies the I2C3 clock source.
  1276. * This parameter can be one of the following values:
  1277. * @arg @ref RCC_I2C3CLKSOURCE_PCLK1 PCLK1 selected as I2C3 clock
  1278. * @arg @ref RCC_I2C3CLKSOURCE_HSI HSI selected as I2C3 clock
  1279. * @arg @ref RCC_I2C3CLKSOURCE_SYSCLK System Clock selected as I2C3 clock
  1280. * @retval None
  1281. */
  1282. #define __HAL_RCC_I2C3_CONFIG(__I2C3_CLKSOURCE__) \
  1283. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_I2C3SEL, (__I2C3_CLKSOURCE__))
  1284. /** @brief Macro to get the I2C3 clock source.
  1285. * @retval The clock source can be one of the following values:
  1286. * @arg @ref RCC_I2C3CLKSOURCE_PCLK1 PCLK1 selected as I2C3 clock
  1287. * @arg @ref RCC_I2C3CLKSOURCE_HSI HSI selected as I2C3 clock
  1288. * @arg @ref RCC_I2C3CLKSOURCE_SYSCLK System Clock selected as I2C3 clock
  1289. */
  1290. #define __HAL_RCC_GET_I2C3_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_I2C3SEL))
  1291. #if defined(I2C4)
  1292. /** @brief Macro to configure the I2C4 clock (I2C4CLK).
  1293. *
  1294. * @param __I2C4_CLKSOURCE__ specifies the I2C4 clock source.
  1295. * This parameter can be one of the following values:
  1296. * @arg @ref RCC_I2C4CLKSOURCE_PCLK1 PCLK1 selected as I2C4 clock
  1297. * @arg @ref RCC_I2C4CLKSOURCE_HSI HSI selected as I2C4 clock
  1298. * @arg @ref RCC_I2C4CLKSOURCE_SYSCLK System Clock selected as I2C4 clock
  1299. * @retval None
  1300. */
  1301. #define __HAL_RCC_I2C4_CONFIG(__I2C4_CLKSOURCE__) \
  1302. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_I2C4SEL, (__I2C4_CLKSOURCE__))
  1303. /** @brief Macro to get the I2C4 clock source.
  1304. * @retval The clock source can be one of the following values:
  1305. * @arg @ref RCC_I2C4CLKSOURCE_PCLK1 PCLK1 selected as I2C4 clock
  1306. * @arg @ref RCC_I2C4CLKSOURCE_HSI HSI selected as I2C4 clock
  1307. * @arg @ref RCC_I2C4CLKSOURCE_SYSCLK System Clock selected as I2C4 clock
  1308. */
  1309. #define __HAL_RCC_GET_I2C4_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_I2C4SEL))
  1310. #endif /* I2C4 */
  1311. /** @brief Macro to configure the USART1 clock (USART1CLK).
  1312. *
  1313. * @param __USART1_CLKSOURCE__ specifies the USART1 clock source.
  1314. * This parameter can be one of the following values:
  1315. * @arg @ref RCC_USART1CLKSOURCE_PCLK2 PCLK2 selected as USART1 clock
  1316. * @arg @ref RCC_USART1CLKSOURCE_HSI HSI selected as USART1 clock
  1317. * @arg @ref RCC_USART1CLKSOURCE_SYSCLK System Clock selected as USART1 clock
  1318. * @arg @ref RCC_USART1CLKSOURCE_LSE SE selected as USART1 clock
  1319. * @retval None
  1320. */
  1321. #define __HAL_RCC_USART1_CONFIG(__USART1_CLKSOURCE__) \
  1322. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_USART1SEL, (__USART1_CLKSOURCE__))
  1323. /** @brief Macro to get the USART1 clock source.
  1324. * @retval The clock source can be one of the following values:
  1325. * @arg @ref RCC_USART1CLKSOURCE_PCLK2 PCLK2 selected as USART1 clock
  1326. * @arg @ref RCC_USART1CLKSOURCE_HSI HSI selected as USART1 clock
  1327. * @arg @ref RCC_USART1CLKSOURCE_SYSCLK System Clock selected as USART1 clock
  1328. * @arg @ref RCC_USART1CLKSOURCE_LSE LSE selected as USART1 clock
  1329. */
  1330. #define __HAL_RCC_GET_USART1_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_USART1SEL))
  1331. /** @brief Macro to configure the USART2 clock (USART2CLK).
  1332. *
  1333. * @param __USART2_CLKSOURCE__ specifies the USART2 clock source.
  1334. * This parameter can be one of the following values:
  1335. * @arg @ref RCC_USART2CLKSOURCE_PCLK1 PCLK1 selected as USART2 clock
  1336. * @arg @ref RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock
  1337. * @arg @ref RCC_USART2CLKSOURCE_SYSCLK System Clock selected as USART2 clock
  1338. * @arg @ref RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock
  1339. * @retval None
  1340. */
  1341. #define __HAL_RCC_USART2_CONFIG(__USART2_CLKSOURCE__) \
  1342. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_USART2SEL, (__USART2_CLKSOURCE__))
  1343. /** @brief Macro to get the USART2 clock source.
  1344. * @retval The clock source can be one of the following values:
  1345. * @arg @ref RCC_USART2CLKSOURCE_PCLK1 PCLK1 selected as USART2 clock
  1346. * @arg @ref RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock
  1347. * @arg @ref RCC_USART2CLKSOURCE_SYSCLK System Clock selected as USART2 clock
  1348. * @arg @ref RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock
  1349. */
  1350. #define __HAL_RCC_GET_USART2_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_USART2SEL))
  1351. #if defined(USART3)
  1352. /** @brief Macro to configure the USART3 clock (USART3CLK).
  1353. *
  1354. * @param __USART3_CLKSOURCE__ specifies the USART3 clock source.
  1355. * This parameter can be one of the following values:
  1356. * @arg @ref RCC_USART3CLKSOURCE_PCLK1 PCLK1 selected as USART3 clock
  1357. * @arg @ref RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock
  1358. * @arg @ref RCC_USART3CLKSOURCE_SYSCLK System Clock selected as USART3 clock
  1359. * @arg @ref RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock
  1360. * @retval None
  1361. */
  1362. #define __HAL_RCC_USART3_CONFIG(__USART3_CLKSOURCE__) \
  1363. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_USART3SEL, (__USART3_CLKSOURCE__))
  1364. /** @brief Macro to get the USART3 clock source.
  1365. * @retval The clock source can be one of the following values:
  1366. * @arg @ref RCC_USART3CLKSOURCE_PCLK1 PCLK1 selected as USART3 clock
  1367. * @arg @ref RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock
  1368. * @arg @ref RCC_USART3CLKSOURCE_SYSCLK System Clock selected as USART3 clock
  1369. * @arg @ref RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock
  1370. */
  1371. #define __HAL_RCC_GET_USART3_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_USART3SEL))
  1372. #endif /* USART3 */
  1373. #if defined(UART4)
  1374. /** @brief Macro to configure the UART4 clock (UART4CLK).
  1375. *
  1376. * @param __UART4_CLKSOURCE__ specifies the UART4 clock source.
  1377. * This parameter can be one of the following values:
  1378. * @arg @ref RCC_UART4CLKSOURCE_PCLK1 PCLK1 selected as UART4 clock
  1379. * @arg @ref RCC_UART4CLKSOURCE_HSI HSI selected as UART4 clock
  1380. * @arg @ref RCC_UART4CLKSOURCE_SYSCLK System Clock selected as UART4 clock
  1381. * @arg @ref RCC_UART4CLKSOURCE_LSE LSE selected as UART4 clock
  1382. * @retval None
  1383. */
  1384. #define __HAL_RCC_UART4_CONFIG(__UART4_CLKSOURCE__) \
  1385. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_UART4SEL, (__UART4_CLKSOURCE__))
  1386. /** @brief Macro to get the UART4 clock source.
  1387. * @retval The clock source can be one of the following values:
  1388. * @arg @ref RCC_UART4CLKSOURCE_PCLK1 PCLK1 selected as UART4 clock
  1389. * @arg @ref RCC_UART4CLKSOURCE_HSI HSI selected as UART4 clock
  1390. * @arg @ref RCC_UART4CLKSOURCE_SYSCLK System Clock selected as UART4 clock
  1391. * @arg @ref RCC_UART4CLKSOURCE_LSE LSE selected as UART4 clock
  1392. */
  1393. #define __HAL_RCC_GET_UART4_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_UART4SEL))
  1394. #endif /* UART4 */
  1395. #if defined(UART5)
  1396. /** @brief Macro to configure the UART5 clock (UART5CLK).
  1397. *
  1398. * @param __UART5_CLKSOURCE__ specifies the UART5 clock source.
  1399. * This parameter can be one of the following values:
  1400. * @arg @ref RCC_UART5CLKSOURCE_PCLK1 PCLK1 selected as UART5 clock
  1401. * @arg @ref RCC_UART5CLKSOURCE_HSI HSI selected as UART5 clock
  1402. * @arg @ref RCC_UART5CLKSOURCE_SYSCLK System Clock selected as UART5 clock
  1403. * @arg @ref RCC_UART5CLKSOURCE_LSE LSE selected as UART5 clock
  1404. * @retval None
  1405. */
  1406. #define __HAL_RCC_UART5_CONFIG(__UART5_CLKSOURCE__) \
  1407. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_UART5SEL, (__UART5_CLKSOURCE__))
  1408. /** @brief Macro to get the UART5 clock source.
  1409. * @retval The clock source can be one of the following values:
  1410. * @arg @ref RCC_UART5CLKSOURCE_PCLK1 PCLK1 selected as UART5 clock
  1411. * @arg @ref RCC_UART5CLKSOURCE_HSI HSI selected as UART5 clock
  1412. * @arg @ref RCC_UART5CLKSOURCE_SYSCLK System Clock selected as UART5 clock
  1413. * @arg @ref RCC_UART5CLKSOURCE_LSE LSE selected as UART5 clock
  1414. */
  1415. #define __HAL_RCC_GET_UART5_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_UART5SEL))
  1416. #endif /* UART5 */
  1417. /** @brief Macro to configure the LPUART1 clock (LPUART1CLK).
  1418. *
  1419. * @param __LPUART1_CLKSOURCE__ specifies the LPUART1 clock source.
  1420. * This parameter can be one of the following values:
  1421. * @arg @ref RCC_LPUART1CLKSOURCE_PCLK1 PCLK1 selected as LPUART1 clock
  1422. * @arg @ref RCC_LPUART1CLKSOURCE_HSI HSI selected as LPUART1 clock
  1423. * @arg @ref RCC_LPUART1CLKSOURCE_SYSCLK System Clock selected as LPUART1 clock
  1424. * @arg @ref RCC_LPUART1CLKSOURCE_LSE LSE selected as LPUART1 clock
  1425. * @retval None
  1426. */
  1427. #define __HAL_RCC_LPUART1_CONFIG(__LPUART1_CLKSOURCE__) \
  1428. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPUART1SEL, (__LPUART1_CLKSOURCE__))
  1429. /** @brief Macro to get the LPUART1 clock source.
  1430. * @retval The clock source can be one of the following values:
  1431. * @arg @ref RCC_LPUART1CLKSOURCE_PCLK1 PCLK1 selected as LPUART1 clock
  1432. * @arg @ref RCC_LPUART1CLKSOURCE_HSI HSI selected as LPUART1 clock
  1433. * @arg @ref RCC_LPUART1CLKSOURCE_SYSCLK System Clock selected as LPUART1 clock
  1434. * @arg @ref RCC_LPUART1CLKSOURCE_LSE LSE selected as LPUART1 clock
  1435. */
  1436. #define __HAL_RCC_GET_LPUART1_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_LPUART1SEL))
  1437. /** @brief Macro to configure the LPTIM1 clock (LPTIM1CLK).
  1438. *
  1439. * @param __LPTIM1_CLKSOURCE__ specifies the LPTIM1 clock source.
  1440. * This parameter can be one of the following values:
  1441. * @arg @ref RCC_LPTIM1CLKSOURCE_PCLK1 PCLK1 selected as LPTIM1 clock
  1442. * @arg @ref RCC_LPTIM1CLKSOURCE_LSI HSI selected as LPTIM1 clock
  1443. * @arg @ref RCC_LPTIM1CLKSOURCE_HSI LSI selected as LPTIM1 clock
  1444. * @arg @ref RCC_LPTIM1CLKSOURCE_LSE LSE selected as LPTIM1 clock
  1445. * @retval None
  1446. */
  1447. #define __HAL_RCC_LPTIM1_CONFIG(__LPTIM1_CLKSOURCE__) \
  1448. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPTIM1SEL, (__LPTIM1_CLKSOURCE__))
  1449. /** @brief Macro to get the LPTIM1 clock source.
  1450. * @retval The clock source can be one of the following values:
  1451. * @arg @ref RCC_LPTIM1CLKSOURCE_PCLK1 PCLK1 selected as LPUART1 clock
  1452. * @arg @ref RCC_LPTIM1CLKSOURCE_LSI HSI selected as LPUART1 clock
  1453. * @arg @ref RCC_LPTIM1CLKSOURCE_HSI System Clock selected as LPUART1 clock
  1454. * @arg @ref RCC_LPTIM1CLKSOURCE_LSE LSE selected as LPUART1 clock
  1455. */
  1456. #define __HAL_RCC_GET_LPTIM1_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_LPTIM1SEL))
  1457. /** @brief Macro to configure the LPTIM2 clock (LPTIM2CLK).
  1458. *
  1459. * @param __LPTIM2_CLKSOURCE__ specifies the LPTIM2 clock source.
  1460. * This parameter can be one of the following values:
  1461. * @arg @ref RCC_LPTIM2CLKSOURCE_PCLK1 PCLK1 selected as LPTIM2 clock
  1462. * @arg @ref RCC_LPTIM2CLKSOURCE_LSI HSI selected as LPTIM2 clock
  1463. * @arg @ref RCC_LPTIM2CLKSOURCE_HSI LSI selected as LPTIM2 clock
  1464. * @arg @ref RCC_LPTIM2CLKSOURCE_LSE LSE selected as LPTIM2 clock
  1465. * @retval None
  1466. */
  1467. #define __HAL_RCC_LPTIM2_CONFIG(__LPTIM2_CLKSOURCE__) \
  1468. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPTIM2SEL, (__LPTIM2_CLKSOURCE__))
  1469. /** @brief Macro to get the LPTIM2 clock source.
  1470. * @retval The clock source can be one of the following values:
  1471. * @arg @ref RCC_LPTIM2CLKSOURCE_PCLK1 PCLK1 selected as LPUART1 clock
  1472. * @arg @ref RCC_LPTIM2CLKSOURCE_LSI HSI selected as LPUART1 clock
  1473. * @arg @ref RCC_LPTIM2CLKSOURCE_HSI System Clock selected as LPUART1 clock
  1474. * @arg @ref RCC_LPTIM2CLKSOURCE_LSE LSE selected as LPUART1 clock
  1475. */
  1476. #define __HAL_RCC_GET_LPTIM2_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_LPTIM2SEL))
  1477. #if defined(SDMMC1)
  1478. /** @brief Macro to configure the SDMMC1 clock.
  1479. *
  1480. @if STM32L486xx
  1481. * @note USB, RNG and SDMMC1 peripherals share the same 48MHz clock source.
  1482. @endif
  1483. *
  1484. @if STM32L443xx
  1485. * @note USB, RNG and SDMMC1 peripherals share the same 48MHz clock source.
  1486. @endif
  1487. *
  1488. * @param __SDMMC1_CLKSOURCE__ specifies the SDMMC1 clock source.
  1489. * This parameter can be one of the following values:
  1490. @if STM32L486xx
  1491. * @arg @ref RCC_SDMMC1CLKSOURCE_NONE No clock selected as SDMMC1 clock for devices without HSI48
  1492. * @arg @ref RCC_SDMMC1CLKSOURCE_MSI MSI selected as SDMMC1 clock
  1493. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLSAI1 PLLSAI1 "Q" Clock selected as SDMMC1 clock
  1494. @endif
  1495. @if STM32L443xx
  1496. * @arg @ref RCC_SDMMC1CLKSOURCE_HSI48 HSI48 selected as SDMMC1 clock for devices with HSI48
  1497. * @arg @ref RCC_SDMMC1CLKSOURCE_MSI MSI selected as SDMMC1 clock
  1498. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLSAI1 PLLSAI1 "Q" Clock selected as SDMMC1 clock
  1499. @endif
  1500. @if STM32L4S9xx
  1501. * @arg @ref RCC_SDMMC1CLKSOURCE_HSI48 HSI48 selected as SDMMC1 clock for devices with HSI48
  1502. * @arg @ref RCC_SDMMC1CLKSOURCE_MSI MSI selected as SDMMC1 clock
  1503. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLSAI1 PLLSAI1 "Q" Clock selected as SDMMC1 clock
  1504. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLP PLL "P" Clock selected as SDMMC1 clock
  1505. @endif
  1506. * @arg @ref RCC_SDMMC1CLKSOURCE_PLL PLL "Q" Clock selected as SDMMC1 clock
  1507. * @retval None
  1508. */
  1509. #if defined(RCC_CCIPR2_SDMMCSEL)
  1510. #define __HAL_RCC_SDMMC1_CONFIG(__SDMMC1_CLKSOURCE__) \
  1511. do \
  1512. { \
  1513. if((__SDMMC1_CLKSOURCE__) == RCC_SDMMC1CLKSOURCE_PLLP) \
  1514. { \
  1515. SET_BIT(RCC->CCIPR2, RCC_CCIPR2_SDMMCSEL); \
  1516. } \
  1517. else \
  1518. { \
  1519. CLEAR_BIT(RCC->CCIPR2, RCC_CCIPR2_SDMMCSEL); \
  1520. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_CLK48SEL, (__SDMMC1_CLKSOURCE__)); \
  1521. } \
  1522. } while(0)
  1523. #else
  1524. #define __HAL_RCC_SDMMC1_CONFIG(__SDMMC1_CLKSOURCE__) \
  1525. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_CLK48SEL, (__SDMMC1_CLKSOURCE__))
  1526. #endif /* RCC_CCIPR2_SDMMCSEL */
  1527. /** @brief Macro to get the SDMMC1 clock.
  1528. * @retval The clock source can be one of the following values:
  1529. @if STM32L486xx
  1530. * @arg @ref RCC_SDMMC1CLKSOURCE_NONE No clock selected as SDMMC1 clock for devices without HSI48
  1531. * @arg @ref RCC_SDMMC1CLKSOURCE_MSI MSI selected as SDMMC1 clock
  1532. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLSAI1 PLLSAI1 "Q" clock (PLL48M2CLK) selected as SDMMC1 clock
  1533. @endif
  1534. @if STM32L443xx
  1535. * @arg @ref RCC_SDMMC1CLKSOURCE_HSI48 HSI48 selected as SDMMC1 clock for devices with HSI48
  1536. * @arg @ref RCC_SDMMC1CLKSOURCE_MSI MSI selected as SDMMC1 clock
  1537. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLSAI1 PLLSAI1 "Q" clock (PLL48M2CLK) selected as SDMMC1 clock
  1538. @endif
  1539. @if STM32L4S9xx
  1540. * @arg @ref RCC_SDMMC1CLKSOURCE_HSI48 HSI48 selected as SDMMC1 clock for devices with HSI48
  1541. * @arg @ref RCC_SDMMC1CLKSOURCE_MSI MSI selected as SDMMC1 clock
  1542. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLSAI1 PLLSAI1 "Q" clock (PLL48M2CLK) selected as SDMMC1 clock
  1543. * @arg @ref RCC_SDMMC1CLKSOURCE_PLLP PLL "P" clock (PLLSAI3CLK) selected as SDMMC1 kernel clock
  1544. @endif
  1545. * @arg @ref RCC_SDMMC1CLKSOURCE_PLL PLL "Q" clock (PLL48M1CLK) selected as SDMMC1 clock
  1546. */
  1547. #if defined(RCC_CCIPR2_SDMMCSEL)
  1548. #define __HAL_RCC_GET_SDMMC1_SOURCE() \
  1549. ((READ_BIT(RCC->CCIPR2, RCC_CCIPR2_SDMMCSEL) != 0U) ? RCC_SDMMC1CLKSOURCE_PLLP : (READ_BIT(RCC->CCIPR, RCC_CCIPR_CLK48SEL)))
  1550. #else
  1551. #define __HAL_RCC_GET_SDMMC1_SOURCE() \
  1552. (READ_BIT(RCC->CCIPR, RCC_CCIPR_CLK48SEL))
  1553. #endif /* RCC_CCIPR2_SDMMCSEL */
  1554. #endif /* SDMMC1 */
  1555. /** @brief Macro to configure the RNG clock.
  1556. *
  1557. * @note USB, RNG and SDMMC1 peripherals share the same 48MHz clock source.
  1558. *
  1559. * @param __RNG_CLKSOURCE__ specifies the RNG clock source.
  1560. * This parameter can be one of the following values:
  1561. @if STM32L486xx
  1562. * @arg @ref RCC_RNGCLKSOURCE_NONE No clock selected as RNG clock for devices without HSI48
  1563. @endif
  1564. @if STM32L443xx
  1565. * @arg @ref RCC_RNGCLKSOURCE_HSI48 HSI48 selected as RNG clock clock for devices with HSI48
  1566. @endif
  1567. * @arg @ref RCC_RNGCLKSOURCE_MSI MSI selected as RNG clock
  1568. * @arg @ref RCC_RNGCLKSOURCE_PLLSAI1 PLLSAI1 Clock selected as RNG clock
  1569. * @arg @ref RCC_RNGCLKSOURCE_PLL PLL Clock selected as RNG clock
  1570. * @retval None
  1571. */
  1572. #define __HAL_RCC_RNG_CONFIG(__RNG_CLKSOURCE__) \
  1573. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_CLK48SEL, (__RNG_CLKSOURCE__))
  1574. /** @brief Macro to get the RNG clock.
  1575. * @retval The clock source can be one of the following values:
  1576. @if STM32L486xx
  1577. * @arg @ref RCC_RNGCLKSOURCE_NONE No clock selected as RNG clock for devices without HSI48
  1578. @endif
  1579. @if STM32L443xx
  1580. * @arg @ref RCC_RNGCLKSOURCE_HSI48 HSI48 selected as RNG clock clock for devices with HSI48
  1581. @endif
  1582. * @arg @ref RCC_RNGCLKSOURCE_MSI MSI selected as RNG clock
  1583. * @arg @ref RCC_RNGCLKSOURCE_PLLSAI1 PLLSAI1 "Q" clock (PLL48M2CLK) selected as RNG clock
  1584. * @arg @ref RCC_RNGCLKSOURCE_PLL PLL "Q" clock (PLL48M1CLK) selected as RNG clock
  1585. */
  1586. #define __HAL_RCC_GET_RNG_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_CLK48SEL))
  1587. #if defined(USB_OTG_FS) || defined(USB)
  1588. /** @brief Macro to configure the USB clock (USBCLK).
  1589. *
  1590. * @note USB, RNG and SDMMC1 peripherals share the same 48MHz clock source.
  1591. *
  1592. * @param __USB_CLKSOURCE__ specifies the USB clock source.
  1593. * This parameter can be one of the following values:
  1594. @if STM32L486xx
  1595. * @arg @ref RCC_USBCLKSOURCE_NONE No clock selected as 48MHz clock for devices without HSI48
  1596. @endif
  1597. @if STM32L443xx
  1598. * @arg @ref RCC_USBCLKSOURCE_HSI48 HSI48 selected as 48MHz clock for devices with HSI48
  1599. @endif
  1600. * @arg @ref RCC_USBCLKSOURCE_MSI MSI selected as USB clock
  1601. * @arg @ref RCC_USBCLKSOURCE_PLLSAI1 PLLSAI1 "Q" clock (PLL48M2CLK) selected as USB clock
  1602. * @arg @ref RCC_USBCLKSOURCE_PLL PLL "Q" clock (PLL48M1CLK) selected as USB clock
  1603. * @retval None
  1604. */
  1605. #define __HAL_RCC_USB_CONFIG(__USB_CLKSOURCE__) \
  1606. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_CLK48SEL, (__USB_CLKSOURCE__))
  1607. /** @brief Macro to get the USB clock source.
  1608. * @retval The clock source can be one of the following values:
  1609. @if STM32L486xx
  1610. * @arg @ref RCC_USBCLKSOURCE_NONE No clock selected as 48MHz clock for devices without HSI48
  1611. @endif
  1612. @if STM32L443xx
  1613. * @arg @ref RCC_USBCLKSOURCE_HSI48 HSI48 selected as 48MHz clock for devices with HSI48
  1614. @endif
  1615. * @arg @ref RCC_USBCLKSOURCE_MSI MSI selected as USB clock
  1616. * @arg @ref RCC_USBCLKSOURCE_PLLSAI1 PLLSAI1 "Q" clock (PLL48M2CLK) selected as USB clock
  1617. * @arg @ref RCC_USBCLKSOURCE_PLL PLL "Q" clock (PLL48M1CLK) selected as USB clock
  1618. */
  1619. #define __HAL_RCC_GET_USB_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_CLK48SEL))
  1620. #endif /* USB_OTG_FS || USB */
  1621. #if defined(RCC_CCIPR_ADCSEL)
  1622. /** @brief Macro to configure the ADC interface clock.
  1623. * @param __ADC_CLKSOURCE__ specifies the ADC digital interface clock source.
  1624. * This parameter can be one of the following values:
  1625. * @arg @ref RCC_ADCCLKSOURCE_NONE No clock selected as ADC clock
  1626. * @arg @ref RCC_ADCCLKSOURCE_PLLSAI1 PLLSAI1 Clock selected as ADC clock
  1627. @if STM32L486xx
  1628. * @arg @ref RCC_ADCCLKSOURCE_PLLSAI2 PLLSAI2 Clock selected as ADC clock for STM32L47x/STM32L48x/STM32L49x/STM32L4Ax devices
  1629. @endif
  1630. * @arg @ref RCC_ADCCLKSOURCE_SYSCLK System Clock selected as ADC clock
  1631. * @retval None
  1632. */
  1633. #define __HAL_RCC_ADC_CONFIG(__ADC_CLKSOURCE__) \
  1634. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_ADCSEL, (__ADC_CLKSOURCE__))
  1635. /** @brief Macro to get the ADC clock source.
  1636. * @retval The clock source can be one of the following values:
  1637. * @arg @ref RCC_ADCCLKSOURCE_NONE No clock selected as ADC clock
  1638. * @arg @ref RCC_ADCCLKSOURCE_PLLSAI1 PLLSAI1 Clock selected as ADC clock
  1639. @if STM32L486xx
  1640. * @arg @ref RCC_ADCCLKSOURCE_PLLSAI2 PLLSAI2 Clock selected as ADC clock for STM32L47x/STM32L48x/STM32L49x/STM32L4Ax devices
  1641. @endif
  1642. * @arg @ref RCC_ADCCLKSOURCE_SYSCLK System Clock selected as ADC clock
  1643. */
  1644. #define __HAL_RCC_GET_ADC_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_ADCSEL))
  1645. #else
  1646. /** @brief Macro to get the ADC clock source.
  1647. * @retval The clock source can be one of the following values:
  1648. * @arg @ref RCC_ADCCLKSOURCE_NONE No clock selected as ADC clock
  1649. * @arg @ref RCC_ADCCLKSOURCE_SYSCLK System Clock selected as ADC clock
  1650. */
  1651. #define __HAL_RCC_GET_ADC_SOURCE() ((__HAL_RCC_ADC_IS_CLK_ENABLED() != 0U) ? RCC_ADCCLKSOURCE_SYSCLK : RCC_ADCCLKSOURCE_NONE)
  1652. #endif /* RCC_CCIPR_ADCSEL */
  1653. #if defined(SWPMI1)
  1654. /** @brief Macro to configure the SWPMI1 clock.
  1655. * @param __SWPMI1_CLKSOURCE__ specifies the SWPMI1 clock source.
  1656. * This parameter can be one of the following values:
  1657. * @arg @ref RCC_SWPMI1CLKSOURCE_PCLK1 PCLK1 Clock selected as SWPMI1 clock
  1658. * @arg @ref RCC_SWPMI1CLKSOURCE_HSI HSI Clock selected as SWPMI1 clock
  1659. * @retval None
  1660. */
  1661. #define __HAL_RCC_SWPMI1_CONFIG(__SWPMI1_CLKSOURCE__) \
  1662. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_SWPMI1SEL, (__SWPMI1_CLKSOURCE__))
  1663. /** @brief Macro to get the SWPMI1 clock source.
  1664. * @retval The clock source can be one of the following values:
  1665. * @arg @ref RCC_SWPMI1CLKSOURCE_PCLK1 PCLK1 Clock selected as SWPMI1 clock
  1666. * @arg @ref RCC_SWPMI1CLKSOURCE_HSI HSI Clock selected as SWPMI1 clock
  1667. */
  1668. #define __HAL_RCC_GET_SWPMI1_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_SWPMI1SEL))
  1669. #endif /* SWPMI1 */
  1670. #if defined(DFSDM1_Filter0)
  1671. /** @brief Macro to configure the DFSDM1 clock.
  1672. * @param __DFSDM1_CLKSOURCE__ specifies the DFSDM1 clock source.
  1673. * This parameter can be one of the following values:
  1674. * @arg @ref RCC_DFSDM1CLKSOURCE_PCLK2 PCLK2 Clock selected as DFSDM1 clock
  1675. * @arg @ref RCC_DFSDM1CLKSOURCE_SYSCLK System Clock selected as DFSDM1 clock
  1676. * @retval None
  1677. */
  1678. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  1679. #define __HAL_RCC_DFSDM1_CONFIG(__DFSDM1_CLKSOURCE__) \
  1680. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_DFSDM1SEL, (__DFSDM1_CLKSOURCE__))
  1681. #else
  1682. #define __HAL_RCC_DFSDM1_CONFIG(__DFSDM1_CLKSOURCE__) \
  1683. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_DFSDM1SEL, (__DFSDM1_CLKSOURCE__))
  1684. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  1685. /** @brief Macro to get the DFSDM1 clock source.
  1686. * @retval The clock source can be one of the following values:
  1687. * @arg @ref RCC_DFSDM1CLKSOURCE_PCLK2 PCLK2 Clock selected as DFSDM1 clock
  1688. * @arg @ref RCC_DFSDM1CLKSOURCE_SYSCLK System Clock selected as DFSDM1 clock
  1689. */
  1690. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  1691. #define __HAL_RCC_GET_DFSDM1_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_DFSDM1SEL))
  1692. #else
  1693. #define __HAL_RCC_GET_DFSDM1_SOURCE() (READ_BIT(RCC->CCIPR, RCC_CCIPR_DFSDM1SEL))
  1694. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  1695. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  1696. /** @brief Macro to configure the DFSDM1 audio clock.
  1697. * @param __DFSDM1AUDIO_CLKSOURCE__ specifies the DFSDM1 audio clock source.
  1698. * This parameter can be one of the following values:
  1699. * @arg @ref RCC_DFSDM1AUDIOCLKSOURCE_SAI1 SAI1 clock selected as DFSDM1 audio clock
  1700. * @arg @ref RCC_DFSDM1AUDIOCLKSOURCE_HSI HSI clock selected as DFSDM1 audio clock
  1701. * @arg @ref RCC_DFSDM1AUDIOCLKSOURCE_MSI MSI clock selected as DFSDM1 audio clock
  1702. * @retval None
  1703. */
  1704. #define __HAL_RCC_DFSDM1AUDIO_CONFIG(__DFSDM1AUDIO_CLKSOURCE__) \
  1705. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_ADFSDM1SEL, (__DFSDM1AUDIO_CLKSOURCE__))
  1706. /** @brief Macro to get the DFSDM1 audio clock source.
  1707. * @retval The clock source can be one of the following values:
  1708. * @arg @ref RCC_DFSDM1AUDIOCLKSOURCE_SAI1 SAI1 clock selected as DFSDM1 audio clock
  1709. * @arg @ref RCC_DFSDM1AUDIOCLKSOURCE_HSI HSI clock selected as DFSDM1 audio clock
  1710. * @arg @ref RCC_DFSDM1AUDIOCLKSOURCE_MSI MSI clock selected as DFSDM1 audio clock
  1711. */
  1712. #define __HAL_RCC_GET_DFSDM1AUDIO_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_ADFSDM1SEL))
  1713. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  1714. #endif /* DFSDM1_Filter0 */
  1715. #if defined(LTDC)
  1716. /** @brief Macro to configure the LTDC clock.
  1717. * @param __LTDC_CLKSOURCE__ specifies the LTDC clock source.
  1718. * This parameter can be one of the following values:
  1719. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV2 PLLSAI2 divider R divided by 2 clock selected as LTDC clock
  1720. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV4 PLLSAI2 divider R divided by 4 clock selected as LTDC clock
  1721. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV8 PLLSAI2 divider R divided by 8 clock selected as LTDC clock
  1722. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV16 PLLSAI2 divider R divided by 16 clock selected as LTDC clock
  1723. * @retval None
  1724. */
  1725. #define __HAL_RCC_LTDC_CONFIG(__LTDC_CLKSOURCE__) \
  1726. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_PLLSAI2DIVR, (__LTDC_CLKSOURCE__))
  1727. /** @brief Macro to get the LTDC clock source.
  1728. * @retval The clock source can be one of the following values:
  1729. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV2 PLLSAI2 divider R divided by 2 clock selected as LTDC clock
  1730. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV4 PLLSAI2 divider R divided by 4 clock selected as LTDC clock
  1731. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV8 PLLSAI2 divider R divided by 8 clock selected as LTDC clock
  1732. * @arg @ref RCC_LTDCCLKSOURCE_PLLSAI2_DIV16 PLLSAI2 divider R divided by 16 clock selected as LTDC clock
  1733. */
  1734. #define __HAL_RCC_GET_LTDC_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_PLLSAI2DIVR))
  1735. #endif /* LTDC */
  1736. #if defined(DSI )
  1737. /** @brief Macro to configure the DSI clock.
  1738. * @param __DSI_CLKSOURCE__ specifies the DSI clock source.
  1739. * This parameter can be one of the following values:
  1740. * @arg @ref RCC_DSICLKSOURCE_DSIPHY DSI-PHY clock selected as DSI clock
  1741. * @arg @ref RCC_DSICLKSOURCE_PLLSAI2 PLLSAI2 R divider clock selected as DSI clock
  1742. * @retval None
  1743. */
  1744. #define __HAL_RCC_DSI_CONFIG(__DSI_CLKSOURCE__) \
  1745. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_DSISEL, (__DSI_CLKSOURCE__))
  1746. /** @brief Macro to get the DSI clock source.
  1747. * @retval The clock source can be one of the following values:
  1748. * @arg @ref RCC_DSICLKSOURCE_DSIPHY DSI-PHY clock selected as DSI clock
  1749. * @arg @ref RCC_DSICLKSOURCE_PLLSAI2 PLLSAI2 R divider clock selected as DSI clock
  1750. */
  1751. #define __HAL_RCC_GET_DSI_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_DSISEL))
  1752. #endif /* DSI */
  1753. #if defined(OCTOSPI1) || defined(OCTOSPI2)
  1754. /** @brief Macro to configure the OctoSPI clock.
  1755. * @param __OSPI_CLKSOURCE__ specifies the OctoSPI clock source.
  1756. * This parameter can be one of the following values:
  1757. * @arg @ref RCC_OSPICLKSOURCE_SYSCLK System Clock selected as OctoSPI clock
  1758. * @arg @ref RCC_OSPICLKSOURCE_MSI MSI clock selected as OctoSPI clock
  1759. * @arg @ref RCC_OSPICLKSOURCE_PLL PLL Q divider clock selected as OctoSPI clock
  1760. * @retval None
  1761. */
  1762. #define __HAL_RCC_OSPI_CONFIG(__OSPI_CLKSOURCE__) \
  1763. MODIFY_REG(RCC->CCIPR2, RCC_CCIPR2_OSPISEL, (__OSPI_CLKSOURCE__))
  1764. /** @brief Macro to get the OctoSPI clock source.
  1765. * @retval The clock source can be one of the following values:
  1766. * @arg @ref RCC_OSPICLKSOURCE_SYSCLK System Clock selected as OctoSPI clock
  1767. * @arg @ref RCC_OSPICLKSOURCE_MSI MSI clock selected as OctoSPI clock
  1768. * @arg @ref RCC_OSPICLKSOURCE_PLL PLL Q divider clock selected as OctoSPI clock
  1769. */
  1770. #define __HAL_RCC_GET_OSPI_SOURCE() (READ_BIT(RCC->CCIPR2, RCC_CCIPR2_OSPISEL))
  1771. #endif /* OCTOSPI1 || OCTOSPI2 */
  1772. /** @defgroup RCCEx_Flags_Interrupts_Management Flags Interrupts Management
  1773. * @brief macros to manage the specified RCC Flags and interrupts.
  1774. * @{
  1775. */
  1776. #if defined(RCC_PLLSAI1_SUPPORT)
  1777. /** @brief Enable PLLSAI1RDY interrupt.
  1778. * @retval None
  1779. */
  1780. #define __HAL_RCC_PLLSAI1_ENABLE_IT() SET_BIT(RCC->CIER, RCC_CIER_PLLSAI1RDYIE)
  1781. /** @brief Disable PLLSAI1RDY interrupt.
  1782. * @retval None
  1783. */
  1784. #define __HAL_RCC_PLLSAI1_DISABLE_IT() CLEAR_BIT(RCC->CIER, RCC_CIER_PLLSAI1RDYIE)
  1785. /** @brief Clear the PLLSAI1RDY interrupt pending bit.
  1786. * @retval None
  1787. */
  1788. #define __HAL_RCC_PLLSAI1_CLEAR_IT() WRITE_REG(RCC->CICR, RCC_CICR_PLLSAI1RDYC)
  1789. /** @brief Check whether PLLSAI1RDY interrupt has occurred or not.
  1790. * @retval TRUE or FALSE.
  1791. */
  1792. #define __HAL_RCC_PLLSAI1_GET_IT_SOURCE() (READ_BIT(RCC->CIFR, RCC_CIFR_PLLSAI1RDYF) == RCC_CIFR_PLLSAI1RDYF)
  1793. /** @brief Check whether the PLLSAI1RDY flag is set or not.
  1794. * @retval TRUE or FALSE.
  1795. */
  1796. #define __HAL_RCC_PLLSAI1_GET_FLAG() (READ_BIT(RCC->CR, RCC_CR_PLLSAI1RDY) == (RCC_CR_PLLSAI1RDY))
  1797. #endif /* RCC_PLLSAI1_SUPPORT */
  1798. #if defined(RCC_PLLSAI2_SUPPORT)
  1799. /** @brief Enable PLLSAI2RDY interrupt.
  1800. * @retval None
  1801. */
  1802. #define __HAL_RCC_PLLSAI2_ENABLE_IT() SET_BIT(RCC->CIER, RCC_CIER_PLLSAI2RDYIE)
  1803. /** @brief Disable PLLSAI2RDY interrupt.
  1804. * @retval None
  1805. */
  1806. #define __HAL_RCC_PLLSAI2_DISABLE_IT() CLEAR_BIT(RCC->CIER, RCC_CIER_PLLSAI2RDYIE)
  1807. /** @brief Clear the PLLSAI2RDY interrupt pending bit.
  1808. * @retval None
  1809. */
  1810. #define __HAL_RCC_PLLSAI2_CLEAR_IT() WRITE_REG(RCC->CICR, RCC_CICR_PLLSAI2RDYC)
  1811. /** @brief Check whether the PLLSAI2RDY interrupt has occurred or not.
  1812. * @retval TRUE or FALSE.
  1813. */
  1814. #define __HAL_RCC_PLLSAI2_GET_IT_SOURCE() (READ_BIT(RCC->CIFR, RCC_CIFR_PLLSAI2RDYF) == RCC_CIFR_PLLSAI2RDYF)
  1815. /** @brief Check whether the PLLSAI2RDY flag is set or not.
  1816. * @retval TRUE or FALSE.
  1817. */
  1818. #define __HAL_RCC_PLLSAI2_GET_FLAG() (READ_BIT(RCC->CR, RCC_CR_PLLSAI2RDY) == (RCC_CR_PLLSAI2RDY))
  1819. #endif /* RCC_PLLSAI2_SUPPORT */
  1820. /**
  1821. * @brief Enable the RCC LSE CSS Extended Interrupt Line.
  1822. * @retval None
  1823. */
  1824. #define __HAL_RCC_LSECSS_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, RCC_EXTI_LINE_LSECSS)
  1825. /**
  1826. * @brief Disable the RCC LSE CSS Extended Interrupt Line.
  1827. * @retval None
  1828. */
  1829. #define __HAL_RCC_LSECSS_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, RCC_EXTI_LINE_LSECSS)
  1830. /**
  1831. * @brief Enable the RCC LSE CSS Event Line.
  1832. * @retval None.
  1833. */
  1834. #define __HAL_RCC_LSECSS_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, RCC_EXTI_LINE_LSECSS)
  1835. /**
  1836. * @brief Disable the RCC LSE CSS Event Line.
  1837. * @retval None.
  1838. */
  1839. #define __HAL_RCC_LSECSS_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, RCC_EXTI_LINE_LSECSS)
  1840. /**
  1841. * @brief Enable the RCC LSE CSS Extended Interrupt Falling Trigger.
  1842. * @retval None.
  1843. */
  1844. #define __HAL_RCC_LSECSS_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, RCC_EXTI_LINE_LSECSS)
  1845. /**
  1846. * @brief Disable the RCC LSE CSS Extended Interrupt Falling Trigger.
  1847. * @retval None.
  1848. */
  1849. #define __HAL_RCC_LSECSS_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, RCC_EXTI_LINE_LSECSS)
  1850. /**
  1851. * @brief Enable the RCC LSE CSS Extended Interrupt Rising Trigger.
  1852. * @retval None.
  1853. */
  1854. #define __HAL_RCC_LSECSS_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, RCC_EXTI_LINE_LSECSS)
  1855. /**
  1856. * @brief Disable the RCC LSE CSS Extended Interrupt Rising Trigger.
  1857. * @retval None.
  1858. */
  1859. #define __HAL_RCC_LSECSS_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, RCC_EXTI_LINE_LSECSS)
  1860. /**
  1861. * @brief Enable the RCC LSE CSS Extended Interrupt Rising & Falling Trigger.
  1862. * @retval None.
  1863. */
  1864. #define __HAL_RCC_LSECSS_EXTI_ENABLE_RISING_FALLING_EDGE() \
  1865. do { \
  1866. __HAL_RCC_LSECSS_EXTI_ENABLE_RISING_EDGE(); \
  1867. __HAL_RCC_LSECSS_EXTI_ENABLE_FALLING_EDGE(); \
  1868. } while(0)
  1869. /**
  1870. * @brief Disable the RCC LSE CSS Extended Interrupt Rising & Falling Trigger.
  1871. * @retval None.
  1872. */
  1873. #define __HAL_RCC_LSECSS_EXTI_DISABLE_RISING_FALLING_EDGE() \
  1874. do { \
  1875. __HAL_RCC_LSECSS_EXTI_DISABLE_RISING_EDGE(); \
  1876. __HAL_RCC_LSECSS_EXTI_DISABLE_FALLING_EDGE(); \
  1877. } while(0)
  1878. /**
  1879. * @brief Check whether the specified RCC LSE CSS EXTI interrupt flag is set or not.
  1880. * @retval EXTI RCC LSE CSS Line Status.
  1881. */
  1882. #define __HAL_RCC_LSECSS_EXTI_GET_FLAG() (READ_BIT(EXTI->PR1, RCC_EXTI_LINE_LSECSS) == RCC_EXTI_LINE_LSECSS)
  1883. /**
  1884. * @brief Clear the RCC LSE CSS EXTI flag.
  1885. * @retval None.
  1886. */
  1887. #define __HAL_RCC_LSECSS_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, RCC_EXTI_LINE_LSECSS)
  1888. /**
  1889. * @brief Generate a Software interrupt on the RCC LSE CSS EXTI line.
  1890. * @retval None.
  1891. */
  1892. #define __HAL_RCC_LSECSS_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, RCC_EXTI_LINE_LSECSS)
  1893. #if defined(CRS)
  1894. /**
  1895. * @brief Enable the specified CRS interrupts.
  1896. * @param __INTERRUPT__ specifies the CRS interrupt sources to be enabled.
  1897. * This parameter can be any combination of the following values:
  1898. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1899. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1900. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1901. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1902. * @retval None
  1903. */
  1904. #define __HAL_RCC_CRS_ENABLE_IT(__INTERRUPT__) SET_BIT(CRS->CR, (__INTERRUPT__))
  1905. /**
  1906. * @brief Disable the specified CRS interrupts.
  1907. * @param __INTERRUPT__ specifies the CRS interrupt sources to be disabled.
  1908. * This parameter can be any combination of the following values:
  1909. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1910. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1911. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1912. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1913. * @retval None
  1914. */
  1915. #define __HAL_RCC_CRS_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(CRS->CR, (__INTERRUPT__))
  1916. /** @brief Check whether the CRS interrupt has occurred or not.
  1917. * @param __INTERRUPT__ specifies the CRS interrupt source to check.
  1918. * This parameter can be one of the following values:
  1919. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1920. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1921. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1922. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1923. * @retval The new state of __INTERRUPT__ (SET or RESET).
  1924. */
  1925. #define __HAL_RCC_CRS_GET_IT_SOURCE(__INTERRUPT__) ((READ_BIT(CRS->CR, (__INTERRUPT__)) != 0U) ? SET : RESET)
  1926. /** @brief Clear the CRS interrupt pending bits
  1927. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  1928. * This parameter can be any combination of the following values:
  1929. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1930. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1931. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1932. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1933. * @arg @ref RCC_CRS_IT_TRIMOVF Trimming overflow or underflow interrupt
  1934. * @arg @ref RCC_CRS_IT_SYNCERR SYNC error interrupt
  1935. * @arg @ref RCC_CRS_IT_SYNCMISS SYNC missed interrupt
  1936. */
  1937. /* CRS IT Error Mask */
  1938. #define RCC_CRS_IT_ERROR_MASK (RCC_CRS_IT_TRIMOVF | RCC_CRS_IT_SYNCERR | RCC_CRS_IT_SYNCMISS)
  1939. #define __HAL_RCC_CRS_CLEAR_IT(__INTERRUPT__) do { \
  1940. if(((__INTERRUPT__) & RCC_CRS_IT_ERROR_MASK) != 0U) \
  1941. { \
  1942. WRITE_REG(CRS->ICR, CRS_ICR_ERRC | ((__INTERRUPT__) & ~RCC_CRS_IT_ERROR_MASK)); \
  1943. } \
  1944. else \
  1945. { \
  1946. WRITE_REG(CRS->ICR, (__INTERRUPT__)); \
  1947. } \
  1948. } while(0)
  1949. /**
  1950. * @brief Check whether the specified CRS flag is set or not.
  1951. * @param __FLAG__ specifies the flag to check.
  1952. * This parameter can be one of the following values:
  1953. * @arg @ref RCC_CRS_FLAG_SYNCOK SYNC event OK
  1954. * @arg @ref RCC_CRS_FLAG_SYNCWARN SYNC warning
  1955. * @arg @ref RCC_CRS_FLAG_ERR Error
  1956. * @arg @ref RCC_CRS_FLAG_ESYNC Expected SYNC
  1957. * @arg @ref RCC_CRS_FLAG_TRIMOVF Trimming overflow or underflow
  1958. * @arg @ref RCC_CRS_FLAG_SYNCERR SYNC error
  1959. * @arg @ref RCC_CRS_FLAG_SYNCMISS SYNC missed
  1960. * @retval The new state of _FLAG_ (TRUE or FALSE).
  1961. */
  1962. #define __HAL_RCC_CRS_GET_FLAG(__FLAG__) (READ_BIT(CRS->ISR, (__FLAG__)) == (__FLAG__))
  1963. /**
  1964. * @brief Clear the CRS specified FLAG.
  1965. * @param __FLAG__ specifies the flag to clear.
  1966. * This parameter can be one of the following values:
  1967. * @arg @ref RCC_CRS_FLAG_SYNCOK SYNC event OK
  1968. * @arg @ref RCC_CRS_FLAG_SYNCWARN SYNC warning
  1969. * @arg @ref RCC_CRS_FLAG_ERR Error
  1970. * @arg @ref RCC_CRS_FLAG_ESYNC Expected SYNC
  1971. * @arg @ref RCC_CRS_FLAG_TRIMOVF Trimming overflow or underflow
  1972. * @arg @ref RCC_CRS_FLAG_SYNCERR SYNC error
  1973. * @arg @ref RCC_CRS_FLAG_SYNCMISS SYNC missed
  1974. * @note RCC_CRS_FLAG_ERR clears RCC_CRS_FLAG_TRIMOVF, RCC_CRS_FLAG_SYNCERR, RCC_CRS_FLAG_SYNCMISS and consequently RCC_CRS_FLAG_ERR
  1975. * @retval None
  1976. */
  1977. /* CRS Flag Error Mask */
  1978. #define RCC_CRS_FLAG_ERROR_MASK (RCC_CRS_FLAG_TRIMOVF | RCC_CRS_FLAG_SYNCERR | RCC_CRS_FLAG_SYNCMISS)
  1979. #define __HAL_RCC_CRS_CLEAR_FLAG(__FLAG__) do { \
  1980. if(((__FLAG__) & RCC_CRS_FLAG_ERROR_MASK) != 0U) \
  1981. { \
  1982. WRITE_REG(CRS->ICR, CRS_ICR_ERRC | ((__FLAG__) & ~RCC_CRS_FLAG_ERROR_MASK)); \
  1983. } \
  1984. else \
  1985. { \
  1986. WRITE_REG(CRS->ICR, (__FLAG__)); \
  1987. } \
  1988. } while(0)
  1989. #endif /* CRS */
  1990. /**
  1991. * @}
  1992. */
  1993. #if defined(CRS)
  1994. /** @defgroup RCCEx_CRS_Extended_Features RCCEx CRS Extended Features
  1995. * @{
  1996. */
  1997. /**
  1998. * @brief Enable the oscillator clock for frequency error counter.
  1999. * @note when the CEN bit is set the CRS_CFGR register becomes write-protected.
  2000. * @retval None
  2001. */
  2002. #define __HAL_RCC_CRS_FREQ_ERROR_COUNTER_ENABLE() SET_BIT(CRS->CR, CRS_CR_CEN)
  2003. /**
  2004. * @brief Disable the oscillator clock for frequency error counter.
  2005. * @retval None
  2006. */
  2007. #define __HAL_RCC_CRS_FREQ_ERROR_COUNTER_DISABLE() CLEAR_BIT(CRS->CR, CRS_CR_CEN)
  2008. /**
  2009. * @brief Enable the automatic hardware adjustment of TRIM bits.
  2010. * @note When the AUTOTRIMEN bit is set the CRS_CFGR register becomes write-protected.
  2011. * @retval None
  2012. */
  2013. #define __HAL_RCC_CRS_AUTOMATIC_CALIB_ENABLE() SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN)
  2014. /**
  2015. * @brief Enable or disable the automatic hardware adjustment of TRIM bits.
  2016. * @retval None
  2017. */
  2018. #define __HAL_RCC_CRS_AUTOMATIC_CALIB_DISABLE() CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN)
  2019. /**
  2020. * @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies
  2021. * @note The RELOAD value should be selected according to the ratio between the target frequency and the frequency
  2022. * of the synchronization source after prescaling. It is then decreased by one in order to
  2023. * reach the expected synchronization on the zero value. The formula is the following:
  2024. * RELOAD = (fTARGET / fSYNC) -1
  2025. * @param __FTARGET__ Target frequency (value in Hz)
  2026. * @param __FSYNC__ Synchronization signal frequency (value in Hz)
  2027. * @retval None
  2028. */
  2029. #define __HAL_RCC_CRS_RELOADVALUE_CALCULATE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
  2030. /**
  2031. * @}
  2032. */
  2033. #endif /* CRS */
  2034. #if defined(PSSI)
  2035. /** @defgroup RCCEx_PSSI_Macros_Aliases RCCEx PSSI Macros Aliases
  2036. * @{
  2037. */
  2038. #define __HAL_RCC_PSSI_CLK_ENABLE() __HAL_RCC_DCMI_CLK_ENABLE()
  2039. #define __HAL_RCC_PSSI_CLK_DISABLE() __HAL_RCC_DCMI_CLK_DISABLE()
  2040. #define __HAL_RCC_PSSI_IS_CLK_ENABLED() __HAL_RCC_DCMI_IS_CLK_ENABLED()
  2041. #define __HAL_RCC_PSSI_IS_CLK_DISABLED() __HAL_RCC_DCMI_IS_CLK_DISABLED()
  2042. #define __HAL_RCC_PSSI_FORCE_RESET() __HAL_RCC_DCMI_FORCE_RESET()
  2043. #define __HAL_RCC_PSSI_RELEASE_RESET() __HAL_RCC_DCMI_RELEASE_RESET()
  2044. #define __HAL_RCC_PSSI_CLK_SLEEP_ENABLE() __HAL_RCC_DCMI_CLK_SLEEP_ENABLE()
  2045. #define __HAL_RCC_PSSI_CLK_SLEEP_DISABLE() __HAL_RCC_DCMI_CLK_SLEEP_DISABLE()
  2046. #define __HAL_RCC_PSSI_IS_CLK_SLEEP_ENABLED() __HAL_RCC_DCMI_IS_CLK_SLEEP_ENABLED()
  2047. #define __HAL_RCC_PSSI_IS_CLK_SLEEP_DISABLED() __HAL_RCC_DCMI_IS_CLK_SLEEP_DISABLED()
  2048. /**
  2049. * @}
  2050. */
  2051. #endif /* PSSI */
  2052. /**
  2053. * @}
  2054. */
  2055. /* Exported functions --------------------------------------------------------*/
  2056. /** @addtogroup RCCEx_Exported_Functions
  2057. * @{
  2058. */
  2059. /** @addtogroup RCCEx_Exported_Functions_Group1
  2060. * @{
  2061. */
  2062. HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  2063. void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  2064. uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk);
  2065. /**
  2066. * @}
  2067. */
  2068. /** @addtogroup RCCEx_Exported_Functions_Group2
  2069. * @{
  2070. */
  2071. #if defined(RCC_PLLSAI1_SUPPORT)
  2072. HAL_StatusTypeDef HAL_RCCEx_EnablePLLSAI1(RCC_PLLSAI1InitTypeDef *PLLSAI1Init);
  2073. HAL_StatusTypeDef HAL_RCCEx_DisablePLLSAI1(void);
  2074. #endif /* RCC_PLLSAI1_SUPPORT */
  2075. #if defined(RCC_PLLSAI2_SUPPORT)
  2076. HAL_StatusTypeDef HAL_RCCEx_EnablePLLSAI2(RCC_PLLSAI2InitTypeDef *PLLSAI2Init);
  2077. HAL_StatusTypeDef HAL_RCCEx_DisablePLLSAI2(void);
  2078. #endif /* RCC_PLLSAI2_SUPPORT */
  2079. void HAL_RCCEx_WakeUpStopCLKConfig(uint32_t WakeUpClk);
  2080. void HAL_RCCEx_StandbyMSIRangeConfig(uint32_t MSIRange);
  2081. void HAL_RCCEx_EnableLSECSS(void);
  2082. void HAL_RCCEx_DisableLSECSS(void);
  2083. void HAL_RCCEx_EnableLSECSS_IT(void);
  2084. void HAL_RCCEx_LSECSS_IRQHandler(void);
  2085. void HAL_RCCEx_LSECSS_Callback(void);
  2086. void HAL_RCCEx_EnableLSCO(uint32_t LSCOSource);
  2087. void HAL_RCCEx_DisableLSCO(void);
  2088. void HAL_RCCEx_EnableMSIPLLMode(void);
  2089. void HAL_RCCEx_DisableMSIPLLMode(void);
  2090. #if defined (OCTOSPI1) && defined (OCTOSPI2)
  2091. void HAL_RCCEx_OCTOSPIDelayConfig(uint32_t Delay1, uint32_t Delay2);
  2092. #endif /* OCTOSPI1 && OCTOSPI2 */
  2093. /**
  2094. * @}
  2095. */
  2096. #if defined(CRS)
  2097. /** @addtogroup RCCEx_Exported_Functions_Group3
  2098. * @{
  2099. */
  2100. void HAL_RCCEx_CRSConfig(RCC_CRSInitTypeDef *pInit);
  2101. void HAL_RCCEx_CRSSoftwareSynchronizationGenerate(void);
  2102. void HAL_RCCEx_CRSGetSynchronizationInfo(RCC_CRSSynchroInfoTypeDef *pSynchroInfo);
  2103. uint32_t HAL_RCCEx_CRSWaitSynchronization(uint32_t Timeout);
  2104. void HAL_RCCEx_CRS_IRQHandler(void);
  2105. void HAL_RCCEx_CRS_SyncOkCallback(void);
  2106. void HAL_RCCEx_CRS_SyncWarnCallback(void);
  2107. void HAL_RCCEx_CRS_ExpectedSyncCallback(void);
  2108. void HAL_RCCEx_CRS_ErrorCallback(uint32_t Error);
  2109. /**
  2110. * @}
  2111. */
  2112. #endif /* CRS */
  2113. /**
  2114. * @}
  2115. */
  2116. /* Private constants ---------------------------------------------------------*/
  2117. /** @addtogroup RCCEx_Private_Constants
  2118. * @{
  2119. */
  2120. /* Define used for IS_RCC_* macros below */
  2121. #if defined(STM32L412xx) || defined(STM32L422xx)
  2122. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2123. RCC_PERIPHCLK_LPUART1 | \
  2124. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2125. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2126. RCC_PERIPHCLK_USB | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_RTC | \
  2127. RCC_PERIPHCLK_RNG)
  2128. #elif defined(STM32L431xx)
  2129. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2130. RCC_PERIPHCLK_LPUART1 | \
  2131. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2132. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2133. RCC_PERIPHCLK_SAI1 | \
  2134. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_SWPMI1 | \
  2135. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1)
  2136. #elif defined(STM32L432xx) || defined(STM32L442xx)
  2137. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | \
  2138. RCC_PERIPHCLK_LPUART1 | \
  2139. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C3 | \
  2140. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2141. RCC_PERIPHCLK_SAI1 | \
  2142. RCC_PERIPHCLK_USB | RCC_PERIPHCLK_ADC | \
  2143. RCC_PERIPHCLK_SWPMI1 | RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG)
  2144. #elif defined(STM32L433xx) || defined(STM32L443xx)
  2145. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 |\
  2146. RCC_PERIPHCLK_LPUART1 | \
  2147. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2148. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2149. RCC_PERIPHCLK_SAI1 | \
  2150. RCC_PERIPHCLK_USB | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_SWPMI1 | \
  2151. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1)
  2152. #elif defined(STM32L451xx)
  2153. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 |\
  2154. RCC_PERIPHCLK_UART4 | \
  2155. RCC_PERIPHCLK_LPUART1 | \
  2156. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2157. RCC_PERIPHCLK_I2C4 | \
  2158. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2159. RCC_PERIPHCLK_SAI1 | \
  2160. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_DFSDM1 | \
  2161. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1)
  2162. #elif defined(STM32L452xx) || defined(STM32L462xx)
  2163. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 |\
  2164. RCC_PERIPHCLK_UART4 | \
  2165. RCC_PERIPHCLK_LPUART1 | \
  2166. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2167. RCC_PERIPHCLK_I2C4 | \
  2168. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2169. RCC_PERIPHCLK_SAI1 | \
  2170. RCC_PERIPHCLK_USB | RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_DFSDM1 | \
  2171. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1)
  2172. #elif defined(STM32L471xx)
  2173. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2174. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  2175. RCC_PERIPHCLK_LPUART1 | \
  2176. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2177. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2178. RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2179. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_SWPMI1 | RCC_PERIPHCLK_DFSDM1 | \
  2180. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1)
  2181. #elif defined(STM32L496xx) || defined(STM32L4A6xx)
  2182. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2183. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  2184. RCC_PERIPHCLK_LPUART1 | \
  2185. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2186. RCC_PERIPHCLK_I2C4 | \
  2187. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2188. RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2189. RCC_PERIPHCLK_USB | \
  2190. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_SWPMI1 | RCC_PERIPHCLK_DFSDM1 | \
  2191. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1)
  2192. #elif defined(STM32L4P5xx) || defined(STM32L4Q5xx)
  2193. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2194. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  2195. RCC_PERIPHCLK_LPUART1 | \
  2196. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2197. RCC_PERIPHCLK_I2C4 | \
  2198. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2199. RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2200. RCC_PERIPHCLK_USB | \
  2201. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_DFSDM1 | RCC_PERIPHCLK_DFSDM1AUDIO | \
  2202. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1 | \
  2203. RCC_PERIPHCLK_OSPI | RCC_PERIPHCLK_LTDC)
  2204. #elif defined(STM32L4R5xx) || defined(STM32L4S5xx)
  2205. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2206. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  2207. RCC_PERIPHCLK_LPUART1 | \
  2208. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2209. RCC_PERIPHCLK_I2C4 | \
  2210. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2211. RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2212. RCC_PERIPHCLK_USB | \
  2213. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_DFSDM1 | RCC_PERIPHCLK_DFSDM1AUDIO | \
  2214. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1 | \
  2215. RCC_PERIPHCLK_OSPI)
  2216. #elif defined(STM32L4R7xx) || defined(STM32L4S7xx)
  2217. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2218. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  2219. RCC_PERIPHCLK_LPUART1 | \
  2220. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2221. RCC_PERIPHCLK_I2C4 | \
  2222. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2223. RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2224. RCC_PERIPHCLK_USB | \
  2225. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_DFSDM1 | RCC_PERIPHCLK_DFSDM1AUDIO | \
  2226. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1 | \
  2227. RCC_PERIPHCLK_OSPI | RCC_PERIPHCLK_LTDC)
  2228. #elif defined(STM32L4R9xx) || defined(STM32L4S9xx)
  2229. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2230. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  2231. RCC_PERIPHCLK_LPUART1 | \
  2232. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2233. RCC_PERIPHCLK_I2C4 | \
  2234. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2235. RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2236. RCC_PERIPHCLK_USB | \
  2237. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_DFSDM1 | RCC_PERIPHCLK_DFSDM1AUDIO | \
  2238. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1 | \
  2239. RCC_PERIPHCLK_OSPI | RCC_PERIPHCLK_LTDC | RCC_PERIPHCLK_DSI)
  2240. #else
  2241. #define RCC_PERIPHCLOCK_ALL (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | RCC_PERIPHCLK_USART3 | \
  2242. RCC_PERIPHCLK_UART4 | RCC_PERIPHCLK_UART5 | \
  2243. RCC_PERIPHCLK_LPUART1 | \
  2244. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_I2C3 | \
  2245. RCC_PERIPHCLK_LPTIM1 | RCC_PERIPHCLK_LPTIM2 | \
  2246. RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_SAI2 | \
  2247. RCC_PERIPHCLK_USB | \
  2248. RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_SWPMI1 | RCC_PERIPHCLK_DFSDM1 | \
  2249. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_SDMMC1)
  2250. #endif /* STM32L412xx || STM32L422xx */
  2251. /**
  2252. * @}
  2253. */
  2254. /* Private macros ------------------------------------------------------------*/
  2255. /** @addtogroup RCCEx_Private_Macros
  2256. * @{
  2257. */
  2258. #define IS_RCC_LSCOSOURCE(__SOURCE__) (((__SOURCE__) == RCC_LSCOSOURCE_LSI) || \
  2259. ((__SOURCE__) == RCC_LSCOSOURCE_LSE))
  2260. #define IS_RCC_PERIPHCLOCK(__SELECTION__) ((((__SELECTION__) & RCC_PERIPHCLOCK_ALL) != 0x00u) && \
  2261. (((__SELECTION__) & ~RCC_PERIPHCLOCK_ALL) == 0x00u))
  2262. #define IS_RCC_USART1CLKSOURCE(__SOURCE__) \
  2263. (((__SOURCE__) == RCC_USART1CLKSOURCE_PCLK2) || \
  2264. ((__SOURCE__) == RCC_USART1CLKSOURCE_SYSCLK) || \
  2265. ((__SOURCE__) == RCC_USART1CLKSOURCE_LSE) || \
  2266. ((__SOURCE__) == RCC_USART1CLKSOURCE_HSI))
  2267. #define IS_RCC_USART2CLKSOURCE(__SOURCE__) \
  2268. (((__SOURCE__) == RCC_USART2CLKSOURCE_PCLK1) || \
  2269. ((__SOURCE__) == RCC_USART2CLKSOURCE_SYSCLK) || \
  2270. ((__SOURCE__) == RCC_USART2CLKSOURCE_LSE) || \
  2271. ((__SOURCE__) == RCC_USART2CLKSOURCE_HSI))
  2272. #if defined(USART3)
  2273. #define IS_RCC_USART3CLKSOURCE(__SOURCE__) \
  2274. (((__SOURCE__) == RCC_USART3CLKSOURCE_PCLK1) || \
  2275. ((__SOURCE__) == RCC_USART3CLKSOURCE_SYSCLK) || \
  2276. ((__SOURCE__) == RCC_USART3CLKSOURCE_LSE) || \
  2277. ((__SOURCE__) == RCC_USART3CLKSOURCE_HSI))
  2278. #endif /* USART3 */
  2279. #if defined(UART4)
  2280. #define IS_RCC_UART4CLKSOURCE(__SOURCE__) \
  2281. (((__SOURCE__) == RCC_UART4CLKSOURCE_PCLK1) || \
  2282. ((__SOURCE__) == RCC_UART4CLKSOURCE_SYSCLK) || \
  2283. ((__SOURCE__) == RCC_UART4CLKSOURCE_LSE) || \
  2284. ((__SOURCE__) == RCC_UART4CLKSOURCE_HSI))
  2285. #endif /* UART4 */
  2286. #if defined(UART5)
  2287. #define IS_RCC_UART5CLKSOURCE(__SOURCE__) \
  2288. (((__SOURCE__) == RCC_UART5CLKSOURCE_PCLK1) || \
  2289. ((__SOURCE__) == RCC_UART5CLKSOURCE_SYSCLK) || \
  2290. ((__SOURCE__) == RCC_UART5CLKSOURCE_LSE) || \
  2291. ((__SOURCE__) == RCC_UART5CLKSOURCE_HSI))
  2292. #endif /* UART5 */
  2293. #define IS_RCC_LPUART1CLKSOURCE(__SOURCE__) \
  2294. (((__SOURCE__) == RCC_LPUART1CLKSOURCE_PCLK1) || \
  2295. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_SYSCLK) || \
  2296. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_LSE) || \
  2297. ((__SOURCE__) == RCC_LPUART1CLKSOURCE_HSI))
  2298. #define IS_RCC_I2C1CLKSOURCE(__SOURCE__) \
  2299. (((__SOURCE__) == RCC_I2C1CLKSOURCE_PCLK1) || \
  2300. ((__SOURCE__) == RCC_I2C1CLKSOURCE_SYSCLK)|| \
  2301. ((__SOURCE__) == RCC_I2C1CLKSOURCE_HSI))
  2302. #if defined(I2C2)
  2303. #define IS_RCC_I2C2CLKSOURCE(__SOURCE__) \
  2304. (((__SOURCE__) == RCC_I2C2CLKSOURCE_PCLK1) || \
  2305. ((__SOURCE__) == RCC_I2C2CLKSOURCE_SYSCLK)|| \
  2306. ((__SOURCE__) == RCC_I2C2CLKSOURCE_HSI))
  2307. #endif /* I2C2 */
  2308. #define IS_RCC_I2C3CLKSOURCE(__SOURCE__) \
  2309. (((__SOURCE__) == RCC_I2C3CLKSOURCE_PCLK1) || \
  2310. ((__SOURCE__) == RCC_I2C3CLKSOURCE_SYSCLK)|| \
  2311. ((__SOURCE__) == RCC_I2C3CLKSOURCE_HSI))
  2312. #if defined(I2C4)
  2313. #define IS_RCC_I2C4CLKSOURCE(__SOURCE__) \
  2314. (((__SOURCE__) == RCC_I2C4CLKSOURCE_PCLK1) || \
  2315. ((__SOURCE__) == RCC_I2C4CLKSOURCE_SYSCLK)|| \
  2316. ((__SOURCE__) == RCC_I2C4CLKSOURCE_HSI))
  2317. #endif /* I2C4 */
  2318. #if defined(RCC_PLLSAI2_SUPPORT)
  2319. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  2320. #define IS_RCC_SAI1CLK(__SOURCE__) \
  2321. (((__SOURCE__) == RCC_SAI1CLKSOURCE_PLLSAI1) || \
  2322. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PLLSAI2) || \
  2323. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PLL) || \
  2324. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PIN) || \
  2325. ((__SOURCE__) == RCC_SAI1CLKSOURCE_HSI))
  2326. #else
  2327. #define IS_RCC_SAI1CLK(__SOURCE__) \
  2328. (((__SOURCE__) == RCC_SAI1CLKSOURCE_PLLSAI1) || \
  2329. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PLLSAI2) || \
  2330. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PLL) || \
  2331. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PIN))
  2332. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  2333. #elif defined(RCC_PLLSAI1_SUPPORT)
  2334. #define IS_RCC_SAI1CLK(__SOURCE__) \
  2335. (((__SOURCE__) == RCC_SAI1CLKSOURCE_PLLSAI1) || \
  2336. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PLL) || \
  2337. ((__SOURCE__) == RCC_SAI1CLKSOURCE_PIN))
  2338. #endif /* RCC_PLLSAI2_SUPPORT */
  2339. #if defined(RCC_PLLSAI2_SUPPORT)
  2340. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  2341. #define IS_RCC_SAI2CLK(__SOURCE__) \
  2342. (((__SOURCE__) == RCC_SAI2CLKSOURCE_PLLSAI1) || \
  2343. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PLLSAI2) || \
  2344. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PLL) || \
  2345. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PIN) || \
  2346. ((__SOURCE__) == RCC_SAI2CLKSOURCE_HSI))
  2347. #else
  2348. #define IS_RCC_SAI2CLK(__SOURCE__) \
  2349. (((__SOURCE__) == RCC_SAI2CLKSOURCE_PLLSAI1) || \
  2350. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PLLSAI2) || \
  2351. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PLL) || \
  2352. ((__SOURCE__) == RCC_SAI2CLKSOURCE_PIN))
  2353. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  2354. #endif /* RCC_PLLSAI2_SUPPORT */
  2355. #define IS_RCC_LPTIM1CLK(__SOURCE__) \
  2356. (((__SOURCE__) == RCC_LPTIM1CLKSOURCE_PCLK1) || \
  2357. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_LSI) || \
  2358. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_HSI) || \
  2359. ((__SOURCE__) == RCC_LPTIM1CLKSOURCE_LSE))
  2360. #define IS_RCC_LPTIM2CLK(__SOURCE__) \
  2361. (((__SOURCE__) == RCC_LPTIM2CLKSOURCE_PCLK1) || \
  2362. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_LSI) || \
  2363. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_HSI) || \
  2364. ((__SOURCE__) == RCC_LPTIM2CLKSOURCE_LSE))
  2365. #if defined(SDMMC1)
  2366. #if defined(RCC_HSI48_SUPPORT) && defined(RCC_CCIPR2_SDMMCSEL)
  2367. #define IS_RCC_SDMMC1CLKSOURCE(__SOURCE__) \
  2368. (((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLLP) || \
  2369. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_HSI48) || \
  2370. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLLSAI1) || \
  2371. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLL) || \
  2372. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_MSI))
  2373. #elif defined(RCC_HSI48_SUPPORT)
  2374. #define IS_RCC_SDMMC1CLKSOURCE(__SOURCE__) \
  2375. (((__SOURCE__) == RCC_SDMMC1CLKSOURCE_HSI48) || \
  2376. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLLSAI1) || \
  2377. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLL) || \
  2378. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_MSI))
  2379. #else
  2380. #define IS_RCC_SDMMC1CLKSOURCE(__SOURCE__) \
  2381. (((__SOURCE__) == RCC_SDMMC1CLKSOURCE_NONE) || \
  2382. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLLSAI1) || \
  2383. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_PLL) || \
  2384. ((__SOURCE__) == RCC_SDMMC1CLKSOURCE_MSI))
  2385. #endif /* RCC_HSI48_SUPPORT */
  2386. #endif /* SDMMC1 */
  2387. #if defined(RCC_HSI48_SUPPORT)
  2388. #if defined(RCC_PLLSAI1_SUPPORT)
  2389. #define IS_RCC_RNGCLKSOURCE(__SOURCE__) \
  2390. (((__SOURCE__) == RCC_RNGCLKSOURCE_HSI48) || \
  2391. ((__SOURCE__) == RCC_RNGCLKSOURCE_PLLSAI1) || \
  2392. ((__SOURCE__) == RCC_RNGCLKSOURCE_PLL) || \
  2393. ((__SOURCE__) == RCC_RNGCLKSOURCE_MSI))
  2394. #else
  2395. #define IS_RCC_RNGCLKSOURCE(__SOURCE__) \
  2396. (((__SOURCE__) == RCC_RNGCLKSOURCE_HSI48) || \
  2397. ((__SOURCE__) == RCC_RNGCLKSOURCE_PLL) || \
  2398. ((__SOURCE__) == RCC_RNGCLKSOURCE_MSI))
  2399. #endif /* RCC_PLLSAI1_SUPPORT */
  2400. #else
  2401. #define IS_RCC_RNGCLKSOURCE(__SOURCE__) \
  2402. (((__SOURCE__) == RCC_RNGCLKSOURCE_NONE) || \
  2403. ((__SOURCE__) == RCC_RNGCLKSOURCE_PLLSAI1) || \
  2404. ((__SOURCE__) == RCC_RNGCLKSOURCE_PLL) || \
  2405. ((__SOURCE__) == RCC_RNGCLKSOURCE_MSI))
  2406. #endif /* RCC_HSI48_SUPPORT */
  2407. #if defined(USB_OTG_FS) || defined(USB)
  2408. #if defined(RCC_HSI48_SUPPORT)
  2409. #if defined(RCC_PLLSAI1_SUPPORT)
  2410. #define IS_RCC_USBCLKSOURCE(__SOURCE__) \
  2411. (((__SOURCE__) == RCC_USBCLKSOURCE_HSI48) || \
  2412. ((__SOURCE__) == RCC_USBCLKSOURCE_PLLSAI1) || \
  2413. ((__SOURCE__) == RCC_USBCLKSOURCE_PLL) || \
  2414. ((__SOURCE__) == RCC_USBCLKSOURCE_MSI))
  2415. #else
  2416. #define IS_RCC_USBCLKSOURCE(__SOURCE__) \
  2417. (((__SOURCE__) == RCC_USBCLKSOURCE_HSI48) || \
  2418. ((__SOURCE__) == RCC_USBCLKSOURCE_PLL) || \
  2419. ((__SOURCE__) == RCC_USBCLKSOURCE_MSI))
  2420. #endif /* RCC_PLLSAI1_SUPPORT */
  2421. #else
  2422. #define IS_RCC_USBCLKSOURCE(__SOURCE__) \
  2423. (((__SOURCE__) == RCC_USBCLKSOURCE_NONE) || \
  2424. ((__SOURCE__) == RCC_USBCLKSOURCE_PLLSAI1) || \
  2425. ((__SOURCE__) == RCC_USBCLKSOURCE_PLL) || \
  2426. ((__SOURCE__) == RCC_USBCLKSOURCE_MSI))
  2427. #endif /* RCC_HSI48_SUPPORT */
  2428. #endif /* USB_OTG_FS || USB */
  2429. #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || defined(STM32L496xx) || defined(STM32L4A6xx)
  2430. #define IS_RCC_ADCCLKSOURCE(__SOURCE__) \
  2431. (((__SOURCE__) == RCC_ADCCLKSOURCE_NONE) || \
  2432. ((__SOURCE__) == RCC_ADCCLKSOURCE_PLLSAI1) || \
  2433. ((__SOURCE__) == RCC_ADCCLKSOURCE_PLLSAI2) || \
  2434. ((__SOURCE__) == RCC_ADCCLKSOURCE_SYSCLK))
  2435. #else
  2436. #if defined(RCC_PLLSAI1_SUPPORT)
  2437. #define IS_RCC_ADCCLKSOURCE(__SOURCE__) \
  2438. (((__SOURCE__) == RCC_ADCCLKSOURCE_NONE) || \
  2439. ((__SOURCE__) == RCC_ADCCLKSOURCE_PLLSAI1) || \
  2440. ((__SOURCE__) == RCC_ADCCLKSOURCE_SYSCLK))
  2441. #else
  2442. #define IS_RCC_ADCCLKSOURCE(__SOURCE__) \
  2443. (((__SOURCE__) == RCC_ADCCLKSOURCE_NONE) || \
  2444. ((__SOURCE__) == RCC_ADCCLKSOURCE_SYSCLK))
  2445. #endif /* RCC_PLLSAI1_SUPPORT */
  2446. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || STM32L496xx || STM32L4A6xx */
  2447. #if defined(SWPMI1)
  2448. #define IS_RCC_SWPMI1CLKSOURCE(__SOURCE__) \
  2449. (((__SOURCE__) == RCC_SWPMI1CLKSOURCE_PCLK1) || \
  2450. ((__SOURCE__) == RCC_SWPMI1CLKSOURCE_HSI))
  2451. #endif /* SWPMI1 */
  2452. #if defined(DFSDM1_Filter0)
  2453. #define IS_RCC_DFSDM1CLKSOURCE(__SOURCE__) \
  2454. (((__SOURCE__) == RCC_DFSDM1CLKSOURCE_PCLK2) || \
  2455. ((__SOURCE__) == RCC_DFSDM1CLKSOURCE_SYSCLK))
  2456. #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  2457. #define IS_RCC_DFSDM1AUDIOCLKSOURCE(__SOURCE__) \
  2458. (((__SOURCE__) == RCC_DFSDM1AUDIOCLKSOURCE_SAI1) || \
  2459. ((__SOURCE__) == RCC_DFSDM1AUDIOCLKSOURCE_HSI) || \
  2460. ((__SOURCE__) == RCC_DFSDM1AUDIOCLKSOURCE_MSI))
  2461. #endif /* STM32L4P5xx || STM32L4Q5xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  2462. #endif /* DFSDM1_Filter0 */
  2463. #if defined(LTDC)
  2464. #define IS_RCC_LTDCCLKSOURCE(__SOURCE__) \
  2465. (((__SOURCE__) == RCC_LTDCCLKSOURCE_PLLSAI2_DIV2) || \
  2466. ((__SOURCE__) == RCC_LTDCCLKSOURCE_PLLSAI2_DIV4) || \
  2467. ((__SOURCE__) == RCC_LTDCCLKSOURCE_PLLSAI2_DIV8) || \
  2468. ((__SOURCE__) == RCC_LTDCCLKSOURCE_PLLSAI2_DIV16))
  2469. #endif /* LTDC */
  2470. #if defined(DSI)
  2471. #define IS_RCC_DSICLKSOURCE(__SOURCE__) \
  2472. (((__SOURCE__) == RCC_DSICLKSOURCE_DSIPHY) || \
  2473. ((__SOURCE__) == RCC_DSICLKSOURCE_PLLSAI2))
  2474. #endif /* DSI */
  2475. #if defined(OCTOSPI1) || defined(OCTOSPI2)
  2476. #define IS_RCC_OSPICLKSOURCE(__SOURCE__) \
  2477. (((__SOURCE__) == RCC_OSPICLKSOURCE_SYSCLK) || \
  2478. ((__SOURCE__) == RCC_OSPICLKSOURCE_MSI) || \
  2479. ((__SOURCE__) == RCC_OSPICLKSOURCE_PLL))
  2480. #endif /* OCTOSPI1 || OCTOSPI2 */
  2481. #if defined(RCC_PLLSAI1_SUPPORT)
  2482. #define IS_RCC_PLLSAI1SOURCE(__VALUE__) IS_RCC_PLLSOURCE(__VALUE__)
  2483. #if defined(RCC_PLLSAI1M_DIV_1_16_SUPPORT)
  2484. #define IS_RCC_PLLSAI1M_VALUE(__VALUE__) ((1U <= (__VALUE__)) && ((__VALUE__) <= 16U))
  2485. #else
  2486. #define IS_RCC_PLLSAI1M_VALUE(__VALUE__) ((1U <= (__VALUE__)) && ((__VALUE__) <= 8U))
  2487. #endif /* RCC_PLLSAI1M_DIV_1_16_SUPPORT */
  2488. #if defined(RCC_PLLSAI1N_MUL_8_127_SUPPORT)
  2489. #define IS_RCC_PLLSAI1N_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 127U))
  2490. #else
  2491. #define IS_RCC_PLLSAI1N_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 86U))
  2492. #endif /* RCC_PLLSAI1N_MUL_8_127_SUPPORT */
  2493. #if defined(RCC_PLLSAI1P_DIV_2_31_SUPPORT)
  2494. #define IS_RCC_PLLSAI1P_VALUE(__VALUE__) (((__VALUE__) >= 2U) && ((__VALUE__) <= 31U))
  2495. #else
  2496. #define IS_RCC_PLLSAI1P_VALUE(__VALUE__) (((__VALUE__) == 7U) || ((__VALUE__) == 17U))
  2497. #endif /* RCC_PLLSAI1P_DIV_2_31_SUPPORT */
  2498. #define IS_RCC_PLLSAI1Q_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2499. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2500. #define IS_RCC_PLLSAI1R_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2501. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2502. #endif /* RCC_PLLSAI1_SUPPORT */
  2503. #if defined(RCC_PLLSAI2_SUPPORT)
  2504. #define IS_RCC_PLLSAI2SOURCE(__VALUE__) IS_RCC_PLLSOURCE(__VALUE__)
  2505. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  2506. #define IS_RCC_PLLSAI2M_VALUE(__VALUE__) ((1U <= (__VALUE__)) && ((__VALUE__) <= 16U))
  2507. #else
  2508. #define IS_RCC_PLLSAI2M_VALUE(__VALUE__) ((1U <= (__VALUE__)) && ((__VALUE__) <= 8U))
  2509. #endif /* RCC_PLLSAI2M_DIV_1_16_SUPPORT */
  2510. #if defined(RCC_PLLSAI2N_MUL_8_127_SUPPORT)
  2511. #define IS_RCC_PLLSAI2N_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 127U))
  2512. #else
  2513. #define IS_RCC_PLLSAI2N_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 86U))
  2514. #endif /* RCC_PLLSAI2N_MUL_8_127_SUPPORT */
  2515. #if defined(RCC_PLLSAI2P_DIV_2_31_SUPPORT)
  2516. #define IS_RCC_PLLSAI2P_VALUE(__VALUE__) (((__VALUE__) >= 2U) && ((__VALUE__) <= 31U))
  2517. #else
  2518. #define IS_RCC_PLLSAI2P_VALUE(__VALUE__) (((__VALUE__) == 7U) || ((__VALUE__) == 17U))
  2519. #endif /* RCC_PLLSAI2P_DIV_2_31_SUPPORT */
  2520. #if defined(RCC_PLLSAI2Q_DIV_SUPPORT)
  2521. #define IS_RCC_PLLSAI2Q_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2522. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2523. #endif /* RCC_PLLSAI2Q_DIV_SUPPORT */
  2524. #define IS_RCC_PLLSAI2R_VALUE(__VALUE__) (((__VALUE__) == 2U) || ((__VALUE__) == 4U) || \
  2525. ((__VALUE__) == 6U) || ((__VALUE__) == 8U))
  2526. #endif /* RCC_PLLSAI2_SUPPORT */
  2527. #if defined (OCTOSPI1) && defined (OCTOSPI2)
  2528. #define IS_RCC_OCTOSPIDELAY(__DELAY__) (((__DELAY__) <= 0xFU))
  2529. #endif /* OCTOSPI1 && OCTOSPI2 */
  2530. #if defined(CRS)
  2531. #define IS_RCC_CRS_SYNC_SOURCE(__SOURCE__) (((__SOURCE__) == RCC_CRS_SYNC_SOURCE_GPIO) || \
  2532. ((__SOURCE__) == RCC_CRS_SYNC_SOURCE_LSE) || \
  2533. ((__SOURCE__) == RCC_CRS_SYNC_SOURCE_USB))
  2534. #define IS_RCC_CRS_SYNC_DIV(__DIV__) (((__DIV__) == RCC_CRS_SYNC_DIV1) || ((__DIV__) == RCC_CRS_SYNC_DIV2) || \
  2535. ((__DIV__) == RCC_CRS_SYNC_DIV4) || ((__DIV__) == RCC_CRS_SYNC_DIV8) || \
  2536. ((__DIV__) == RCC_CRS_SYNC_DIV16) || ((__DIV__) == RCC_CRS_SYNC_DIV32) || \
  2537. ((__DIV__) == RCC_CRS_SYNC_DIV64) || ((__DIV__) == RCC_CRS_SYNC_DIV128))
  2538. #define IS_RCC_CRS_SYNC_POLARITY(__POLARITY__) (((__POLARITY__) == RCC_CRS_SYNC_POLARITY_RISING) || \
  2539. ((__POLARITY__) == RCC_CRS_SYNC_POLARITY_FALLING))
  2540. #define IS_RCC_CRS_RELOADVALUE(__VALUE__) (((__VALUE__) <= 0xFFFFU))
  2541. #define IS_RCC_CRS_ERRORLIMIT(__VALUE__) (((__VALUE__) <= 0xFFU))
  2542. #if defined(STM32L412xx) || defined(STM32L422xx)
  2543. #define IS_RCC_CRS_HSI48CALIBRATION(__VALUE__) (((__VALUE__) <= 0x7FU))
  2544. #else
  2545. #define IS_RCC_CRS_HSI48CALIBRATION(__VALUE__) (((__VALUE__) <= 0x3FU))
  2546. #endif /* STM32L412xx || STM32L422xx */
  2547. #define IS_RCC_CRS_FREQERRORDIR(__DIR__) (((__DIR__) == RCC_CRS_FREQERRORDIR_UP) || \
  2548. ((__DIR__) == RCC_CRS_FREQERRORDIR_DOWN))
  2549. #endif /* CRS */
  2550. /**
  2551. * @}
  2552. */
  2553. /**
  2554. * @}
  2555. */
  2556. /**
  2557. * @}
  2558. */
  2559. #ifdef __cplusplus
  2560. }
  2561. #endif
  2562. #endif /* STM32L4xx_HAL_RCC_EX_H */