stm32f1xx_hal_rcc_ex.h 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_rcc_ex.h
  4. * @author MCD Application Team
  5. * @version V1.0.4
  6. * @date 29-April-2016
  7. * @brief Header file of RCC HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F1xx_HAL_RCC_EX_H
  39. #define __STM32F1xx_HAL_RCC_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f1xx_hal_def.h"
  45. /** @addtogroup STM32F1xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup RCCEx
  49. * @{
  50. */
  51. /** @addtogroup RCCEx_Private_Constants
  52. * @{
  53. */
  54. #if defined(STM32F105xC) || defined(STM32F107xC)
  55. /* Alias word address of PLLI2SON bit */
  56. #define PLLI2SON_BITNUMBER POSITION_VAL(RCC_CR_PLL3ON)
  57. #define RCC_CR_PLLI2SON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32) + (PLLI2SON_BITNUMBER * 4)))
  58. /* Alias word address of PLL2ON bit */
  59. #define PLL2ON_BITNUMBER POSITION_VAL(RCC_CR_PLL2ON)
  60. #define RCC_CR_PLL2ON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32) + (PLL2ON_BITNUMBER * 4)))
  61. #define PLLI2S_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */
  62. #define PLL2_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */
  63. #endif /* STM32F105xC || STM32F107xC */
  64. #define CR_REG_INDEX ((uint8_t)1)
  65. /**
  66. * @}
  67. */
  68. /** @addtogroup RCCEx_Private_Macros
  69. * @{
  70. */
  71. #if defined(STM32F105xC) || defined(STM32F107xC)
  72. #define IS_RCC_PREDIV1_SOURCE(__SOURCE__) (((__SOURCE__) == RCC_PREDIV1_SOURCE_HSE) || \
  73. ((__SOURCE__) == RCC_PREDIV1_SOURCE_PLL2))
  74. #endif /* STM32F105xC || STM32F107xC */
  75. #if defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F100xB)\
  76. || defined(STM32F100xE)
  77. #define IS_RCC_HSE_PREDIV(__DIV__) (((__DIV__) == RCC_HSE_PREDIV_DIV1) || ((__DIV__) == RCC_HSE_PREDIV_DIV2) || \
  78. ((__DIV__) == RCC_HSE_PREDIV_DIV3) || ((__DIV__) == RCC_HSE_PREDIV_DIV4) || \
  79. ((__DIV__) == RCC_HSE_PREDIV_DIV5) || ((__DIV__) == RCC_HSE_PREDIV_DIV6) || \
  80. ((__DIV__) == RCC_HSE_PREDIV_DIV7) || ((__DIV__) == RCC_HSE_PREDIV_DIV8) || \
  81. ((__DIV__) == RCC_HSE_PREDIV_DIV9) || ((__DIV__) == RCC_HSE_PREDIV_DIV10) || \
  82. ((__DIV__) == RCC_HSE_PREDIV_DIV11) || ((__DIV__) == RCC_HSE_PREDIV_DIV12) || \
  83. ((__DIV__) == RCC_HSE_PREDIV_DIV13) || ((__DIV__) == RCC_HSE_PREDIV_DIV14) || \
  84. ((__DIV__) == RCC_HSE_PREDIV_DIV15) || ((__DIV__) == RCC_HSE_PREDIV_DIV16))
  85. #else
  86. #define IS_RCC_HSE_PREDIV(__DIV__) (((__DIV__) == RCC_HSE_PREDIV_DIV1) || ((__DIV__) == RCC_HSE_PREDIV_DIV2))
  87. #endif /* STM32F105xC || STM32F107xC || STM32F100xB || STM32F100xE */
  88. #if defined(STM32F105xC) || defined(STM32F107xC)
  89. #define IS_RCC_PLL_MUL(__MUL__) (((__MUL__) == RCC_PLL_MUL4) || ((__MUL__) == RCC_PLL_MUL5) || \
  90. ((__MUL__) == RCC_PLL_MUL6) || ((__MUL__) == RCC_PLL_MUL7) || \
  91. ((__MUL__) == RCC_PLL_MUL8) || ((__MUL__) == RCC_PLL_MUL9) || \
  92. ((__MUL__) == RCC_PLL_MUL6_5))
  93. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || ((__SOURCE__) == RCC_MCO1SOURCE_HSI) \
  94. || ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) \
  95. || ((__SOURCE__) == RCC_MCO1SOURCE_PLL2CLK) || ((__SOURCE__) == RCC_MCO1SOURCE_PLL3CLK) \
  96. || ((__SOURCE__) == RCC_MCO1SOURCE_PLL3CLK_DIV2) || ((__SOURCE__) == RCC_MCO1SOURCE_EXT_HSE) \
  97. || ((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK))
  98. #else
  99. #define IS_RCC_PLL_MUL(__MUL__) (((__MUL__) == RCC_PLL_MUL2) || ((__MUL__) == RCC_PLL_MUL3) || \
  100. ((__MUL__) == RCC_PLL_MUL4) || ((__MUL__) == RCC_PLL_MUL5) || \
  101. ((__MUL__) == RCC_PLL_MUL6) || ((__MUL__) == RCC_PLL_MUL7) || \
  102. ((__MUL__) == RCC_PLL_MUL8) || ((__MUL__) == RCC_PLL_MUL9) || \
  103. ((__MUL__) == RCC_PLL_MUL10) || ((__MUL__) == RCC_PLL_MUL11) || \
  104. ((__MUL__) == RCC_PLL_MUL12) || ((__MUL__) == RCC_PLL_MUL13) || \
  105. ((__MUL__) == RCC_PLL_MUL14) || ((__MUL__) == RCC_PLL_MUL15) || \
  106. ((__MUL__) == RCC_PLL_MUL16))
  107. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || ((__SOURCE__) == RCC_MCO1SOURCE_HSI) \
  108. || ((__SOURCE__) == RCC_MCO1SOURCE_HSE) || ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) \
  109. || ((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK))
  110. #endif /* STM32F105xC || STM32F107xC*/
  111. #define IS_RCC_ADCPLLCLK_DIV(__ADCCLK__) (((__ADCCLK__) == RCC_ADCPCLK2_DIV2) || ((__ADCCLK__) == RCC_ADCPCLK2_DIV4) || \
  112. ((__ADCCLK__) == RCC_ADCPCLK2_DIV6) || ((__ADCCLK__) == RCC_ADCPCLK2_DIV8))
  113. #if defined(STM32F105xC) || defined(STM32F107xC)
  114. #define IS_RCC_I2S2CLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_I2S2CLKSOURCE_SYSCLK) || ((__SOURCE__) == RCC_I2S2CLKSOURCE_PLLI2S_VCO))
  115. #define IS_RCC_I2S3CLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_I2S3CLKSOURCE_SYSCLK) || ((__SOURCE__) == RCC_I2S3CLKSOURCE_PLLI2S_VCO))
  116. #define IS_RCC_USBPLLCLK_DIV(__USBCLK__) (((__USBCLK__) == RCC_USBCLKSOURCE_PLL_DIV2) || ((__USBCLK__) == RCC_USBCLKSOURCE_PLL_DIV3))
  117. #define IS_RCC_PLLI2S_MUL(__MUL__) (((__MUL__) == RCC_PLLI2S_MUL8) || ((__MUL__) == RCC_PLLI2S_MUL9) || \
  118. ((__MUL__) == RCC_PLLI2S_MUL10) || ((__MUL__) == RCC_PLLI2S_MUL11) || \
  119. ((__MUL__) == RCC_PLLI2S_MUL12) || ((__MUL__) == RCC_PLLI2S_MUL13) || \
  120. ((__MUL__) == RCC_PLLI2S_MUL14) || ((__MUL__) == RCC_PLLI2S_MUL16) || \
  121. ((__MUL__) == RCC_PLLI2S_MUL20))
  122. #define IS_RCC_HSE_PREDIV2(__DIV__) (((__DIV__) == RCC_HSE_PREDIV2_DIV1) || ((__DIV__) == RCC_HSE_PREDIV2_DIV2) || \
  123. ((__DIV__) == RCC_HSE_PREDIV2_DIV3) || ((__DIV__) == RCC_HSE_PREDIV2_DIV4) || \
  124. ((__DIV__) == RCC_HSE_PREDIV2_DIV5) || ((__DIV__) == RCC_HSE_PREDIV2_DIV6) || \
  125. ((__DIV__) == RCC_HSE_PREDIV2_DIV7) || ((__DIV__) == RCC_HSE_PREDIV2_DIV8) || \
  126. ((__DIV__) == RCC_HSE_PREDIV2_DIV9) || ((__DIV__) == RCC_HSE_PREDIV2_DIV10) || \
  127. ((__DIV__) == RCC_HSE_PREDIV2_DIV11) || ((__DIV__) == RCC_HSE_PREDIV2_DIV12) || \
  128. ((__DIV__) == RCC_HSE_PREDIV2_DIV13) || ((__DIV__) == RCC_HSE_PREDIV2_DIV14) || \
  129. ((__DIV__) == RCC_HSE_PREDIV2_DIV15) || ((__DIV__) == RCC_HSE_PREDIV2_DIV16))
  130. #define IS_RCC_PLL2(__PLL__) (((__PLL__) == RCC_PLL2_NONE) || ((__PLL__) == RCC_PLL2_OFF) || \
  131. ((__PLL__) == RCC_PLL2_ON))
  132. #define IS_RCC_PLL2_MUL(__MUL__) (((__MUL__) == RCC_PLL2_MUL8) || ((__MUL__) == RCC_PLL2_MUL9) || \
  133. ((__MUL__) == RCC_PLL2_MUL10) || ((__MUL__) == RCC_PLL2_MUL11) || \
  134. ((__MUL__) == RCC_PLL2_MUL12) || ((__MUL__) == RCC_PLL2_MUL13) || \
  135. ((__MUL__) == RCC_PLL2_MUL14) || ((__MUL__) == RCC_PLL2_MUL16) || \
  136. ((__MUL__) == RCC_PLL2_MUL20))
  137. #define IS_RCC_PERIPHCLOCK(__SELECTION__) \
  138. ((((__SELECTION__) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC) || \
  139. (((__SELECTION__) & RCC_PERIPHCLK_ADC) == RCC_PERIPHCLK_ADC) || \
  140. (((__SELECTION__) & RCC_PERIPHCLK_I2S2) == RCC_PERIPHCLK_I2S2) || \
  141. (((__SELECTION__) & RCC_PERIPHCLK_I2S3) == RCC_PERIPHCLK_I2S3) || \
  142. (((__SELECTION__) & RCC_PERIPHCLK_USB) == RCC_PERIPHCLK_USB))
  143. #elif defined(STM32F103xE) || defined(STM32F103xG)
  144. #define IS_RCC_I2S2CLKSOURCE(__SOURCE__) ((__SOURCE__) == RCC_I2S2CLKSOURCE_SYSCLK)
  145. #define IS_RCC_I2S3CLKSOURCE(__SOURCE__) ((__SOURCE__) == RCC_I2S3CLKSOURCE_SYSCLK)
  146. #define IS_RCC_PERIPHCLOCK(__SELECTION__) \
  147. ((((__SELECTION__) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC) || \
  148. (((__SELECTION__) & RCC_PERIPHCLK_ADC) == RCC_PERIPHCLK_ADC) || \
  149. (((__SELECTION__) & RCC_PERIPHCLK_I2S2) == RCC_PERIPHCLK_I2S2) || \
  150. (((__SELECTION__) & RCC_PERIPHCLK_I2S3) == RCC_PERIPHCLK_I2S3) || \
  151. (((__SELECTION__) & RCC_PERIPHCLK_USB) == RCC_PERIPHCLK_USB))
  152. #elif defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  153. || defined(STM32F103xB)
  154. #define IS_RCC_PERIPHCLOCK(__SELECTION__) \
  155. ((((__SELECTION__) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC) || \
  156. (((__SELECTION__) & RCC_PERIPHCLK_ADC) == RCC_PERIPHCLK_ADC) || \
  157. (((__SELECTION__) & RCC_PERIPHCLK_USB) == RCC_PERIPHCLK_USB))
  158. #else
  159. #define IS_RCC_PERIPHCLOCK(__SELECTION__) \
  160. ((((__SELECTION__) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC) || \
  161. (((__SELECTION__) & RCC_PERIPHCLK_ADC) == RCC_PERIPHCLK_ADC))
  162. #endif /* STM32F105xC || STM32F107xC */
  163. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  164. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)
  165. #define IS_RCC_USBPLLCLK_DIV(__USBCLK__) (((__USBCLK__) == RCC_USBCLKSOURCE_PLL) || ((__USBCLK__) == RCC_USBCLKSOURCE_PLL_DIV1_5))
  166. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG */
  167. /**
  168. * @}
  169. */
  170. /* Exported types ------------------------------------------------------------*/
  171. /** @defgroup RCCEx_Exported_Types RCCEx Exported Types
  172. * @{
  173. */
  174. #if defined(STM32F105xC) || defined(STM32F107xC)
  175. /**
  176. * @brief RCC PLL2 configuration structure definition
  177. */
  178. typedef struct
  179. {
  180. uint32_t PLL2State; /*!< The new state of the PLL2.
  181. This parameter can be a value of @ref RCCEx_PLL2_Config */
  182. uint32_t PLL2MUL; /*!< PLL2MUL: Multiplication factor for PLL2 VCO input clock
  183. This parameter must be a value of @ref RCCEx_PLL2_Multiplication_Factor*/
  184. #if defined(STM32F105xC) || defined(STM32F107xC)
  185. uint32_t HSEPrediv2Value; /*!< The Prediv2 factor value.
  186. This parameter can be a value of @ref RCCEx_Prediv2_Factor */
  187. #endif /* STM32F105xC || STM32F107xC */
  188. } RCC_PLL2InitTypeDef;
  189. #endif /* STM32F105xC || STM32F107xC */
  190. /**
  191. * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
  192. */
  193. typedef struct
  194. {
  195. uint32_t OscillatorType; /*!< The oscillators to be configured.
  196. This parameter can be a value of @ref RCC_Oscillator_Type */
  197. #if defined(STM32F105xC) || defined(STM32F107xC)
  198. uint32_t Prediv1Source; /*!< The Prediv1 source value.
  199. This parameter can be a value of @ref RCCEx_Prediv1_Source */
  200. #endif /* STM32F105xC || STM32F107xC */
  201. uint32_t HSEState; /*!< The new state of the HSE.
  202. This parameter can be a value of @ref RCC_HSE_Config */
  203. uint32_t HSEPredivValue; /*!< The Prediv1 factor value (named PREDIV1 or PLLXTPRE in RM)
  204. This parameter can be a value of @ref RCCEx_Prediv1_Factor */
  205. uint32_t LSEState; /*!< The new state of the LSE.
  206. This parameter can be a value of @ref RCC_LSE_Config */
  207. uint32_t HSIState; /*!< The new state of the HSI.
  208. This parameter can be a value of @ref RCC_HSI_Config */
  209. uint32_t HSICalibrationValue; /*!< The HSI calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  210. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
  211. uint32_t LSIState; /*!< The new state of the LSI.
  212. This parameter can be a value of @ref RCC_LSI_Config */
  213. RCC_PLLInitTypeDef PLL; /*!< PLL structure parameters */
  214. #if defined(STM32F105xC) || defined(STM32F107xC)
  215. RCC_PLL2InitTypeDef PLL2; /*!< PLL2 structure parameters */
  216. #endif /* STM32F105xC || STM32F107xC */
  217. } RCC_OscInitTypeDef;
  218. #if defined(STM32F105xC) || defined(STM32F107xC)
  219. /**
  220. * @brief RCC PLLI2S configuration structure definition
  221. */
  222. typedef struct
  223. {
  224. uint32_t PLLI2SMUL; /*!< PLLI2SMUL: Multiplication factor for PLLI2S VCO input clock
  225. This parameter must be a value of @ref RCCEx_PLLI2S_Multiplication_Factor*/
  226. #if defined(STM32F105xC) || defined(STM32F107xC)
  227. uint32_t HSEPrediv2Value; /*!< The Prediv2 factor value.
  228. This parameter can be a value of @ref RCCEx_Prediv2_Factor */
  229. #endif /* STM32F105xC || STM32F107xC */
  230. } RCC_PLLI2SInitTypeDef;
  231. #endif /* STM32F105xC || STM32F107xC */
  232. /**
  233. * @brief RCC extended clocks structure definition
  234. */
  235. typedef struct
  236. {
  237. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  238. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  239. uint32_t RTCClockSelection; /*!< specifies the RTC clock source.
  240. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  241. uint32_t AdcClockSelection; /*!< ADC clock source
  242. This parameter can be a value of @ref RCCEx_ADC_Prescaler */
  243. #if defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC)\
  244. || defined(STM32F107xC)
  245. uint32_t I2s2ClockSelection; /*!< I2S2 clock source
  246. This parameter can be a value of @ref RCCEx_I2S2_Clock_Source */
  247. uint32_t I2s3ClockSelection; /*!< I2S3 clock source
  248. This parameter can be a value of @ref RCCEx_I2S3_Clock_Source */
  249. #if defined(STM32F105xC) || defined(STM32F107xC)
  250. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters
  251. This parameter will be used only when PLLI2S is selected as Clock Source I2S2 or I2S3 */
  252. #endif /* STM32F105xC || STM32F107xC */
  253. #endif /* STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  254. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  255. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
  256. || defined(STM32F105xC) || defined(STM32F107xC)
  257. uint32_t UsbClockSelection; /*!< USB clock source
  258. This parameter can be a value of @ref RCCEx_USB_Prescaler */
  259. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  260. } RCC_PeriphCLKInitTypeDef;
  261. /**
  262. * @}
  263. */
  264. /* Exported constants --------------------------------------------------------*/
  265. /** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
  266. * @{
  267. */
  268. /** @defgroup RCCEx_Periph_Clock_Selection Periph Clock Selection
  269. * @{
  270. */
  271. #define RCC_PERIPHCLK_RTC ((uint32_t)0x00000001)
  272. #define RCC_PERIPHCLK_ADC ((uint32_t)0x00000002)
  273. #if defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC)\
  274. || defined(STM32F107xC)
  275. #define RCC_PERIPHCLK_I2S2 ((uint32_t)0x00000004)
  276. #define RCC_PERIPHCLK_I2S3 ((uint32_t)0x00000008)
  277. #endif /* STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  278. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  279. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
  280. || defined(STM32F105xC) || defined(STM32F107xC)
  281. #define RCC_PERIPHCLK_USB ((uint32_t)0x00000010)
  282. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  283. /**
  284. * @}
  285. */
  286. /** @defgroup RCCEx_ADC_Prescaler ADC Prescaler
  287. * @{
  288. */
  289. #define RCC_ADCPCLK2_DIV2 RCC_CFGR_ADCPRE_DIV2
  290. #define RCC_ADCPCLK2_DIV4 RCC_CFGR_ADCPRE_DIV4
  291. #define RCC_ADCPCLK2_DIV6 RCC_CFGR_ADCPRE_DIV6
  292. #define RCC_ADCPCLK2_DIV8 RCC_CFGR_ADCPRE_DIV8
  293. /**
  294. * @}
  295. */
  296. #if defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC)\
  297. || defined(STM32F107xC)
  298. /** @defgroup RCCEx_I2S2_Clock_Source I2S2 Clock Source
  299. * @{
  300. */
  301. #define RCC_I2S2CLKSOURCE_SYSCLK ((uint32_t)0x00000000)
  302. #if defined(STM32F105xC) || defined(STM32F107xC)
  303. #define RCC_I2S2CLKSOURCE_PLLI2S_VCO RCC_CFGR2_I2S2SRC
  304. #endif /* STM32F105xC || STM32F107xC */
  305. /**
  306. * @}
  307. */
  308. /** @defgroup RCCEx_I2S3_Clock_Source I2S3 Clock Source
  309. * @{
  310. */
  311. #define RCC_I2S3CLKSOURCE_SYSCLK ((uint32_t)0x00000000)
  312. #if defined(STM32F105xC) || defined(STM32F107xC)
  313. #define RCC_I2S3CLKSOURCE_PLLI2S_VCO RCC_CFGR2_I2S3SRC
  314. #endif /* STM32F105xC || STM32F107xC */
  315. /**
  316. * @}
  317. */
  318. #endif /* STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  319. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  320. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)
  321. /** @defgroup RCCEx_USB_Prescaler USB Prescaler
  322. * @{
  323. */
  324. #define RCC_USBCLKSOURCE_PLL RCC_CFGR_USBPRE
  325. #define RCC_USBCLKSOURCE_PLL_DIV1_5 ((uint32_t)0x00000000)
  326. /**
  327. * @}
  328. */
  329. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG */
  330. #if defined(STM32F105xC) || defined(STM32F107xC)
  331. /** @defgroup RCCEx_USB_Prescaler USB Prescaler
  332. * @{
  333. */
  334. #define RCC_USBCLKSOURCE_PLL_DIV2 RCC_CFGR_OTGFSPRE
  335. #define RCC_USBCLKSOURCE_PLL_DIV3 ((uint32_t)0x00000000)
  336. /**
  337. * @}
  338. */
  339. /** @defgroup RCCEx_PLLI2S_Multiplication_Factor PLLI2S Multiplication Factor
  340. * @{
  341. */
  342. #define RCC_PLLI2S_MUL8 RCC_CFGR2_PLL3MUL8 /*!< PLLI2S input clock * 8 */
  343. #define RCC_PLLI2S_MUL9 RCC_CFGR2_PLL3MUL9 /*!< PLLI2S input clock * 9 */
  344. #define RCC_PLLI2S_MUL10 RCC_CFGR2_PLL3MUL10 /*!< PLLI2S input clock * 10 */
  345. #define RCC_PLLI2S_MUL11 RCC_CFGR2_PLL3MUL11 /*!< PLLI2S input clock * 11 */
  346. #define RCC_PLLI2S_MUL12 RCC_CFGR2_PLL3MUL12 /*!< PLLI2S input clock * 12 */
  347. #define RCC_PLLI2S_MUL13 RCC_CFGR2_PLL3MUL13 /*!< PLLI2S input clock * 13 */
  348. #define RCC_PLLI2S_MUL14 RCC_CFGR2_PLL3MUL14 /*!< PLLI2S input clock * 14 */
  349. #define RCC_PLLI2S_MUL16 RCC_CFGR2_PLL3MUL16 /*!< PLLI2S input clock * 16 */
  350. #define RCC_PLLI2S_MUL20 RCC_CFGR2_PLL3MUL20 /*!< PLLI2S input clock * 20 */
  351. /**
  352. * @}
  353. */
  354. #endif /* STM32F105xC || STM32F107xC */
  355. #if defined(STM32F105xC) || defined(STM32F107xC)
  356. /** @defgroup RCCEx_Prediv1_Source Prediv1 Source
  357. * @{
  358. */
  359. #define RCC_PREDIV1_SOURCE_HSE RCC_CFGR2_PREDIV1SRC_HSE
  360. #define RCC_PREDIV1_SOURCE_PLL2 RCC_CFGR2_PREDIV1SRC_PLL2
  361. /**
  362. * @}
  363. */
  364. #endif /* STM32F105xC || STM32F107xC */
  365. /** @defgroup RCCEx_Prediv1_Factor HSE Prediv1 Factor
  366. * @{
  367. */
  368. #define RCC_HSE_PREDIV_DIV1 ((uint32_t)0x00000000)
  369. #if defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F100xB)\
  370. || defined(STM32F100xE)
  371. #define RCC_HSE_PREDIV_DIV2 RCC_CFGR2_PREDIV1_DIV2
  372. #define RCC_HSE_PREDIV_DIV3 RCC_CFGR2_PREDIV1_DIV3
  373. #define RCC_HSE_PREDIV_DIV4 RCC_CFGR2_PREDIV1_DIV4
  374. #define RCC_HSE_PREDIV_DIV5 RCC_CFGR2_PREDIV1_DIV5
  375. #define RCC_HSE_PREDIV_DIV6 RCC_CFGR2_PREDIV1_DIV6
  376. #define RCC_HSE_PREDIV_DIV7 RCC_CFGR2_PREDIV1_DIV7
  377. #define RCC_HSE_PREDIV_DIV8 RCC_CFGR2_PREDIV1_DIV8
  378. #define RCC_HSE_PREDIV_DIV9 RCC_CFGR2_PREDIV1_DIV9
  379. #define RCC_HSE_PREDIV_DIV10 RCC_CFGR2_PREDIV1_DIV10
  380. #define RCC_HSE_PREDIV_DIV11 RCC_CFGR2_PREDIV1_DIV11
  381. #define RCC_HSE_PREDIV_DIV12 RCC_CFGR2_PREDIV1_DIV12
  382. #define RCC_HSE_PREDIV_DIV13 RCC_CFGR2_PREDIV1_DIV13
  383. #define RCC_HSE_PREDIV_DIV14 RCC_CFGR2_PREDIV1_DIV14
  384. #define RCC_HSE_PREDIV_DIV15 RCC_CFGR2_PREDIV1_DIV15
  385. #define RCC_HSE_PREDIV_DIV16 RCC_CFGR2_PREDIV1_DIV16
  386. #else
  387. #define RCC_HSE_PREDIV_DIV2 RCC_CFGR_PLLXTPRE
  388. #endif /* STM32F105xC || STM32F107xC || STM32F100xB || STM32F100xE */
  389. /**
  390. * @}
  391. */
  392. #if defined(STM32F105xC) || defined(STM32F107xC)
  393. /** @defgroup RCCEx_Prediv2_Factor HSE Prediv2 Factor
  394. * @{
  395. */
  396. #define RCC_HSE_PREDIV2_DIV1 RCC_CFGR2_PREDIV2_DIV1 /*!< PREDIV2 input clock not divided */
  397. #define RCC_HSE_PREDIV2_DIV2 RCC_CFGR2_PREDIV2_DIV2 /*!< PREDIV2 input clock divided by 2 */
  398. #define RCC_HSE_PREDIV2_DIV3 RCC_CFGR2_PREDIV2_DIV3 /*!< PREDIV2 input clock divided by 3 */
  399. #define RCC_HSE_PREDIV2_DIV4 RCC_CFGR2_PREDIV2_DIV4 /*!< PREDIV2 input clock divided by 4 */
  400. #define RCC_HSE_PREDIV2_DIV5 RCC_CFGR2_PREDIV2_DIV5 /*!< PREDIV2 input clock divided by 5 */
  401. #define RCC_HSE_PREDIV2_DIV6 RCC_CFGR2_PREDIV2_DIV6 /*!< PREDIV2 input clock divided by 6 */
  402. #define RCC_HSE_PREDIV2_DIV7 RCC_CFGR2_PREDIV2_DIV7 /*!< PREDIV2 input clock divided by 7 */
  403. #define RCC_HSE_PREDIV2_DIV8 RCC_CFGR2_PREDIV2_DIV8 /*!< PREDIV2 input clock divided by 8 */
  404. #define RCC_HSE_PREDIV2_DIV9 RCC_CFGR2_PREDIV2_DIV9 /*!< PREDIV2 input clock divided by 9 */
  405. #define RCC_HSE_PREDIV2_DIV10 RCC_CFGR2_PREDIV2_DIV10 /*!< PREDIV2 input clock divided by 10 */
  406. #define RCC_HSE_PREDIV2_DIV11 RCC_CFGR2_PREDIV2_DIV11 /*!< PREDIV2 input clock divided by 11 */
  407. #define RCC_HSE_PREDIV2_DIV12 RCC_CFGR2_PREDIV2_DIV12 /*!< PREDIV2 input clock divided by 12 */
  408. #define RCC_HSE_PREDIV2_DIV13 RCC_CFGR2_PREDIV2_DIV13 /*!< PREDIV2 input clock divided by 13 */
  409. #define RCC_HSE_PREDIV2_DIV14 RCC_CFGR2_PREDIV2_DIV14 /*!< PREDIV2 input clock divided by 14 */
  410. #define RCC_HSE_PREDIV2_DIV15 RCC_CFGR2_PREDIV2_DIV15 /*!< PREDIV2 input clock divided by 15 */
  411. #define RCC_HSE_PREDIV2_DIV16 RCC_CFGR2_PREDIV2_DIV16 /*!< PREDIV2 input clock divided by 16 */
  412. /**
  413. * @}
  414. */
  415. /** @defgroup RCCEx_PLL2_Config PLL Config
  416. * @{
  417. */
  418. #define RCC_PLL2_NONE ((uint32_t)0x00000000)
  419. #define RCC_PLL2_OFF ((uint32_t)0x00000001)
  420. #define RCC_PLL2_ON ((uint32_t)0x00000002)
  421. /**
  422. * @}
  423. */
  424. /** @defgroup RCCEx_PLL2_Multiplication_Factor PLL2 Multiplication Factor
  425. * @{
  426. */
  427. #define RCC_PLL2_MUL8 RCC_CFGR2_PLL2MUL8 /*!< PLL2 input clock * 8 */
  428. #define RCC_PLL2_MUL9 RCC_CFGR2_PLL2MUL9 /*!< PLL2 input clock * 9 */
  429. #define RCC_PLL2_MUL10 RCC_CFGR2_PLL2MUL10 /*!< PLL2 input clock * 10 */
  430. #define RCC_PLL2_MUL11 RCC_CFGR2_PLL2MUL11 /*!< PLL2 input clock * 11 */
  431. #define RCC_PLL2_MUL12 RCC_CFGR2_PLL2MUL12 /*!< PLL2 input clock * 12 */
  432. #define RCC_PLL2_MUL13 RCC_CFGR2_PLL2MUL13 /*!< PLL2 input clock * 13 */
  433. #define RCC_PLL2_MUL14 RCC_CFGR2_PLL2MUL14 /*!< PLL2 input clock * 14 */
  434. #define RCC_PLL2_MUL16 RCC_CFGR2_PLL2MUL16 /*!< PLL2 input clock * 16 */
  435. #define RCC_PLL2_MUL20 RCC_CFGR2_PLL2MUL20 /*!< PLL2 input clock * 20 */
  436. /**
  437. * @}
  438. */
  439. #endif /* STM32F105xC || STM32F107xC */
  440. /** @defgroup RCCEx_PLL_Multiplication_Factor PLL Multiplication Factor
  441. * @{
  442. */
  443. #if defined(STM32F105xC) || defined(STM32F107xC)
  444. #else
  445. #define RCC_PLL_MUL2 RCC_CFGR_PLLMULL2
  446. #define RCC_PLL_MUL3 RCC_CFGR_PLLMULL3
  447. #endif /* STM32F105xC || STM32F107xC */
  448. #define RCC_PLL_MUL4 RCC_CFGR_PLLMULL4
  449. #define RCC_PLL_MUL5 RCC_CFGR_PLLMULL5
  450. #define RCC_PLL_MUL6 RCC_CFGR_PLLMULL6
  451. #define RCC_PLL_MUL7 RCC_CFGR_PLLMULL7
  452. #define RCC_PLL_MUL8 RCC_CFGR_PLLMULL8
  453. #define RCC_PLL_MUL9 RCC_CFGR_PLLMULL9
  454. #if defined(STM32F105xC) || defined(STM32F107xC)
  455. #define RCC_PLL_MUL6_5 RCC_CFGR_PLLMULL6_5
  456. #else
  457. #define RCC_PLL_MUL10 RCC_CFGR_PLLMULL10
  458. #define RCC_PLL_MUL11 RCC_CFGR_PLLMULL11
  459. #define RCC_PLL_MUL12 RCC_CFGR_PLLMULL12
  460. #define RCC_PLL_MUL13 RCC_CFGR_PLLMULL13
  461. #define RCC_PLL_MUL14 RCC_CFGR_PLLMULL14
  462. #define RCC_PLL_MUL15 RCC_CFGR_PLLMULL15
  463. #define RCC_PLL_MUL16 RCC_CFGR_PLLMULL16
  464. #endif /* STM32F105xC || STM32F107xC */
  465. /**
  466. * @}
  467. */
  468. /** @defgroup RCCEx_MCO1_Clock_Source MCO1 Clock Source
  469. * @{
  470. */
  471. #define RCC_MCO1SOURCE_NOCLOCK ((uint32_t)RCC_CFGR_MCO_NOCLOCK)
  472. #define RCC_MCO1SOURCE_SYSCLK ((uint32_t)RCC_CFGR_MCO_SYSCLK)
  473. #define RCC_MCO1SOURCE_HSI ((uint32_t)RCC_CFGR_MCO_HSI)
  474. #define RCC_MCO1SOURCE_HSE ((uint32_t)RCC_CFGR_MCO_HSE)
  475. #define RCC_MCO1SOURCE_PLLCLK ((uint32_t)RCC_CFGR_MCO_PLLCLK_DIV2)
  476. #if defined(STM32F105xC) || defined(STM32F107xC)
  477. #define RCC_MCO1SOURCE_PLL2CLK ((uint32_t)RCC_CFGR_MCO_PLL2CLK)
  478. #define RCC_MCO1SOURCE_PLL3CLK_DIV2 ((uint32_t)RCC_CFGR_MCO_PLL3CLK_DIV2)
  479. #define RCC_MCO1SOURCE_EXT_HSE ((uint32_t)RCC_CFGR_MCO_EXT_HSE)
  480. #define RCC_MCO1SOURCE_PLL3CLK ((uint32_t)RCC_CFGR_MCO_PLL3CLK)
  481. #endif /* STM32F105xC || STM32F107xC*/
  482. /**
  483. * @}
  484. */
  485. #if defined(STM32F105xC) || defined(STM32F107xC)
  486. /** @defgroup RCCEx_Interrupt RCCEx Interrupt
  487. * @{
  488. */
  489. #define RCC_IT_PLL2RDY ((uint8_t)RCC_CIR_PLL2RDYF)
  490. #define RCC_IT_PLLI2SRDY ((uint8_t)RCC_CIR_PLL3RDYF)
  491. /**
  492. * @}
  493. */
  494. /** @defgroup RCCEx_Flag RCCEx Flag
  495. * Elements values convention: 0XXYYYYYb
  496. * - YYYYY : Flag position in the register
  497. * - XX : Register index
  498. * - 01: CR register
  499. * @{
  500. */
  501. /* Flags in the CR register */
  502. #define RCC_FLAG_PLL2RDY ((uint8_t)((CR_REG_INDEX << 5) | POSITION_VAL(RCC_CR_PLL2RDY)))
  503. #define RCC_FLAG_PLLI2SRDY ((uint8_t)((CR_REG_INDEX << 5) | POSITION_VAL(RCC_CR_PLL3RDY)))
  504. /**
  505. * @}
  506. */
  507. #endif /* STM32F105xC || STM32F107xC*/
  508. /**
  509. * @}
  510. */
  511. /* Exported macro ------------------------------------------------------------*/
  512. /** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
  513. * @{
  514. */
  515. /** @defgroup RCCEx_Peripheral_Clock_Enable_Disable Peripheral Clock Enable Disable
  516. * @brief Enable or disable the AHB1 peripheral clock.
  517. * @note After reset, the peripheral clock (used for registers read/write access)
  518. * is disabled and the application software has to enable this clock before
  519. * using it.
  520. * @{
  521. */
  522. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  523. || defined(STM32F103xG) || defined(STM32F105xC) || defined (STM32F107xC)\
  524. || defined (STM32F100xE)
  525. #define __HAL_RCC_DMA2_CLK_ENABLE() do { \
  526. __IO uint32_t tmpreg; \
  527. SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN);\
  528. /* Delay after an RCC peripheral clock enabling */ \
  529. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA2EN);\
  530. UNUSED(tmpreg); \
  531. } while(0)
  532. #define __HAL_RCC_DMA2_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_DMA2EN))
  533. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG || STM32F105xC || STM32F107xC || STM32F100xE */
  534. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  535. || defined(STM32F103xG) || defined (STM32F100xE)
  536. #define __HAL_RCC_FSMC_CLK_ENABLE() do { \
  537. __IO uint32_t tmpreg; \
  538. SET_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);\
  539. /* Delay after an RCC peripheral clock enabling */ \
  540. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);\
  541. UNUSED(tmpreg); \
  542. } while(0)
  543. #define __HAL_RCC_FSMC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_FSMCEN))
  544. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG || STM32F100xE */
  545. #if defined(STM32F103xE) || defined(STM32F103xG)
  546. #define __HAL_RCC_SDIO_CLK_ENABLE() do { \
  547. __IO uint32_t tmpreg; \
  548. SET_BIT(RCC->AHBENR, RCC_AHBENR_SDIOEN);\
  549. /* Delay after an RCC peripheral clock enabling */ \
  550. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_SDIOEN);\
  551. UNUSED(tmpreg); \
  552. } while(0)
  553. #define __HAL_RCC_SDIO_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_SDIOEN))
  554. #endif /* STM32F103xE || STM32F103xG */
  555. #if defined(STM32F105xC) || defined(STM32F107xC)
  556. #define __HAL_RCC_USB_OTG_FS_CLK_ENABLE() do { \
  557. __IO uint32_t tmpreg; \
  558. SET_BIT(RCC->AHBENR, RCC_AHBENR_OTGFSEN);\
  559. /* Delay after an RCC peripheral clock enabling */ \
  560. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_OTGFSEN);\
  561. UNUSED(tmpreg); \
  562. } while(0)
  563. #define __HAL_RCC_USB_OTG_FS_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_OTGFSEN))
  564. #endif /* STM32F105xC || STM32F107xC*/
  565. #if defined(STM32F107xC)
  566. #define __HAL_RCC_ETHMAC_CLK_ENABLE() do { \
  567. __IO uint32_t tmpreg; \
  568. SET_BIT(RCC->AHBENR, RCC_AHBENR_ETHMACEN);\
  569. /* Delay after an RCC peripheral clock enabling */ \
  570. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_ETHMACEN);\
  571. UNUSED(tmpreg); \
  572. } while(0)
  573. #define __HAL_RCC_ETHMACTX_CLK_ENABLE() do { \
  574. __IO uint32_t tmpreg; \
  575. SET_BIT(RCC->AHBENR, RCC_AHBENR_ETHMACTXEN);\
  576. /* Delay after an RCC peripheral clock enabling */ \
  577. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_ETHMACTXEN);\
  578. UNUSED(tmpreg); \
  579. } while(0)
  580. #define __HAL_RCC_ETHMACRX_CLK_ENABLE() do { \
  581. __IO uint32_t tmpreg; \
  582. SET_BIT(RCC->AHBENR, RCC_AHBENR_ETHMACRXEN);\
  583. /* Delay after an RCC peripheral clock enabling */ \
  584. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_ETHMACRXEN);\
  585. UNUSED(tmpreg); \
  586. } while(0)
  587. #define __HAL_RCC_ETHMAC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_ETHMACEN))
  588. #define __HAL_RCC_ETHMACTX_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_ETHMACTXEN))
  589. #define __HAL_RCC_ETHMACRX_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_ETHMACRXEN))
  590. /**
  591. * @brief Enable ETHERNET clock.
  592. */
  593. #define __HAL_RCC_ETH_CLK_ENABLE() do { \
  594. __HAL_RCC_ETHMAC_CLK_ENABLE(); \
  595. __HAL_RCC_ETHMACTX_CLK_ENABLE(); \
  596. __HAL_RCC_ETHMACRX_CLK_ENABLE(); \
  597. } while(0)
  598. /**
  599. * @brief Disable ETHERNET clock.
  600. */
  601. #define __HAL_RCC_ETH_CLK_DISABLE() do { \
  602. __HAL_RCC_ETHMACTX_CLK_DISABLE(); \
  603. __HAL_RCC_ETHMACRX_CLK_DISABLE(); \
  604. __HAL_RCC_ETHMAC_CLK_DISABLE(); \
  605. } while(0)
  606. #endif /* STM32F107xC*/
  607. /**
  608. * @}
  609. */
  610. /** @defgroup RCCEx_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
  611. * @brief Get the enable or disable status of the AHB1 peripheral clock.
  612. * @note After reset, the peripheral clock (used for registers read/write access)
  613. * is disabled and the application software has to enable this clock before
  614. * using it.
  615. * @{
  616. */
  617. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  618. || defined(STM32F103xG) || defined(STM32F105xC) || defined (STM32F107xC)\
  619. || defined (STM32F100xE)
  620. #define __HAL_RCC_DMA2_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA2EN)) != RESET)
  621. #define __HAL_RCC_DMA2_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA2EN)) == RESET)
  622. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG || STM32F105xC || STM32F107xC || STM32F100xE */
  623. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  624. || defined(STM32F103xG) || defined (STM32F100xE)
  625. #define __HAL_RCC_FSMC_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_FSMCEN)) != RESET)
  626. #define __HAL_RCC_FSMC_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_FSMCEN)) == RESET)
  627. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG || STM32F100xE */
  628. #if defined(STM32F103xE) || defined(STM32F103xG)
  629. #define __HAL_RCC_SDIO_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_SDIOEN)) != RESET)
  630. #define __HAL_RCC_SDIO_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_SDIOEN)) == RESET)
  631. #endif /* STM32F103xE || STM32F103xG */
  632. #if defined(STM32F105xC) || defined(STM32F107xC)
  633. #define __HAL_RCC_USB_OTG_FS_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_OTGFSEN)) != RESET)
  634. #define __HAL_RCC_USB_OTG_FS_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_OTGFSEN)) == RESET)
  635. #endif /* STM32F105xC || STM32F107xC*/
  636. #if defined(STM32F107xC)
  637. #define __HAL_RCC_ETHMAC_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_ETHMACEN)) != RESET)
  638. #define __HAL_RCC_ETHMAC_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_ETHMACEN)) == RESET)
  639. #define __HAL_RCC_ETHMACTX_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_ETHMACTXEN)) != RESET)
  640. #define __HAL_RCC_ETHMACTX_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_ETHMACTXEN)) == RESET)
  641. #define __HAL_RCC_ETHMACRX_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_ETHMACRXEN)) != RESET)
  642. #define __HAL_RCC_ETHMACRX_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_ETHMACRXEN)) == RESET)
  643. #endif /* STM32F107xC*/
  644. /**
  645. * @}
  646. */
  647. /** @defgroup RCCEx_APB1_Clock_Enable_Disable APB1 Clock Enable Disable
  648. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  649. * @note After reset, the peripheral clock (used for registers read/write access)
  650. * is disabled and the application software has to enable this clock before
  651. * using it.
  652. * @{
  653. */
  654. #if defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE)\
  655. || defined(STM32F103xG) || defined(STM32F105xC) ||defined(STM32F107xC)
  656. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  657. __IO uint32_t tmpreg; \
  658. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  659. /* Delay after an RCC peripheral clock enabling */ \
  660. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  661. UNUSED(tmpreg); \
  662. } while(0)
  663. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  664. #endif /* STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  665. #if defined(STM32F100xB) || defined(STM32F100xE) || defined(STM32F101xB)\
  666. || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F102xB)\
  667. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
  668. || defined(STM32F105xC) || defined(STM32F107xC)
  669. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  670. __IO uint32_t tmpreg; \
  671. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  672. /* Delay after an RCC peripheral clock enabling */ \
  673. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  674. UNUSED(tmpreg); \
  675. } while(0)
  676. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  677. __IO uint32_t tmpreg; \
  678. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  679. /* Delay after an RCC peripheral clock enabling */ \
  680. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  681. UNUSED(tmpreg); \
  682. } while(0)
  683. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  684. __IO uint32_t tmpreg; \
  685. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  686. /* Delay after an RCC peripheral clock enabling */ \
  687. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  688. UNUSED(tmpreg); \
  689. } while(0)
  690. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  691. __IO uint32_t tmpreg; \
  692. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  693. /* Delay after an RCC peripheral clock enabling */ \
  694. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  695. UNUSED(tmpreg); \
  696. } while(0)
  697. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  698. #define __HAL_RCC_SPI2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI2EN))
  699. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  700. #define __HAL_RCC_I2C2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN))
  701. #endif /* STM32F100xB || STM32F101xB || STM32F101xE || (...) || STM32F105xC || STM32F107xC */
  702. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  703. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)
  704. #define __HAL_RCC_USB_CLK_ENABLE() do { \
  705. __IO uint32_t tmpreg; \
  706. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USBEN);\
  707. /* Delay after an RCC peripheral clock enabling */ \
  708. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USBEN);\
  709. UNUSED(tmpreg); \
  710. } while(0)
  711. #define __HAL_RCC_USB_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USBEN))
  712. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG */
  713. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  714. || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
  715. #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
  716. __IO uint32_t tmpreg; \
  717. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
  718. /* Delay after an RCC peripheral clock enabling */ \
  719. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
  720. UNUSED(tmpreg); \
  721. } while(0)
  722. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  723. __IO uint32_t tmpreg; \
  724. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  725. /* Delay after an RCC peripheral clock enabling */ \
  726. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  727. UNUSED(tmpreg); \
  728. } while(0)
  729. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  730. __IO uint32_t tmpreg; \
  731. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  732. /* Delay after an RCC peripheral clock enabling */ \
  733. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  734. UNUSED(tmpreg); \
  735. } while(0)
  736. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  737. __IO uint32_t tmpreg; \
  738. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  739. /* Delay after an RCC peripheral clock enabling */ \
  740. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  741. UNUSED(tmpreg); \
  742. } while(0)
  743. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  744. __IO uint32_t tmpreg; \
  745. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  746. /* Delay after an RCC peripheral clock enabling */ \
  747. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  748. UNUSED(tmpreg); \
  749. } while(0)
  750. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  751. __IO uint32_t tmpreg; \
  752. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  753. /* Delay after an RCC peripheral clock enabling */ \
  754. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  755. UNUSED(tmpreg); \
  756. } while(0)
  757. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  758. __IO uint32_t tmpreg; \
  759. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  760. /* Delay after an RCC peripheral clock enabling */ \
  761. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  762. UNUSED(tmpreg); \
  763. } while(0)
  764. #define __HAL_RCC_TIM5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM5EN))
  765. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  766. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  767. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  768. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  769. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  770. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  771. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || (...) || STM32F105xC || STM32F107xC */
  772. #if defined(STM32F100xB) || defined (STM32F100xE)
  773. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  774. __IO uint32_t tmpreg; \
  775. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  776. /* Delay after an RCC peripheral clock enabling */ \
  777. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  778. UNUSED(tmpreg); \
  779. } while(0)
  780. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  781. __IO uint32_t tmpreg; \
  782. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  783. /* Delay after an RCC peripheral clock enabling */ \
  784. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  785. UNUSED(tmpreg); \
  786. } while(0)
  787. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  788. __IO uint32_t tmpreg; \
  789. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  790. /* Delay after an RCC peripheral clock enabling */ \
  791. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  792. UNUSED(tmpreg); \
  793. } while(0)
  794. #define __HAL_RCC_CEC_CLK_ENABLE() do { \
  795. __IO uint32_t tmpreg; \
  796. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  797. /* Delay after an RCC peripheral clock enabling */ \
  798. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  799. UNUSED(tmpreg); \
  800. } while(0)
  801. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  802. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  803. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  804. #define __HAL_RCC_CEC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CECEN))
  805. #endif /* STM32F100xB || STM32F100xE */
  806. #ifdef STM32F100xE
  807. #define __HAL_RCC_TIM5_CLK_ENABLE() do { \
  808. __IO uint32_t tmpreg; \
  809. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
  810. /* Delay after an RCC peripheral clock enabling */ \
  811. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
  812. UNUSED(tmpreg); \
  813. } while(0)
  814. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  815. __IO uint32_t tmpreg; \
  816. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  817. /* Delay after an RCC peripheral clock enabling */ \
  818. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  819. UNUSED(tmpreg); \
  820. } while(0)
  821. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  822. __IO uint32_t tmpreg; \
  823. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  824. /* Delay after an RCC peripheral clock enabling */ \
  825. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  826. UNUSED(tmpreg); \
  827. } while(0)
  828. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  829. __IO uint32_t tmpreg; \
  830. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  831. /* Delay after an RCC peripheral clock enabling */ \
  832. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  833. UNUSED(tmpreg); \
  834. } while(0)
  835. #define __HAL_RCC_SPI3_CLK_ENABLE() do { \
  836. __IO uint32_t tmpreg; \
  837. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  838. /* Delay after an RCC peripheral clock enabling */ \
  839. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI3EN);\
  840. UNUSED(tmpreg); \
  841. } while(0)
  842. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  843. __IO uint32_t tmpreg; \
  844. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  845. /* Delay after an RCC peripheral clock enabling */ \
  846. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  847. UNUSED(tmpreg); \
  848. } while(0)
  849. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  850. __IO uint32_t tmpreg; \
  851. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  852. /* Delay after an RCC peripheral clock enabling */ \
  853. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  854. UNUSED(tmpreg); \
  855. } while(0)
  856. #define __HAL_RCC_TIM5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM5EN))
  857. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  858. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  859. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  860. #define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
  861. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  862. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  863. #endif /* STM32F100xE */
  864. #if defined(STM32F105xC) || defined(STM32F107xC)
  865. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  866. __IO uint32_t tmpreg; \
  867. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  868. /* Delay after an RCC peripheral clock enabling */ \
  869. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  870. UNUSED(tmpreg); \
  871. } while(0)
  872. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  873. #endif /* STM32F105xC || STM32F107xC */
  874. #if defined(STM32F101xG) || defined(STM32F103xG)
  875. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  876. __IO uint32_t tmpreg; \
  877. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  878. /* Delay after an RCC peripheral clock enabling */ \
  879. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  880. UNUSED(tmpreg); \
  881. } while(0)
  882. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  883. __IO uint32_t tmpreg; \
  884. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  885. /* Delay after an RCC peripheral clock enabling */ \
  886. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  887. UNUSED(tmpreg); \
  888. } while(0)
  889. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  890. __IO uint32_t tmpreg; \
  891. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  892. /* Delay after an RCC peripheral clock enabling */ \
  893. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  894. UNUSED(tmpreg); \
  895. } while(0)
  896. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  897. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  898. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  899. #endif /* STM32F101xG || STM32F103xG*/
  900. /**
  901. * @}
  902. */
  903. /** @defgroup RCCEx_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  904. * @brief Get the enable or disable status of the APB1 peripheral clock.
  905. * @note After reset, the peripheral clock (used for registers read/write access)
  906. * is disabled and the application software has to enable this clock before
  907. * using it.
  908. * @{
  909. */
  910. #if defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE)\
  911. || defined(STM32F103xG) || defined(STM32F105xC) ||defined(STM32F107xC)
  912. #define __HAL_RCC_CAN1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) != RESET)
  913. #define __HAL_RCC_CAN1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN1EN)) == RESET)
  914. #endif /* STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  915. #if defined(STM32F100xB) || defined(STM32F100xE) || defined(STM32F101xB)\
  916. || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F102xB)\
  917. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
  918. || defined(STM32F105xC) || defined(STM32F107xC)
  919. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  920. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  921. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) != RESET)
  922. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) == RESET)
  923. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
  924. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
  925. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) != RESET)
  926. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) == RESET)
  927. #endif /* STM32F100xB || STM32F101xB || STM32F101xE || (...) || STM32F105xC || STM32F107xC */
  928. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  929. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)
  930. #define __HAL_RCC_USB_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USBEN)) != RESET)
  931. #define __HAL_RCC_USB_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USBEN)) == RESET)
  932. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG */
  933. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  934. || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
  935. #define __HAL_RCC_TIM5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM5EN)) != RESET)
  936. #define __HAL_RCC_TIM5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM5EN)) == RESET)
  937. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  938. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  939. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  940. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  941. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  942. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  943. #define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) != RESET)
  944. #define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) == RESET)
  945. #define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) != RESET)
  946. #define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) == RESET)
  947. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  948. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  949. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || (...) || STM32F105xC || STM32F107xC */
  950. #if defined(STM32F100xB) || defined (STM32F100xE)
  951. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  952. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  953. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  954. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  955. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  956. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  957. #define __HAL_RCC_CEC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CECEN)) != RESET)
  958. #define __HAL_RCC_CEC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CECEN)) == RESET)
  959. #endif /* STM32F100xB || STM32F100xE */
  960. #ifdef STM32F100xE
  961. #define __HAL_RCC_TIM5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM5EN)) != RESET)
  962. #define __HAL_RCC_TIM5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM5EN)) == RESET)
  963. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) != RESET)
  964. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) == RESET)
  965. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) != RESET)
  966. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) == RESET)
  967. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) != RESET)
  968. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) == RESET)
  969. #define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
  970. #define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
  971. #define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) != RESET)
  972. #define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) == RESET)
  973. #define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) != RESET)
  974. #define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) == RESET)
  975. #define __HAL_RCC_CAN2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) != RESET)
  976. #define __HAL_RCC_CAN2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_CAN2EN)) == RESET)
  977. #endif /* STM32F100xE */
  978. #if defined(STM32F105xC) || defined(STM32F107xC)
  979. #define __HAL_RCC_TIM12_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) != RESET)
  980. #define __HAL_RCC_TIM12_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM12EN)) == RESET)
  981. #endif /* STM32F105xC || STM32F107xC */
  982. #if defined(STM32F101xG) || defined(STM32F103xG)
  983. #define __HAL_RCC_TIM13_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) != RESET)
  984. #define __HAL_RCC_TIM13_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM13EN)) == RESET)
  985. #define __HAL_RCC_TIM14_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) != RESET)
  986. #define __HAL_RCC_TIM14_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM14EN)) == RESET)
  987. #endif /* STM32F101xG || STM32F103xG*/
  988. /**
  989. * @}
  990. */
  991. /** @defgroup RCCEx_APB2_Clock_Enable_Disable APB2 Clock Enable Disable
  992. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  993. * @note After reset, the peripheral clock (used for registers read/write access)
  994. * is disabled and the application software has to enable this clock before
  995. * using it.
  996. * @{
  997. */
  998. #if defined(STM32F101xG) || defined(STM32F103x6) || defined(STM32F103xB)\
  999. || defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F103xE)\
  1000. || defined(STM32F103xG)
  1001. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  1002. __IO uint32_t tmpreg; \
  1003. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1004. /* Delay after an RCC peripheral clock enabling */ \
  1005. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1006. UNUSED(tmpreg); \
  1007. } while(0)
  1008. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  1009. #endif /* STM32F101xG || STM32F103x6 || STM32F103xB || STM32F105xC || STM32F107xC || STM32F103xE || STM32F103xG */
  1010. #if defined(STM32F100xB) || defined(STM32F100xE)
  1011. #define __HAL_RCC_TIM15_CLK_ENABLE() do { \
  1012. __IO uint32_t tmpreg; \
  1013. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN);\
  1014. /* Delay after an RCC peripheral clock enabling */ \
  1015. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM15EN);\
  1016. UNUSED(tmpreg); \
  1017. } while(0)
  1018. #define __HAL_RCC_TIM16_CLK_ENABLE() do { \
  1019. __IO uint32_t tmpreg; \
  1020. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN);\
  1021. /* Delay after an RCC peripheral clock enabling */ \
  1022. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM16EN);\
  1023. UNUSED(tmpreg); \
  1024. } while(0)
  1025. #define __HAL_RCC_TIM17_CLK_ENABLE() do { \
  1026. __IO uint32_t tmpreg; \
  1027. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN);\
  1028. /* Delay after an RCC peripheral clock enabling */ \
  1029. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM17EN);\
  1030. UNUSED(tmpreg); \
  1031. } while(0)
  1032. #define __HAL_RCC_TIM15_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM15EN))
  1033. #define __HAL_RCC_TIM16_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM16EN))
  1034. #define __HAL_RCC_TIM17_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM17EN))
  1035. #endif /* STM32F100xB || STM32F100xE */
  1036. #if defined(STM32F100xE) || defined(STM32F101xB) || defined(STM32F101xE)\
  1037. || defined(STM32F101xG) || defined(STM32F100xB) || defined(STM32F103xB)\
  1038. || defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC)\
  1039. || defined(STM32F107xC)
  1040. #define __HAL_RCC_GPIOE_CLK_ENABLE() do { \
  1041. __IO uint32_t tmpreg; \
  1042. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPEEN);\
  1043. /* Delay after an RCC peripheral clock enabling */ \
  1044. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPEEN);\
  1045. UNUSED(tmpreg); \
  1046. } while(0)
  1047. #define __HAL_RCC_GPIOE_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPEEN))
  1048. #endif /* STM32F101x6 || STM32F101xB || STM32F101xE || (...) || STM32F105xC || STM32F107xC */
  1049. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  1050. || defined(STM32F103xG)
  1051. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  1052. __IO uint32_t tmpreg; \
  1053. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPFEN);\
  1054. /* Delay after an RCC peripheral clock enabling */ \
  1055. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPFEN);\
  1056. UNUSED(tmpreg); \
  1057. } while(0)
  1058. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  1059. __IO uint32_t tmpreg; \
  1060. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPGEN);\
  1061. /* Delay after an RCC peripheral clock enabling */ \
  1062. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPGEN);\
  1063. UNUSED(tmpreg); \
  1064. } while(0)
  1065. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPFEN))
  1066. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPGEN))
  1067. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG*/
  1068. #if defined(STM32F103xE) || defined(STM32F103xG)
  1069. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  1070. __IO uint32_t tmpreg; \
  1071. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1072. /* Delay after an RCC peripheral clock enabling */ \
  1073. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1074. UNUSED(tmpreg); \
  1075. } while(0)
  1076. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  1077. __IO uint32_t tmpreg; \
  1078. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1079. /* Delay after an RCC peripheral clock enabling */ \
  1080. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1081. UNUSED(tmpreg); \
  1082. } while(0)
  1083. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  1084. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  1085. #endif /* STM32F103xE || STM32F103xG */
  1086. #if defined(STM32F100xE)
  1087. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  1088. __IO uint32_t tmpreg; \
  1089. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPFEN);\
  1090. /* Delay after an RCC peripheral clock enabling */ \
  1091. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPFEN);\
  1092. UNUSED(tmpreg); \
  1093. } while(0)
  1094. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  1095. __IO uint32_t tmpreg; \
  1096. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPGEN);\
  1097. /* Delay after an RCC peripheral clock enabling */ \
  1098. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPGEN);\
  1099. UNUSED(tmpreg); \
  1100. } while(0)
  1101. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPFEN))
  1102. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPGEN))
  1103. #endif /* STM32F100xE */
  1104. #if defined(STM32F101xG) || defined(STM32F103xG)
  1105. #define __HAL_RCC_TIM9_CLK_ENABLE() do { \
  1106. __IO uint32_t tmpreg; \
  1107. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
  1108. /* Delay after an RCC peripheral clock enabling */ \
  1109. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
  1110. UNUSED(tmpreg); \
  1111. } while(0)
  1112. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  1113. __IO uint32_t tmpreg; \
  1114. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  1115. /* Delay after an RCC peripheral clock enabling */ \
  1116. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  1117. UNUSED(tmpreg); \
  1118. } while(0)
  1119. #define __HAL_RCC_TIM11_CLK_ENABLE() do { \
  1120. __IO uint32_t tmpreg; \
  1121. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
  1122. /* Delay after an RCC peripheral clock enabling */ \
  1123. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
  1124. UNUSED(tmpreg); \
  1125. } while(0)
  1126. #define __HAL_RCC_TIM9_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM9EN))
  1127. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  1128. #define __HAL_RCC_TIM11_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM11EN))
  1129. #endif /* STM32F101xG || STM32F103xG */
  1130. /**
  1131. * @}
  1132. */
  1133. /** @defgroup RCCEx_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  1134. * @brief Get the enable or disable status of the APB2 peripheral clock.
  1135. * @note After reset, the peripheral clock (used for registers read/write access)
  1136. * is disabled and the application software has to enable this clock before
  1137. * using it.
  1138. * @{
  1139. */
  1140. #if defined(STM32F101xG) || defined(STM32F103x6) || defined(STM32F103xB)\
  1141. || defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F103xE)\
  1142. || defined(STM32F103xG)
  1143. #define __HAL_RCC_ADC2_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) != RESET)
  1144. #define __HAL_RCC_ADC2_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC2EN)) == RESET)
  1145. #endif /* STM32F101xG || STM32F103x6 || STM32F103xB || STM32F105xC || STM32F107xC || STM32F103xE || STM32F103xG */
  1146. #if defined(STM32F100xB) || defined(STM32F100xE)
  1147. #define __HAL_RCC_TIM15_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM15EN)) != RESET)
  1148. #define __HAL_RCC_TIM15_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM15EN)) == RESET)
  1149. #define __HAL_RCC_TIM16_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM16EN)) != RESET)
  1150. #define __HAL_RCC_TIM16_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM16EN)) == RESET)
  1151. #define __HAL_RCC_TIM17_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM17EN)) != RESET)
  1152. #define __HAL_RCC_TIM17_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM17EN)) == RESET)
  1153. #endif /* STM32F100xB || STM32F100xE */
  1154. #if defined(STM32F100xE) || defined(STM32F101xB) || defined(STM32F101xE)\
  1155. || defined(STM32F101xG) || defined(STM32F100xB) || defined(STM32F103xB)\
  1156. || defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC)\
  1157. || defined(STM32F107xC)
  1158. #define __HAL_RCC_GPIOE_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPEEN)) != RESET)
  1159. #define __HAL_RCC_GPIOE_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPEEN)) == RESET)
  1160. #endif /* STM32F101x6 || STM32F101xB || STM32F101xE || (...) || STM32F105xC || STM32F107xC */
  1161. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  1162. || defined(STM32F103xG)
  1163. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPFEN)) != RESET)
  1164. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPFEN)) == RESET)
  1165. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPGEN)) != RESET)
  1166. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPGEN)) == RESET)
  1167. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG*/
  1168. #if defined(STM32F103xE) || defined(STM32F103xG)
  1169. #define __HAL_RCC_TIM8_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) != RESET)
  1170. #define __HAL_RCC_TIM8_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM8EN)) == RESET)
  1171. #define __HAL_RCC_ADC3_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) != RESET)
  1172. #define __HAL_RCC_ADC3_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC3EN)) == RESET)
  1173. #endif /* STM32F103xE || STM32F103xG */
  1174. #if defined(STM32F100xE)
  1175. #define __HAL_RCC_GPIOF_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPFEN)) != RESET)
  1176. #define __HAL_RCC_GPIOF_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPFEN)) == RESET)
  1177. #define __HAL_RCC_GPIOG_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPGEN)) != RESET)
  1178. #define __HAL_RCC_GPIOG_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPGEN)) == RESET)
  1179. #endif /* STM32F100xE */
  1180. #if defined(STM32F101xG) || defined(STM32F103xG)
  1181. #define __HAL_RCC_TIM9_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM9EN)) != RESET)
  1182. #define __HAL_RCC_TIM9_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM9EN)) == RESET)
  1183. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) != RESET)
  1184. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) == RESET)
  1185. #define __HAL_RCC_TIM11_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM11EN)) != RESET)
  1186. #define __HAL_RCC_TIM11_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM11EN)) == RESET)
  1187. #endif /* STM32F101xG || STM32F103xG */
  1188. /**
  1189. * @}
  1190. */
  1191. #if defined(STM32F105xC) || defined(STM32F107xC)
  1192. /** @defgroup RCCEx_Peripheral_Clock_Force_Release Peripheral Clock Force Release
  1193. * @brief Force or release AHB peripheral reset.
  1194. * @{
  1195. */
  1196. #define __HAL_RCC_AHB_FORCE_RESET() (RCC->AHBRSTR = 0xFFFFFFFFU)
  1197. #define __HAL_RCC_USB_OTG_FS_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_OTGFSRST))
  1198. #if defined(STM32F107xC)
  1199. #define __HAL_RCC_ETHMAC_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_ETHMACRST))
  1200. #endif /* STM32F107xC */
  1201. #define __HAL_RCC_AHB_RELEASE_RESET() (RCC->AHBRSTR = 0x00)
  1202. #define __HAL_RCC_USB_OTG_FS_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_OTGFSRST))
  1203. #if defined(STM32F107xC)
  1204. #define __HAL_RCC_ETHMAC_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_ETHMACRST))
  1205. #endif /* STM32F107xC */
  1206. /**
  1207. * @}
  1208. */
  1209. #endif /* STM32F105xC || STM32F107xC */
  1210. /** @defgroup RCCEx_APB1_Force_Release_Reset APB1 Force Release Reset
  1211. * @brief Force or release APB1 peripheral reset.
  1212. * @{
  1213. */
  1214. #if defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE)\
  1215. || defined(STM32F103xG) || defined(STM32F105xC) ||defined(STM32F107xC)
  1216. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  1217. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  1218. #endif /* STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
  1219. #if defined(STM32F100xB) || defined(STM32F100xE) || defined(STM32F101xB)\
  1220. || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F102xB)\
  1221. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
  1222. || defined(STM32F105xC) || defined(STM32F107xC)
  1223. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  1224. #define __HAL_RCC_SPI2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
  1225. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  1226. #define __HAL_RCC_I2C2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
  1227. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  1228. #define __HAL_RCC_SPI2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI2RST))
  1229. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  1230. #define __HAL_RCC_I2C2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C2RST))
  1231. #endif /* STM32F100xB || STM32F101xB || STM32F101xE || (...) || STM32F105xC || STM32F107xC */
  1232. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  1233. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)
  1234. #define __HAL_RCC_USB_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USBRST))
  1235. #define __HAL_RCC_USB_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USBRST))
  1236. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG */
  1237. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  1238. || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
  1239. #define __HAL_RCC_TIM5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM5RST))
  1240. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  1241. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  1242. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  1243. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  1244. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  1245. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  1246. #define __HAL_RCC_TIM5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM5RST))
  1247. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  1248. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  1249. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  1250. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  1251. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  1252. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  1253. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || (...) || STM32F105xC || STM32F107xC */
  1254. #if defined(STM32F100xB) || defined (STM32F100xE)
  1255. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  1256. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  1257. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  1258. #define __HAL_RCC_CEC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CECRST))
  1259. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  1260. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  1261. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  1262. #define __HAL_RCC_CEC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CECRST))
  1263. #endif /* STM32F100xB || STM32F100xE */
  1264. #if defined (STM32F100xE)
  1265. #define __HAL_RCC_TIM5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM5RST))
  1266. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  1267. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  1268. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  1269. #define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
  1270. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  1271. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  1272. #define __HAL_RCC_TIM5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM5RST))
  1273. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  1274. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  1275. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  1276. #define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
  1277. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  1278. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  1279. #endif /* STM32F100xE */
  1280. #if defined(STM32F105xC) || defined(STM32F107xC)
  1281. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  1282. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  1283. #endif /* STM32F105xC || STM32F107xC */
  1284. #if defined(STM32F101xG) || defined(STM32F103xG)
  1285. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  1286. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  1287. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  1288. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  1289. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  1290. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  1291. #endif /* STM32F101xG || STM32F103xG */
  1292. /**
  1293. * @}
  1294. */
  1295. /** @defgroup RCCEx_APB2_Force_Release_Reset APB2 Force Release Reset
  1296. * @brief Force or release APB2 peripheral reset.
  1297. * @{
  1298. */
  1299. #if defined(STM32F101xG) || defined(STM32F103x6) || defined(STM32F103xB)\
  1300. || defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F103xE)\
  1301. || defined(STM32F103xG)
  1302. #define __HAL_RCC_ADC2_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_ADC2RST))
  1303. #define __HAL_RCC_ADC2_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_ADC2RST))
  1304. #endif /* STM32F101xG || STM32F103x6 || STM32F103xB || STM32F105xC || STM32F107xC || STM32F103xE || STM32F103xG */
  1305. #if defined(STM32F100xB) || defined(STM32F100xE)
  1306. #define __HAL_RCC_TIM15_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM15RST))
  1307. #define __HAL_RCC_TIM16_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM16RST))
  1308. #define __HAL_RCC_TIM17_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM17RST))
  1309. #define __HAL_RCC_TIM15_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM15RST))
  1310. #define __HAL_RCC_TIM16_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM16RST))
  1311. #define __HAL_RCC_TIM17_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM17RST))
  1312. #endif /* STM32F100xB || STM32F100xE */
  1313. #if defined(STM32F100xE) || defined(STM32F101xB) || defined(STM32F101xE)\
  1314. || defined(STM32F101xG) || defined(STM32F100xB) || defined(STM32F103xB)\
  1315. || defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC)\
  1316. || defined(STM32F107xC)
  1317. #define __HAL_RCC_GPIOE_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPERST))
  1318. #define __HAL_RCC_GPIOE_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPERST))
  1319. #endif /* STM32F101x6 || STM32F101xB || STM32F101xE || (...) || STM32F105xC || STM32F107xC */
  1320. #if defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG)\
  1321. || defined(STM32F103xG)
  1322. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPFRST))
  1323. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPGRST))
  1324. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPFRST))
  1325. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPGRST))
  1326. #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG*/
  1327. #if defined(STM32F103xE) || defined(STM32F103xG)
  1328. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  1329. #define __HAL_RCC_ADC3_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_ADC3RST))
  1330. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  1331. #define __HAL_RCC_ADC3_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_ADC3RST))
  1332. #endif /* STM32F103xE || STM32F103xG */
  1333. #if defined(STM32F100xE)
  1334. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPFRST))
  1335. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPGRST))
  1336. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPFRST))
  1337. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPGRST))
  1338. #endif /* STM32F100xE */
  1339. #if defined(STM32F101xG) || defined(STM32F103xG)
  1340. #define __HAL_RCC_TIM9_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM9RST))
  1341. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  1342. #define __HAL_RCC_TIM11_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM11RST))
  1343. #define __HAL_RCC_TIM9_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM9RST))
  1344. #define __HAL_RCC_TIM10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  1345. #define __HAL_RCC_TIM11_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM11RST))
  1346. #endif /* STM32F101xG || STM32F103xG*/
  1347. /**
  1348. * @}
  1349. */
  1350. /** @defgroup RCCEx_HSE_Configuration HSE Configuration
  1351. * @{
  1352. */
  1353. #if defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F100xB)\
  1354. || defined(STM32F100xE)
  1355. /**
  1356. * @brief Macro to configure the External High Speed oscillator (HSE) Predivision factor for PLL.
  1357. * @note Predivision factor can not be changed if PLL is used as system clock
  1358. * In this case, you have to select another source of the system clock, disable the PLL and
  1359. * then change the HSE predivision factor.
  1360. * @param __HSE_PREDIV_VALUE__ specifies the division value applied to HSE.
  1361. * This parameter must be a number between RCC_HSE_PREDIV_DIV1 and RCC_HSE_PREDIV_DIV16.
  1362. */
  1363. #define __HAL_RCC_HSE_PREDIV_CONFIG(__HSE_PREDIV_VALUE__) MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV1, (uint32_t)(__HSE_PREDIV_VALUE__))
  1364. #else
  1365. /**
  1366. * @brief Macro to configure the External High Speed oscillator (HSE) Predivision factor for PLL.
  1367. * @note Predivision factor can not be changed if PLL is used as system clock
  1368. * In this case, you have to select another source of the system clock, disable the PLL and
  1369. * then change the HSE predivision factor.
  1370. * @param __HSE_PREDIV_VALUE__ specifies the division value applied to HSE.
  1371. * This parameter must be a number between RCC_HSE_PREDIV_DIV1 and RCC_HSE_PREDIV_DIV2.
  1372. */
  1373. #define __HAL_RCC_HSE_PREDIV_CONFIG(__HSE_PREDIV_VALUE__) \
  1374. MODIFY_REG(RCC->CFGR,RCC_CFGR_PLLXTPRE, (uint32_t)(__HSE_PREDIV_VALUE__))
  1375. #endif /* STM32F105xC || STM32F107xC */
  1376. #if defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F100xB)\
  1377. || defined(STM32F100xE)
  1378. /**
  1379. * @brief Macro to get prediv1 factor for PLL.
  1380. */
  1381. #define __HAL_RCC_HSE_GET_PREDIV() READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1)
  1382. #else
  1383. /**
  1384. * @brief Macro to get prediv1 factor for PLL.
  1385. */
  1386. #define __HAL_RCC_HSE_GET_PREDIV() READ_BIT(RCC->CFGR, RCC_CFGR_PLLXTPRE)
  1387. #endif /* STM32F105xC || STM32F107xC || STM32F100xB || STM32F100xE */
  1388. /**
  1389. * @}
  1390. */
  1391. #if defined(STM32F105xC) || defined(STM32F107xC)
  1392. /** @defgroup RCCEx_PLLI2S_Configuration PLLI2S Configuration
  1393. * @{
  1394. */
  1395. /** @brief Macros to enable the main PLLI2S.
  1396. * @note After enabling the main PLLI2S, the application software should wait on
  1397. * PLLI2SRDY flag to be set indicating that PLLI2S clock is stable and can
  1398. * be used as system clock source.
  1399. * @note The main PLLI2S is disabled by hardware when entering STOP and STANDBY modes.
  1400. */
  1401. #define __HAL_RCC_PLLI2S_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLI2SON_BB = ENABLE)
  1402. /** @brief Macros to disable the main PLLI2S.
  1403. * @note The main PLLI2S is disabled by hardware when entering STOP and STANDBY modes.
  1404. */
  1405. #define __HAL_RCC_PLLI2S_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLI2SON_BB = DISABLE)
  1406. /** @brief macros to configure the main PLLI2S multiplication factor.
  1407. * @note This function must be used only when the main PLLI2S is disabled.
  1408. *
  1409. * @param __PLLI2SMUL__ specifies the multiplication factor for PLLI2S VCO output clock
  1410. * This parameter can be one of the following values:
  1411. * @arg @ref RCC_PLLI2S_MUL8 PLLI2SVCO = PLLI2S clock entry x 8
  1412. * @arg @ref RCC_PLLI2S_MUL9 PLLI2SVCO = PLLI2S clock entry x 9
  1413. * @arg @ref RCC_PLLI2S_MUL10 PLLI2SVCO = PLLI2S clock entry x 10
  1414. * @arg @ref RCC_PLLI2S_MUL11 PLLI2SVCO = PLLI2S clock entry x 11
  1415. * @arg @ref RCC_PLLI2S_MUL12 PLLI2SVCO = PLLI2S clock entry x 12
  1416. * @arg @ref RCC_PLLI2S_MUL13 PLLI2SVCO = PLLI2S clock entry x 13
  1417. * @arg @ref RCC_PLLI2S_MUL14 PLLI2SVCO = PLLI2S clock entry x 14
  1418. * @arg @ref RCC_PLLI2S_MUL16 PLLI2SVCO = PLLI2S clock entry x 16
  1419. * @arg @ref RCC_PLLI2S_MUL20 PLLI2SVCO = PLLI2S clock entry x 20
  1420. *
  1421. */
  1422. #define __HAL_RCC_PLLI2S_CONFIG(__PLLI2SMUL__)\
  1423. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PLL3MUL,(__PLLI2SMUL__))
  1424. /**
  1425. * @}
  1426. */
  1427. #endif /* STM32F105xC || STM32F107xC */
  1428. /** @defgroup RCCEx_Peripheral_Configuration Peripheral Configuration
  1429. * @brief Macros to configure clock source of different peripherals.
  1430. * @{
  1431. */
  1432. #if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
  1433. || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)
  1434. /** @brief Macro to configure the USB clock.
  1435. * @param __USBCLKSOURCE__ specifies the USB clock source.
  1436. * This parameter can be one of the following values:
  1437. * @arg @ref RCC_USBCLKSOURCE_PLL PLL clock divided by 1 selected as USB clock
  1438. * @arg @ref RCC_USBCLKSOURCE_PLL_DIV1_5 PLL clock divided by 1.5 selected as USB clock
  1439. */
  1440. #define __HAL_RCC_USB_CONFIG(__USBCLKSOURCE__) \
  1441. MODIFY_REG(RCC->CFGR, RCC_CFGR_USBPRE, (uint32_t)(__USBCLKSOURCE__))
  1442. /** @brief Macro to get the USB clock (USBCLK).
  1443. * @retval The clock source can be one of the following values:
  1444. * @arg @ref RCC_USBCLKSOURCE_PLL PLL clock divided by 1 selected as USB clock
  1445. * @arg @ref RCC_USBCLKSOURCE_PLL_DIV1_5 PLL clock divided by 1.5 selected as USB clock
  1446. */
  1447. #define __HAL_RCC_GET_USB_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_USBPRE)))
  1448. #endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG */
  1449. #if defined(STM32F105xC) || defined(STM32F107xC)
  1450. /** @brief Macro to configure the USB OTSclock.
  1451. * @param __USBCLKSOURCE__ specifies the USB clock source.
  1452. * This parameter can be one of the following values:
  1453. * @arg @ref RCC_USBCLKSOURCE_PLL_DIV2 PLL clock divided by 2 selected as USB OTG FS clock
  1454. * @arg @ref RCC_USBCLKSOURCE_PLL_DIV3 PLL clock divided by 3 selected as USB OTG FS clock
  1455. */
  1456. #define __HAL_RCC_USB_CONFIG(__USBCLKSOURCE__) \
  1457. MODIFY_REG(RCC->CFGR, RCC_CFGR_OTGFSPRE, (uint32_t)(__USBCLKSOURCE__))
  1458. /** @brief Macro to get the USB clock (USBCLK).
  1459. * @retval The clock source can be one of the following values:
  1460. * @arg @ref RCC_USBCLKSOURCE_PLL_DIV2 PLL clock divided by 2 selected as USB OTG FS clock
  1461. * @arg @ref RCC_USBCLKSOURCE_PLL_DIV3 PLL clock divided by 3 selected as USB OTG FS clock
  1462. */
  1463. #define __HAL_RCC_GET_USB_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_OTGFSPRE)))
  1464. #endif /* STM32F105xC || STM32F107xC */
  1465. /** @brief Macro to configure the ADCx clock (x=1 to 3 depending on devices).
  1466. * @param __ADCCLKSOURCE__ specifies the ADC clock source.
  1467. * This parameter can be one of the following values:
  1468. * @arg @ref RCC_ADCPCLK2_DIV2 PCLK2 clock divided by 2 selected as ADC clock
  1469. * @arg @ref RCC_ADCPCLK2_DIV4 PCLK2 clock divided by 4 selected as ADC clock
  1470. * @arg @ref RCC_ADCPCLK2_DIV6 PCLK2 clock divided by 6 selected as ADC clock
  1471. * @arg @ref RCC_ADCPCLK2_DIV8 PCLK2 clock divided by 8 selected as ADC clock
  1472. */
  1473. #define __HAL_RCC_ADC_CONFIG(__ADCCLKSOURCE__) \
  1474. MODIFY_REG(RCC->CFGR, RCC_CFGR_ADCPRE, (uint32_t)(__ADCCLKSOURCE__))
  1475. /** @brief Macro to get the ADC clock (ADCxCLK, x=1 to 3 depending on devices).
  1476. * @retval The clock source can be one of the following values:
  1477. * @arg @ref RCC_ADCPCLK2_DIV2 PCLK2 clock divided by 2 selected as ADC clock
  1478. * @arg @ref RCC_ADCPCLK2_DIV4 PCLK2 clock divided by 4 selected as ADC clock
  1479. * @arg @ref RCC_ADCPCLK2_DIV6 PCLK2 clock divided by 6 selected as ADC clock
  1480. * @arg @ref RCC_ADCPCLK2_DIV8 PCLK2 clock divided by 8 selected as ADC clock
  1481. */
  1482. #define __HAL_RCC_GET_ADC_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_ADCPRE)))
  1483. /**
  1484. * @}
  1485. */
  1486. #if defined(STM32F105xC) || defined(STM32F107xC)
  1487. /** @addtogroup RCCEx_HSE_Configuration
  1488. * @{
  1489. */
  1490. /**
  1491. * @brief Macro to configure the PLL2 & PLLI2S Predivision factor.
  1492. * @note Predivision factor can not be changed if PLL2 is used indirectly as system clock
  1493. * In this case, you have to select another source of the system clock, disable the PLL2 and PLLI2S and
  1494. * then change the PREDIV2 factor.
  1495. * @param __HSE_PREDIV2_VALUE__ specifies the PREDIV2 value applied to PLL2 & PLLI2S.
  1496. * This parameter must be a number between RCC_HSE_PREDIV2_DIV1 and RCC_HSE_PREDIV2_DIV16.
  1497. */
  1498. #define __HAL_RCC_HSE_PREDIV2_CONFIG(__HSE_PREDIV2_VALUE__) \
  1499. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV2, (uint32_t)(__HSE_PREDIV2_VALUE__))
  1500. /**
  1501. * @brief Macro to get prediv2 factor for PLL2 & PLL3.
  1502. */
  1503. #define __HAL_RCC_HSE_GET_PREDIV2() READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV2)
  1504. /**
  1505. * @}
  1506. */
  1507. /** @addtogroup RCCEx_PLLI2S_Configuration
  1508. * @{
  1509. */
  1510. /** @brief Macros to enable the main PLL2.
  1511. * @note After enabling the main PLL2, the application software should wait on
  1512. * PLL2RDY flag to be set indicating that PLL2 clock is stable and can
  1513. * be used as system clock source.
  1514. * @note The main PLL2 is disabled by hardware when entering STOP and STANDBY modes.
  1515. */
  1516. #define __HAL_RCC_PLL2_ENABLE() (*(__IO uint32_t *) RCC_CR_PLL2ON_BB = ENABLE)
  1517. /** @brief Macros to disable the main PLL2.
  1518. * @note The main PLL2 can not be disabled if it is used indirectly as system clock source
  1519. * @note The main PLL2 is disabled by hardware when entering STOP and STANDBY modes.
  1520. */
  1521. #define __HAL_RCC_PLL2_DISABLE() (*(__IO uint32_t *) RCC_CR_PLL2ON_BB = DISABLE)
  1522. /** @brief macros to configure the main PLL2 multiplication factor.
  1523. * @note This function must be used only when the main PLL2 is disabled.
  1524. *
  1525. * @param __PLL2MUL__ specifies the multiplication factor for PLL2 VCO output clock
  1526. * This parameter can be one of the following values:
  1527. * @arg @ref RCC_PLL2_MUL8 PLL2VCO = PLL2 clock entry x 8
  1528. * @arg @ref RCC_PLL2_MUL9 PLL2VCO = PLL2 clock entry x 9
  1529. * @arg @ref RCC_PLL2_MUL10 PLL2VCO = PLL2 clock entry x 10
  1530. * @arg @ref RCC_PLL2_MUL11 PLL2VCO = PLL2 clock entry x 11
  1531. * @arg @ref RCC_PLL2_MUL12 PLL2VCO = PLL2 clock entry x 12
  1532. * @arg @ref RCC_PLL2_MUL13 PLL2VCO = PLL2 clock entry x 13
  1533. * @arg @ref RCC_PLL2_MUL14 PLL2VCO = PLL2 clock entry x 14
  1534. * @arg @ref RCC_PLL2_MUL16 PLL2VCO = PLL2 clock entry x 16
  1535. * @arg @ref RCC_PLL2_MUL20 PLL2VCO = PLL2 clock entry x 20
  1536. *
  1537. */
  1538. #define __HAL_RCC_PLL2_CONFIG(__PLL2MUL__)\
  1539. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PLL2MUL,(__PLL2MUL__))
  1540. /**
  1541. * @}
  1542. */
  1543. /** @defgroup RCCEx_I2S_Configuration I2S Configuration
  1544. * @brief Macros to configure clock source of I2S peripherals.
  1545. * @{
  1546. */
  1547. /** @brief Macro to configure the I2S2 clock.
  1548. * @param __I2S2CLKSOURCE__ specifies the I2S2 clock source.
  1549. * This parameter can be one of the following values:
  1550. * @arg @ref RCC_I2S2CLKSOURCE_SYSCLK system clock selected as I2S3 clock entry
  1551. * @arg @ref RCC_I2S2CLKSOURCE_PLLI2S_VCO PLLI2S VCO clock selected as I2S3 clock entry
  1552. */
  1553. #define __HAL_RCC_I2S2_CONFIG(__I2S2CLKSOURCE__) \
  1554. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_I2S2SRC, (uint32_t)(__I2S2CLKSOURCE__))
  1555. /** @brief Macro to get the I2S2 clock (I2S2CLK).
  1556. * @retval The clock source can be one of the following values:
  1557. * @arg @ref RCC_I2S2CLKSOURCE_SYSCLK system clock selected as I2S3 clock entry
  1558. * @arg @ref RCC_I2S2CLKSOURCE_PLLI2S_VCO PLLI2S VCO clock selected as I2S3 clock entry
  1559. */
  1560. #define __HAL_RCC_GET_I2S2_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_I2S2SRC)))
  1561. /** @brief Macro to configure the I2S3 clock.
  1562. * @param __I2S2CLKSOURCE__ specifies the I2S3 clock source.
  1563. * This parameter can be one of the following values:
  1564. * @arg @ref RCC_I2S3CLKSOURCE_SYSCLK system clock selected as I2S3 clock entry
  1565. * @arg @ref RCC_I2S3CLKSOURCE_PLLI2S_VCO PLLI2S VCO clock selected as I2S3 clock entry
  1566. */
  1567. #define __HAL_RCC_I2S3_CONFIG(__I2S2CLKSOURCE__) \
  1568. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_I2S3SRC, (uint32_t)(__I2S2CLKSOURCE__))
  1569. /** @brief Macro to get the I2S3 clock (I2S3CLK).
  1570. * @retval The clock source can be one of the following values:
  1571. * @arg @ref RCC_I2S3CLKSOURCE_SYSCLK system clock selected as I2S3 clock entry
  1572. * @arg @ref RCC_I2S3CLKSOURCE_PLLI2S_VCO PLLI2S VCO clock selected as I2S3 clock entry
  1573. */
  1574. #define __HAL_RCC_GET_I2S3_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_I2S3SRC)))
  1575. /**
  1576. * @}
  1577. */
  1578. #endif /* STM32F105xC || STM32F107xC */
  1579. /**
  1580. * @}
  1581. */
  1582. /* Exported functions --------------------------------------------------------*/
  1583. /** @addtogroup RCCEx_Exported_Functions
  1584. * @{
  1585. */
  1586. /** @addtogroup RCCEx_Exported_Functions_Group1
  1587. * @{
  1588. */
  1589. HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  1590. void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  1591. uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk);
  1592. /**
  1593. * @}
  1594. */
  1595. #if defined(STM32F105xC) || defined(STM32F107xC)
  1596. /** @addtogroup RCCEx_Exported_Functions_Group2
  1597. * @{
  1598. */
  1599. HAL_StatusTypeDef HAL_RCCEx_EnablePLLI2S(RCC_PLLI2SInitTypeDef *PLLI2SInit);
  1600. HAL_StatusTypeDef HAL_RCCEx_DisablePLLI2S(void);
  1601. /**
  1602. * @}
  1603. */
  1604. /** @addtogroup RCCEx_Exported_Functions_Group3
  1605. * @{
  1606. */
  1607. HAL_StatusTypeDef HAL_RCCEx_EnablePLL2(RCC_PLL2InitTypeDef *PLL2Init);
  1608. HAL_StatusTypeDef HAL_RCCEx_DisablePLL2(void);
  1609. /**
  1610. * @}
  1611. */
  1612. #endif /* STM32F105xC || STM32F107xC */
  1613. /**
  1614. * @}
  1615. */
  1616. /**
  1617. * @}
  1618. */
  1619. /**
  1620. * @}
  1621. */
  1622. #ifdef __cplusplus
  1623. }
  1624. #endif
  1625. #endif /* __STM32F1xx_HAL_RCC_EX_H */
  1626. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/