stm32f1xx_ll_rcc.h 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_ll_rcc.h
  4. * @author MCD Application Team
  5. * @version V1.1.1
  6. * @date 12-May-2017
  7. * @brief Header file of RCC LL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F1xx_LL_RCC_H
  39. #define __STM32F1xx_LL_RCC_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f1xx.h"
  45. /** @addtogroup STM32F1xx_LL_Driver
  46. * @{
  47. */
  48. #if defined(RCC)
  49. /** @defgroup RCC_LL RCC
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /* Private constants ---------------------------------------------------------*/
  55. /* Private macros ------------------------------------------------------------*/
  56. #if defined(USE_FULL_LL_DRIVER)
  57. /** @defgroup RCC_LL_Private_Macros RCC Private Macros
  58. * @{
  59. */
  60. /**
  61. * @}
  62. */
  63. #endif /*USE_FULL_LL_DRIVER*/
  64. /* Exported types ------------------------------------------------------------*/
  65. #if defined(USE_FULL_LL_DRIVER)
  66. /** @defgroup RCC_LL_Exported_Types RCC Exported Types
  67. * @{
  68. */
  69. /** @defgroup LL_ES_CLOCK_FREQ Clocks Frequency Structure
  70. * @{
  71. */
  72. /**
  73. * @brief RCC Clocks Frequency Structure
  74. */
  75. typedef struct
  76. {
  77. uint32_t SYSCLK_Frequency; /*!< SYSCLK clock frequency */
  78. uint32_t HCLK_Frequency; /*!< HCLK clock frequency */
  79. uint32_t PCLK1_Frequency; /*!< PCLK1 clock frequency */
  80. uint32_t PCLK2_Frequency; /*!< PCLK2 clock frequency */
  81. } LL_RCC_ClocksTypeDef;
  82. /**
  83. * @}
  84. */
  85. /**
  86. * @}
  87. */
  88. #endif /* USE_FULL_LL_DRIVER */
  89. /* Exported constants --------------------------------------------------------*/
  90. /** @defgroup RCC_LL_Exported_Constants RCC Exported Constants
  91. * @{
  92. */
  93. /** @defgroup RCC_LL_EC_OSC_VALUES Oscillator Values adaptation
  94. * @brief Defines used to adapt values of different oscillators
  95. * @note These values could be modified in the user environment according to
  96. * HW set-up.
  97. * @{
  98. */
  99. #if !defined (HSE_VALUE)
  100. #define HSE_VALUE 8000000U /*!< Value of the HSE oscillator in Hz */
  101. #endif /* HSE_VALUE */
  102. #if !defined (HSI_VALUE)
  103. #define HSI_VALUE 8000000U /*!< Value of the HSI oscillator in Hz */
  104. #endif /* HSI_VALUE */
  105. #if !defined (LSE_VALUE)
  106. #define LSE_VALUE 32768U /*!< Value of the LSE oscillator in Hz */
  107. #endif /* LSE_VALUE */
  108. #if !defined (LSI_VALUE)
  109. #define LSI_VALUE 32000U /*!< Value of the LSI oscillator in Hz */
  110. #endif /* LSI_VALUE */
  111. /**
  112. * @}
  113. */
  114. /** @defgroup RCC_LL_EC_CLEAR_FLAG Clear Flags Defines
  115. * @brief Flags defines which can be used with LL_RCC_WriteReg function
  116. * @{
  117. */
  118. #define LL_RCC_CIR_LSIRDYC RCC_CIR_LSIRDYC /*!< LSI Ready Interrupt Clear */
  119. #define LL_RCC_CIR_LSERDYC RCC_CIR_LSERDYC /*!< LSE Ready Interrupt Clear */
  120. #define LL_RCC_CIR_HSIRDYC RCC_CIR_HSIRDYC /*!< HSI Ready Interrupt Clear */
  121. #define LL_RCC_CIR_HSERDYC RCC_CIR_HSERDYC /*!< HSE Ready Interrupt Clear */
  122. #define LL_RCC_CIR_PLLRDYC RCC_CIR_PLLRDYC /*!< PLL Ready Interrupt Clear */
  123. #define LL_RCC_CIR_PLL3RDYC RCC_CIR_PLL3RDYC /*!< PLL3(PLLI2S) Ready Interrupt Clear */
  124. #define LL_RCC_CIR_PLL2RDYC RCC_CIR_PLL2RDYC /*!< PLL2 Ready Interrupt Clear */
  125. #define LL_RCC_CIR_CSSC RCC_CIR_CSSC /*!< Clock Security System Interrupt Clear */
  126. /**
  127. * @}
  128. */
  129. /** @defgroup RCC_LL_EC_GET_FLAG Get Flags Defines
  130. * @brief Flags defines which can be used with LL_RCC_ReadReg function
  131. * @{
  132. */
  133. #define LL_RCC_CIR_LSIRDYF RCC_CIR_LSIRDYF /*!< LSI Ready Interrupt flag */
  134. #define LL_RCC_CIR_LSERDYF RCC_CIR_LSERDYF /*!< LSE Ready Interrupt flag */
  135. #define LL_RCC_CIR_HSIRDYF RCC_CIR_HSIRDYF /*!< HSI Ready Interrupt flag */
  136. #define LL_RCC_CIR_HSERDYF RCC_CIR_HSERDYF /*!< HSE Ready Interrupt flag */
  137. #define LL_RCC_CIR_PLLRDYF RCC_CIR_PLLRDYF /*!< PLL Ready Interrupt flag */
  138. #define LL_RCC_CIR_PLL3RDYF RCC_CIR_PLL3RDYF /*!< PLL3(PLLI2S) Ready Interrupt flag */
  139. #define LL_RCC_CIR_PLL2RDYF RCC_CIR_PLL2RDYF /*!< PLL2 Ready Interrupt flag */
  140. #define LL_RCC_CIR_CSSF RCC_CIR_CSSF /*!< Clock Security System Interrupt flag */
  141. #define LL_RCC_CSR_PINRSTF RCC_CSR_PINRSTF /*!< PIN reset flag */
  142. #define LL_RCC_CSR_PORRSTF RCC_CSR_PORRSTF /*!< POR/PDR reset flag */
  143. #define LL_RCC_CSR_SFTRSTF RCC_CSR_SFTRSTF /*!< Software Reset flag */
  144. #define LL_RCC_CSR_IWDGRSTF RCC_CSR_IWDGRSTF /*!< Independent Watchdog reset flag */
  145. #define LL_RCC_CSR_WWDGRSTF RCC_CSR_WWDGRSTF /*!< Window watchdog reset flag */
  146. #define LL_RCC_CSR_LPWRRSTF RCC_CSR_LPWRRSTF /*!< Low-Power reset flag */
  147. /**
  148. * @}
  149. */
  150. /** @defgroup RCC_LL_EC_IT IT Defines
  151. * @brief IT defines which can be used with LL_RCC_ReadReg and LL_RCC_WriteReg functions
  152. * @{
  153. */
  154. #define LL_RCC_CIR_LSIRDYIE RCC_CIR_LSIRDYIE /*!< LSI Ready Interrupt Enable */
  155. #define LL_RCC_CIR_LSERDYIE RCC_CIR_LSERDYIE /*!< LSE Ready Interrupt Enable */
  156. #define LL_RCC_CIR_HSIRDYIE RCC_CIR_HSIRDYIE /*!< HSI Ready Interrupt Enable */
  157. #define LL_RCC_CIR_HSERDYIE RCC_CIR_HSERDYIE /*!< HSE Ready Interrupt Enable */
  158. #define LL_RCC_CIR_PLLRDYIE RCC_CIR_PLLRDYIE /*!< PLL Ready Interrupt Enable */
  159. #define LL_RCC_CIR_PLL3RDYIE RCC_CIR_PLL3RDYIE /*!< PLL3(PLLI2S) Ready Interrupt Enable */
  160. #define LL_RCC_CIR_PLL2RDYIE RCC_CIR_PLL2RDYIE /*!< PLL2 Ready Interrupt Enable */
  161. /**
  162. * @}
  163. */
  164. #if defined(RCC_CFGR2_PREDIV2)
  165. /** @defgroup RCC_LL_EC_HSE_PREDIV2_DIV HSE PREDIV2 Division factor
  166. * @{
  167. */
  168. #define LL_RCC_HSE_PREDIV2_DIV_1 RCC_CFGR2_PREDIV2_DIV1 /*!< PREDIV2 input clock not divided */
  169. #define LL_RCC_HSE_PREDIV2_DIV_2 RCC_CFGR2_PREDIV2_DIV2 /*!< PREDIV2 input clock divided by 2 */
  170. #define LL_RCC_HSE_PREDIV2_DIV_3 RCC_CFGR2_PREDIV2_DIV3 /*!< PREDIV2 input clock divided by 3 */
  171. #define LL_RCC_HSE_PREDIV2_DIV_4 RCC_CFGR2_PREDIV2_DIV4 /*!< PREDIV2 input clock divided by 4 */
  172. #define LL_RCC_HSE_PREDIV2_DIV_5 RCC_CFGR2_PREDIV2_DIV5 /*!< PREDIV2 input clock divided by 5 */
  173. #define LL_RCC_HSE_PREDIV2_DIV_6 RCC_CFGR2_PREDIV2_DIV6 /*!< PREDIV2 input clock divided by 6 */
  174. #define LL_RCC_HSE_PREDIV2_DIV_7 RCC_CFGR2_PREDIV2_DIV7 /*!< PREDIV2 input clock divided by 7 */
  175. #define LL_RCC_HSE_PREDIV2_DIV_8 RCC_CFGR2_PREDIV2_DIV8 /*!< PREDIV2 input clock divided by 8 */
  176. #define LL_RCC_HSE_PREDIV2_DIV_9 RCC_CFGR2_PREDIV2_DIV9 /*!< PREDIV2 input clock divided by 9 */
  177. #define LL_RCC_HSE_PREDIV2_DIV_10 RCC_CFGR2_PREDIV2_DIV10 /*!< PREDIV2 input clock divided by 10 */
  178. #define LL_RCC_HSE_PREDIV2_DIV_11 RCC_CFGR2_PREDIV2_DIV11 /*!< PREDIV2 input clock divided by 11 */
  179. #define LL_RCC_HSE_PREDIV2_DIV_12 RCC_CFGR2_PREDIV2_DIV12 /*!< PREDIV2 input clock divided by 12 */
  180. #define LL_RCC_HSE_PREDIV2_DIV_13 RCC_CFGR2_PREDIV2_DIV13 /*!< PREDIV2 input clock divided by 13 */
  181. #define LL_RCC_HSE_PREDIV2_DIV_14 RCC_CFGR2_PREDIV2_DIV14 /*!< PREDIV2 input clock divided by 14 */
  182. #define LL_RCC_HSE_PREDIV2_DIV_15 RCC_CFGR2_PREDIV2_DIV15 /*!< PREDIV2 input clock divided by 15 */
  183. #define LL_RCC_HSE_PREDIV2_DIV_16 RCC_CFGR2_PREDIV2_DIV16 /*!< PREDIV2 input clock divided by 16 */
  184. /**
  185. * @}
  186. */
  187. #endif /* RCC_CFGR2_PREDIV2 */
  188. /** @defgroup RCC_LL_EC_SYS_CLKSOURCE System clock switch
  189. * @{
  190. */
  191. #define LL_RCC_SYS_CLKSOURCE_HSI RCC_CFGR_SW_HSI /*!< HSI selection as system clock */
  192. #define LL_RCC_SYS_CLKSOURCE_HSE RCC_CFGR_SW_HSE /*!< HSE selection as system clock */
  193. #define LL_RCC_SYS_CLKSOURCE_PLL RCC_CFGR_SW_PLL /*!< PLL selection as system clock */
  194. /**
  195. * @}
  196. */
  197. /** @defgroup RCC_LL_EC_SYS_CLKSOURCE_STATUS System clock switch status
  198. * @{
  199. */
  200. #define LL_RCC_SYS_CLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  201. #define LL_RCC_SYS_CLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  202. #define LL_RCC_SYS_CLKSOURCE_STATUS_PLL RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  203. /**
  204. * @}
  205. */
  206. /** @defgroup RCC_LL_EC_SYSCLK_DIV AHB prescaler
  207. * @{
  208. */
  209. #define LL_RCC_SYSCLK_DIV_1 RCC_CFGR_HPRE_DIV1 /*!< SYSCLK not divided */
  210. #define LL_RCC_SYSCLK_DIV_2 RCC_CFGR_HPRE_DIV2 /*!< SYSCLK divided by 2 */
  211. #define LL_RCC_SYSCLK_DIV_4 RCC_CFGR_HPRE_DIV4 /*!< SYSCLK divided by 4 */
  212. #define LL_RCC_SYSCLK_DIV_8 RCC_CFGR_HPRE_DIV8 /*!< SYSCLK divided by 8 */
  213. #define LL_RCC_SYSCLK_DIV_16 RCC_CFGR_HPRE_DIV16 /*!< SYSCLK divided by 16 */
  214. #define LL_RCC_SYSCLK_DIV_64 RCC_CFGR_HPRE_DIV64 /*!< SYSCLK divided by 64 */
  215. #define LL_RCC_SYSCLK_DIV_128 RCC_CFGR_HPRE_DIV128 /*!< SYSCLK divided by 128 */
  216. #define LL_RCC_SYSCLK_DIV_256 RCC_CFGR_HPRE_DIV256 /*!< SYSCLK divided by 256 */
  217. #define LL_RCC_SYSCLK_DIV_512 RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
  218. /**
  219. * @}
  220. */
  221. /** @defgroup RCC_LL_EC_APB1_DIV APB low-speed prescaler (APB1)
  222. * @{
  223. */
  224. #define LL_RCC_APB1_DIV_1 RCC_CFGR_PPRE1_DIV1 /*!< HCLK not divided */
  225. #define LL_RCC_APB1_DIV_2 RCC_CFGR_PPRE1_DIV2 /*!< HCLK divided by 2 */
  226. #define LL_RCC_APB1_DIV_4 RCC_CFGR_PPRE1_DIV4 /*!< HCLK divided by 4 */
  227. #define LL_RCC_APB1_DIV_8 RCC_CFGR_PPRE1_DIV8 /*!< HCLK divided by 8 */
  228. #define LL_RCC_APB1_DIV_16 RCC_CFGR_PPRE1_DIV16 /*!< HCLK divided by 16 */
  229. /**
  230. * @}
  231. */
  232. /** @defgroup RCC_LL_EC_APB2_DIV APB high-speed prescaler (APB2)
  233. * @{
  234. */
  235. #define LL_RCC_APB2_DIV_1 RCC_CFGR_PPRE2_DIV1 /*!< HCLK not divided */
  236. #define LL_RCC_APB2_DIV_2 RCC_CFGR_PPRE2_DIV2 /*!< HCLK divided by 2 */
  237. #define LL_RCC_APB2_DIV_4 RCC_CFGR_PPRE2_DIV4 /*!< HCLK divided by 4 */
  238. #define LL_RCC_APB2_DIV_8 RCC_CFGR_PPRE2_DIV8 /*!< HCLK divided by 8 */
  239. #define LL_RCC_APB2_DIV_16 RCC_CFGR_PPRE2_DIV16 /*!< HCLK divided by 16 */
  240. /**
  241. * @}
  242. */
  243. /** @defgroup RCC_LL_EC_MCO1SOURCE MCO1 SOURCE selection
  244. * @{
  245. */
  246. #define LL_RCC_MCO1SOURCE_NOCLOCK RCC_CFGR_MCOSEL_NOCLOCK /*!< MCO output disabled, no clock on MCO */
  247. #define LL_RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCOSEL_SYSCLK /*!< SYSCLK selection as MCO source */
  248. #define LL_RCC_MCO1SOURCE_HSI RCC_CFGR_MCOSEL_HSI /*!< HSI selection as MCO source */
  249. #define LL_RCC_MCO1SOURCE_HSE RCC_CFGR_MCOSEL_HSE /*!< HSE selection as MCO source */
  250. #define LL_RCC_MCO1SOURCE_PLLCLK_DIV_2 RCC_CFGR_MCOSEL_PLL_DIV2 /*!< PLL clock divided by 2*/
  251. #if defined(RCC_CFGR_MCOSEL_PLL2CLK)
  252. #define LL_RCC_MCO1SOURCE_PLL2CLK RCC_CFGR_MCOSEL_PLL2 /*!< PLL2 clock selected as MCO source*/
  253. #endif /* RCC_CFGR_MCOSEL_PLL2CLK */
  254. #if defined(RCC_CFGR_MCOSEL_PLL3CLK_DIV2)
  255. #define LL_RCC_MCO1SOURCE_PLLI2SCLK_DIV2 RCC_CFGR_MCOSEL_PLL3_DIV2 /*!< PLLI2S clock divided by 2 selected as MCO source*/
  256. #endif /* RCC_CFGR_MCOSEL_PLL3CLK_DIV2 */
  257. #if defined(RCC_CFGR_MCOSEL_EXT_HSE)
  258. #define LL_RCC_MCO1SOURCE_EXT_HSE RCC_CFGR_MCOSEL_EXT_HSE /*!< XT1 external 3-25 MHz oscillator clock selected as MCO source */
  259. #endif /* RCC_CFGR_MCOSEL_EXT_HSE */
  260. #if defined(RCC_CFGR_MCOSEL_PLL3CLK)
  261. #define LL_RCC_MCO1SOURCE_PLLI2SCLK RCC_CFGR_MCOSEL_PLL3CLK /*!< PLLI2S clock selected as MCO source */
  262. #endif /* RCC_CFGR_MCOSEL_PLL3CLK */
  263. /**
  264. * @}
  265. */
  266. #if defined(USE_FULL_LL_DRIVER)
  267. /** @defgroup RCC_LL_EC_PERIPH_FREQUENCY Peripheral clock frequency
  268. * @{
  269. */
  270. #define LL_RCC_PERIPH_FREQUENCY_NO 0x00000000U /*!< No clock enabled for the peripheral */
  271. #define LL_RCC_PERIPH_FREQUENCY_NA 0xFFFFFFFFU /*!< Frequency cannot be provided as external clock */
  272. /**
  273. * @}
  274. */
  275. #endif /* USE_FULL_LL_DRIVER */
  276. #if defined(RCC_CFGR2_I2S2SRC)
  277. /** @defgroup RCC_LL_EC_I2S2CLKSOURCE Peripheral I2S clock source selection
  278. * @{
  279. */
  280. #define LL_RCC_I2S2_CLKSOURCE_SYSCLK RCC_CFGR2_I2S2SRC /*!< System clock (SYSCLK) selected as I2S2 clock entry */
  281. #define LL_RCC_I2S2_CLKSOURCE_PLLI2S_VCO (uint32_t)(RCC_CFGR2_I2S2SRC | (RCC_CFGR2_I2S2SRC >> 16U)) /*!< PLLI2S VCO clock selected as I2S2 clock entry */
  282. #define LL_RCC_I2S3_CLKSOURCE_SYSCLK RCC_CFGR2_I2S3SRC /*!< System clock (SYSCLK) selected as I2S3 clock entry */
  283. #define LL_RCC_I2S3_CLKSOURCE_PLLI2S_VCO (uint32_t)(RCC_CFGR2_I2S3SRC | (RCC_CFGR2_I2S3SRC >> 16U)) /*!< PLLI2S VCO clock selected as I2S3 clock entry */
  284. /**
  285. * @}
  286. */
  287. #endif /* RCC_CFGR2_I2S2SRC */
  288. #if defined(USB_OTG_FS) || defined(USB)
  289. /** @defgroup RCC_LL_EC_USB_CLKSOURCE Peripheral USB clock source selection
  290. * @{
  291. */
  292. #if defined(RCC_CFGR_USBPRE)
  293. #define LL_RCC_USB_CLKSOURCE_PLL RCC_CFGR_USBPRE /*!< PLL clock is not divided */
  294. #define LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5 0x00000000U /*!< PLL clock is divided by 1.5 */
  295. #endif /*RCC_CFGR_USBPRE*/
  296. #if defined(RCC_CFGR_OTGFSPRE)
  297. #define LL_RCC_USB_CLKSOURCE_PLL_DIV_2 RCC_CFGR_OTGFSPRE /*!< PLL clock is divided by 2 */
  298. #define LL_RCC_USB_CLKSOURCE_PLL_DIV_3 0x00000000U /*!< PLL clock is divided by 3 */
  299. #endif /*RCC_CFGR_OTGFSPRE*/
  300. /**
  301. * @}
  302. */
  303. #endif /* USB_OTG_FS || USB */
  304. /** @defgroup RCC_LL_EC_ADC_CLKSOURCE_PCLK2 Peripheral ADC clock source selection
  305. * @{
  306. */
  307. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_2 RCC_CFGR_ADCPRE_DIV2 /*ADC prescaler PCLK2 divided by 2*/
  308. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_4 RCC_CFGR_ADCPRE_DIV4 /*ADC prescaler PCLK2 divided by 4*/
  309. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_6 RCC_CFGR_ADCPRE_DIV6 /*ADC prescaler PCLK2 divided by 6*/
  310. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_8 RCC_CFGR_ADCPRE_DIV8 /*ADC prescaler PCLK2 divided by 8*/
  311. /**
  312. * @}
  313. */
  314. #if defined(RCC_CFGR2_I2S2SRC)
  315. /** @defgroup RCC_LL_EC_I2S2 Peripheral I2S get clock source
  316. * @{
  317. */
  318. #define LL_RCC_I2S2_CLKSOURCE RCC_CFGR2_I2S2SRC /*!< I2S2 Clock source selection */
  319. #define LL_RCC_I2S3_CLKSOURCE RCC_CFGR2_I2S3SRC /*!< I2S3 Clock source selection */
  320. /**
  321. * @}
  322. */
  323. #endif /* RCC_CFGR2_I2S2SRC */
  324. #if defined(USB_OTG_FS) || defined(USB)
  325. /** @defgroup RCC_LL_EC_USB Peripheral USB get clock source
  326. * @{
  327. */
  328. #define LL_RCC_USB_CLKSOURCE 0x00400000U /*!< USB Clock source selection */
  329. /**
  330. * @}
  331. */
  332. #endif /* USB_OTG_FS || USB */
  333. /** @defgroup RCC_LL_EC_ADC Peripheral ADC get clock source
  334. * @{
  335. */
  336. #define LL_RCC_ADC_CLKSOURCE RCC_CFGR_ADCPRE /*!< ADC Clock source selection */
  337. /**
  338. * @}
  339. */
  340. /** @defgroup RCC_LL_EC_RTC_CLKSOURCE RTC clock source selection
  341. * @{
  342. */
  343. #define LL_RCC_RTC_CLKSOURCE_NONE 0x00000000U /*!< No clock used as RTC clock */
  344. #define LL_RCC_RTC_CLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
  345. #define LL_RCC_RTC_CLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
  346. #define LL_RCC_RTC_CLKSOURCE_HSE_DIV128 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 128 used as RTC clock */
  347. /**
  348. * @}
  349. */
  350. /** @defgroup RCC_LL_EC_PLL_MUL PLL Multiplicator factor
  351. * @{
  352. */
  353. #if defined(RCC_CFGR_PLLMULL2)
  354. #define LL_RCC_PLL_MUL_2 RCC_CFGR_PLLMULL2 /*!< PLL input clock*2 */
  355. #endif /*RCC_CFGR_PLLMULL2*/
  356. #if defined(RCC_CFGR_PLLMULL3)
  357. #define LL_RCC_PLL_MUL_3 RCC_CFGR_PLLMULL3 /*!< PLL input clock*3 */
  358. #endif /*RCC_CFGR_PLLMULL3*/
  359. #define LL_RCC_PLL_MUL_4 RCC_CFGR_PLLMULL4 /*!< PLL input clock*4 */
  360. #define LL_RCC_PLL_MUL_5 RCC_CFGR_PLLMULL5 /*!< PLL input clock*5 */
  361. #define LL_RCC_PLL_MUL_6 RCC_CFGR_PLLMULL6 /*!< PLL input clock*6 */
  362. #define LL_RCC_PLL_MUL_7 RCC_CFGR_PLLMULL7 /*!< PLL input clock*7 */
  363. #define LL_RCC_PLL_MUL_8 RCC_CFGR_PLLMULL8 /*!< PLL input clock*8 */
  364. #define LL_RCC_PLL_MUL_9 RCC_CFGR_PLLMULL9 /*!< PLL input clock*9 */
  365. #if defined(RCC_CFGR_PLLMULL6_5)
  366. #define LL_RCC_PLL_MUL_6_5 RCC_CFGR_PLLMULL6_5 /*!< PLL input clock*6 */
  367. #else
  368. #define LL_RCC_PLL_MUL_10 RCC_CFGR_PLLMULL10 /*!< PLL input clock*10 */
  369. #define LL_RCC_PLL_MUL_11 RCC_CFGR_PLLMULL11 /*!< PLL input clock*11 */
  370. #define LL_RCC_PLL_MUL_12 RCC_CFGR_PLLMULL12 /*!< PLL input clock*12 */
  371. #define LL_RCC_PLL_MUL_13 RCC_CFGR_PLLMULL13 /*!< PLL input clock*13 */
  372. #define LL_RCC_PLL_MUL_14 RCC_CFGR_PLLMULL14 /*!< PLL input clock*14 */
  373. #define LL_RCC_PLL_MUL_15 RCC_CFGR_PLLMULL15 /*!< PLL input clock*15 */
  374. #define LL_RCC_PLL_MUL_16 RCC_CFGR_PLLMULL16 /*!< PLL input clock*16 */
  375. #endif /*RCC_CFGR_PLLMULL6_5*/
  376. /**
  377. * @}
  378. */
  379. /** @defgroup RCC_LL_EC_PLLSOURCE PLL SOURCE
  380. * @{
  381. */
  382. #define LL_RCC_PLLSOURCE_HSI_DIV_2 0x00000000U /*!< HSI clock divided by 2 selected as PLL entry clock source */
  383. #define LL_RCC_PLLSOURCE_HSE RCC_CFGR_PLLSRC /*!< HSE/PREDIV1 clock selected as PLL entry clock source */
  384. #if defined(RCC_CFGR2_PREDIV1SRC)
  385. #define LL_RCC_PLLSOURCE_PLL2 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/PREDIV1 clock selected as PLL entry clock source */
  386. #endif /*RCC_CFGR2_PREDIV1SRC*/
  387. #define LL_RCC_PLLSOURCE_HSE_DIV_1 RCC_CFGR_PLLSRC /*!< HSE clock selected as PLL entry clock source */
  388. #if defined(RCC_CFGR2_PREDIV1)
  389. #define LL_RCC_PLLSOURCE_HSE_DIV_2 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV2) /*!< HSE/2 clock selected as PLL entry clock source */
  390. #define LL_RCC_PLLSOURCE_HSE_DIV_3 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV3) /*!< HSE/3 clock selected as PLL entry clock source */
  391. #define LL_RCC_PLLSOURCE_HSE_DIV_4 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV4) /*!< HSE/4 clock selected as PLL entry clock source */
  392. #define LL_RCC_PLLSOURCE_HSE_DIV_5 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV5) /*!< HSE/5 clock selected as PLL entry clock source */
  393. #define LL_RCC_PLLSOURCE_HSE_DIV_6 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV6) /*!< HSE/6 clock selected as PLL entry clock source */
  394. #define LL_RCC_PLLSOURCE_HSE_DIV_7 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV7) /*!< HSE/7 clock selected as PLL entry clock source */
  395. #define LL_RCC_PLLSOURCE_HSE_DIV_8 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV8) /*!< HSE/8 clock selected as PLL entry clock source */
  396. #define LL_RCC_PLLSOURCE_HSE_DIV_9 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV9) /*!< HSE/9 clock selected as PLL entry clock source */
  397. #define LL_RCC_PLLSOURCE_HSE_DIV_10 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV10) /*!< HSE/10 clock selected as PLL entry clock source */
  398. #define LL_RCC_PLLSOURCE_HSE_DIV_11 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV11) /*!< HSE/11 clock selected as PLL entry clock source */
  399. #define LL_RCC_PLLSOURCE_HSE_DIV_12 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV12) /*!< HSE/12 clock selected as PLL entry clock source */
  400. #define LL_RCC_PLLSOURCE_HSE_DIV_13 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV13) /*!< HSE/13 clock selected as PLL entry clock source */
  401. #define LL_RCC_PLLSOURCE_HSE_DIV_14 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV14) /*!< HSE/14 clock selected as PLL entry clock source */
  402. #define LL_RCC_PLLSOURCE_HSE_DIV_15 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV15) /*!< HSE/15 clock selected as PLL entry clock source */
  403. #define LL_RCC_PLLSOURCE_HSE_DIV_16 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV16) /*!< HSE/16 clock selected as PLL entry clock source */
  404. #if defined(RCC_CFGR2_PREDIV1SRC)
  405. #define LL_RCC_PLLSOURCE_PLL2_DIV_2 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV2 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/2 clock selected as PLL entry clock source */
  406. #define LL_RCC_PLLSOURCE_PLL2_DIV_3 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV3 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/3 clock selected as PLL entry clock source */
  407. #define LL_RCC_PLLSOURCE_PLL2_DIV_4 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV4 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/4 clock selected as PLL entry clock source */
  408. #define LL_RCC_PLLSOURCE_PLL2_DIV_5 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV5 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/5 clock selected as PLL entry clock source */
  409. #define LL_RCC_PLLSOURCE_PLL2_DIV_6 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV6 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/6 clock selected as PLL entry clock source */
  410. #define LL_RCC_PLLSOURCE_PLL2_DIV_7 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV7 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/7 clock selected as PLL entry clock source */
  411. #define LL_RCC_PLLSOURCE_PLL2_DIV_8 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV8 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/8 clock selected as PLL entry clock source */
  412. #define LL_RCC_PLLSOURCE_PLL2_DIV_9 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV9 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/9 clock selected as PLL entry clock source */
  413. #define LL_RCC_PLLSOURCE_PLL2_DIV_10 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV10 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/10 clock selected as PLL entry clock source */
  414. #define LL_RCC_PLLSOURCE_PLL2_DIV_11 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV11 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/11 clock selected as PLL entry clock source */
  415. #define LL_RCC_PLLSOURCE_PLL2_DIV_12 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV12 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/12 clock selected as PLL entry clock source */
  416. #define LL_RCC_PLLSOURCE_PLL2_DIV_13 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV13 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/13 clock selected as PLL entry clock source */
  417. #define LL_RCC_PLLSOURCE_PLL2_DIV_14 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV14 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/14 clock selected as PLL entry clock source */
  418. #define LL_RCC_PLLSOURCE_PLL2_DIV_15 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV15 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/15 clock selected as PLL entry clock source */
  419. #define LL_RCC_PLLSOURCE_PLL2_DIV_16 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV16 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/16 clock selected as PLL entry clock source */
  420. #endif /*RCC_CFGR2_PREDIV1SRC*/
  421. #else
  422. #define LL_RCC_PLLSOURCE_HSE_DIV_2 (RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE) /*!< HSE/2 clock selected as PLL entry clock source */
  423. #endif /*RCC_CFGR2_PREDIV1*/
  424. /**
  425. * @}
  426. */
  427. /** @defgroup RCC_LL_EC_PREDIV_DIV PREDIV Division factor
  428. * @{
  429. */
  430. #if defined(RCC_CFGR2_PREDIV1)
  431. #define LL_RCC_PREDIV_DIV_1 RCC_CFGR2_PREDIV1_DIV1 /*!< PREDIV1 input clock not divided */
  432. #define LL_RCC_PREDIV_DIV_2 RCC_CFGR2_PREDIV1_DIV2 /*!< PREDIV1 input clock divided by 2 */
  433. #define LL_RCC_PREDIV_DIV_3 RCC_CFGR2_PREDIV1_DIV3 /*!< PREDIV1 input clock divided by 3 */
  434. #define LL_RCC_PREDIV_DIV_4 RCC_CFGR2_PREDIV1_DIV4 /*!< PREDIV1 input clock divided by 4 */
  435. #define LL_RCC_PREDIV_DIV_5 RCC_CFGR2_PREDIV1_DIV5 /*!< PREDIV1 input clock divided by 5 */
  436. #define LL_RCC_PREDIV_DIV_6 RCC_CFGR2_PREDIV1_DIV6 /*!< PREDIV1 input clock divided by 6 */
  437. #define LL_RCC_PREDIV_DIV_7 RCC_CFGR2_PREDIV1_DIV7 /*!< PREDIV1 input clock divided by 7 */
  438. #define LL_RCC_PREDIV_DIV_8 RCC_CFGR2_PREDIV1_DIV8 /*!< PREDIV1 input clock divided by 8 */
  439. #define LL_RCC_PREDIV_DIV_9 RCC_CFGR2_PREDIV1_DIV9 /*!< PREDIV1 input clock divided by 9 */
  440. #define LL_RCC_PREDIV_DIV_10 RCC_CFGR2_PREDIV1_DIV10 /*!< PREDIV1 input clock divided by 10 */
  441. #define LL_RCC_PREDIV_DIV_11 RCC_CFGR2_PREDIV1_DIV11 /*!< PREDIV1 input clock divided by 11 */
  442. #define LL_RCC_PREDIV_DIV_12 RCC_CFGR2_PREDIV1_DIV12 /*!< PREDIV1 input clock divided by 12 */
  443. #define LL_RCC_PREDIV_DIV_13 RCC_CFGR2_PREDIV1_DIV13 /*!< PREDIV1 input clock divided by 13 */
  444. #define LL_RCC_PREDIV_DIV_14 RCC_CFGR2_PREDIV1_DIV14 /*!< PREDIV1 input clock divided by 14 */
  445. #define LL_RCC_PREDIV_DIV_15 RCC_CFGR2_PREDIV1_DIV15 /*!< PREDIV1 input clock divided by 15 */
  446. #define LL_RCC_PREDIV_DIV_16 RCC_CFGR2_PREDIV1_DIV16 /*!< PREDIV1 input clock divided by 16 */
  447. #else
  448. #define LL_RCC_PREDIV_DIV_1 0x00000000U /*!< HSE divider clock clock not divided */
  449. #define LL_RCC_PREDIV_DIV_2 RCC_CFGR_PLLXTPRE /*!< HSE divider clock divided by 2 for PLL entry */
  450. #endif /*RCC_CFGR2_PREDIV1*/
  451. /**
  452. * @}
  453. */
  454. #if defined(RCC_PLLI2S_SUPPORT)
  455. /** @defgroup RCC_LL_EC_PLLI2S_MUL PLLI2S MUL
  456. * @{
  457. */
  458. #define LL_RCC_PLLI2S_MUL_8 RCC_CFGR2_PLL3MUL8 /*!< PLLI2S input clock * 8 */
  459. #define LL_RCC_PLLI2S_MUL_9 RCC_CFGR2_PLL3MUL9 /*!< PLLI2S input clock * 9 */
  460. #define LL_RCC_PLLI2S_MUL_10 RCC_CFGR2_PLL3MUL10 /*!< PLLI2S input clock * 10 */
  461. #define LL_RCC_PLLI2S_MUL_11 RCC_CFGR2_PLL3MUL11 /*!< PLLI2S input clock * 11 */
  462. #define LL_RCC_PLLI2S_MUL_12 RCC_CFGR2_PLL3MUL12 /*!< PLLI2S input clock * 12 */
  463. #define LL_RCC_PLLI2S_MUL_13 RCC_CFGR2_PLL3MUL13 /*!< PLLI2S input clock * 13 */
  464. #define LL_RCC_PLLI2S_MUL_14 RCC_CFGR2_PLL3MUL14 /*!< PLLI2S input clock * 14 */
  465. #define LL_RCC_PLLI2S_MUL_16 RCC_CFGR2_PLL3MUL16 /*!< PLLI2S input clock * 16 */
  466. #define LL_RCC_PLLI2S_MUL_20 RCC_CFGR2_PLL3MUL20 /*!< PLLI2S input clock * 20 */
  467. /**
  468. * @}
  469. */
  470. #endif /* RCC_PLLI2S_SUPPORT */
  471. #if defined(RCC_PLL2_SUPPORT)
  472. /** @defgroup RCC_LL_EC_PLL2_MUL PLL2 MUL
  473. * @{
  474. */
  475. #define LL_RCC_PLL2_MUL_8 RCC_CFGR2_PLL2MUL8 /*!< PLL2 input clock * 8 */
  476. #define LL_RCC_PLL2_MUL_9 RCC_CFGR2_PLL2MUL9 /*!< PLL2 input clock * 9 */
  477. #define LL_RCC_PLL2_MUL_10 RCC_CFGR2_PLL2MUL10 /*!< PLL2 input clock * 10 */
  478. #define LL_RCC_PLL2_MUL_11 RCC_CFGR2_PLL2MUL11 /*!< PLL2 input clock * 11 */
  479. #define LL_RCC_PLL2_MUL_12 RCC_CFGR2_PLL2MUL12 /*!< PLL2 input clock * 12 */
  480. #define LL_RCC_PLL2_MUL_13 RCC_CFGR2_PLL2MUL13 /*!< PLL2 input clock * 13 */
  481. #define LL_RCC_PLL2_MUL_14 RCC_CFGR2_PLL2MUL14 /*!< PLL2 input clock * 14 */
  482. #define LL_RCC_PLL2_MUL_16 RCC_CFGR2_PLL2MUL16 /*!< PLL2 input clock * 16 */
  483. #define LL_RCC_PLL2_MUL_20 RCC_CFGR2_PLL2MUL20 /*!< PLL2 input clock * 20 */
  484. /**
  485. * @}
  486. */
  487. #endif /* RCC_PLL2_SUPPORT */
  488. /**
  489. * @}
  490. */
  491. /* Exported macro ------------------------------------------------------------*/
  492. /** @defgroup RCC_LL_Exported_Macros RCC Exported Macros
  493. * @{
  494. */
  495. /** @defgroup RCC_LL_EM_WRITE_READ Common Write and read registers Macros
  496. * @{
  497. */
  498. /**
  499. * @brief Write a value in RCC register
  500. * @param __REG__ Register to be written
  501. * @param __VALUE__ Value to be written in the register
  502. * @retval None
  503. */
  504. #define LL_RCC_WriteReg(__REG__, __VALUE__) WRITE_REG(RCC->__REG__, (__VALUE__))
  505. /**
  506. * @brief Read a value in RCC register
  507. * @param __REG__ Register to be read
  508. * @retval Register value
  509. */
  510. #define LL_RCC_ReadReg(__REG__) READ_REG(RCC->__REG__)
  511. /**
  512. * @}
  513. */
  514. /** @defgroup RCC_LL_EM_CALC_FREQ Calculate frequencies
  515. * @{
  516. */
  517. #if defined(RCC_CFGR_PLLMULL6_5)
  518. /**
  519. * @brief Helper macro to calculate the PLLCLK frequency
  520. * @note ex: @ref __LL_RCC_CALC_PLLCLK_FREQ (HSE_VALUE / (@ref LL_RCC_PLL_GetPrediv () + 1), @ref LL_RCC_PLL_GetMultiplicator());
  521. * @param __INPUTFREQ__ PLL Input frequency (based on HSE div Prediv1 / HSI div 2 / PLL2 div Prediv1)
  522. * @param __PLLMUL__: This parameter can be one of the following values:
  523. * @arg @ref LL_RCC_PLL_MUL_4
  524. * @arg @ref LL_RCC_PLL_MUL_5
  525. * @arg @ref LL_RCC_PLL_MUL_6
  526. * @arg @ref LL_RCC_PLL_MUL_7
  527. * @arg @ref LL_RCC_PLL_MUL_8
  528. * @arg @ref LL_RCC_PLL_MUL_9
  529. * @arg @ref LL_RCC_PLL_MUL_6_5
  530. * @retval PLL clock frequency (in Hz)
  531. */
  532. #define __LL_RCC_CALC_PLLCLK_FREQ(__INPUTFREQ__, __PLLMUL__) \
  533. (((__PLLMUL__) != RCC_CFGR_PLLMULL6_5) ? \
  534. ((__INPUTFREQ__) * ((((__PLLMUL__) & RCC_CFGR_PLLMULL) >> RCC_CFGR_PLLMULL_Pos) + 2U)) :\
  535. (((__INPUTFREQ__) * 13U) / 2U))
  536. #else
  537. /**
  538. * @brief Helper macro to calculate the PLLCLK frequency
  539. * @note ex: @ref __LL_RCC_CALC_PLLCLK_FREQ (HSE_VALUE / (@ref LL_RCC_PLL_GetPrediv () + 1), @ref LL_RCC_PLL_GetMultiplicator ());
  540. * @param __INPUTFREQ__ PLL Input frequency (based on HSE div Prediv1 or div 2 / HSI div 2)
  541. * @param __PLLMUL__: This parameter can be one of the following values:
  542. * @arg @ref LL_RCC_PLL_MUL_2
  543. * @arg @ref LL_RCC_PLL_MUL_3
  544. * @arg @ref LL_RCC_PLL_MUL_4
  545. * @arg @ref LL_RCC_PLL_MUL_5
  546. * @arg @ref LL_RCC_PLL_MUL_6
  547. * @arg @ref LL_RCC_PLL_MUL_7
  548. * @arg @ref LL_RCC_PLL_MUL_8
  549. * @arg @ref LL_RCC_PLL_MUL_9
  550. * @arg @ref LL_RCC_PLL_MUL_10
  551. * @arg @ref LL_RCC_PLL_MUL_11
  552. * @arg @ref LL_RCC_PLL_MUL_12
  553. * @arg @ref LL_RCC_PLL_MUL_13
  554. * @arg @ref LL_RCC_PLL_MUL_14
  555. * @arg @ref LL_RCC_PLL_MUL_15
  556. * @arg @ref LL_RCC_PLL_MUL_16
  557. * @retval PLL clock frequency (in Hz)
  558. */
  559. #define __LL_RCC_CALC_PLLCLK_FREQ(__INPUTFREQ__, __PLLMUL__) ((__INPUTFREQ__) * (((__PLLMUL__) >> RCC_CFGR_PLLMULL_Pos) + 2U))
  560. #endif /* RCC_CFGR_PLLMULL6_5 */
  561. #if defined(RCC_PLLI2S_SUPPORT)
  562. /**
  563. * @brief Helper macro to calculate the PLLI2S frequency
  564. * @note ex: @ref __LL_RCC_CALC_PLLI2SCLK_FREQ (HSE_VALUE, @ref LL_RCC_PLLI2S_GetMultiplicator (), @ref LL_RCC_HSE_GetPrediv2 ());
  565. * @param __INPUTFREQ__ PLLI2S Input frequency (based on HSE value)
  566. * @param __PLLI2SMUL__: This parameter can be one of the following values:
  567. * @arg @ref LL_RCC_PLLI2S_MUL_8
  568. * @arg @ref LL_RCC_PLLI2S_MUL_9
  569. * @arg @ref LL_RCC_PLLI2S_MUL_10
  570. * @arg @ref LL_RCC_PLLI2S_MUL_11
  571. * @arg @ref LL_RCC_PLLI2S_MUL_12
  572. * @arg @ref LL_RCC_PLLI2S_MUL_13
  573. * @arg @ref LL_RCC_PLLI2S_MUL_14
  574. * @arg @ref LL_RCC_PLLI2S_MUL_16
  575. * @arg @ref LL_RCC_PLLI2S_MUL_20
  576. * @param __PLLI2SDIV__: This parameter can be one of the following values:
  577. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  578. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  579. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  580. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  581. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  582. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  583. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  584. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  585. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  586. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  587. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  588. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  589. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  590. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  591. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  592. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  593. * @retval PLLI2S clock frequency (in Hz)
  594. */
  595. #define __LL_RCC_CALC_PLLI2SCLK_FREQ(__INPUTFREQ__, __PLLI2SMUL__, __PLLI2SDIV__) (((__INPUTFREQ__) * (((__PLLI2SMUL__) >> RCC_CFGR2_PLL3MUL_Pos) + 2U)) / (((__PLLI2SDIV__) >> RCC_CFGR2_PREDIV2_Pos) + 1U))
  596. #endif /* RCC_PLLI2S_SUPPORT */
  597. #if defined(RCC_PLL2_SUPPORT)
  598. /**
  599. * @brief Helper macro to calculate the PLL2 frequency
  600. * @note ex: @ref __LL_RCC_CALC_PLL2CLK_FREQ (HSE_VALUE, @ref LL_RCC_PLL2_GetMultiplicator (), @ref LL_RCC_HSE_GetPrediv2 ());
  601. * @param __INPUTFREQ__ PLL2 Input frequency (based on HSE value)
  602. * @param __PLL2MUL__: This parameter can be one of the following values:
  603. * @arg @ref LL_RCC_PLL2_MUL_8
  604. * @arg @ref LL_RCC_PLL2_MUL_9
  605. * @arg @ref LL_RCC_PLL2_MUL_10
  606. * @arg @ref LL_RCC_PLL2_MUL_11
  607. * @arg @ref LL_RCC_PLL2_MUL_12
  608. * @arg @ref LL_RCC_PLL2_MUL_13
  609. * @arg @ref LL_RCC_PLL2_MUL_14
  610. * @arg @ref LL_RCC_PLL2_MUL_16
  611. * @arg @ref LL_RCC_PLL2_MUL_20
  612. * @param __PLL2DIV__: This parameter can be one of the following values:
  613. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  614. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  615. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  616. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  617. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  618. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  619. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  620. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  621. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  622. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  623. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  624. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  625. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  626. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  627. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  628. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  629. * @retval PLL2 clock frequency (in Hz)
  630. */
  631. #define __LL_RCC_CALC_PLL2CLK_FREQ(__INPUTFREQ__, __PLL2MUL__, __PLL2DIV__) (((__INPUTFREQ__) * (((__PLL2MUL__) >> RCC_CFGR2_PLL2MUL_Pos) + 2U)) / (((__PLL2DIV__) >> RCC_CFGR2_PREDIV2_Pos) + 1U))
  632. #endif /* RCC_PLL2_SUPPORT */
  633. /**
  634. * @brief Helper macro to calculate the HCLK frequency
  635. * @note: __AHBPRESCALER__ be retrieved by @ref LL_RCC_GetAHBPrescaler
  636. * ex: __LL_RCC_CALC_HCLK_FREQ(LL_RCC_GetAHBPrescaler())
  637. * @param __SYSCLKFREQ__ SYSCLK frequency (based on HSE/HSI/PLLCLK)
  638. * @param __AHBPRESCALER__: This parameter can be one of the following values:
  639. * @arg @ref LL_RCC_SYSCLK_DIV_1
  640. * @arg @ref LL_RCC_SYSCLK_DIV_2
  641. * @arg @ref LL_RCC_SYSCLK_DIV_4
  642. * @arg @ref LL_RCC_SYSCLK_DIV_8
  643. * @arg @ref LL_RCC_SYSCLK_DIV_16
  644. * @arg @ref LL_RCC_SYSCLK_DIV_64
  645. * @arg @ref LL_RCC_SYSCLK_DIV_128
  646. * @arg @ref LL_RCC_SYSCLK_DIV_256
  647. * @arg @ref LL_RCC_SYSCLK_DIV_512
  648. * @retval HCLK clock frequency (in Hz)
  649. */
  650. #define __LL_RCC_CALC_HCLK_FREQ(__SYSCLKFREQ__, __AHBPRESCALER__) ((__SYSCLKFREQ__) >> AHBPrescTable[((__AHBPRESCALER__) & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos])
  651. /**
  652. * @brief Helper macro to calculate the PCLK1 frequency (ABP1)
  653. * @note: __APB1PRESCALER__ be retrieved by @ref LL_RCC_GetAPB1Prescaler
  654. * ex: __LL_RCC_CALC_PCLK1_FREQ(LL_RCC_GetAPB1Prescaler())
  655. * @param __HCLKFREQ__ HCLK frequency
  656. * @param __APB1PRESCALER__: This parameter can be one of the following values:
  657. * @arg @ref LL_RCC_APB1_DIV_1
  658. * @arg @ref LL_RCC_APB1_DIV_2
  659. * @arg @ref LL_RCC_APB1_DIV_4
  660. * @arg @ref LL_RCC_APB1_DIV_8
  661. * @arg @ref LL_RCC_APB1_DIV_16
  662. * @retval PCLK1 clock frequency (in Hz)
  663. */
  664. #define __LL_RCC_CALC_PCLK1_FREQ(__HCLKFREQ__, __APB1PRESCALER__) ((__HCLKFREQ__) >> APBPrescTable[(__APB1PRESCALER__) >> RCC_CFGR_PPRE1_Pos])
  665. /**
  666. * @brief Helper macro to calculate the PCLK2 frequency (ABP2)
  667. * @note: __APB2PRESCALER__ be retrieved by @ref LL_RCC_GetAPB2Prescaler
  668. * ex: __LL_RCC_CALC_PCLK2_FREQ(LL_RCC_GetAPB2Prescaler())
  669. * @param __HCLKFREQ__ HCLK frequency
  670. * @param __APB2PRESCALER__: This parameter can be one of the following values:
  671. * @arg @ref LL_RCC_APB2_DIV_1
  672. * @arg @ref LL_RCC_APB2_DIV_2
  673. * @arg @ref LL_RCC_APB2_DIV_4
  674. * @arg @ref LL_RCC_APB2_DIV_8
  675. * @arg @ref LL_RCC_APB2_DIV_16
  676. * @retval PCLK2 clock frequency (in Hz)
  677. */
  678. #define __LL_RCC_CALC_PCLK2_FREQ(__HCLKFREQ__, __APB2PRESCALER__) ((__HCLKFREQ__) >> APBPrescTable[(__APB2PRESCALER__) >> RCC_CFGR_PPRE2_Pos])
  679. /**
  680. * @}
  681. */
  682. /**
  683. * @}
  684. */
  685. /* Exported functions --------------------------------------------------------*/
  686. /** @defgroup RCC_LL_Exported_Functions RCC Exported Functions
  687. * @{
  688. */
  689. /** @defgroup RCC_LL_EF_HSE HSE
  690. * @{
  691. */
  692. /**
  693. * @brief Enable the Clock Security System.
  694. * @rmtoll CR CSSON LL_RCC_HSE_EnableCSS
  695. * @retval None
  696. */
  697. __STATIC_INLINE void LL_RCC_HSE_EnableCSS(void)
  698. {
  699. SET_BIT(RCC->CR, RCC_CR_CSSON);
  700. }
  701. /**
  702. * @brief Enable HSE external oscillator (HSE Bypass)
  703. * @rmtoll CR HSEBYP LL_RCC_HSE_EnableBypass
  704. * @retval None
  705. */
  706. __STATIC_INLINE void LL_RCC_HSE_EnableBypass(void)
  707. {
  708. SET_BIT(RCC->CR, RCC_CR_HSEBYP);
  709. }
  710. /**
  711. * @brief Disable HSE external oscillator (HSE Bypass)
  712. * @rmtoll CR HSEBYP LL_RCC_HSE_DisableBypass
  713. * @retval None
  714. */
  715. __STATIC_INLINE void LL_RCC_HSE_DisableBypass(void)
  716. {
  717. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP);
  718. }
  719. /**
  720. * @brief Enable HSE crystal oscillator (HSE ON)
  721. * @rmtoll CR HSEON LL_RCC_HSE_Enable
  722. * @retval None
  723. */
  724. __STATIC_INLINE void LL_RCC_HSE_Enable(void)
  725. {
  726. SET_BIT(RCC->CR, RCC_CR_HSEON);
  727. }
  728. /**
  729. * @brief Disable HSE crystal oscillator (HSE ON)
  730. * @rmtoll CR HSEON LL_RCC_HSE_Disable
  731. * @retval None
  732. */
  733. __STATIC_INLINE void LL_RCC_HSE_Disable(void)
  734. {
  735. CLEAR_BIT(RCC->CR, RCC_CR_HSEON);
  736. }
  737. /**
  738. * @brief Check if HSE oscillator Ready
  739. * @rmtoll CR HSERDY LL_RCC_HSE_IsReady
  740. * @retval State of bit (1 or 0).
  741. */
  742. __STATIC_INLINE uint32_t LL_RCC_HSE_IsReady(void)
  743. {
  744. return (READ_BIT(RCC->CR, RCC_CR_HSERDY) == (RCC_CR_HSERDY));
  745. }
  746. #if defined(RCC_CFGR2_PREDIV2)
  747. /**
  748. * @brief Get PREDIV2 division factor
  749. * @rmtoll CFGR2 PREDIV2 LL_RCC_HSE_GetPrediv2
  750. * @retval Returned value can be one of the following values:
  751. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  752. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  753. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  754. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  755. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  756. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  757. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  758. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  759. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  760. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  761. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  762. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  763. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  764. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  765. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  766. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  767. */
  768. __STATIC_INLINE uint32_t LL_RCC_HSE_GetPrediv2(void)
  769. {
  770. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV2));
  771. }
  772. #endif /* RCC_CFGR2_PREDIV2 */
  773. /**
  774. * @}
  775. */
  776. /** @defgroup RCC_LL_EF_HSI HSI
  777. * @{
  778. */
  779. /**
  780. * @brief Enable HSI oscillator
  781. * @rmtoll CR HSION LL_RCC_HSI_Enable
  782. * @retval None
  783. */
  784. __STATIC_INLINE void LL_RCC_HSI_Enable(void)
  785. {
  786. SET_BIT(RCC->CR, RCC_CR_HSION);
  787. }
  788. /**
  789. * @brief Disable HSI oscillator
  790. * @rmtoll CR HSION LL_RCC_HSI_Disable
  791. * @retval None
  792. */
  793. __STATIC_INLINE void LL_RCC_HSI_Disable(void)
  794. {
  795. CLEAR_BIT(RCC->CR, RCC_CR_HSION);
  796. }
  797. /**
  798. * @brief Check if HSI clock is ready
  799. * @rmtoll CR HSIRDY LL_RCC_HSI_IsReady
  800. * @retval State of bit (1 or 0).
  801. */
  802. __STATIC_INLINE uint32_t LL_RCC_HSI_IsReady(void)
  803. {
  804. return (READ_BIT(RCC->CR, RCC_CR_HSIRDY) == (RCC_CR_HSIRDY));
  805. }
  806. /**
  807. * @brief Get HSI Calibration value
  808. * @note When HSITRIM is written, HSICAL is updated with the sum of
  809. * HSITRIM and the factory trim value
  810. * @rmtoll CR HSICAL LL_RCC_HSI_GetCalibration
  811. * @retval Between Min_Data = 0x00 and Max_Data = 0xFF
  812. */
  813. __STATIC_INLINE uint32_t LL_RCC_HSI_GetCalibration(void)
  814. {
  815. return (uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSICAL) >> RCC_CR_HSICAL_Pos);
  816. }
  817. /**
  818. * @brief Set HSI Calibration trimming
  819. * @note user-programmable trimming value that is added to the HSICAL
  820. * @note Default value is 16, which, when added to the HSICAL value,
  821. * should trim the HSI to 16 MHz +/- 1 %
  822. * @rmtoll CR HSITRIM LL_RCC_HSI_SetCalibTrimming
  823. * @param Value between Min_Data = 0x00 and Max_Data = 0x1F
  824. * @retval None
  825. */
  826. __STATIC_INLINE void LL_RCC_HSI_SetCalibTrimming(uint32_t Value)
  827. {
  828. MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, Value << RCC_CR_HSITRIM_Pos);
  829. }
  830. /**
  831. * @brief Get HSI Calibration trimming
  832. * @rmtoll CR HSITRIM LL_RCC_HSI_GetCalibTrimming
  833. * @retval Between Min_Data = 0x00 and Max_Data = 0x1F
  834. */
  835. __STATIC_INLINE uint32_t LL_RCC_HSI_GetCalibTrimming(void)
  836. {
  837. return (uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSITRIM) >> RCC_CR_HSITRIM_Pos);
  838. }
  839. /**
  840. * @}
  841. */
  842. /** @defgroup RCC_LL_EF_LSE LSE
  843. * @{
  844. */
  845. /**
  846. * @brief Enable Low Speed External (LSE) crystal.
  847. * @rmtoll BDCR LSEON LL_RCC_LSE_Enable
  848. * @retval None
  849. */
  850. __STATIC_INLINE void LL_RCC_LSE_Enable(void)
  851. {
  852. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON);
  853. }
  854. /**
  855. * @brief Disable Low Speed External (LSE) crystal.
  856. * @rmtoll BDCR LSEON LL_RCC_LSE_Disable
  857. * @retval None
  858. */
  859. __STATIC_INLINE void LL_RCC_LSE_Disable(void)
  860. {
  861. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON);
  862. }
  863. /**
  864. * @brief Enable external clock source (LSE bypass).
  865. * @rmtoll BDCR LSEBYP LL_RCC_LSE_EnableBypass
  866. * @retval None
  867. */
  868. __STATIC_INLINE void LL_RCC_LSE_EnableBypass(void)
  869. {
  870. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP);
  871. }
  872. /**
  873. * @brief Disable external clock source (LSE bypass).
  874. * @rmtoll BDCR LSEBYP LL_RCC_LSE_DisableBypass
  875. * @retval None
  876. */
  877. __STATIC_INLINE void LL_RCC_LSE_DisableBypass(void)
  878. {
  879. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP);
  880. }
  881. /**
  882. * @brief Check if LSE oscillator Ready
  883. * @rmtoll BDCR LSERDY LL_RCC_LSE_IsReady
  884. * @retval State of bit (1 or 0).
  885. */
  886. __STATIC_INLINE uint32_t LL_RCC_LSE_IsReady(void)
  887. {
  888. return (READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == (RCC_BDCR_LSERDY));
  889. }
  890. /**
  891. * @}
  892. */
  893. /** @defgroup RCC_LL_EF_LSI LSI
  894. * @{
  895. */
  896. /**
  897. * @brief Enable LSI Oscillator
  898. * @rmtoll CSR LSION LL_RCC_LSI_Enable
  899. * @retval None
  900. */
  901. __STATIC_INLINE void LL_RCC_LSI_Enable(void)
  902. {
  903. SET_BIT(RCC->CSR, RCC_CSR_LSION);
  904. }
  905. /**
  906. * @brief Disable LSI Oscillator
  907. * @rmtoll CSR LSION LL_RCC_LSI_Disable
  908. * @retval None
  909. */
  910. __STATIC_INLINE void LL_RCC_LSI_Disable(void)
  911. {
  912. CLEAR_BIT(RCC->CSR, RCC_CSR_LSION);
  913. }
  914. /**
  915. * @brief Check if LSI is Ready
  916. * @rmtoll CSR LSIRDY LL_RCC_LSI_IsReady
  917. * @retval State of bit (1 or 0).
  918. */
  919. __STATIC_INLINE uint32_t LL_RCC_LSI_IsReady(void)
  920. {
  921. return (READ_BIT(RCC->CSR, RCC_CSR_LSIRDY) == (RCC_CSR_LSIRDY));
  922. }
  923. /**
  924. * @}
  925. */
  926. /** @defgroup RCC_LL_EF_System System
  927. * @{
  928. */
  929. /**
  930. * @brief Configure the system clock source
  931. * @rmtoll CFGR SW LL_RCC_SetSysClkSource
  932. * @param Source This parameter can be one of the following values:
  933. * @arg @ref LL_RCC_SYS_CLKSOURCE_HSI
  934. * @arg @ref LL_RCC_SYS_CLKSOURCE_HSE
  935. * @arg @ref LL_RCC_SYS_CLKSOURCE_PLL
  936. * @retval None
  937. */
  938. __STATIC_INLINE void LL_RCC_SetSysClkSource(uint32_t Source)
  939. {
  940. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, Source);
  941. }
  942. /**
  943. * @brief Get the system clock source
  944. * @rmtoll CFGR SWS LL_RCC_GetSysClkSource
  945. * @retval Returned value can be one of the following values:
  946. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSI
  947. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSE
  948. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_PLL
  949. */
  950. __STATIC_INLINE uint32_t LL_RCC_GetSysClkSource(void)
  951. {
  952. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_SWS));
  953. }
  954. /**
  955. * @brief Set AHB prescaler
  956. * @rmtoll CFGR HPRE LL_RCC_SetAHBPrescaler
  957. * @param Prescaler This parameter can be one of the following values:
  958. * @arg @ref LL_RCC_SYSCLK_DIV_1
  959. * @arg @ref LL_RCC_SYSCLK_DIV_2
  960. * @arg @ref LL_RCC_SYSCLK_DIV_4
  961. * @arg @ref LL_RCC_SYSCLK_DIV_8
  962. * @arg @ref LL_RCC_SYSCLK_DIV_16
  963. * @arg @ref LL_RCC_SYSCLK_DIV_64
  964. * @arg @ref LL_RCC_SYSCLK_DIV_128
  965. * @arg @ref LL_RCC_SYSCLK_DIV_256
  966. * @arg @ref LL_RCC_SYSCLK_DIV_512
  967. * @retval None
  968. */
  969. __STATIC_INLINE void LL_RCC_SetAHBPrescaler(uint32_t Prescaler)
  970. {
  971. MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, Prescaler);
  972. }
  973. /**
  974. * @brief Set APB1 prescaler
  975. * @rmtoll CFGR PPRE1 LL_RCC_SetAPB1Prescaler
  976. * @param Prescaler This parameter can be one of the following values:
  977. * @arg @ref LL_RCC_APB1_DIV_1
  978. * @arg @ref LL_RCC_APB1_DIV_2
  979. * @arg @ref LL_RCC_APB1_DIV_4
  980. * @arg @ref LL_RCC_APB1_DIV_8
  981. * @arg @ref LL_RCC_APB1_DIV_16
  982. * @retval None
  983. */
  984. __STATIC_INLINE void LL_RCC_SetAPB1Prescaler(uint32_t Prescaler)
  985. {
  986. MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE1, Prescaler);
  987. }
  988. /**
  989. * @brief Set APB2 prescaler
  990. * @rmtoll CFGR PPRE2 LL_RCC_SetAPB2Prescaler
  991. * @param Prescaler This parameter can be one of the following values:
  992. * @arg @ref LL_RCC_APB2_DIV_1
  993. * @arg @ref LL_RCC_APB2_DIV_2
  994. * @arg @ref LL_RCC_APB2_DIV_4
  995. * @arg @ref LL_RCC_APB2_DIV_8
  996. * @arg @ref LL_RCC_APB2_DIV_16
  997. * @retval None
  998. */
  999. __STATIC_INLINE void LL_RCC_SetAPB2Prescaler(uint32_t Prescaler)
  1000. {
  1001. MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE2, Prescaler);
  1002. }
  1003. /**
  1004. * @brief Get AHB prescaler
  1005. * @rmtoll CFGR HPRE LL_RCC_GetAHBPrescaler
  1006. * @retval Returned value can be one of the following values:
  1007. * @arg @ref LL_RCC_SYSCLK_DIV_1
  1008. * @arg @ref LL_RCC_SYSCLK_DIV_2
  1009. * @arg @ref LL_RCC_SYSCLK_DIV_4
  1010. * @arg @ref LL_RCC_SYSCLK_DIV_8
  1011. * @arg @ref LL_RCC_SYSCLK_DIV_16
  1012. * @arg @ref LL_RCC_SYSCLK_DIV_64
  1013. * @arg @ref LL_RCC_SYSCLK_DIV_128
  1014. * @arg @ref LL_RCC_SYSCLK_DIV_256
  1015. * @arg @ref LL_RCC_SYSCLK_DIV_512
  1016. */
  1017. __STATIC_INLINE uint32_t LL_RCC_GetAHBPrescaler(void)
  1018. {
  1019. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_HPRE));
  1020. }
  1021. /**
  1022. * @brief Get APB1 prescaler
  1023. * @rmtoll CFGR PPRE1 LL_RCC_GetAPB1Prescaler
  1024. * @retval Returned value can be one of the following values:
  1025. * @arg @ref LL_RCC_APB1_DIV_1
  1026. * @arg @ref LL_RCC_APB1_DIV_2
  1027. * @arg @ref LL_RCC_APB1_DIV_4
  1028. * @arg @ref LL_RCC_APB1_DIV_8
  1029. * @arg @ref LL_RCC_APB1_DIV_16
  1030. */
  1031. __STATIC_INLINE uint32_t LL_RCC_GetAPB1Prescaler(void)
  1032. {
  1033. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PPRE1));
  1034. }
  1035. /**
  1036. * @brief Get APB2 prescaler
  1037. * @rmtoll CFGR PPRE2 LL_RCC_GetAPB2Prescaler
  1038. * @retval Returned value can be one of the following values:
  1039. * @arg @ref LL_RCC_APB2_DIV_1
  1040. * @arg @ref LL_RCC_APB2_DIV_2
  1041. * @arg @ref LL_RCC_APB2_DIV_4
  1042. * @arg @ref LL_RCC_APB2_DIV_8
  1043. * @arg @ref LL_RCC_APB2_DIV_16
  1044. */
  1045. __STATIC_INLINE uint32_t LL_RCC_GetAPB2Prescaler(void)
  1046. {
  1047. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PPRE2));
  1048. }
  1049. /**
  1050. * @}
  1051. */
  1052. /** @defgroup RCC_LL_EF_MCO MCO
  1053. * @{
  1054. */
  1055. /**
  1056. * @brief Configure MCOx
  1057. * @rmtoll CFGR MCO LL_RCC_ConfigMCO
  1058. * @param MCOxSource This parameter can be one of the following values:
  1059. * @arg @ref LL_RCC_MCO1SOURCE_NOCLOCK
  1060. * @arg @ref LL_RCC_MCO1SOURCE_SYSCLK
  1061. * @arg @ref LL_RCC_MCO1SOURCE_HSI
  1062. * @arg @ref LL_RCC_MCO1SOURCE_HSE
  1063. * @arg @ref LL_RCC_MCO1SOURCE_PLLCLK_DIV_2
  1064. * @arg @ref LL_RCC_MCO1SOURCE_PLL2CLK (*)
  1065. * @arg @ref LL_RCC_MCO1SOURCE_PLLI2SCLK_DIV2 (*)
  1066. * @arg @ref LL_RCC_MCO1SOURCE_EXT_HSE (*)
  1067. * @arg @ref LL_RCC_MCO1SOURCE_PLLI2SCLK (*)
  1068. *
  1069. * (*) value not defined in all devices
  1070. * @retval None
  1071. */
  1072. __STATIC_INLINE void LL_RCC_ConfigMCO(uint32_t MCOxSource)
  1073. {
  1074. MODIFY_REG(RCC->CFGR, RCC_CFGR_MCOSEL, MCOxSource);
  1075. }
  1076. /**
  1077. * @}
  1078. */
  1079. /** @defgroup RCC_LL_EF_Peripheral_Clock_Source Peripheral Clock Source
  1080. * @{
  1081. */
  1082. #if defined(RCC_CFGR2_I2S2SRC)
  1083. /**
  1084. * @brief Configure I2Sx clock source
  1085. * @rmtoll CFGR2 I2S2SRC LL_RCC_SetI2SClockSource\n
  1086. * CFGR2 I2S3SRC LL_RCC_SetI2SClockSource
  1087. * @param I2SxSource This parameter can be one of the following values:
  1088. * @arg @ref LL_RCC_I2S2_CLKSOURCE_SYSCLK
  1089. * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLI2S_VCO
  1090. * @arg @ref LL_RCC_I2S3_CLKSOURCE_SYSCLK
  1091. * @arg @ref LL_RCC_I2S3_CLKSOURCE_PLLI2S_VCO
  1092. * @retval None
  1093. */
  1094. __STATIC_INLINE void LL_RCC_SetI2SClockSource(uint32_t I2SxSource)
  1095. {
  1096. MODIFY_REG(RCC->CFGR2, (I2SxSource & 0xFFFF0000U), (I2SxSource << 16U));
  1097. }
  1098. #endif /* RCC_CFGR2_I2S2SRC */
  1099. #if defined(USB_OTG_FS) || defined(USB)
  1100. /**
  1101. * @brief Configure USB clock source
  1102. * @rmtoll CFGR OTGFSPRE LL_RCC_SetUSBClockSource\n
  1103. * CFGR USBPRE LL_RCC_SetUSBClockSource
  1104. * @param USBxSource This parameter can be one of the following values:
  1105. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL (*)
  1106. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5 (*)
  1107. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_2 (*)
  1108. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_3 (*)
  1109. *
  1110. * (*) value not defined in all devices
  1111. * @retval None
  1112. */
  1113. __STATIC_INLINE void LL_RCC_SetUSBClockSource(uint32_t USBxSource)
  1114. {
  1115. #if defined(RCC_CFGR_USBPRE)
  1116. MODIFY_REG(RCC->CFGR, RCC_CFGR_USBPRE, USBxSource);
  1117. #else /*RCC_CFGR_OTGFSPRE*/
  1118. MODIFY_REG(RCC->CFGR, RCC_CFGR_OTGFSPRE, USBxSource);
  1119. #endif /*RCC_CFGR_USBPRE*/
  1120. }
  1121. #endif /* USB_OTG_FS || USB */
  1122. /**
  1123. * @brief Configure ADC clock source
  1124. * @rmtoll CFGR ADCPRE LL_RCC_SetADCClockSource
  1125. * @param ADCxSource This parameter can be one of the following values:
  1126. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_2
  1127. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_4
  1128. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_6
  1129. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_8
  1130. * @retval None
  1131. */
  1132. __STATIC_INLINE void LL_RCC_SetADCClockSource(uint32_t ADCxSource)
  1133. {
  1134. MODIFY_REG(RCC->CFGR, RCC_CFGR_ADCPRE, ADCxSource);
  1135. }
  1136. #if defined(RCC_CFGR2_I2S2SRC)
  1137. /**
  1138. * @brief Get I2Sx clock source
  1139. * @rmtoll CFGR2 I2S2SRC LL_RCC_GetI2SClockSource\n
  1140. * CFGR2 I2S3SRC LL_RCC_GetI2SClockSource
  1141. * @param I2Sx This parameter can be one of the following values:
  1142. * @arg @ref LL_RCC_I2S2_CLKSOURCE
  1143. * @arg @ref LL_RCC_I2S3_CLKSOURCE
  1144. * @retval Returned value can be one of the following values:
  1145. * @arg @ref LL_RCC_I2S2_CLKSOURCE_SYSCLK
  1146. * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLI2S_VCO
  1147. * @arg @ref LL_RCC_I2S3_CLKSOURCE_SYSCLK
  1148. * @arg @ref LL_RCC_I2S3_CLKSOURCE_PLLI2S_VCO
  1149. */
  1150. __STATIC_INLINE uint32_t LL_RCC_GetI2SClockSource(uint32_t I2Sx)
  1151. {
  1152. return (uint32_t)(READ_BIT(RCC->CFGR2, I2Sx) >> 16U | I2Sx);
  1153. }
  1154. #endif /* RCC_CFGR2_I2S2SRC */
  1155. #if defined(USB_OTG_FS) || defined(USB)
  1156. /**
  1157. * @brief Get USBx clock source
  1158. * @rmtoll CFGR OTGFSPRE LL_RCC_GetUSBClockSource\n
  1159. * CFGR USBPRE LL_RCC_GetUSBClockSource
  1160. * @param USBx This parameter can be one of the following values:
  1161. * @arg @ref LL_RCC_USB_CLKSOURCE
  1162. * @retval Returned value can be one of the following values:
  1163. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL (*)
  1164. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5 (*)
  1165. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_2 (*)
  1166. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_3 (*)
  1167. *
  1168. * (*) value not defined in all devices
  1169. */
  1170. __STATIC_INLINE uint32_t LL_RCC_GetUSBClockSource(uint32_t USBx)
  1171. {
  1172. return (uint32_t)(READ_BIT(RCC->CFGR, USBx));
  1173. }
  1174. #endif /* USB_OTG_FS || USB */
  1175. /**
  1176. * @brief Get ADCx clock source
  1177. * @rmtoll CFGR ADCPRE LL_RCC_GetADCClockSource
  1178. * @param ADCx This parameter can be one of the following values:
  1179. * @arg @ref LL_RCC_ADC_CLKSOURCE
  1180. * @retval Returned value can be one of the following values:
  1181. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_2
  1182. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_4
  1183. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_6
  1184. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_8
  1185. */
  1186. __STATIC_INLINE uint32_t LL_RCC_GetADCClockSource(uint32_t ADCx)
  1187. {
  1188. return (uint32_t)(READ_BIT(RCC->CFGR, ADCx));
  1189. }
  1190. /**
  1191. * @}
  1192. */
  1193. /** @defgroup RCC_LL_EF_RTC RTC
  1194. * @{
  1195. */
  1196. /**
  1197. * @brief Set RTC Clock Source
  1198. * @note Once the RTC clock source has been selected, it cannot be changed any more unless
  1199. * the Backup domain is reset. The BDRST bit can be used to reset them.
  1200. * @rmtoll BDCR RTCSEL LL_RCC_SetRTCClockSource
  1201. * @param Source This parameter can be one of the following values:
  1202. * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE
  1203. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE
  1204. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI
  1205. * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE_DIV128
  1206. * @retval None
  1207. */
  1208. __STATIC_INLINE void LL_RCC_SetRTCClockSource(uint32_t Source)
  1209. {
  1210. MODIFY_REG(RCC->BDCR, RCC_BDCR_RTCSEL, Source);
  1211. }
  1212. /**
  1213. * @brief Get RTC Clock Source
  1214. * @rmtoll BDCR RTCSEL LL_RCC_GetRTCClockSource
  1215. * @retval Returned value can be one of the following values:
  1216. * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE
  1217. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE
  1218. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI
  1219. * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE_DIV128
  1220. */
  1221. __STATIC_INLINE uint32_t LL_RCC_GetRTCClockSource(void)
  1222. {
  1223. return (uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL));
  1224. }
  1225. /**
  1226. * @brief Enable RTC
  1227. * @rmtoll BDCR RTCEN LL_RCC_EnableRTC
  1228. * @retval None
  1229. */
  1230. __STATIC_INLINE void LL_RCC_EnableRTC(void)
  1231. {
  1232. SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN);
  1233. }
  1234. /**
  1235. * @brief Disable RTC
  1236. * @rmtoll BDCR RTCEN LL_RCC_DisableRTC
  1237. * @retval None
  1238. */
  1239. __STATIC_INLINE void LL_RCC_DisableRTC(void)
  1240. {
  1241. CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN);
  1242. }
  1243. /**
  1244. * @brief Check if RTC has been enabled or not
  1245. * @rmtoll BDCR RTCEN LL_RCC_IsEnabledRTC
  1246. * @retval State of bit (1 or 0).
  1247. */
  1248. __STATIC_INLINE uint32_t LL_RCC_IsEnabledRTC(void)
  1249. {
  1250. return (READ_BIT(RCC->BDCR, RCC_BDCR_RTCEN) == (RCC_BDCR_RTCEN));
  1251. }
  1252. /**
  1253. * @brief Force the Backup domain reset
  1254. * @rmtoll BDCR BDRST LL_RCC_ForceBackupDomainReset
  1255. * @retval None
  1256. */
  1257. __STATIC_INLINE void LL_RCC_ForceBackupDomainReset(void)
  1258. {
  1259. SET_BIT(RCC->BDCR, RCC_BDCR_BDRST);
  1260. }
  1261. /**
  1262. * @brief Release the Backup domain reset
  1263. * @rmtoll BDCR BDRST LL_RCC_ReleaseBackupDomainReset
  1264. * @retval None
  1265. */
  1266. __STATIC_INLINE void LL_RCC_ReleaseBackupDomainReset(void)
  1267. {
  1268. CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST);
  1269. }
  1270. /**
  1271. * @}
  1272. */
  1273. /** @defgroup RCC_LL_EF_PLL PLL
  1274. * @{
  1275. */
  1276. /**
  1277. * @brief Enable PLL
  1278. * @rmtoll CR PLLON LL_RCC_PLL_Enable
  1279. * @retval None
  1280. */
  1281. __STATIC_INLINE void LL_RCC_PLL_Enable(void)
  1282. {
  1283. SET_BIT(RCC->CR, RCC_CR_PLLON);
  1284. }
  1285. /**
  1286. * @brief Disable PLL
  1287. * @note Cannot be disabled if the PLL clock is used as the system clock
  1288. * @rmtoll CR PLLON LL_RCC_PLL_Disable
  1289. * @retval None
  1290. */
  1291. __STATIC_INLINE void LL_RCC_PLL_Disable(void)
  1292. {
  1293. CLEAR_BIT(RCC->CR, RCC_CR_PLLON);
  1294. }
  1295. /**
  1296. * @brief Check if PLL Ready
  1297. * @rmtoll CR PLLRDY LL_RCC_PLL_IsReady
  1298. * @retval State of bit (1 or 0).
  1299. */
  1300. __STATIC_INLINE uint32_t LL_RCC_PLL_IsReady(void)
  1301. {
  1302. return (READ_BIT(RCC->CR, RCC_CR_PLLRDY) == (RCC_CR_PLLRDY));
  1303. }
  1304. /**
  1305. * @brief Configure PLL used for SYSCLK Domain
  1306. * @rmtoll CFGR PLLSRC LL_RCC_PLL_ConfigDomain_SYS\n
  1307. * CFGR PLLXTPRE LL_RCC_PLL_ConfigDomain_SYS\n
  1308. * CFGR PLLMULL LL_RCC_PLL_ConfigDomain_SYS\n
  1309. * CFGR2 PREDIV1 LL_RCC_PLL_ConfigDomain_SYS\n
  1310. * CFGR2 PREDIV1SRC LL_RCC_PLL_ConfigDomain_SYS
  1311. * @param Source This parameter can be one of the following values:
  1312. * @arg @ref LL_RCC_PLLSOURCE_HSI_DIV_2
  1313. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_1
  1314. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_2 (*)
  1315. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_3 (*)
  1316. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_4 (*)
  1317. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_5 (*)
  1318. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_6 (*)
  1319. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_7 (*)
  1320. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_8 (*)
  1321. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_9 (*)
  1322. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_10 (*)
  1323. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_11 (*)
  1324. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_12 (*)
  1325. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_13 (*)
  1326. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_14 (*)
  1327. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_15 (*)
  1328. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_16 (*)
  1329. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_2 (*)
  1330. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_3 (*)
  1331. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_4 (*)
  1332. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_5 (*)
  1333. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_6 (*)
  1334. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_7 (*)
  1335. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_8 (*)
  1336. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_9 (*)
  1337. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_10 (*)
  1338. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_11 (*)
  1339. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_12 (*)
  1340. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_13 (*)
  1341. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_14 (*)
  1342. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_15 (*)
  1343. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_16 (*)
  1344. *
  1345. * (*) value not defined in all devices
  1346. * @param PLLMul This parameter can be one of the following values:
  1347. * @arg @ref LL_RCC_PLL_MUL_2 (*)
  1348. * @arg @ref LL_RCC_PLL_MUL_3 (*)
  1349. * @arg @ref LL_RCC_PLL_MUL_4
  1350. * @arg @ref LL_RCC_PLL_MUL_5
  1351. * @arg @ref LL_RCC_PLL_MUL_6
  1352. * @arg @ref LL_RCC_PLL_MUL_7
  1353. * @arg @ref LL_RCC_PLL_MUL_8
  1354. * @arg @ref LL_RCC_PLL_MUL_9
  1355. * @arg @ref LL_RCC_PLL_MUL_6_5 (*)
  1356. * @arg @ref LL_RCC_PLL_MUL_10 (*)
  1357. * @arg @ref LL_RCC_PLL_MUL_11 (*)
  1358. * @arg @ref LL_RCC_PLL_MUL_12 (*)
  1359. * @arg @ref LL_RCC_PLL_MUL_13 (*)
  1360. * @arg @ref LL_RCC_PLL_MUL_14 (*)
  1361. * @arg @ref LL_RCC_PLL_MUL_15 (*)
  1362. * @arg @ref LL_RCC_PLL_MUL_16 (*)
  1363. *
  1364. * (*) value not defined in all devices
  1365. * @retval None
  1366. */
  1367. __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SYS(uint32_t Source, uint32_t PLLMul)
  1368. {
  1369. MODIFY_REG(RCC->CFGR, RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL,
  1370. (Source & (RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE)) | PLLMul);
  1371. #if defined(RCC_CFGR2_PREDIV1)
  1372. #if defined(RCC_CFGR2_PREDIV1SRC)
  1373. MODIFY_REG(RCC->CFGR2, (RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC),
  1374. (Source & RCC_CFGR2_PREDIV1) | ((Source & (RCC_CFGR2_PREDIV1SRC << 4U)) >> 4U));
  1375. #else
  1376. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV1, (Source & RCC_CFGR2_PREDIV1));
  1377. #endif /*RCC_CFGR2_PREDIV1SRC*/
  1378. #endif /*RCC_CFGR2_PREDIV1*/
  1379. }
  1380. /**
  1381. * @brief Get the oscillator used as PLL clock source.
  1382. * @rmtoll CFGR PLLSRC LL_RCC_PLL_GetMainSource\n
  1383. * CFGR2 PREDIV1SRC LL_RCC_PLL_GetMainSource
  1384. * @retval Returned value can be one of the following values:
  1385. * @arg @ref LL_RCC_PLLSOURCE_HSI_DIV_2
  1386. * @arg @ref LL_RCC_PLLSOURCE_HSE
  1387. * @arg @ref LL_RCC_PLLSOURCE_PLL2 (*)
  1388. *
  1389. * (*) value not defined in all devices
  1390. */
  1391. __STATIC_INLINE uint32_t LL_RCC_PLL_GetMainSource(void)
  1392. {
  1393. #if defined(RCC_CFGR2_PREDIV1SRC)
  1394. register uint32_t pllsrc = READ_BIT(RCC->CFGR, RCC_CFGR_PLLSRC);
  1395. register uint32_t predivsrc = (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC) << 4U);
  1396. return (uint32_t)(pllsrc | predivsrc);
  1397. #else
  1398. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLSRC));
  1399. #endif /*RCC_CFGR2_PREDIV1SRC*/
  1400. }
  1401. /**
  1402. * @brief Get PLL multiplication Factor
  1403. * @rmtoll CFGR PLLMULL LL_RCC_PLL_GetMultiplicator
  1404. * @retval Returned value can be one of the following values:
  1405. * @arg @ref LL_RCC_PLL_MUL_2 (*)
  1406. * @arg @ref LL_RCC_PLL_MUL_3 (*)
  1407. * @arg @ref LL_RCC_PLL_MUL_4
  1408. * @arg @ref LL_RCC_PLL_MUL_5
  1409. * @arg @ref LL_RCC_PLL_MUL_6
  1410. * @arg @ref LL_RCC_PLL_MUL_7
  1411. * @arg @ref LL_RCC_PLL_MUL_8
  1412. * @arg @ref LL_RCC_PLL_MUL_9
  1413. * @arg @ref LL_RCC_PLL_MUL_6_5 (*)
  1414. * @arg @ref LL_RCC_PLL_MUL_10 (*)
  1415. * @arg @ref LL_RCC_PLL_MUL_11 (*)
  1416. * @arg @ref LL_RCC_PLL_MUL_12 (*)
  1417. * @arg @ref LL_RCC_PLL_MUL_13 (*)
  1418. * @arg @ref LL_RCC_PLL_MUL_14 (*)
  1419. * @arg @ref LL_RCC_PLL_MUL_15 (*)
  1420. * @arg @ref LL_RCC_PLL_MUL_16 (*)
  1421. *
  1422. * (*) value not defined in all devices
  1423. */
  1424. __STATIC_INLINE uint32_t LL_RCC_PLL_GetMultiplicator(void)
  1425. {
  1426. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLMULL));
  1427. }
  1428. /**
  1429. * @brief Get PREDIV1 division factor for the main PLL
  1430. * @note They can be written only when the PLL is disabled
  1431. * @rmtoll CFGR2 PREDIV1 LL_RCC_PLL_GetPrediv\n
  1432. * CFGR2 PLLXTPRE LL_RCC_PLL_GetPrediv
  1433. * @retval Returned value can be one of the following values:
  1434. * @arg @ref LL_RCC_PREDIV_DIV_1
  1435. * @arg @ref LL_RCC_PREDIV_DIV_2
  1436. * @arg @ref LL_RCC_PREDIV_DIV_3 (*)
  1437. * @arg @ref LL_RCC_PREDIV_DIV_4 (*)
  1438. * @arg @ref LL_RCC_PREDIV_DIV_5 (*)
  1439. * @arg @ref LL_RCC_PREDIV_DIV_6 (*)
  1440. * @arg @ref LL_RCC_PREDIV_DIV_7 (*)
  1441. * @arg @ref LL_RCC_PREDIV_DIV_8 (*)
  1442. * @arg @ref LL_RCC_PREDIV_DIV_9 (*)
  1443. * @arg @ref LL_RCC_PREDIV_DIV_10 (*)
  1444. * @arg @ref LL_RCC_PREDIV_DIV_11 (*)
  1445. * @arg @ref LL_RCC_PREDIV_DIV_12 (*)
  1446. * @arg @ref LL_RCC_PREDIV_DIV_13 (*)
  1447. * @arg @ref LL_RCC_PREDIV_DIV_14 (*)
  1448. * @arg @ref LL_RCC_PREDIV_DIV_15 (*)
  1449. * @arg @ref LL_RCC_PREDIV_DIV_16 (*)
  1450. *
  1451. * (*) value not defined in all devices
  1452. */
  1453. __STATIC_INLINE uint32_t LL_RCC_PLL_GetPrediv(void)
  1454. {
  1455. #if defined(RCC_CFGR2_PREDIV1)
  1456. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1));
  1457. #else
  1458. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLXTPRE));
  1459. #endif /*RCC_CFGR2_PREDIV1*/
  1460. }
  1461. /**
  1462. * @}
  1463. */
  1464. #if defined(RCC_PLLI2S_SUPPORT)
  1465. /** @defgroup RCC_LL_EF_PLLI2S PLLI2S
  1466. * @{
  1467. */
  1468. /**
  1469. * @brief Enable PLLI2S
  1470. * @rmtoll CR PLL3ON LL_RCC_PLLI2S_Enable
  1471. * @retval None
  1472. */
  1473. __STATIC_INLINE void LL_RCC_PLLI2S_Enable(void)
  1474. {
  1475. SET_BIT(RCC->CR, RCC_CR_PLL3ON);
  1476. }
  1477. /**
  1478. * @brief Disable PLLI2S
  1479. * @rmtoll CR PLL3ON LL_RCC_PLLI2S_Disable
  1480. * @retval None
  1481. */
  1482. __STATIC_INLINE void LL_RCC_PLLI2S_Disable(void)
  1483. {
  1484. CLEAR_BIT(RCC->CR, RCC_CR_PLL3ON);
  1485. }
  1486. /**
  1487. * @brief Check if PLLI2S Ready
  1488. * @rmtoll CR PLL3RDY LL_RCC_PLLI2S_IsReady
  1489. * @retval State of bit (1 or 0).
  1490. */
  1491. __STATIC_INLINE uint32_t LL_RCC_PLLI2S_IsReady(void)
  1492. {
  1493. return (READ_BIT(RCC->CR, RCC_CR_PLL3RDY) == (RCC_CR_PLL3RDY));
  1494. }
  1495. /**
  1496. * @brief Configure PLLI2S used for I2S Domain
  1497. * @rmtoll CFGR2 PREDIV2 LL_RCC_PLL_ConfigDomain_PLLI2S\n
  1498. * CFGR2 PLL3MUL LL_RCC_PLL_ConfigDomain_PLLI2S
  1499. * @param Divider This parameter can be one of the following values:
  1500. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  1501. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  1502. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  1503. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  1504. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  1505. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  1506. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  1507. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  1508. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  1509. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  1510. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  1511. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  1512. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  1513. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  1514. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  1515. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  1516. * @param Multiplicator This parameter can be one of the following values:
  1517. * @arg @ref LL_RCC_PLLI2S_MUL_8
  1518. * @arg @ref LL_RCC_PLLI2S_MUL_9
  1519. * @arg @ref LL_RCC_PLLI2S_MUL_10
  1520. * @arg @ref LL_RCC_PLLI2S_MUL_11
  1521. * @arg @ref LL_RCC_PLLI2S_MUL_12
  1522. * @arg @ref LL_RCC_PLLI2S_MUL_13
  1523. * @arg @ref LL_RCC_PLLI2S_MUL_14
  1524. * @arg @ref LL_RCC_PLLI2S_MUL_16
  1525. * @arg @ref LL_RCC_PLLI2S_MUL_20
  1526. * @retval None
  1527. */
  1528. __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_PLLI2S(uint32_t Divider, uint32_t Multiplicator)
  1529. {
  1530. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL3MUL, Divider | Multiplicator);
  1531. }
  1532. /**
  1533. * @brief Get PLLI2S Multiplication Factor
  1534. * @rmtoll CFGR2 PLL3MUL LL_RCC_PLLI2S_GetMultiplicator
  1535. * @retval Returned value can be one of the following values:
  1536. * @arg @ref LL_RCC_PLLI2S_MUL_8
  1537. * @arg @ref LL_RCC_PLLI2S_MUL_9
  1538. * @arg @ref LL_RCC_PLLI2S_MUL_10
  1539. * @arg @ref LL_RCC_PLLI2S_MUL_11
  1540. * @arg @ref LL_RCC_PLLI2S_MUL_12
  1541. * @arg @ref LL_RCC_PLLI2S_MUL_13
  1542. * @arg @ref LL_RCC_PLLI2S_MUL_14
  1543. * @arg @ref LL_RCC_PLLI2S_MUL_16
  1544. * @arg @ref LL_RCC_PLLI2S_MUL_20
  1545. */
  1546. __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetMultiplicator(void)
  1547. {
  1548. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PLL3MUL));
  1549. }
  1550. /**
  1551. * @}
  1552. */
  1553. #endif /* RCC_PLLI2S_SUPPORT */
  1554. #if defined(RCC_PLL2_SUPPORT)
  1555. /** @defgroup RCC_LL_EF_PLL2 PLL2
  1556. * @{
  1557. */
  1558. /**
  1559. * @brief Enable PLL2
  1560. * @rmtoll CR PLL2ON LL_RCC_PLL2_Enable
  1561. * @retval None
  1562. */
  1563. __STATIC_INLINE void LL_RCC_PLL2_Enable(void)
  1564. {
  1565. SET_BIT(RCC->CR, RCC_CR_PLL2ON);
  1566. }
  1567. /**
  1568. * @brief Disable PLL2
  1569. * @rmtoll CR PLL2ON LL_RCC_PLL2_Disable
  1570. * @retval None
  1571. */
  1572. __STATIC_INLINE void LL_RCC_PLL2_Disable(void)
  1573. {
  1574. CLEAR_BIT(RCC->CR, RCC_CR_PLL2ON);
  1575. }
  1576. /**
  1577. * @brief Check if PLL2 Ready
  1578. * @rmtoll CR PLL2RDY LL_RCC_PLL2_IsReady
  1579. * @retval State of bit (1 or 0).
  1580. */
  1581. __STATIC_INLINE uint32_t LL_RCC_PLL2_IsReady(void)
  1582. {
  1583. return (READ_BIT(RCC->CR, RCC_CR_PLL2RDY) == (RCC_CR_PLL2RDY));
  1584. }
  1585. /**
  1586. * @brief Configure PLL2 used for PLL2 Domain
  1587. * @rmtoll CFGR2 PREDIV2 LL_RCC_PLL_ConfigDomain_PLL2\n
  1588. * CFGR2 PLL2MUL LL_RCC_PLL_ConfigDomain_PLL2
  1589. * @param Divider This parameter can be one of the following values:
  1590. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  1591. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  1592. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  1593. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  1594. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  1595. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  1596. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  1597. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  1598. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  1599. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  1600. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  1601. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  1602. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  1603. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  1604. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  1605. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  1606. * @param Multiplicator This parameter can be one of the following values:
  1607. * @arg @ref LL_RCC_PLL2_MUL_8
  1608. * @arg @ref LL_RCC_PLL2_MUL_9
  1609. * @arg @ref LL_RCC_PLL2_MUL_10
  1610. * @arg @ref LL_RCC_PLL2_MUL_11
  1611. * @arg @ref LL_RCC_PLL2_MUL_12
  1612. * @arg @ref LL_RCC_PLL2_MUL_13
  1613. * @arg @ref LL_RCC_PLL2_MUL_14
  1614. * @arg @ref LL_RCC_PLL2_MUL_16
  1615. * @arg @ref LL_RCC_PLL2_MUL_20
  1616. * @retval None
  1617. */
  1618. __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_PLL2(uint32_t Divider, uint32_t Multiplicator)
  1619. {
  1620. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL, Divider | Multiplicator);
  1621. }
  1622. /**
  1623. * @brief Get PLL2 Multiplication Factor
  1624. * @rmtoll CFGR2 PLL2MUL LL_RCC_PLL2_GetMultiplicator
  1625. * @retval Returned value can be one of the following values:
  1626. * @arg @ref LL_RCC_PLL2_MUL_8
  1627. * @arg @ref LL_RCC_PLL2_MUL_9
  1628. * @arg @ref LL_RCC_PLL2_MUL_10
  1629. * @arg @ref LL_RCC_PLL2_MUL_11
  1630. * @arg @ref LL_RCC_PLL2_MUL_12
  1631. * @arg @ref LL_RCC_PLL2_MUL_13
  1632. * @arg @ref LL_RCC_PLL2_MUL_14
  1633. * @arg @ref LL_RCC_PLL2_MUL_16
  1634. * @arg @ref LL_RCC_PLL2_MUL_20
  1635. */
  1636. __STATIC_INLINE uint32_t LL_RCC_PLL2_GetMultiplicator(void)
  1637. {
  1638. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PLL2MUL));
  1639. }
  1640. /**
  1641. * @}
  1642. */
  1643. #endif /* RCC_PLL2_SUPPORT */
  1644. /** @defgroup RCC_LL_EF_FLAG_Management FLAG Management
  1645. * @{
  1646. */
  1647. /**
  1648. * @brief Clear LSI ready interrupt flag
  1649. * @rmtoll CIR LSIRDYC LL_RCC_ClearFlag_LSIRDY
  1650. * @retval None
  1651. */
  1652. __STATIC_INLINE void LL_RCC_ClearFlag_LSIRDY(void)
  1653. {
  1654. SET_BIT(RCC->CIR, RCC_CIR_LSIRDYC);
  1655. }
  1656. /**
  1657. * @brief Clear LSE ready interrupt flag
  1658. * @rmtoll CIR LSERDYC LL_RCC_ClearFlag_LSERDY
  1659. * @retval None
  1660. */
  1661. __STATIC_INLINE void LL_RCC_ClearFlag_LSERDY(void)
  1662. {
  1663. SET_BIT(RCC->CIR, RCC_CIR_LSERDYC);
  1664. }
  1665. /**
  1666. * @brief Clear HSI ready interrupt flag
  1667. * @rmtoll CIR HSIRDYC LL_RCC_ClearFlag_HSIRDY
  1668. * @retval None
  1669. */
  1670. __STATIC_INLINE void LL_RCC_ClearFlag_HSIRDY(void)
  1671. {
  1672. SET_BIT(RCC->CIR, RCC_CIR_HSIRDYC);
  1673. }
  1674. /**
  1675. * @brief Clear HSE ready interrupt flag
  1676. * @rmtoll CIR HSERDYC LL_RCC_ClearFlag_HSERDY
  1677. * @retval None
  1678. */
  1679. __STATIC_INLINE void LL_RCC_ClearFlag_HSERDY(void)
  1680. {
  1681. SET_BIT(RCC->CIR, RCC_CIR_HSERDYC);
  1682. }
  1683. /**
  1684. * @brief Clear PLL ready interrupt flag
  1685. * @rmtoll CIR PLLRDYC LL_RCC_ClearFlag_PLLRDY
  1686. * @retval None
  1687. */
  1688. __STATIC_INLINE void LL_RCC_ClearFlag_PLLRDY(void)
  1689. {
  1690. SET_BIT(RCC->CIR, RCC_CIR_PLLRDYC);
  1691. }
  1692. #if defined(RCC_PLLI2S_SUPPORT)
  1693. /**
  1694. * @brief Clear PLLI2S ready interrupt flag
  1695. * @rmtoll CIR PLL3RDYC LL_RCC_ClearFlag_PLLI2SRDY
  1696. * @retval None
  1697. */
  1698. __STATIC_INLINE void LL_RCC_ClearFlag_PLLI2SRDY(void)
  1699. {
  1700. SET_BIT(RCC->CIR, RCC_CIR_PLL3RDYC);
  1701. }
  1702. #endif /* RCC_PLLI2S_SUPPORT */
  1703. #if defined(RCC_PLL2_SUPPORT)
  1704. /**
  1705. * @brief Clear PLL2 ready interrupt flag
  1706. * @rmtoll CIR PLL2RDYC LL_RCC_ClearFlag_PLL2RDY
  1707. * @retval None
  1708. */
  1709. __STATIC_INLINE void LL_RCC_ClearFlag_PLL2RDY(void)
  1710. {
  1711. SET_BIT(RCC->CIR, RCC_CIR_PLL2RDYC);
  1712. }
  1713. #endif /* RCC_PLL2_SUPPORT */
  1714. /**
  1715. * @brief Clear Clock security system interrupt flag
  1716. * @rmtoll CIR CSSC LL_RCC_ClearFlag_HSECSS
  1717. * @retval None
  1718. */
  1719. __STATIC_INLINE void LL_RCC_ClearFlag_HSECSS(void)
  1720. {
  1721. SET_BIT(RCC->CIR, RCC_CIR_CSSC);
  1722. }
  1723. /**
  1724. * @brief Check if LSI ready interrupt occurred or not
  1725. * @rmtoll CIR LSIRDYF LL_RCC_IsActiveFlag_LSIRDY
  1726. * @retval State of bit (1 or 0).
  1727. */
  1728. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSIRDY(void)
  1729. {
  1730. return (READ_BIT(RCC->CIR, RCC_CIR_LSIRDYF) == (RCC_CIR_LSIRDYF));
  1731. }
  1732. /**
  1733. * @brief Check if LSE ready interrupt occurred or not
  1734. * @rmtoll CIR LSERDYF LL_RCC_IsActiveFlag_LSERDY
  1735. * @retval State of bit (1 or 0).
  1736. */
  1737. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSERDY(void)
  1738. {
  1739. return (READ_BIT(RCC->CIR, RCC_CIR_LSERDYF) == (RCC_CIR_LSERDYF));
  1740. }
  1741. /**
  1742. * @brief Check if HSI ready interrupt occurred or not
  1743. * @rmtoll CIR HSIRDYF LL_RCC_IsActiveFlag_HSIRDY
  1744. * @retval State of bit (1 or 0).
  1745. */
  1746. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSIRDY(void)
  1747. {
  1748. return (READ_BIT(RCC->CIR, RCC_CIR_HSIRDYF) == (RCC_CIR_HSIRDYF));
  1749. }
  1750. /**
  1751. * @brief Check if HSE ready interrupt occurred or not
  1752. * @rmtoll CIR HSERDYF LL_RCC_IsActiveFlag_HSERDY
  1753. * @retval State of bit (1 or 0).
  1754. */
  1755. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSERDY(void)
  1756. {
  1757. return (READ_BIT(RCC->CIR, RCC_CIR_HSERDYF) == (RCC_CIR_HSERDYF));
  1758. }
  1759. /**
  1760. * @brief Check if PLL ready interrupt occurred or not
  1761. * @rmtoll CIR PLLRDYF LL_RCC_IsActiveFlag_PLLRDY
  1762. * @retval State of bit (1 or 0).
  1763. */
  1764. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLRDY(void)
  1765. {
  1766. return (READ_BIT(RCC->CIR, RCC_CIR_PLLRDYF) == (RCC_CIR_PLLRDYF));
  1767. }
  1768. #if defined(RCC_PLLI2S_SUPPORT)
  1769. /**
  1770. * @brief Check if PLLI2S ready interrupt occurred or not
  1771. * @rmtoll CIR PLL3RDYF LL_RCC_IsActiveFlag_PLLI2SRDY
  1772. * @retval State of bit (1 or 0).
  1773. */
  1774. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLI2SRDY(void)
  1775. {
  1776. return (READ_BIT(RCC->CIR, RCC_CIR_PLL3RDYF) == (RCC_CIR_PLL3RDYF));
  1777. }
  1778. #endif /* RCC_PLLI2S_SUPPORT */
  1779. #if defined(RCC_PLL2_SUPPORT)
  1780. /**
  1781. * @brief Check if PLL2 ready interrupt occurred or not
  1782. * @rmtoll CIR PLL2RDYF LL_RCC_IsActiveFlag_PLL2RDY
  1783. * @retval State of bit (1 or 0).
  1784. */
  1785. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLL2RDY(void)
  1786. {
  1787. return (READ_BIT(RCC->CIR, RCC_CIR_PLL2RDYF) == (RCC_CIR_PLL2RDYF));
  1788. }
  1789. #endif /* RCC_PLL2_SUPPORT */
  1790. /**
  1791. * @brief Check if Clock security system interrupt occurred or not
  1792. * @rmtoll CIR CSSF LL_RCC_IsActiveFlag_HSECSS
  1793. * @retval State of bit (1 or 0).
  1794. */
  1795. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSECSS(void)
  1796. {
  1797. return (READ_BIT(RCC->CIR, RCC_CIR_CSSF) == (RCC_CIR_CSSF));
  1798. }
  1799. /**
  1800. * @brief Check if RCC flag Independent Watchdog reset is set or not.
  1801. * @rmtoll CSR IWDGRSTF LL_RCC_IsActiveFlag_IWDGRST
  1802. * @retval State of bit (1 or 0).
  1803. */
  1804. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_IWDGRST(void)
  1805. {
  1806. return (READ_BIT(RCC->CSR, RCC_CSR_IWDGRSTF) == (RCC_CSR_IWDGRSTF));
  1807. }
  1808. /**
  1809. * @brief Check if RCC flag Low Power reset is set or not.
  1810. * @rmtoll CSR LPWRRSTF LL_RCC_IsActiveFlag_LPWRRST
  1811. * @retval State of bit (1 or 0).
  1812. */
  1813. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LPWRRST(void)
  1814. {
  1815. return (READ_BIT(RCC->CSR, RCC_CSR_LPWRRSTF) == (RCC_CSR_LPWRRSTF));
  1816. }
  1817. /**
  1818. * @brief Check if RCC flag Pin reset is set or not.
  1819. * @rmtoll CSR PINRSTF LL_RCC_IsActiveFlag_PINRST
  1820. * @retval State of bit (1 or 0).
  1821. */
  1822. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PINRST(void)
  1823. {
  1824. return (READ_BIT(RCC->CSR, RCC_CSR_PINRSTF) == (RCC_CSR_PINRSTF));
  1825. }
  1826. /**
  1827. * @brief Check if RCC flag POR/PDR reset is set or not.
  1828. * @rmtoll CSR PORRSTF LL_RCC_IsActiveFlag_PORRST
  1829. * @retval State of bit (1 or 0).
  1830. */
  1831. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PORRST(void)
  1832. {
  1833. return (READ_BIT(RCC->CSR, RCC_CSR_PORRSTF) == (RCC_CSR_PORRSTF));
  1834. }
  1835. /**
  1836. * @brief Check if RCC flag Software reset is set or not.
  1837. * @rmtoll CSR SFTRSTF LL_RCC_IsActiveFlag_SFTRST
  1838. * @retval State of bit (1 or 0).
  1839. */
  1840. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_SFTRST(void)
  1841. {
  1842. return (READ_BIT(RCC->CSR, RCC_CSR_SFTRSTF) == (RCC_CSR_SFTRSTF));
  1843. }
  1844. /**
  1845. * @brief Check if RCC flag Window Watchdog reset is set or not.
  1846. * @rmtoll CSR WWDGRSTF LL_RCC_IsActiveFlag_WWDGRST
  1847. * @retval State of bit (1 or 0).
  1848. */
  1849. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_WWDGRST(void)
  1850. {
  1851. return (READ_BIT(RCC->CSR, RCC_CSR_WWDGRSTF) == (RCC_CSR_WWDGRSTF));
  1852. }
  1853. /**
  1854. * @brief Set RMVF bit to clear the reset flags.
  1855. * @rmtoll CSR RMVF LL_RCC_ClearResetFlags
  1856. * @retval None
  1857. */
  1858. __STATIC_INLINE void LL_RCC_ClearResetFlags(void)
  1859. {
  1860. SET_BIT(RCC->CSR, RCC_CSR_RMVF);
  1861. }
  1862. /**
  1863. * @}
  1864. */
  1865. /** @defgroup RCC_LL_EF_IT_Management IT Management
  1866. * @{
  1867. */
  1868. /**
  1869. * @brief Enable LSI ready interrupt
  1870. * @rmtoll CIR LSIRDYIE LL_RCC_EnableIT_LSIRDY
  1871. * @retval None
  1872. */
  1873. __STATIC_INLINE void LL_RCC_EnableIT_LSIRDY(void)
  1874. {
  1875. SET_BIT(RCC->CIR, RCC_CIR_LSIRDYIE);
  1876. }
  1877. /**
  1878. * @brief Enable LSE ready interrupt
  1879. * @rmtoll CIR LSERDYIE LL_RCC_EnableIT_LSERDY
  1880. * @retval None
  1881. */
  1882. __STATIC_INLINE void LL_RCC_EnableIT_LSERDY(void)
  1883. {
  1884. SET_BIT(RCC->CIR, RCC_CIR_LSERDYIE);
  1885. }
  1886. /**
  1887. * @brief Enable HSI ready interrupt
  1888. * @rmtoll CIR HSIRDYIE LL_RCC_EnableIT_HSIRDY
  1889. * @retval None
  1890. */
  1891. __STATIC_INLINE void LL_RCC_EnableIT_HSIRDY(void)
  1892. {
  1893. SET_BIT(RCC->CIR, RCC_CIR_HSIRDYIE);
  1894. }
  1895. /**
  1896. * @brief Enable HSE ready interrupt
  1897. * @rmtoll CIR HSERDYIE LL_RCC_EnableIT_HSERDY
  1898. * @retval None
  1899. */
  1900. __STATIC_INLINE void LL_RCC_EnableIT_HSERDY(void)
  1901. {
  1902. SET_BIT(RCC->CIR, RCC_CIR_HSERDYIE);
  1903. }
  1904. /**
  1905. * @brief Enable PLL ready interrupt
  1906. * @rmtoll CIR PLLRDYIE LL_RCC_EnableIT_PLLRDY
  1907. * @retval None
  1908. */
  1909. __STATIC_INLINE void LL_RCC_EnableIT_PLLRDY(void)
  1910. {
  1911. SET_BIT(RCC->CIR, RCC_CIR_PLLRDYIE);
  1912. }
  1913. #if defined(RCC_PLLI2S_SUPPORT)
  1914. /**
  1915. * @brief Enable PLLI2S ready interrupt
  1916. * @rmtoll CIR PLL3RDYIE LL_RCC_EnableIT_PLLI2SRDY
  1917. * @retval None
  1918. */
  1919. __STATIC_INLINE void LL_RCC_EnableIT_PLLI2SRDY(void)
  1920. {
  1921. SET_BIT(RCC->CIR, RCC_CIR_PLL3RDYIE);
  1922. }
  1923. #endif /* RCC_PLLI2S_SUPPORT */
  1924. #if defined(RCC_PLL2_SUPPORT)
  1925. /**
  1926. * @brief Enable PLL2 ready interrupt
  1927. * @rmtoll CIR PLL2RDYIE LL_RCC_EnableIT_PLL2RDY
  1928. * @retval None
  1929. */
  1930. __STATIC_INLINE void LL_RCC_EnableIT_PLL2RDY(void)
  1931. {
  1932. SET_BIT(RCC->CIR, RCC_CIR_PLL2RDYIE);
  1933. }
  1934. #endif /* RCC_PLL2_SUPPORT */
  1935. /**
  1936. * @brief Disable LSI ready interrupt
  1937. * @rmtoll CIR LSIRDYIE LL_RCC_DisableIT_LSIRDY
  1938. * @retval None
  1939. */
  1940. __STATIC_INLINE void LL_RCC_DisableIT_LSIRDY(void)
  1941. {
  1942. CLEAR_BIT(RCC->CIR, RCC_CIR_LSIRDYIE);
  1943. }
  1944. /**
  1945. * @brief Disable LSE ready interrupt
  1946. * @rmtoll CIR LSERDYIE LL_RCC_DisableIT_LSERDY
  1947. * @retval None
  1948. */
  1949. __STATIC_INLINE void LL_RCC_DisableIT_LSERDY(void)
  1950. {
  1951. CLEAR_BIT(RCC->CIR, RCC_CIR_LSERDYIE);
  1952. }
  1953. /**
  1954. * @brief Disable HSI ready interrupt
  1955. * @rmtoll CIR HSIRDYIE LL_RCC_DisableIT_HSIRDY
  1956. * @retval None
  1957. */
  1958. __STATIC_INLINE void LL_RCC_DisableIT_HSIRDY(void)
  1959. {
  1960. CLEAR_BIT(RCC->CIR, RCC_CIR_HSIRDYIE);
  1961. }
  1962. /**
  1963. * @brief Disable HSE ready interrupt
  1964. * @rmtoll CIR HSERDYIE LL_RCC_DisableIT_HSERDY
  1965. * @retval None
  1966. */
  1967. __STATIC_INLINE void LL_RCC_DisableIT_HSERDY(void)
  1968. {
  1969. CLEAR_BIT(RCC->CIR, RCC_CIR_HSERDYIE);
  1970. }
  1971. /**
  1972. * @brief Disable PLL ready interrupt
  1973. * @rmtoll CIR PLLRDYIE LL_RCC_DisableIT_PLLRDY
  1974. * @retval None
  1975. */
  1976. __STATIC_INLINE void LL_RCC_DisableIT_PLLRDY(void)
  1977. {
  1978. CLEAR_BIT(RCC->CIR, RCC_CIR_PLLRDYIE);
  1979. }
  1980. #if defined(RCC_PLLI2S_SUPPORT)
  1981. /**
  1982. * @brief Disable PLLI2S ready interrupt
  1983. * @rmtoll CIR PLL3RDYIE LL_RCC_DisableIT_PLLI2SRDY
  1984. * @retval None
  1985. */
  1986. __STATIC_INLINE void LL_RCC_DisableIT_PLLI2SRDY(void)
  1987. {
  1988. CLEAR_BIT(RCC->CIR, RCC_CIR_PLL3RDYIE);
  1989. }
  1990. #endif /* RCC_PLLI2S_SUPPORT */
  1991. #if defined(RCC_PLL2_SUPPORT)
  1992. /**
  1993. * @brief Disable PLL2 ready interrupt
  1994. * @rmtoll CIR PLL2RDYIE LL_RCC_DisableIT_PLL2RDY
  1995. * @retval None
  1996. */
  1997. __STATIC_INLINE void LL_RCC_DisableIT_PLL2RDY(void)
  1998. {
  1999. CLEAR_BIT(RCC->CIR, RCC_CIR_PLL2RDYIE);
  2000. }
  2001. #endif /* RCC_PLL2_SUPPORT */
  2002. /**
  2003. * @brief Checks if LSI ready interrupt source is enabled or disabled.
  2004. * @rmtoll CIR LSIRDYIE LL_RCC_IsEnabledIT_LSIRDY
  2005. * @retval State of bit (1 or 0).
  2006. */
  2007. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSIRDY(void)
  2008. {
  2009. return (READ_BIT(RCC->CIR, RCC_CIR_LSIRDYIE) == (RCC_CIR_LSIRDYIE));
  2010. }
  2011. /**
  2012. * @brief Checks if LSE ready interrupt source is enabled or disabled.
  2013. * @rmtoll CIR LSERDYIE LL_RCC_IsEnabledIT_LSERDY
  2014. * @retval State of bit (1 or 0).
  2015. */
  2016. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSERDY(void)
  2017. {
  2018. return (READ_BIT(RCC->CIR, RCC_CIR_LSERDYIE) == (RCC_CIR_LSERDYIE));
  2019. }
  2020. /**
  2021. * @brief Checks if HSI ready interrupt source is enabled or disabled.
  2022. * @rmtoll CIR HSIRDYIE LL_RCC_IsEnabledIT_HSIRDY
  2023. * @retval State of bit (1 or 0).
  2024. */
  2025. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSIRDY(void)
  2026. {
  2027. return (READ_BIT(RCC->CIR, RCC_CIR_HSIRDYIE) == (RCC_CIR_HSIRDYIE));
  2028. }
  2029. /**
  2030. * @brief Checks if HSE ready interrupt source is enabled or disabled.
  2031. * @rmtoll CIR HSERDYIE LL_RCC_IsEnabledIT_HSERDY
  2032. * @retval State of bit (1 or 0).
  2033. */
  2034. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSERDY(void)
  2035. {
  2036. return (READ_BIT(RCC->CIR, RCC_CIR_HSERDYIE) == (RCC_CIR_HSERDYIE));
  2037. }
  2038. /**
  2039. * @brief Checks if PLL ready interrupt source is enabled or disabled.
  2040. * @rmtoll CIR PLLRDYIE LL_RCC_IsEnabledIT_PLLRDY
  2041. * @retval State of bit (1 or 0).
  2042. */
  2043. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLRDY(void)
  2044. {
  2045. return (READ_BIT(RCC->CIR, RCC_CIR_PLLRDYIE) == (RCC_CIR_PLLRDYIE));
  2046. }
  2047. #if defined(RCC_PLLI2S_SUPPORT)
  2048. /**
  2049. * @brief Checks if PLLI2S ready interrupt source is enabled or disabled.
  2050. * @rmtoll CIR PLL3RDYIE LL_RCC_IsEnabledIT_PLLI2SRDY
  2051. * @retval State of bit (1 or 0).
  2052. */
  2053. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLI2SRDY(void)
  2054. {
  2055. return (READ_BIT(RCC->CIR, RCC_CIR_PLL3RDYIE) == (RCC_CIR_PLL3RDYIE));
  2056. }
  2057. #endif /* RCC_PLLI2S_SUPPORT */
  2058. #if defined(RCC_PLL2_SUPPORT)
  2059. /**
  2060. * @brief Checks if PLL2 ready interrupt source is enabled or disabled.
  2061. * @rmtoll CIR PLL2RDYIE LL_RCC_IsEnabledIT_PLL2RDY
  2062. * @retval State of bit (1 or 0).
  2063. */
  2064. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLL2RDY(void)
  2065. {
  2066. return (READ_BIT(RCC->CIR, RCC_CIR_PLL2RDYIE) == (RCC_CIR_PLL2RDYIE));
  2067. }
  2068. #endif /* RCC_PLL2_SUPPORT */
  2069. /**
  2070. * @}
  2071. */
  2072. #if defined(USE_FULL_LL_DRIVER)
  2073. /** @defgroup RCC_LL_EF_Init De-initialization function
  2074. * @{
  2075. */
  2076. ErrorStatus LL_RCC_DeInit(void);
  2077. /**
  2078. * @}
  2079. */
  2080. /** @defgroup RCC_LL_EF_Get_Freq Get system and peripherals clocks frequency functions
  2081. * @{
  2082. */
  2083. void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks);
  2084. #if defined(RCC_CFGR2_I2S2SRC)
  2085. uint32_t LL_RCC_GetI2SClockFreq(uint32_t I2SxSource);
  2086. #endif /* RCC_CFGR2_I2S2SRC */
  2087. #if defined(USB_OTG_FS) || defined(USB)
  2088. uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource);
  2089. #endif /* USB_OTG_FS || USB */
  2090. uint32_t LL_RCC_GetADCClockFreq(uint32_t ADCxSource);
  2091. /**
  2092. * @}
  2093. */
  2094. #endif /* USE_FULL_LL_DRIVER */
  2095. /**
  2096. * @}
  2097. */
  2098. /**
  2099. * @}
  2100. */
  2101. #endif /* RCC */
  2102. /**
  2103. * @}
  2104. */
  2105. #ifdef __cplusplus
  2106. }
  2107. #endif
  2108. #endif /* __STM32F1xx_LL_RCC_H */
  2109. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/