stm32f0xx_hal_rcc_ex.h 92 KB

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