stm32f0xx_hal_rcc_ex.h 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_hal_rcc_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL Extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F0xx_HAL_RCC_EX_H
  21. #define __STM32F0xx_HAL_RCC_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f0xx_hal_def.h"
  27. /** @addtogroup STM32F0xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup RCC
  31. * @{
  32. */
  33. /** @addtogroup RCC_Private_Macros
  34. * @{
  35. */
  36. #if defined(RCC_HSI48_SUPPORT)
  37. #define IS_RCC_OSCILLATORTYPE(OSCILLATOR) (((OSCILLATOR) == RCC_OSCILLATORTYPE_NONE) || \
  38. (((OSCILLATOR) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  39. (((OSCILLATOR) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  40. (((OSCILLATOR) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  41. (((OSCILLATOR) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE) || \
  42. (((OSCILLATOR) & RCC_OSCILLATORTYPE_HSI14) == RCC_OSCILLATORTYPE_HSI14) || \
  43. (((OSCILLATOR) & RCC_OSCILLATORTYPE_HSI48) == RCC_OSCILLATORTYPE_HSI48))
  44. #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
  45. ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
  46. ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK) || \
  47. ((SOURCE) == RCC_SYSCLKSOURCE_HSI48))
  48. #define IS_RCC_SYSCLKSOURCE_STATUS(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSI) || \
  49. ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSE) || \
  50. ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_PLLCLK) || \
  51. ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSI48))
  52. #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
  53. ((SOURCE) == RCC_PLLSOURCE_HSI48) || \
  54. ((SOURCE) == RCC_PLLSOURCE_HSE))
  55. #define IS_RCC_HSI48(HSI48) (((HSI48) == RCC_HSI48_OFF) || ((HSI48) == RCC_HSI48_ON))
  56. #else
  57. #define IS_RCC_OSCILLATORTYPE(OSCILLATOR) (((OSCILLATOR) == RCC_OSCILLATORTYPE_NONE) || \
  58. (((OSCILLATOR) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  59. (((OSCILLATOR) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  60. (((OSCILLATOR) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  61. (((OSCILLATOR) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE) || \
  62. (((OSCILLATOR) & RCC_OSCILLATORTYPE_HSI14) == RCC_OSCILLATORTYPE_HSI14))
  63. #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
  64. ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
  65. ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK))
  66. #define IS_RCC_SYSCLKSOURCE_STATUS(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSI) || \
  67. ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_HSE) || \
  68. ((SOURCE) == RCC_SYSCLKSOURCE_STATUS_PLLCLK))
  69. #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
  70. ((SOURCE) == RCC_PLLSOURCE_HSE))
  71. #endif /* RCC_HSI48_SUPPORT */
  72. #if defined(RCC_CFGR_PLLNODIV) && !defined(RCC_CFGR_MCO_HSI48)
  73. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_NOCLOCK) || \
  74. ((SOURCE) == RCC_MCO1SOURCE_LSI) || \
  75. ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
  76. ((SOURCE) == RCC_MCO1SOURCE_SYSCLK) || \
  77. ((SOURCE) == RCC_MCO1SOURCE_HSI) || \
  78. ((SOURCE) == RCC_MCO1SOURCE_HSE) || \
  79. ((SOURCE) == RCC_MCO1SOURCE_PLLCLK) || \
  80. ((SOURCE) == RCC_MCO1SOURCE_PLLCLK_DIV2) || \
  81. ((SOURCE) == RCC_MCO1SOURCE_HSI14))
  82. #elif defined(RCC_CFGR_PLLNODIV) && defined(RCC_CFGR_MCO_HSI48)
  83. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_NOCLOCK) || \
  84. ((SOURCE) == RCC_MCO1SOURCE_LSI) || \
  85. ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
  86. ((SOURCE) == RCC_MCO1SOURCE_SYSCLK) || \
  87. ((SOURCE) == RCC_MCO1SOURCE_HSI) || \
  88. ((SOURCE) == RCC_MCO1SOURCE_HSE) || \
  89. ((SOURCE) == RCC_MCO1SOURCE_PLLCLK) || \
  90. ((SOURCE) == RCC_MCO1SOURCE_PLLCLK_DIV2) || \
  91. ((SOURCE) == RCC_MCO1SOURCE_HSI14) || \
  92. ((SOURCE) == RCC_MCO1SOURCE_HSI48))
  93. #elif !defined(RCC_CFGR_PLLNODIV) && !defined(RCC_CFGR_MCO_HSI48)
  94. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_NOCLOCK) || \
  95. ((SOURCE) == RCC_MCO1SOURCE_LSI) || \
  96. ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
  97. ((SOURCE) == RCC_MCO1SOURCE_SYSCLK) || \
  98. ((SOURCE) == RCC_MCO1SOURCE_HSI) || \
  99. ((SOURCE) == RCC_MCO1SOURCE_HSE) || \
  100. ((SOURCE) == RCC_MCO1SOURCE_PLLCLK_DIV2) || \
  101. ((SOURCE) == RCC_MCO1SOURCE_HSI14))
  102. #endif /* RCC_CFGR_PLLNODIV && !RCC_CFGR_MCO_HSI48 */
  103. /**
  104. * @}
  105. */
  106. /** @addtogroup RCC_Exported_Constants
  107. * @{
  108. */
  109. #if defined(RCC_HSI48_SUPPORT)
  110. /** @addtogroup RCC_PLL_Clock_Source
  111. * @{
  112. */
  113. #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI_PREDIV
  114. #define RCC_PLLSOURCE_HSI48 RCC_CFGR_PLLSRC_HSI48_PREDIV
  115. /**
  116. * @}
  117. */
  118. /** @addtogroup RCC_Interrupt
  119. * @{
  120. */
  121. #define RCC_IT_HSI48 RCC_CIR_HSI48RDYF /*!< HSI48 Ready Interrupt flag */
  122. /**
  123. * @}
  124. */
  125. /** @addtogroup RCC_Flag
  126. * @{
  127. */
  128. #define RCC_FLAG_HSI48RDY ((uint8_t)((CR2_REG_INDEX << 5U) | RCC_CR2_HSI48RDY_BitNumber))
  129. /**
  130. * @}
  131. */
  132. /** @addtogroup RCC_System_Clock_Source
  133. * @{
  134. */
  135. #define RCC_SYSCLKSOURCE_HSI48 RCC_CFGR_SW_HSI48
  136. /**
  137. * @}
  138. */
  139. /** @addtogroup RCC_System_Clock_Source_Status
  140. * @{
  141. */
  142. #define RCC_SYSCLKSOURCE_STATUS_HSI48 RCC_CFGR_SWS_HSI48
  143. /**
  144. * @}
  145. */
  146. #else
  147. /** @addtogroup RCC_PLL_Clock_Source
  148. * @{
  149. */
  150. #if defined(STM32F070xB) || defined(STM32F070x6) || defined(STM32F030xC)
  151. #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI_PREDIV
  152. #else
  153. #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI_DIV2
  154. #endif
  155. /**
  156. * @}
  157. */
  158. #endif /* RCC_HSI48_SUPPORT */
  159. /** @addtogroup RCC_MCO_Clock_Source
  160. * @{
  161. */
  162. #if defined(RCC_CFGR_PLLNODIV)
  163. #define RCC_MCO1SOURCE_PLLCLK (RCC_CFGR_MCO_PLL | RCC_CFGR_PLLNODIV)
  164. #endif /* RCC_CFGR_PLLNODIV */
  165. #if defined(RCC_CFGR_MCO_HSI48)
  166. #define RCC_MCO1SOURCE_HSI48 RCC_CFGR_MCO_HSI48
  167. #endif /* SRCC_CFGR_MCO_HSI48 */
  168. /**
  169. * @}
  170. */
  171. /**
  172. * @}
  173. */
  174. /**
  175. * @}
  176. */
  177. /** @addtogroup RCCEx
  178. * @{
  179. */
  180. /* Private Constants -------------------------------------------------------------*/
  181. #if defined(CRS)
  182. /** @addtogroup RCCEx_Private_Constants
  183. * @{
  184. */
  185. /* CRS IT Error Mask */
  186. #define RCC_CRS_IT_ERROR_MASK ((uint32_t)(RCC_CRS_IT_TRIMOVF | RCC_CRS_IT_SYNCERR | RCC_CRS_IT_SYNCMISS))
  187. /* CRS Flag Error Mask */
  188. #define RCC_CRS_FLAG_ERROR_MASK ((uint32_t)(RCC_CRS_FLAG_TRIMOVF | RCC_CRS_FLAG_SYNCERR | RCC_CRS_FLAG_SYNCMISS))
  189. /**
  190. * @}
  191. */
  192. #endif /* CRS */
  193. /* Private macro -------------------------------------------------------------*/
  194. /** @defgroup RCCEx_Private_Macros RCCEx Private Macros
  195. * @{
  196. */
  197. #if defined(STM32F030x6) || defined(STM32F030x8) || defined(STM32F031x6) || defined(STM32F038xx)\
  198. || defined(STM32F030xC)
  199. #define IS_RCC_PERIPHCLOCK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
  200. RCC_PERIPHCLK_RTC))
  201. #endif /* STM32F030x6 || STM32F030x8 || STM32F031x6 || STM32F038xx ||
  202. STM32F030xC */
  203. #if defined(STM32F070x6) || defined(STM32F070xB)
  204. #define IS_RCC_PERIPHCLOCK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
  205. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USB))
  206. #endif /* STM32F070x6 || STM32F070xB */
  207. #if defined(STM32F042x6) || defined(STM32F048xx)
  208. #define IS_RCC_PERIPHCLOCK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
  209. RCC_PERIPHCLK_CEC | RCC_PERIPHCLK_RTC | \
  210. RCC_PERIPHCLK_USB))
  211. #endif /* STM32F042x6 || STM32F048xx */
  212. #if defined(STM32F051x8) || defined(STM32F058xx)
  213. #define IS_RCC_PERIPHCLOCK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 | \
  214. RCC_PERIPHCLK_CEC | RCC_PERIPHCLK_RTC))
  215. #endif /* STM32F051x8 || STM32F058xx */
  216. #if defined(STM32F071xB)
  217. #define IS_RCC_PERIPHCLOCK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | \
  218. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_CEC | \
  219. RCC_PERIPHCLK_RTC))
  220. #endif /* STM32F071xB */
  221. #if defined(STM32F072xB) || defined(STM32F078xx)
  222. #define IS_RCC_PERIPHCLOCK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | \
  223. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_CEC | \
  224. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USB))
  225. #endif /* STM32F072xB || STM32F078xx */
  226. #if defined(STM32F091xC) || defined(STM32F098xx)
  227. #define IS_RCC_PERIPHCLOCK(SELECTION) ((SELECTION) <= (RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2 | \
  228. RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_CEC | \
  229. RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART3 ))
  230. #endif /* STM32F091xC || STM32F098xx */
  231. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx)
  232. #define IS_RCC_USBCLKSOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSOURCE_HSI48) || \
  233. ((SOURCE) == RCC_USBCLKSOURCE_PLL))
  234. #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || STM32F078xx */
  235. #if defined(STM32F070x6) || defined(STM32F070xB)
  236. #define IS_RCC_USBCLKSOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSOURCE_NONE) || \
  237. ((SOURCE) == RCC_USBCLKSOURCE_PLL))
  238. #endif /* STM32F070x6 || STM32F070xB */
  239. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  240. || defined(STM32F091xC) || defined(STM32F098xx)
  241. #define IS_RCC_USART2CLKSOURCE(SOURCE) (((SOURCE) == RCC_USART2CLKSOURCE_PCLK1) || \
  242. ((SOURCE) == RCC_USART2CLKSOURCE_SYSCLK) || \
  243. ((SOURCE) == RCC_USART2CLKSOURCE_LSE) || \
  244. ((SOURCE) == RCC_USART2CLKSOURCE_HSI))
  245. #endif /* STM32F071xB || STM32F072xB || STM32F078xx || */
  246. /* STM32F091xC || STM32F098xx */
  247. #if defined(STM32F091xC) || defined(STM32F098xx)
  248. #define IS_RCC_USART3CLKSOURCE(SOURCE) (((SOURCE) == RCC_USART3CLKSOURCE_PCLK1) || \
  249. ((SOURCE) == RCC_USART3CLKSOURCE_SYSCLK) || \
  250. ((SOURCE) == RCC_USART3CLKSOURCE_LSE) || \
  251. ((SOURCE) == RCC_USART3CLKSOURCE_HSI))
  252. #endif /* STM32F091xC || STM32F098xx */
  253. #if defined(STM32F042x6) || defined(STM32F048xx)\
  254. || defined(STM32F051x8) || defined(STM32F058xx)\
  255. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  256. || defined(STM32F091xC) || defined(STM32F098xx)
  257. #define IS_RCC_CECCLKSOURCE(SOURCE) (((SOURCE) == RCC_CECCLKSOURCE_HSI) || \
  258. ((SOURCE) == RCC_CECCLKSOURCE_LSE))
  259. #endif /* STM32F042x6 || STM32F048xx || */
  260. /* STM32F051x8 || STM32F058xx || */
  261. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  262. /* STM32F091xC || STM32F098xx */
  263. #if defined(RCC_CFGR_MCOPRE)
  264. #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1) || ((DIV) == RCC_MCODIV_2) || \
  265. ((DIV) == RCC_MCODIV_4) || ((DIV) == RCC_MCODIV_8) || \
  266. ((DIV) == RCC_MCODIV_16) || ((DIV) == RCC_MCODIV_32) || \
  267. ((DIV) == RCC_MCODIV_64) || ((DIV) == RCC_MCODIV_128))
  268. #else
  269. #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1))
  270. #endif /* RCC_CFGR_MCOPRE */
  271. #define IS_RCC_LSE_DRIVE(__DRIVE__) (((__DRIVE__) == RCC_LSEDRIVE_LOW) || \
  272. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMLOW) || \
  273. ((__DRIVE__) == RCC_LSEDRIVE_MEDIUMHIGH) || \
  274. ((__DRIVE__) == RCC_LSEDRIVE_HIGH))
  275. #if defined(CRS)
  276. #define IS_RCC_CRS_SYNC_SOURCE(_SOURCE_) (((_SOURCE_) == RCC_CRS_SYNC_SOURCE_GPIO) || \
  277. ((_SOURCE_) == RCC_CRS_SYNC_SOURCE_LSE) || \
  278. ((_SOURCE_) == RCC_CRS_SYNC_SOURCE_USB))
  279. #define IS_RCC_CRS_SYNC_DIV(_DIV_) (((_DIV_) == RCC_CRS_SYNC_DIV1) || ((_DIV_) == RCC_CRS_SYNC_DIV2) || \
  280. ((_DIV_) == RCC_CRS_SYNC_DIV4) || ((_DIV_) == RCC_CRS_SYNC_DIV8) || \
  281. ((_DIV_) == RCC_CRS_SYNC_DIV16) || ((_DIV_) == RCC_CRS_SYNC_DIV32) || \
  282. ((_DIV_) == RCC_CRS_SYNC_DIV64) || ((_DIV_) == RCC_CRS_SYNC_DIV128))
  283. #define IS_RCC_CRS_SYNC_POLARITY(_POLARITY_) (((_POLARITY_) == RCC_CRS_SYNC_POLARITY_RISING) || \
  284. ((_POLARITY_) == RCC_CRS_SYNC_POLARITY_FALLING))
  285. #define IS_RCC_CRS_RELOADVALUE(_VALUE_) (((_VALUE_) <= 0xFFFFU))
  286. #define IS_RCC_CRS_ERRORLIMIT(_VALUE_) (((_VALUE_) <= 0xFFU))
  287. #define IS_RCC_CRS_HSI48CALIBRATION(_VALUE_) (((_VALUE_) <= 0x3FU))
  288. #define IS_RCC_CRS_FREQERRORDIR(_DIR_) (((_DIR_) == RCC_CRS_FREQERRORDIR_UP) || \
  289. ((_DIR_) == RCC_CRS_FREQERRORDIR_DOWN))
  290. #endif /* CRS */
  291. /**
  292. * @}
  293. */
  294. /* Exported types ------------------------------------------------------------*/
  295. /** @defgroup RCCEx_Exported_Types RCCEx Exported Types
  296. * @{
  297. */
  298. /**
  299. * @brief RCC extended clocks structure definition
  300. */
  301. #if defined(STM32F030x6) || defined(STM32F030x8) || defined(STM32F031x6) || defined(STM32F038xx)\
  302. || defined(STM32F030xC)
  303. typedef struct
  304. {
  305. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  306. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  307. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
  308. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  309. uint32_t Usart1ClockSelection; /*!< USART1 clock source
  310. This parameter can be a value of @ref RCC_USART1_Clock_Source */
  311. uint32_t I2c1ClockSelection; /*!< I2C1 clock source
  312. This parameter can be a value of @ref RCC_I2C1_Clock_Source */
  313. }RCC_PeriphCLKInitTypeDef;
  314. #endif /* STM32F030x6 || STM32F030x8 || STM32F031x6 || STM32F038xx ||
  315. STM32F030xC */
  316. #if defined(STM32F070x6) || defined(STM32F070xB)
  317. typedef struct
  318. {
  319. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  320. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  321. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
  322. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  323. uint32_t Usart1ClockSelection; /*!< USART1 clock source
  324. This parameter can be a value of @ref RCC_USART1_Clock_Source */
  325. uint32_t I2c1ClockSelection; /*!< I2C1 clock source
  326. This parameter can be a value of @ref RCC_I2C1_Clock_Source */
  327. uint32_t UsbClockSelection; /*!< USB clock source
  328. This parameter can be a value of @ref RCCEx_USB_Clock_Source */
  329. }RCC_PeriphCLKInitTypeDef;
  330. #endif /* STM32F070x6 || STM32F070xB */
  331. #if defined(STM32F042x6) || defined(STM32F048xx)
  332. typedef struct
  333. {
  334. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  335. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  336. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
  337. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  338. uint32_t Usart1ClockSelection; /*!< USART1 clock source
  339. This parameter can be a value of @ref RCC_USART1_Clock_Source */
  340. uint32_t I2c1ClockSelection; /*!< I2C1 clock source
  341. This parameter can be a value of @ref RCC_I2C1_Clock_Source */
  342. uint32_t CecClockSelection; /*!< HDMI CEC clock source
  343. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  344. uint32_t UsbClockSelection; /*!< USB clock source
  345. This parameter can be a value of @ref RCCEx_USB_Clock_Source */
  346. }RCC_PeriphCLKInitTypeDef;
  347. #endif /* STM32F042x6 || STM32F048xx */
  348. #if defined(STM32F051x8) || defined(STM32F058xx)
  349. typedef struct
  350. {
  351. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  352. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  353. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
  354. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  355. uint32_t Usart1ClockSelection; /*!< USART1 clock source
  356. This parameter can be a value of @ref RCC_USART1_Clock_Source */
  357. uint32_t I2c1ClockSelection; /*!< I2C1 clock source
  358. This parameter can be a value of @ref RCC_I2C1_Clock_Source */
  359. uint32_t CecClockSelection; /*!< HDMI CEC clock source
  360. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  361. }RCC_PeriphCLKInitTypeDef;
  362. #endif /* STM32F051x8 || STM32F058xx */
  363. #if defined(STM32F071xB)
  364. typedef struct
  365. {
  366. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  367. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  368. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
  369. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  370. uint32_t Usart1ClockSelection; /*!< USART1 clock source
  371. This parameter can be a value of @ref RCC_USART1_Clock_Source */
  372. uint32_t Usart2ClockSelection; /*!< USART2 clock source
  373. This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
  374. uint32_t I2c1ClockSelection; /*!< I2C1 clock source
  375. This parameter can be a value of @ref RCC_I2C1_Clock_Source */
  376. uint32_t CecClockSelection; /*!< HDMI CEC clock source
  377. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  378. }RCC_PeriphCLKInitTypeDef;
  379. #endif /* STM32F071xB */
  380. #if defined(STM32F072xB) || defined(STM32F078xx)
  381. typedef struct
  382. {
  383. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  384. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  385. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
  386. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  387. uint32_t Usart1ClockSelection; /*!< USART1 clock source
  388. This parameter can be a value of @ref RCC_USART1_Clock_Source */
  389. uint32_t Usart2ClockSelection; /*!< USART2 clock source
  390. This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
  391. uint32_t I2c1ClockSelection; /*!< I2C1 clock source
  392. This parameter can be a value of @ref RCC_I2C1_Clock_Source */
  393. uint32_t CecClockSelection; /*!< HDMI CEC clock source
  394. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  395. uint32_t UsbClockSelection; /*!< USB clock source
  396. This parameter can be a value of @ref RCCEx_USB_Clock_Source */
  397. }RCC_PeriphCLKInitTypeDef;
  398. #endif /* STM32F072xB || STM32F078xx */
  399. #if defined(STM32F091xC) || defined(STM32F098xx)
  400. typedef struct
  401. {
  402. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  403. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  404. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection
  405. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  406. uint32_t Usart1ClockSelection; /*!< USART1 clock source
  407. This parameter can be a value of @ref RCC_USART1_Clock_Source */
  408. uint32_t Usart2ClockSelection; /*!< USART2 clock source
  409. This parameter can be a value of @ref RCCEx_USART2_Clock_Source */
  410. uint32_t Usart3ClockSelection; /*!< USART3 clock source
  411. This parameter can be a value of @ref RCCEx_USART3_Clock_Source */
  412. uint32_t I2c1ClockSelection; /*!< I2C1 clock source
  413. This parameter can be a value of @ref RCC_I2C1_Clock_Source */
  414. uint32_t CecClockSelection; /*!< HDMI CEC clock source
  415. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  416. }RCC_PeriphCLKInitTypeDef;
  417. #endif /* STM32F091xC || STM32F098xx */
  418. #if defined(CRS)
  419. /**
  420. * @brief RCC_CRS Init structure definition
  421. */
  422. typedef struct
  423. {
  424. uint32_t Prescaler; /*!< Specifies the division factor of the SYNC signal.
  425. This parameter can be a value of @ref RCCEx_CRS_SynchroDivider */
  426. uint32_t Source; /*!< Specifies the SYNC signal source.
  427. This parameter can be a value of @ref RCCEx_CRS_SynchroSource */
  428. uint32_t Polarity; /*!< Specifies the input polarity for the SYNC signal source.
  429. This parameter can be a value of @ref RCCEx_CRS_SynchroPolarity */
  430. uint32_t ReloadValue; /*!< Specifies the value to be loaded in the frequency error counter with each SYNC event.
  431. It can be calculated in using macro @ref __HAL_RCC_CRS_RELOADVALUE_CALCULATE(__FTARGET__, __FSYNC__)
  432. This parameter must be a number between 0 and 0xFFFF or a value of @ref RCCEx_CRS_ReloadValueDefault .*/
  433. uint32_t ErrorLimitValue; /*!< Specifies the value to be used to evaluate the captured frequency error value.
  434. This parameter must be a number between 0 and 0xFF or a value of @ref RCCEx_CRS_ErrorLimitDefault */
  435. uint32_t HSI48CalibrationValue; /*!< Specifies a user-programmable trimming value to the HSI48 oscillator.
  436. This parameter must be a number between 0 and 0x3F or a value of @ref RCCEx_CRS_HSI48CalibrationDefault */
  437. }RCC_CRSInitTypeDef;
  438. /**
  439. * @brief RCC_CRS Synchronization structure definition
  440. */
  441. typedef struct
  442. {
  443. uint32_t ReloadValue; /*!< Specifies the value loaded in the Counter reload value.
  444. This parameter must be a number between 0 and 0xFFFFU */
  445. uint32_t HSI48CalibrationValue; /*!< Specifies value loaded in HSI48 oscillator smooth trimming.
  446. This parameter must be a number between 0 and 0x3FU */
  447. uint32_t FreqErrorCapture; /*!< Specifies the value loaded in the .FECAP, the frequency error counter
  448. value latched in the time of the last SYNC event.
  449. This parameter must be a number between 0 and 0xFFFFU */
  450. uint32_t FreqErrorDirection; /*!< Specifies the value loaded in the .FEDIR, the counting direction of the
  451. frequency error counter latched in the time of the last SYNC event.
  452. It shows whether the actual frequency is below or above the target.
  453. This parameter must be a value of @ref RCCEx_CRS_FreqErrorDirection*/
  454. }RCC_CRSSynchroInfoTypeDef;
  455. #endif /* CRS */
  456. /**
  457. * @}
  458. */
  459. /* Exported constants --------------------------------------------------------*/
  460. /** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
  461. * @{
  462. */
  463. /** @defgroup RCCEx_Periph_Clock_Selection RCCEx Periph Clock Selection
  464. * @{
  465. */
  466. #if defined(STM32F030x6) || defined(STM32F030x8) || defined(STM32F031x6) || defined(STM32F038xx)\
  467. || defined(STM32F030xC)
  468. #define RCC_PERIPHCLK_USART1 (0x00000001U)
  469. #define RCC_PERIPHCLK_I2C1 (0x00000020U)
  470. #define RCC_PERIPHCLK_RTC (0x00010000U)
  471. #endif /* STM32F030x6 || STM32F030x8 || STM32F031x6 || STM32F038xx ||
  472. STM32F030xC */
  473. #if defined(STM32F070x6) || defined(STM32F070xB)
  474. #define RCC_PERIPHCLK_USART1 (0x00000001U)
  475. #define RCC_PERIPHCLK_I2C1 (0x00000020U)
  476. #define RCC_PERIPHCLK_RTC (0x00010000U)
  477. #define RCC_PERIPHCLK_USB (0x00020000U)
  478. #endif /* STM32F070x6 || STM32F070xB */
  479. #if defined(STM32F042x6) || defined(STM32F048xx)
  480. #define RCC_PERIPHCLK_USART1 (0x00000001U)
  481. #define RCC_PERIPHCLK_I2C1 (0x00000020U)
  482. #define RCC_PERIPHCLK_CEC (0x00000400U)
  483. #define RCC_PERIPHCLK_RTC (0x00010000U)
  484. #define RCC_PERIPHCLK_USB (0x00020000U)
  485. #endif /* STM32F042x6 || STM32F048xx */
  486. #if defined(STM32F051x8) || defined(STM32F058xx)
  487. #define RCC_PERIPHCLK_USART1 (0x00000001U)
  488. #define RCC_PERIPHCLK_I2C1 (0x00000020U)
  489. #define RCC_PERIPHCLK_CEC (0x00000400U)
  490. #define RCC_PERIPHCLK_RTC (0x00010000U)
  491. #endif /* STM32F051x8 || STM32F058xx */
  492. #if defined(STM32F071xB)
  493. #define RCC_PERIPHCLK_USART1 (0x00000001U)
  494. #define RCC_PERIPHCLK_USART2 (0x00000002U)
  495. #define RCC_PERIPHCLK_I2C1 (0x00000020U)
  496. #define RCC_PERIPHCLK_CEC (0x00000400U)
  497. #define RCC_PERIPHCLK_RTC (0x00010000U)
  498. #endif /* STM32F071xB */
  499. #if defined(STM32F072xB) || defined(STM32F078xx)
  500. #define RCC_PERIPHCLK_USART1 (0x00000001U)
  501. #define RCC_PERIPHCLK_USART2 (0x00000002U)
  502. #define RCC_PERIPHCLK_I2C1 (0x00000020U)
  503. #define RCC_PERIPHCLK_CEC (0x00000400U)
  504. #define RCC_PERIPHCLK_RTC (0x00010000U)
  505. #define RCC_PERIPHCLK_USB (0x00020000U)
  506. #endif /* STM32F072xB || STM32F078xx */
  507. #if defined(STM32F091xC) || defined(STM32F098xx)
  508. #define RCC_PERIPHCLK_USART1 (0x00000001U)
  509. #define RCC_PERIPHCLK_USART2 (0x00000002U)
  510. #define RCC_PERIPHCLK_I2C1 (0x00000020U)
  511. #define RCC_PERIPHCLK_CEC (0x00000400U)
  512. #define RCC_PERIPHCLK_RTC (0x00010000U)
  513. #define RCC_PERIPHCLK_USART3 (0x00040000U)
  514. #endif /* STM32F091xC || STM32F098xx */
  515. /**
  516. * @}
  517. */
  518. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx)
  519. /** @defgroup RCCEx_USB_Clock_Source RCCEx USB Clock Source
  520. * @{
  521. */
  522. #define RCC_USBCLKSOURCE_HSI48 RCC_CFGR3_USBSW_HSI48 /*!< HSI48 clock selected as USB clock source */
  523. #define RCC_USBCLKSOURCE_PLL RCC_CFGR3_USBSW_PLLCLK /*!< PLL clock (PLLCLK) selected as USB clock */
  524. /**
  525. * @}
  526. */
  527. #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || STM32F078xx */
  528. #if defined(STM32F070x6) || defined(STM32F070xB)
  529. /** @defgroup RCCEx_USB_Clock_Source RCCEx USB Clock Source
  530. * @{
  531. */
  532. #define RCC_USBCLKSOURCE_NONE (0x00000000U) /*!< USB clock disabled */
  533. #define RCC_USBCLKSOURCE_PLL RCC_CFGR3_USBSW_PLLCLK /*!< PLL clock (PLLCLK) selected as USB clock */
  534. /**
  535. * @}
  536. */
  537. #endif /* STM32F070x6 || STM32F070xB */
  538. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  539. || defined(STM32F091xC) || defined(STM32F098xx)
  540. /** @defgroup RCCEx_USART2_Clock_Source RCCEx USART2 Clock Source
  541. * @{
  542. */
  543. #define RCC_USART2CLKSOURCE_PCLK1 RCC_CFGR3_USART2SW_PCLK
  544. #define RCC_USART2CLKSOURCE_SYSCLK RCC_CFGR3_USART2SW_SYSCLK
  545. #define RCC_USART2CLKSOURCE_LSE RCC_CFGR3_USART2SW_LSE
  546. #define RCC_USART2CLKSOURCE_HSI RCC_CFGR3_USART2SW_HSI
  547. /**
  548. * @}
  549. */
  550. #endif /* STM32F071xB || STM32F072xB || STM32F078xx || */
  551. /* STM32F091xC || STM32F098xx */
  552. #if defined(STM32F091xC) || defined(STM32F098xx)
  553. /** @defgroup RCCEx_USART3_Clock_Source RCCEx USART3 Clock Source
  554. * @{
  555. */
  556. #define RCC_USART3CLKSOURCE_PCLK1 RCC_CFGR3_USART3SW_PCLK
  557. #define RCC_USART3CLKSOURCE_SYSCLK RCC_CFGR3_USART3SW_SYSCLK
  558. #define RCC_USART3CLKSOURCE_LSE RCC_CFGR3_USART3SW_LSE
  559. #define RCC_USART3CLKSOURCE_HSI RCC_CFGR3_USART3SW_HSI
  560. /**
  561. * @}
  562. */
  563. #endif /* STM32F091xC || STM32F098xx */
  564. #if defined(STM32F042x6) || defined(STM32F048xx)\
  565. || defined(STM32F051x8) || defined(STM32F058xx)\
  566. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  567. || defined(STM32F091xC) || defined(STM32F098xx)
  568. /** @defgroup RCCEx_CEC_Clock_Source RCCEx CEC Clock Source
  569. * @{
  570. */
  571. #define RCC_CECCLKSOURCE_HSI RCC_CFGR3_CECSW_HSI_DIV244
  572. #define RCC_CECCLKSOURCE_LSE RCC_CFGR3_CECSW_LSE
  573. /**
  574. * @}
  575. */
  576. #endif /* STM32F042x6 || STM32F048xx || */
  577. /* STM32F051x8 || STM32F058xx || */
  578. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  579. /* STM32F091xC || STM32F098xx */
  580. /** @defgroup RCCEx_MCOx_Clock_Prescaler RCCEx MCOx Clock Prescaler
  581. * @{
  582. */
  583. #if defined(RCC_CFGR_MCOPRE)
  584. #define RCC_MCODIV_1 (0x00000000U)
  585. #define RCC_MCODIV_2 (0x10000000U)
  586. #define RCC_MCODIV_4 (0x20000000U)
  587. #define RCC_MCODIV_8 (0x30000000U)
  588. #define RCC_MCODIV_16 (0x40000000U)
  589. #define RCC_MCODIV_32 (0x50000000U)
  590. #define RCC_MCODIV_64 (0x60000000U)
  591. #define RCC_MCODIV_128 (0x70000000U)
  592. #else
  593. #define RCC_MCODIV_1 (0x00000000U)
  594. #endif /* RCC_CFGR_MCOPRE */
  595. /**
  596. * @}
  597. */
  598. /** @defgroup RCCEx_LSEDrive_Configuration RCC LSE Drive Configuration
  599. * @{
  600. */
  601. #define RCC_LSEDRIVE_LOW (0x00000000U) /*!< Xtal mode lower driving capability */
  602. #define RCC_LSEDRIVE_MEDIUMLOW RCC_BDCR_LSEDRV_1 /*!< Xtal mode medium low driving capability */
  603. #define RCC_LSEDRIVE_MEDIUMHIGH RCC_BDCR_LSEDRV_0 /*!< Xtal mode medium high driving capability */
  604. #define RCC_LSEDRIVE_HIGH RCC_BDCR_LSEDRV /*!< Xtal mode higher driving capability */
  605. /**
  606. * @}
  607. */
  608. #if defined(CRS)
  609. /** @defgroup RCCEx_CRS_Status RCCEx CRS Status
  610. * @{
  611. */
  612. #define RCC_CRS_NONE (0x00000000U)
  613. #define RCC_CRS_TIMEOUT (0x00000001U)
  614. #define RCC_CRS_SYNCOK (0x00000002U)
  615. #define RCC_CRS_SYNCWARN (0x00000004U)
  616. #define RCC_CRS_SYNCERR (0x00000008U)
  617. #define RCC_CRS_SYNCMISS (0x00000010U)
  618. #define RCC_CRS_TRIMOVF (0x00000020U)
  619. /**
  620. * @}
  621. */
  622. /** @defgroup RCCEx_CRS_SynchroSource RCCEx CRS Synchronization Source
  623. * @{
  624. */
  625. #define RCC_CRS_SYNC_SOURCE_GPIO (0x00000000U) /*!< Synchro Signal source GPIO */
  626. #define RCC_CRS_SYNC_SOURCE_LSE CRS_CFGR_SYNCSRC_0 /*!< Synchro Signal source LSE */
  627. #define RCC_CRS_SYNC_SOURCE_USB CRS_CFGR_SYNCSRC_1 /*!< Synchro Signal source USB SOF (default)*/
  628. /**
  629. * @}
  630. */
  631. /** @defgroup RCCEx_CRS_SynchroDivider RCCEx CRS Synchronization Divider
  632. * @{
  633. */
  634. #define RCC_CRS_SYNC_DIV1 (0x00000000U) /*!< Synchro Signal not divided (default) */
  635. #define RCC_CRS_SYNC_DIV2 CRS_CFGR_SYNCDIV_0 /*!< Synchro Signal divided by 2 */
  636. #define RCC_CRS_SYNC_DIV4 CRS_CFGR_SYNCDIV_1 /*!< Synchro Signal divided by 4 */
  637. #define RCC_CRS_SYNC_DIV8 (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
  638. #define RCC_CRS_SYNC_DIV16 CRS_CFGR_SYNCDIV_2 /*!< Synchro Signal divided by 16 */
  639. #define RCC_CRS_SYNC_DIV32 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
  640. #define RCC_CRS_SYNC_DIV64 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
  641. #define RCC_CRS_SYNC_DIV128 CRS_CFGR_SYNCDIV /*!< Synchro Signal divided by 128 */
  642. /**
  643. * @}
  644. */
  645. /** @defgroup RCCEx_CRS_SynchroPolarity RCCEx CRS Synchronization Polarity
  646. * @{
  647. */
  648. #define RCC_CRS_SYNC_POLARITY_RISING (0x00000000U) /*!< Synchro Active on rising edge (default) */
  649. #define RCC_CRS_SYNC_POLARITY_FALLING CRS_CFGR_SYNCPOL /*!< Synchro Active on falling edge */
  650. /**
  651. * @}
  652. */
  653. /** @defgroup RCCEx_CRS_ReloadValueDefault RCCEx CRS Default Reload Value
  654. * @{
  655. */
  656. #define RCC_CRS_RELOADVALUE_DEFAULT (0x0000BB7FU) /*!< The reset value of the RELOAD field corresponds
  657. to a target frequency of 48 MHz and a synchronization signal frequency of 1 kHz (SOF signal from USB). */
  658. /**
  659. * @}
  660. */
  661. /** @defgroup RCCEx_CRS_ErrorLimitDefault RCCEx CRS Default Error Limit Value
  662. * @{
  663. */
  664. #define RCC_CRS_ERRORLIMIT_DEFAULT (0x00000022U) /*!< Default Frequency error limit */
  665. /**
  666. * @}
  667. */
  668. /** @defgroup RCCEx_CRS_HSI48CalibrationDefault RCCEx CRS Default HSI48 Calibration vakye
  669. * @{
  670. */
  671. #define RCC_CRS_HSI48CALIBRATION_DEFAULT (0x00000020U) /*!< The default value is 32, which corresponds to the middle of the trimming interval.
  672. The trimming step is around 67 kHz between two consecutive TRIM steps. A higher TRIM value
  673. corresponds to a higher output frequency */
  674. /**
  675. * @}
  676. */
  677. /** @defgroup RCCEx_CRS_FreqErrorDirection RCCEx CRS Frequency Error Direction
  678. * @{
  679. */
  680. #define RCC_CRS_FREQERRORDIR_UP (0x00000000U) /*!< Upcounting direction, the actual frequency is above the target */
  681. #define RCC_CRS_FREQERRORDIR_DOWN ((uint32_t)CRS_ISR_FEDIR) /*!< Downcounting direction, the actual frequency is below the target */
  682. /**
  683. * @}
  684. */
  685. /** @defgroup RCCEx_CRS_Interrupt_Sources RCCEx CRS Interrupt Sources
  686. * @{
  687. */
  688. #define RCC_CRS_IT_SYNCOK CRS_CR_SYNCOKIE /*!< SYNC event OK */
  689. #define RCC_CRS_IT_SYNCWARN CRS_CR_SYNCWARNIE /*!< SYNC warning */
  690. #define RCC_CRS_IT_ERR CRS_CR_ERRIE /*!< Error */
  691. #define RCC_CRS_IT_ESYNC CRS_CR_ESYNCIE /*!< Expected SYNC */
  692. #define RCC_CRS_IT_SYNCERR CRS_CR_ERRIE /*!< SYNC error */
  693. #define RCC_CRS_IT_SYNCMISS CRS_CR_ERRIE /*!< SYNC missed */
  694. #define RCC_CRS_IT_TRIMOVF CRS_CR_ERRIE /*!< Trimming overflow or underflow */
  695. /**
  696. * @}
  697. */
  698. /** @defgroup RCCEx_CRS_Flags RCCEx CRS Flags
  699. * @{
  700. */
  701. #define RCC_CRS_FLAG_SYNCOK CRS_ISR_SYNCOKF /*!< SYNC event OK flag */
  702. #define RCC_CRS_FLAG_SYNCWARN CRS_ISR_SYNCWARNF /*!< SYNC warning flag */
  703. #define RCC_CRS_FLAG_ERR CRS_ISR_ERRF /*!< Error flag */
  704. #define RCC_CRS_FLAG_ESYNC CRS_ISR_ESYNCF /*!< Expected SYNC flag */
  705. #define RCC_CRS_FLAG_SYNCERR CRS_ISR_SYNCERR /*!< SYNC error */
  706. #define RCC_CRS_FLAG_SYNCMISS CRS_ISR_SYNCMISS /*!< SYNC missed*/
  707. #define RCC_CRS_FLAG_TRIMOVF CRS_ISR_TRIMOVF /*!< Trimming overflow or underflow */
  708. /**
  709. * @}
  710. */
  711. #endif /* CRS */
  712. /**
  713. * @}
  714. */
  715. /* Exported macros ------------------------------------------------------------*/
  716. /** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
  717. * @{
  718. */
  719. /** @defgroup RCCEx_Peripheral_Clock_Enable_Disable RCCEx_Peripheral_Clock_Enable_Disable
  720. * @brief Enables or disables the AHB1 peripheral clock.
  721. * @note After reset, the peripheral clock (used for registers read/write access)
  722. * is disabled and the application software has to enable this clock before
  723. * using it.
  724. * @{
  725. */
  726. #if defined(GPIOD)
  727. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  728. __IO uint32_t tmpreg; \
  729. SET_BIT(RCC->AHBENR, RCC_AHBENR_GPIODEN);\
  730. /* Delay after an RCC peripheral clock enabling */ \
  731. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_GPIODEN);\
  732. UNUSED(tmpreg); \
  733. } while(0U)
  734. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIODEN))
  735. #endif /* GPIOD */
  736. #if defined(GPIOE)
  737. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  738. __IO uint32_t tmpreg; \
  739. SET_BIT(RCC->AHBENR, RCC_AHBENR_GPIOEEN);\
  740. /* Delay after an RCC peripheral clock enabling */ \
  741. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_GPIOEEN);\
  742. UNUSED(tmpreg); \
  743. } while(0U)
  744. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIOEEN))
  745. #endif /* GPIOE */
  746. #if defined(STM32F042x6) || defined(STM32F048xx)\
  747. || defined(STM32F051x8) || defined(STM32F058xx)\
  748. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  749. || defined(STM32F091xC) || defined(STM32F098xx)
  750. #define __HAL_RCC_TSC_CLK_ENABLE() do { \
  751. __IO uint32_t tmpreg; \
  752. SET_BIT(RCC->AHBENR, RCC_AHBENR_TSCEN);\
  753. /* Delay after an RCC peripheral clock enabling */ \
  754. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_TSCEN);\
  755. UNUSED(tmpreg); \
  756. } while(0U)
  757. #define __HAL_RCC_TSC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_TSCEN))
  758. #endif /* STM32F042x6 || STM32F048xx || */
  759. /* STM32F051x8 || STM32F058xx || */
  760. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  761. /* STM32F091xC || STM32F098xx */
  762. #if defined(STM32F091xC) || defined(STM32F098xx)
  763. #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
  764. __IO uint32_t tmpreg; \
  765. SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN);\
  766. /* Delay after an RCC peripheral clock enabling */ \
  767. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN);\
  768. UNUSED(tmpreg); \
  769. } while(0U)
  770. #define __HAL_RCC_DMA2_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_DMA2EN))
  771. #endif /* STM32F091xC || STM32F098xx */
  772. /** @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  773. * @note After reset, the peripheral clock (used for registers read/write access)
  774. * is disabled and the application software has to enable this clock before
  775. * using it.
  776. */
  777. #if defined(STM32F030x8)\
  778. || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  779. || defined(STM32F051x8) || defined(STM32F058xx)\
  780. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  781. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  782. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  783. __IO uint32_t tmpreg; \
  784. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
  785. /* Delay after an RCC peripheral clock enabling */ \
  786. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
  787. UNUSED(tmpreg); \
  788. } while(0U)
  789. #define __HAL_RCC_USART2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART2EN))
  790. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || */
  791. /* STM32F051x8 || STM32F058xx || STM32F070x6 || */
  792. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  793. /* STM32F091xC || STM32F098xx || STM32F030xC */
  794. #if defined(STM32F030x8)\
  795. || defined(STM32F042x6) || defined(STM32F048xx)\
  796. || defined(STM32F051x8) || defined(STM32F058xx)\
  797. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  798. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  799. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  800. __IO uint32_t tmpreg; \
  801. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  802. /* Delay after an RCC peripheral clock enabling */ \
  803. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  804. UNUSED(tmpreg); \
  805. } while(0U)
  806. #define __HAL_RCC_SPI2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI2EN))
  807. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || */
  808. /* STM32F051x8 || STM32F058xx || */
  809. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  810. /* STM32F091xC || STM32F098xx || STM32F030xC */
  811. #if defined(STM32F031x6) || defined(STM32F038xx)\
  812. || defined(STM32F042x6) || defined(STM32F048xx)\
  813. || defined(STM32F051x8) || defined(STM32F058xx)\
  814. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  815. || defined(STM32F091xC) || defined(STM32F098xx)
  816. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  817. __IO uint32_t tmpreg; \
  818. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  819. /* Delay after an RCC peripheral clock enabling */ \
  820. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  821. UNUSED(tmpreg); \
  822. } while(0U)
  823. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  824. #endif /* STM32F031x6 || STM32F038xx || */
  825. /* STM32F042x6 || STM32F048xx || */
  826. /* STM32F051x8 || STM32F058xx || */
  827. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  828. /* STM32F091xC || STM32F098xx */
  829. #if defined(STM32F030x8) \
  830. || defined(STM32F051x8) || defined(STM32F058xx)\
  831. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  832. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  833. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  834. __IO uint32_t tmpreg; \
  835. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  836. /* Delay after an RCC peripheral clock enabling */ \
  837. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  838. UNUSED(tmpreg); \
  839. } while(0U)
  840. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  841. __IO uint32_t tmpreg; \
  842. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  843. /* Delay after an RCC peripheral clock enabling */ \
  844. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  845. UNUSED(tmpreg); \
  846. } while(0U)
  847. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  848. #define __HAL_RCC_I2C2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN))
  849. #endif /* STM32F030x8 || */
  850. /* STM32F051x8 || STM32F058xx || */
  851. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  852. /* STM32F091xC || STM32F098xx || STM32F030xC */
  853. #if defined(STM32F051x8) || defined(STM32F058xx)\
  854. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  855. || defined(STM32F091xC) || defined(STM32F098xx)
  856. #define __HAL_RCC_DAC1_CLK_ENABLE() do { \
  857. __IO uint32_t tmpreg; \
  858. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  859. /* Delay after an RCC peripheral clock enabling */ \
  860. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  861. UNUSED(tmpreg); \
  862. } while(0U)
  863. #define __HAL_RCC_DAC1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  864. #endif /* STM32F051x8 || STM32F058xx || */
  865. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  866. /* STM32F091xC || STM32F098xx */
  867. #if defined(STM32F042x6) || defined(STM32F048xx)\
  868. || defined(STM32F051x8) || defined(STM32F058xx)\
  869. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  870. || defined(STM32F091xC) || defined(STM32F098xx)
  871. #define __HAL_RCC_CEC_CLK_ENABLE() do { \
  872. __IO uint32_t tmpreg; \
  873. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  874. /* Delay after an RCC peripheral clock enabling */ \
  875. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  876. UNUSED(tmpreg); \
  877. } while(0U)
  878. #define __HAL_RCC_CEC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CECEN))
  879. #endif /* STM32F042x6 || STM32F048xx || */
  880. /* STM32F051x8 || STM32F058xx || */
  881. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  882. /* STM32F091xC || STM32F098xx */
  883. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  884. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  885. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  886. __IO uint32_t tmpreg; \
  887. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  888. /* Delay after an RCC peripheral clock enabling */ \
  889. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  890. UNUSED(tmpreg); \
  891. } while(0U)
  892. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  893. __IO uint32_t tmpreg; \
  894. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  895. /* Delay after an RCC peripheral clock enabling */ \
  896. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  897. UNUSED(tmpreg); \
  898. } while(0U)
  899. #define __HAL_RCC_USART4_CLK_ENABLE() do { \
  900. __IO uint32_t tmpreg; \
  901. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART4EN);\
  902. /* Delay after an RCC peripheral clock enabling */ \
  903. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART4EN);\
  904. UNUSED(tmpreg); \
  905. } while(0U)
  906. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  907. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  908. #define __HAL_RCC_USART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART4EN))
  909. #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  910. /* STM32F091xC || STM32F098xx || STM32F030xC */
  911. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  912. || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
  913. #define __HAL_RCC_USB_CLK_ENABLE() do { \
  914. __IO uint32_t tmpreg; \
  915. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USBEN);\
  916. /* Delay after an RCC peripheral clock enabling */ \
  917. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USBEN);\
  918. UNUSED(tmpreg); \
  919. } while(0U)
  920. #define __HAL_RCC_USB_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USBEN))
  921. #endif /* STM32F042x6 || STM32F048xx || STM32F070x6 || */
  922. /* STM32F072xB || STM32F078xx || STM32F070xB */
  923. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB)\
  924. || defined(STM32F091xC) || defined(STM32F098xx)
  925. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  926. __IO uint32_t tmpreg; \
  927. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CANEN);\
  928. /* Delay after an RCC peripheral clock enabling */ \
  929. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CANEN);\
  930. UNUSED(tmpreg); \
  931. } while(0U)
  932. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CANEN))
  933. #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || */
  934. /* STM32F091xC || STM32F098xx */
  935. #if defined(CRS)
  936. #define __HAL_RCC_CRS_CLK_ENABLE() do { \
  937. __IO uint32_t tmpreg; \
  938. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CRSEN);\
  939. /* Delay after an RCC peripheral clock enabling */ \
  940. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CRSEN);\
  941. UNUSED(tmpreg); \
  942. } while(0U)
  943. #define __HAL_RCC_CRS_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CRSEN))
  944. #endif /* CRS */
  945. #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  946. #define __HAL_RCC_USART5_CLK_ENABLE() do { \
  947. __IO uint32_t tmpreg; \
  948. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART5EN);\
  949. /* Delay after an RCC peripheral clock enabling */ \
  950. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART5EN);\
  951. UNUSED(tmpreg); \
  952. } while(0U)
  953. #define __HAL_RCC_USART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART5EN))
  954. #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
  955. /** @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  956. * @note After reset, the peripheral clock (used for registers read/write access)
  957. * is disabled and the application software has to enable this clock before
  958. * using it.
  959. */
  960. #if defined(STM32F030x8) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  961. || defined(STM32F051x8) || defined(STM32F058xx)\
  962. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  963. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  964. #define __HAL_RCC_TIM15_CLK_ENABLE() do { \
  965. __IO uint32_t tmpreg; \
  966. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN);\
  967. /* Delay after an RCC peripheral clock enabling */ \
  968. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN);\
  969. UNUSED(tmpreg); \
  970. } while(0U)
  971. #define __HAL_RCC_TIM15_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM15EN))
  972. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || STM32F070x6 || */
  973. /* STM32F051x8 || STM32F058xx || */
  974. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  975. /* STM32F091xC || STM32F098xx || STM32F030xC */
  976. #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  977. #define __HAL_RCC_USART6_CLK_ENABLE() do { \
  978. __IO uint32_t tmpreg; \
  979. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
  980. /* Delay after an RCC peripheral clock enabling */ \
  981. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
  982. UNUSED(tmpreg); \
  983. } while(0U)
  984. #define __HAL_RCC_USART6_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART6EN))
  985. #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
  986. #if defined(STM32F091xC) || defined(STM32F098xx)
  987. #define __HAL_RCC_USART7_CLK_ENABLE() do { \
  988. __IO uint32_t tmpreg; \
  989. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART7EN);\
  990. /* Delay after an RCC peripheral clock enabling */ \
  991. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART7EN);\
  992. UNUSED(tmpreg); \
  993. } while(0U)
  994. #define __HAL_RCC_USART8_CLK_ENABLE() do { \
  995. __IO uint32_t tmpreg; \
  996. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART8EN);\
  997. /* Delay after an RCC peripheral clock enabling */ \
  998. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART8EN);\
  999. UNUSED(tmpreg); \
  1000. } while(0U)
  1001. #define __HAL_RCC_USART7_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART7EN))
  1002. #define __HAL_RCC_USART8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART8EN))
  1003. #endif /* STM32F091xC || STM32F098xx */
  1004. /**
  1005. * @}
  1006. */
  1007. /** @defgroup RCCEx_Force_Release_Peripheral_Reset RCCEx Force Release Peripheral Reset
  1008. * @brief Forces or releases peripheral reset.
  1009. * @{
  1010. */
  1011. /** @brief Force or release AHB peripheral reset.
  1012. */
  1013. #if defined(GPIOD)
  1014. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIODRST))
  1015. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIODRST))
  1016. #endif /* GPIOD */
  1017. #if defined(GPIOE)
  1018. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIOERST))
  1019. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIOERST))
  1020. #endif /* GPIOE */
  1021. #if defined(STM32F042x6) || defined(STM32F048xx)\
  1022. || defined(STM32F051x8) || defined(STM32F058xx)\
  1023. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1024. || defined(STM32F091xC) || defined(STM32F098xx)
  1025. #define __HAL_RCC_TSC_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_TSCRST))
  1026. #define __HAL_RCC_TSC_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_TSCRST))
  1027. #endif /* STM32F042x6 || STM32F048xx || */
  1028. /* STM32F051x8 || STM32F058xx || */
  1029. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1030. /* STM32F091xC || STM32F098xx */
  1031. /** @brief Force or release APB1 peripheral reset.
  1032. */
  1033. #if defined(STM32F030x8) \
  1034. || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  1035. || defined(STM32F051x8) || defined(STM32F058xx)\
  1036. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1037. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1038. #define __HAL_RCC_USART2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
  1039. #define __HAL_RCC_SPI2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
  1040. #define __HAL_RCC_USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
  1041. #define __HAL_RCC_SPI2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI2RST))
  1042. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || STM32F070x6 || */
  1043. /* STM32F051x8 || STM32F058xx || */
  1044. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1045. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1046. #if defined(STM32F031x6) || defined(STM32F038xx)\
  1047. || defined(STM32F042x6) || defined(STM32F048xx)\
  1048. || defined(STM32F051x8) || defined(STM32F058xx)\
  1049. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1050. || defined(STM32F091xC) || defined(STM32F098xx)
  1051. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  1052. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  1053. #endif /* STM32F031x6 || STM32F038xx || */
  1054. /* STM32F042x6 || STM32F048xx || */
  1055. /* STM32F051x8 || STM32F058xx || */
  1056. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1057. /* STM32F091xC || STM32F098xx */
  1058. #if defined(STM32F030x8) \
  1059. || defined(STM32F051x8) || defined(STM32F058xx)\
  1060. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1061. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1062. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  1063. #define __HAL_RCC_I2C2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
  1064. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  1065. #define __HAL_RCC_I2C2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C2RST))
  1066. #endif /* STM32F030x8 || */
  1067. /* STM32F051x8 || STM32F058xx || */
  1068. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1069. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1070. #if defined(STM32F051x8) || defined(STM32F058xx)\
  1071. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1072. || defined(STM32F091xC) || defined(STM32F098xx)
  1073. #define __HAL_RCC_DAC1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  1074. #define __HAL_RCC_DAC1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  1075. #endif /* STM32F051x8 || STM32F058xx || */
  1076. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1077. /* STM32F091xC || STM32F098xx */
  1078. #if defined(STM32F042x6) || defined(STM32F048xx)\
  1079. || defined(STM32F051x8) || defined(STM32F058xx)\
  1080. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1081. || defined(STM32F091xC) || defined(STM32F098xx)
  1082. #define __HAL_RCC_CEC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CECRST))
  1083. #define __HAL_RCC_CEC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CECRST))
  1084. #endif /* STM32F042x6 || STM32F048xx || */
  1085. /* STM32F051x8 || STM32F058xx || */
  1086. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1087. /* STM32F091xC || STM32F098xx */
  1088. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1089. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1090. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  1091. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  1092. #define __HAL_RCC_USART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART4RST))
  1093. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  1094. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  1095. #define __HAL_RCC_USART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART4RST))
  1096. #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1097. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1098. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  1099. || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
  1100. #define __HAL_RCC_USB_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USBRST))
  1101. #define __HAL_RCC_USB_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USBRST))
  1102. #endif /* STM32F042x6 || STM32F048xx || STM32F070x6 || */
  1103. /* STM32F072xB || STM32F078xx || STM32F070xB */
  1104. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB)\
  1105. || defined(STM32F091xC) || defined(STM32F098xx)
  1106. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CANRST))
  1107. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CANRST))
  1108. #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || */
  1109. /* STM32F091xC || STM32F098xx */
  1110. #if defined(CRS)
  1111. #define __HAL_RCC_CRS_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CRSRST))
  1112. #define __HAL_RCC_CRS_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CRSRST))
  1113. #endif /* CRS */
  1114. #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1115. #define __HAL_RCC_USART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART5RST))
  1116. #define __HAL_RCC_USART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART5RST))
  1117. #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
  1118. /** @brief Force or release APB2 peripheral reset.
  1119. */
  1120. #if defined(STM32F030x8) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  1121. || defined(STM32F051x8) || defined(STM32F058xx)\
  1122. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1123. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1124. #define __HAL_RCC_TIM15_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM15RST))
  1125. #define __HAL_RCC_TIM15_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM15RST))
  1126. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || STM32F070x6 || */
  1127. /* STM32F051x8 || STM32F058xx || */
  1128. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1129. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1130. #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1131. #define __HAL_RCC_USART6_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART6RST))
  1132. #define __HAL_RCC_USART6_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART6RST))
  1133. #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
  1134. #if defined(STM32F091xC) || defined(STM32F098xx)
  1135. #define __HAL_RCC_USART7_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART7RST))
  1136. #define __HAL_RCC_USART8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART8RST))
  1137. #define __HAL_RCC_USART7_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART7RST))
  1138. #define __HAL_RCC_USART8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART8RST))
  1139. #endif /* STM32F091xC || STM32F098xx */
  1140. /**
  1141. * @}
  1142. */
  1143. /** @defgroup RCCEx_Peripheral_Clock_Enable_Disable_Status Peripheral Clock Enable Disable Status
  1144. * @brief Get the enable or disable status of peripheral clock.
  1145. * @note After reset, the peripheral clock (used for registers read/write access)
  1146. * is disabled and the application software has to enable this clock before
  1147. * using it.
  1148. * @{
  1149. */
  1150. /** @brief AHB Peripheral Clock Enable Disable Status
  1151. */
  1152. #if defined(GPIOD)
  1153. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIODEN)) != RESET)
  1154. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIODEN)) == RESET)
  1155. #endif /* GPIOD */
  1156. #if defined(GPIOE)
  1157. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOEEN)) != RESET)
  1158. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOEEN)) == RESET)
  1159. #endif /* GPIOE */
  1160. #if defined(STM32F042x6) || defined(STM32F048xx)\
  1161. || defined(STM32F051x8) || defined(STM32F058xx)\
  1162. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1163. || defined(STM32F091xC) || defined(STM32F098xx)
  1164. #define __HAL_RCC_TSC_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_TSCEN)) != RESET)
  1165. #define __HAL_RCC_TSC_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_TSCEN)) == RESET)
  1166. #endif /* STM32F042x6 || STM32F048xx || */
  1167. /* STM32F051x8 || STM32F058xx || */
  1168. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1169. /* STM32F091xC || STM32F098xx */
  1170. #if defined(STM32F091xC) || defined(STM32F098xx)
  1171. #define __HAL_RCC_DMA2_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA2EN)) != RESET)
  1172. #define __HAL_RCC_DMA2_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA2EN)) == RESET)
  1173. #endif /* STM32F091xC || STM32F098xx */
  1174. /** @brief APB1 Peripheral Clock Enable Disable Status
  1175. */
  1176. #if defined(STM32F030x8)\
  1177. || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  1178. || defined(STM32F051x8) || defined(STM32F058xx)\
  1179. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1180. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1181. #define __HAL_RCC_USART2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) != RESET)
  1182. #define __HAL_RCC_USART2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) == RESET)
  1183. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || */
  1184. /* STM32F051x8 || STM32F058xx || STM32F070x6 || */
  1185. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1186. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1187. #if defined(STM32F030x8)\
  1188. || defined(STM32F042x6) || defined(STM32F048xx)\
  1189. || defined(STM32F051x8) || defined(STM32F058xx)\
  1190. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1191. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1192. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) != RESET)
  1193. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) == RESET)
  1194. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || */
  1195. /* STM32F051x8 || STM32F058xx || */
  1196. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1197. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1198. #if defined(STM32F031x6) || defined(STM32F038xx)\
  1199. || defined(STM32F042x6) || defined(STM32F048xx)\
  1200. || defined(STM32F051x8) || defined(STM32F058xx)\
  1201. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1202. || defined(STM32F091xC) || defined(STM32F098xx)
  1203. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  1204. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  1205. #endif /* STM32F031x6 || STM32F038xx || */
  1206. /* STM32F042x6 || STM32F048xx || */
  1207. /* STM32F051x8 || STM32F058xx || */
  1208. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1209. /* STM32F091xC || STM32F098xx */
  1210. #if defined(STM32F030x8) \
  1211. || defined(STM32F051x8) || defined(STM32F058xx)\
  1212. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1213. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1214. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  1215. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) != RESET)
  1216. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  1217. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) == RESET)
  1218. #endif /* STM32F030x8 || */
  1219. /* STM32F051x8 || STM32F058xx || */
  1220. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1221. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1222. #if defined(STM32F051x8) || defined(STM32F058xx)\
  1223. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1224. || defined(STM32F091xC) || defined(STM32F098xx)
  1225. #define __HAL_RCC_DAC1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DAC1EN)) != RESET)
  1226. #define __HAL_RCC_DAC1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DAC1EN)) == RESET)
  1227. #endif /* STM32F051x8 || STM32F058xx || */
  1228. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1229. /* STM32F091xC || STM32F098xx */
  1230. #if defined(STM32F042x6) || defined(STM32F048xx)\
  1231. || defined(STM32F051x8) || defined(STM32F058xx)\
  1232. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1233. || defined(STM32F091xC) || defined(STM32F098xx)
  1234. #define __HAL_RCC_CEC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CECEN)) != RESET)
  1235. #define __HAL_RCC_CEC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CECEN)) == RESET)
  1236. #endif /* STM32F042x6 || STM32F048xx || */
  1237. /* STM32F051x8 || STM32F058xx || */
  1238. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1239. /* STM32F091xC || STM32F098xx */
  1240. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1241. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1242. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  1243. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
  1244. #define __HAL_RCC_USART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART4EN)) != RESET)
  1245. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  1246. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
  1247. #define __HAL_RCC_USART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART4EN)) == RESET)
  1248. #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1249. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1250. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  1251. || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)
  1252. #define __HAL_RCC_USB_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USBEN)) != RESET)
  1253. #define __HAL_RCC_USB_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USBEN)) == RESET)
  1254. #endif /* STM32F042x6 || STM32F048xx || STM32F070x6 || */
  1255. /* STM32F072xB || STM32F078xx || STM32F070xB */
  1256. #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB)\
  1257. || defined(STM32F091xC) || defined(STM32F098xx)
  1258. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) != RESET)
  1259. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) == RESET)
  1260. #endif /* STM32F042x6 || STM32F048xx || STM32F072xB || */
  1261. /* STM32F091xC || STM32F098xx */
  1262. #if defined(CRS)
  1263. #define __HAL_RCC_CRS_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CRSEN)) != RESET)
  1264. #define __HAL_RCC_CRS_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CRSEN)) == RESET)
  1265. #endif /* CRS */
  1266. #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1267. #define __HAL_RCC_USART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART5EN)) != RESET)
  1268. #define __HAL_RCC_USART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART5EN)) == RESET)
  1269. #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
  1270. /** @brief APB1 Peripheral Clock Enable Disable Status
  1271. */
  1272. #if defined(STM32F030x8) || defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F070x6)\
  1273. || defined(STM32F051x8) || defined(STM32F058xx)\
  1274. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)\
  1275. || defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1276. #define __HAL_RCC_TIM15_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM15EN)) != RESET)
  1277. #define __HAL_RCC_TIM15_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM15EN)) == RESET)
  1278. #endif /* STM32F030x8 || STM32F042x6 || STM32F048xx || STM32F070x6 || */
  1279. /* STM32F051x8 || STM32F058xx || */
  1280. /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F070xB || */
  1281. /* STM32F091xC || STM32F098xx || STM32F030xC */
  1282. #if defined(STM32F091xC) || defined(STM32F098xx) || defined(STM32F030xC)
  1283. #define __HAL_RCC_USART6_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART6EN)) != RESET)
  1284. #define __HAL_RCC_USART6_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART6EN)) == RESET)
  1285. #endif /* STM32F091xC || STM32F098xx || STM32F030xC */
  1286. #if defined(STM32F091xC) || defined(STM32F098xx)
  1287. #define __HAL_RCC_USART7_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART7EN)) != RESET)
  1288. #define __HAL_RCC_USART8_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART8EN)) != RESET)
  1289. #define __HAL_RCC_USART7_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART7EN)) == RESET)
  1290. #define __HAL_RCC_USART8_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART8EN)) == RESET)
  1291. #endif /* STM32F091xC || STM32F098xx */
  1292. /**
  1293. * @}
  1294. */
  1295. /** @defgroup RCCEx_HSI48_Enable_Disable RCCEx HSI48 Enable Disable
  1296. * @brief Macros to enable or disable the Internal 48Mhz High Speed oscillator (HSI48).
  1297. * @note The HSI48 is stopped by hardware when entering STOP and STANDBY modes.
  1298. * @note HSI48 can not be stopped if it is used as system clock source. In this case,
  1299. * you have to select another source of the system clock then stop the HSI14.
  1300. * @note After enabling the HSI48 with __HAL_RCC_HSI48_ENABLE(), the application software
  1301. * should wait on HSI48RDY flag to be set indicating that HSI48 clock is stable and can be
  1302. * used as system clock source. This is not necessary if HAL_RCC_OscConfig() is used.
  1303. * @note When the HSI48 is stopped, HSI48RDY flag goes low after 6 HSI48 oscillator
  1304. * clock cycles.
  1305. * @{
  1306. */
  1307. #if defined(RCC_HSI48_SUPPORT)
  1308. #define __HAL_RCC_HSI48_ENABLE() SET_BIT(RCC->CR2, RCC_CR2_HSI48ON)
  1309. #define __HAL_RCC_HSI48_DISABLE() CLEAR_BIT(RCC->CR2, RCC_CR2_HSI48ON)
  1310. /** @brief Macro to get the Internal 48Mhz High Speed oscillator (HSI48) state.
  1311. * @retval The clock source can be one of the following values:
  1312. * @arg @ref RCC_HSI48_ON HSI48 enabled
  1313. * @arg @ref RCC_HSI48_OFF HSI48 disabled
  1314. */
  1315. #define __HAL_RCC_GET_HSI48_STATE() \
  1316. (((uint32_t)(READ_BIT(RCC->CR2, RCC_CR2_HSI48ON)) != RESET) ? RCC_HSI48_ON : RCC_HSI48_OFF)
  1317. #endif /* RCC_HSI48_SUPPORT */
  1318. /**
  1319. * @}
  1320. */
  1321. /** @defgroup RCCEx_Peripheral_Clock_Source_Config RCCEx Peripheral Clock Source Config
  1322. * @{
  1323. */
  1324. #if defined(STM32F042x6) || defined(STM32F048xx)\
  1325. || defined(STM32F072xB) || defined(STM32F078xx)\
  1326. || defined(STM32F070x6) || defined(STM32F070xB)
  1327. /** @brief Macro to configure the USB clock (USBCLK).
  1328. * @param __USBCLKSOURCE__ specifies the USB clock source.
  1329. * This parameter can be one of the following values:
  1330. @if STM32F070xB
  1331. @elseif STM32F070x6
  1332. @else
  1333. * @arg @ref RCC_USBCLKSOURCE_HSI48 HSI48 selected as USB clock
  1334. @endif
  1335. * @arg @ref RCC_USBCLKSOURCE_PLL PLL Clock selected as USB clock
  1336. */
  1337. #define __HAL_RCC_USB_CONFIG(__USBCLKSOURCE__) \
  1338. MODIFY_REG(RCC->CFGR3, RCC_CFGR3_USBSW, (uint32_t)(__USBCLKSOURCE__))
  1339. /** @brief Macro to get the USB clock source.
  1340. * @retval The clock source can be one of the following values:
  1341. @if STM32F070xB
  1342. @elseif STM32F070x6
  1343. @else
  1344. * @arg @ref RCC_USBCLKSOURCE_HSI48 HSI48 selected as USB clock
  1345. @endif
  1346. * @arg @ref RCC_USBCLKSOURCE_PLL PLL Clock selected as USB clock
  1347. */
  1348. #define __HAL_RCC_GET_USB_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_USBSW)))
  1349. #endif /* STM32F042x6 || STM32F048xx || */
  1350. /* STM32F072xB || STM32F078xx || */
  1351. /* STM32F070x6 || STM32F070xB */
  1352. #if defined(STM32F042x6) || defined(STM32F048xx)\
  1353. || defined(STM32F051x8) || defined(STM32F058xx)\
  1354. || defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1355. || defined(STM32F091xC) || defined(STM32F098xx)
  1356. /** @brief Macro to configure the CEC clock.
  1357. * @param __CECCLKSOURCE__ specifies the CEC clock source.
  1358. * This parameter can be one of the following values:
  1359. * @arg @ref RCC_CECCLKSOURCE_HSI HSI selected as CEC clock
  1360. * @arg @ref RCC_CECCLKSOURCE_LSE LSE selected as CEC clock
  1361. */
  1362. #define __HAL_RCC_CEC_CONFIG(__CECCLKSOURCE__) \
  1363. MODIFY_REG(RCC->CFGR3, RCC_CFGR3_CECSW, (uint32_t)(__CECCLKSOURCE__))
  1364. /** @brief Macro to get the HDMI CEC clock source.
  1365. * @retval The clock source can be one of the following values:
  1366. * @arg @ref RCC_CECCLKSOURCE_HSI HSI selected as CEC clock
  1367. * @arg @ref RCC_CECCLKSOURCE_LSE LSE selected as CEC clock
  1368. */
  1369. #define __HAL_RCC_GET_CEC_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_CECSW)))
  1370. #endif /* STM32F042x6 || STM32F048xx || */
  1371. /* STM32F051x8 || STM32F058xx || */
  1372. /* STM32F071xB || STM32F072xB || STM32F078xx || */
  1373. /* STM32F091xC || defined(STM32F098xx) */
  1374. #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)\
  1375. || defined(STM32F091xC) || defined(STM32F098xx)
  1376. /** @brief Macro to configure the USART2 clock (USART2CLK).
  1377. * @param __USART2CLKSOURCE__ specifies the USART2 clock source.
  1378. * This parameter can be one of the following values:
  1379. * @arg @ref RCC_USART2CLKSOURCE_PCLK1 PCLK1 selected as USART2 clock
  1380. * @arg @ref RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock
  1381. * @arg @ref RCC_USART2CLKSOURCE_SYSCLK System Clock selected as USART2 clock
  1382. * @arg @ref RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock
  1383. */
  1384. #define __HAL_RCC_USART2_CONFIG(__USART2CLKSOURCE__) \
  1385. MODIFY_REG(RCC->CFGR3, RCC_CFGR3_USART2SW, (uint32_t)(__USART2CLKSOURCE__))
  1386. /** @brief Macro to get the USART2 clock source.
  1387. * @retval The clock source can be one of the following values:
  1388. * @arg @ref RCC_USART2CLKSOURCE_PCLK1 PCLK1 selected as USART2 clock
  1389. * @arg @ref RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock
  1390. * @arg @ref RCC_USART2CLKSOURCE_SYSCLK System Clock selected as USART2 clock
  1391. * @arg @ref RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock
  1392. */
  1393. #define __HAL_RCC_GET_USART2_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_USART2SW)))
  1394. #endif /* STM32F071xB || STM32F072xB || STM32F078xx || STM32F091xC || STM32F098xx*/
  1395. #if defined(STM32F091xC) || defined(STM32F098xx)
  1396. /** @brief Macro to configure the USART3 clock (USART3CLK).
  1397. * @param __USART3CLKSOURCE__ specifies the USART3 clock source.
  1398. * This parameter can be one of the following values:
  1399. * @arg @ref RCC_USART3CLKSOURCE_PCLK1 PCLK1 selected as USART3 clock
  1400. * @arg @ref RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock
  1401. * @arg @ref RCC_USART3CLKSOURCE_SYSCLK System Clock selected as USART3 clock
  1402. * @arg @ref RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock
  1403. */
  1404. #define __HAL_RCC_USART3_CONFIG(__USART3CLKSOURCE__) \
  1405. MODIFY_REG(RCC->CFGR3, RCC_CFGR3_USART3SW, (uint32_t)(__USART3CLKSOURCE__))
  1406. /** @brief Macro to get the USART3 clock source.
  1407. * @retval The clock source can be one of the following values:
  1408. * @arg @ref RCC_USART3CLKSOURCE_PCLK1 PCLK1 selected as USART3 clock
  1409. * @arg @ref RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock
  1410. * @arg @ref RCC_USART3CLKSOURCE_SYSCLK System Clock selected as USART3 clock
  1411. * @arg @ref RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock
  1412. */
  1413. #define __HAL_RCC_GET_USART3_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR3, RCC_CFGR3_USART3SW)))
  1414. #endif /* STM32F091xC || STM32F098xx */
  1415. /**
  1416. * @}
  1417. */
  1418. /** @defgroup RCCEx_LSE_Configuration LSE Drive Configuration
  1419. * @{
  1420. */
  1421. /**
  1422. * @brief Macro to configure the External Low Speed oscillator (LSE) drive capability.
  1423. * @param __RCC_LSEDRIVE__ specifies the new state of the LSE drive capability.
  1424. * This parameter can be one of the following values:
  1425. * @arg @ref RCC_LSEDRIVE_LOW LSE oscillator low drive capability.
  1426. * @arg @ref RCC_LSEDRIVE_MEDIUMLOW LSE oscillator medium low drive capability.
  1427. * @arg @ref RCC_LSEDRIVE_MEDIUMHIGH LSE oscillator medium high drive capability.
  1428. * @arg @ref RCC_LSEDRIVE_HIGH LSE oscillator high drive capability.
  1429. * @retval None
  1430. */
  1431. #define __HAL_RCC_LSEDRIVE_CONFIG(__RCC_LSEDRIVE__) (MODIFY_REG(RCC->BDCR,\
  1432. RCC_BDCR_LSEDRV, (uint32_t)(__RCC_LSEDRIVE__) ))
  1433. /**
  1434. * @}
  1435. */
  1436. #if defined(CRS)
  1437. /** @defgroup RCCEx_IT_And_Flag RCCEx IT and Flag
  1438. * @{
  1439. */
  1440. /* Interrupt & Flag management */
  1441. /**
  1442. * @brief Enable the specified CRS interrupts.
  1443. * @param __INTERRUPT__ specifies the CRS interrupt sources to be enabled.
  1444. * This parameter can be any combination of the following values:
  1445. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1446. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1447. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1448. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1449. * @retval None
  1450. */
  1451. #define __HAL_RCC_CRS_ENABLE_IT(__INTERRUPT__) SET_BIT(CRS->CR, (__INTERRUPT__))
  1452. /**
  1453. * @brief Disable the specified CRS interrupts.
  1454. * @param __INTERRUPT__ specifies the CRS interrupt sources to be disabled.
  1455. * This parameter can be any combination of the following values:
  1456. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1457. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1458. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1459. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1460. * @retval None
  1461. */
  1462. #define __HAL_RCC_CRS_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(CRS->CR, (__INTERRUPT__))
  1463. /** @brief Check whether the CRS interrupt has occurred or not.
  1464. * @param __INTERRUPT__ specifies the CRS interrupt source to check.
  1465. * This parameter can be one of the following values:
  1466. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1467. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1468. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1469. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1470. * @retval The new state of __INTERRUPT__ (SET or RESET).
  1471. */
  1472. #define __HAL_RCC_CRS_GET_IT_SOURCE(__INTERRUPT__) ((READ_BIT(CRS->CR, (__INTERRUPT__)) != RESET) ? SET : RESET)
  1473. /** @brief Clear the CRS interrupt pending bits
  1474. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  1475. * This parameter can be any combination of the following values:
  1476. * @arg @ref RCC_CRS_IT_SYNCOK SYNC event OK interrupt
  1477. * @arg @ref RCC_CRS_IT_SYNCWARN SYNC warning interrupt
  1478. * @arg @ref RCC_CRS_IT_ERR Synchronization or trimming error interrupt
  1479. * @arg @ref RCC_CRS_IT_ESYNC Expected SYNC interrupt
  1480. * @arg @ref RCC_CRS_IT_TRIMOVF Trimming overflow or underflow interrupt
  1481. * @arg @ref RCC_CRS_IT_SYNCERR SYNC error interrupt
  1482. * @arg @ref RCC_CRS_IT_SYNCMISS SYNC missed interrupt
  1483. */
  1484. #define __HAL_RCC_CRS_CLEAR_IT(__INTERRUPT__) do { \
  1485. if(((__INTERRUPT__) & RCC_CRS_IT_ERROR_MASK) != RESET) \
  1486. { \
  1487. WRITE_REG(CRS->ICR, CRS_ICR_ERRC | ((__INTERRUPT__) & ~RCC_CRS_IT_ERROR_MASK)); \
  1488. } \
  1489. else \
  1490. { \
  1491. WRITE_REG(CRS->ICR, (__INTERRUPT__)); \
  1492. } \
  1493. } while(0U)
  1494. /**
  1495. * @brief Check whether the specified CRS flag is set or not.
  1496. * @param __FLAG__ specifies the flag to check.
  1497. * This parameter can be one of the following values:
  1498. * @arg @ref RCC_CRS_FLAG_SYNCOK SYNC event OK
  1499. * @arg @ref RCC_CRS_FLAG_SYNCWARN SYNC warning
  1500. * @arg @ref RCC_CRS_FLAG_ERR Error
  1501. * @arg @ref RCC_CRS_FLAG_ESYNC Expected SYNC
  1502. * @arg @ref RCC_CRS_FLAG_TRIMOVF Trimming overflow or underflow
  1503. * @arg @ref RCC_CRS_FLAG_SYNCERR SYNC error
  1504. * @arg @ref RCC_CRS_FLAG_SYNCMISS SYNC missed
  1505. * @retval The new state of _FLAG_ (TRUE or FALSE).
  1506. */
  1507. #define __HAL_RCC_CRS_GET_FLAG(__FLAG__) (READ_BIT(CRS->ISR, (__FLAG__)) == (__FLAG__))
  1508. /**
  1509. * @brief Clear the CRS specified FLAG.
  1510. * @param __FLAG__ specifies the flag to clear.
  1511. * This parameter can be one of the following values:
  1512. * @arg @ref RCC_CRS_FLAG_SYNCOK SYNC event OK
  1513. * @arg @ref RCC_CRS_FLAG_SYNCWARN SYNC warning
  1514. * @arg @ref RCC_CRS_FLAG_ERR Error
  1515. * @arg @ref RCC_CRS_FLAG_ESYNC Expected SYNC
  1516. * @arg @ref RCC_CRS_FLAG_TRIMOVF Trimming overflow or underflow
  1517. * @arg @ref RCC_CRS_FLAG_SYNCERR SYNC error
  1518. * @arg @ref RCC_CRS_FLAG_SYNCMISS SYNC missed
  1519. * @note RCC_CRS_FLAG_ERR clears RCC_CRS_FLAG_TRIMOVF, RCC_CRS_FLAG_SYNCERR, RCC_CRS_FLAG_SYNCMISS and consequently RCC_CRS_FLAG_ERR
  1520. * @retval None
  1521. */
  1522. #define __HAL_RCC_CRS_CLEAR_FLAG(__FLAG__) do { \
  1523. if(((__FLAG__) & RCC_CRS_FLAG_ERROR_MASK) != RESET) \
  1524. { \
  1525. WRITE_REG(CRS->ICR, CRS_ICR_ERRC | ((__FLAG__) & ~RCC_CRS_FLAG_ERROR_MASK)); \
  1526. } \
  1527. else \
  1528. { \
  1529. WRITE_REG(CRS->ICR, (__FLAG__)); \
  1530. } \
  1531. } while(0U)
  1532. /**
  1533. * @}
  1534. */
  1535. /** @defgroup RCCEx_CRS_Extended_Features RCCEx CRS Extended Features
  1536. * @{
  1537. */
  1538. /**
  1539. * @brief Enable the oscillator clock for frequency error counter.
  1540. * @note when the CEN bit is set the CRS_CFGR register becomes write-protected.
  1541. * @retval None
  1542. */
  1543. #define __HAL_RCC_CRS_FREQ_ERROR_COUNTER_ENABLE() SET_BIT(CRS->CR, CRS_CR_CEN)
  1544. /**
  1545. * @brief Disable the oscillator clock for frequency error counter.
  1546. * @retval None
  1547. */
  1548. #define __HAL_RCC_CRS_FREQ_ERROR_COUNTER_DISABLE() CLEAR_BIT(CRS->CR, CRS_CR_CEN)
  1549. /**
  1550. * @brief Enable the automatic hardware adjustment of TRIM bits.
  1551. * @note When the AUTOTRIMEN bit is set the CRS_CFGR register becomes write-protected.
  1552. * @retval None
  1553. */
  1554. #define __HAL_RCC_CRS_AUTOMATIC_CALIB_ENABLE() SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN)
  1555. /**
  1556. * @brief Disable the automatic hardware adjustment of TRIM bits.
  1557. * @retval None
  1558. */
  1559. #define __HAL_RCC_CRS_AUTOMATIC_CALIB_DISABLE() CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN)
  1560. /**
  1561. * @brief Macro to calculate reload value to be set in CRS register according to target and sync frequencies
  1562. * @note The RELOAD value should be selected according to the ratio between the target frequency and the frequency
  1563. * of the synchronization source after prescaling. It is then decreased by one in order to
  1564. * reach the expected synchronization on the zero value. The formula is the following:
  1565. * RELOAD = (fTARGET / fSYNC) -1
  1566. * @param __FTARGET__ Target frequency (value in Hz)
  1567. * @param __FSYNC__ Synchronization signal frequency (value in Hz)
  1568. * @retval None
  1569. */
  1570. #define __HAL_RCC_CRS_RELOADVALUE_CALCULATE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
  1571. /**
  1572. * @}
  1573. */
  1574. #endif /* CRS */
  1575. /**
  1576. * @}
  1577. */
  1578. /* Exported functions --------------------------------------------------------*/
  1579. /** @addtogroup RCCEx_Exported_Functions
  1580. * @{
  1581. */
  1582. /** @addtogroup RCCEx_Exported_Functions_Group1
  1583. * @{
  1584. */
  1585. HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  1586. void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  1587. uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk);
  1588. /**
  1589. * @}
  1590. */
  1591. #if defined(CRS)
  1592. /** @addtogroup RCCEx_Exported_Functions_Group3
  1593. * @{
  1594. */
  1595. void HAL_RCCEx_CRSConfig(RCC_CRSInitTypeDef *pInit);
  1596. void HAL_RCCEx_CRSSoftwareSynchronizationGenerate(void);
  1597. void HAL_RCCEx_CRSGetSynchronizationInfo(RCC_CRSSynchroInfoTypeDef *pSynchroInfo);
  1598. uint32_t HAL_RCCEx_CRSWaitSynchronization(uint32_t Timeout);
  1599. void HAL_RCCEx_CRS_IRQHandler(void);
  1600. void HAL_RCCEx_CRS_SyncOkCallback(void);
  1601. void HAL_RCCEx_CRS_SyncWarnCallback(void);
  1602. void HAL_RCCEx_CRS_ExpectedSyncCallback(void);
  1603. void HAL_RCCEx_CRS_ErrorCallback(uint32_t Error);
  1604. /**
  1605. * @}
  1606. */
  1607. #endif /* CRS */
  1608. /**
  1609. * @}
  1610. */
  1611. /**
  1612. * @}
  1613. */
  1614. /**
  1615. * @}
  1616. */
  1617. /**
  1618. * @}
  1619. */
  1620. #ifdef __cplusplus
  1621. }
  1622. #endif
  1623. #endif /* __STM32F0xx_HAL_RCC_EX_H */
  1624. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/