stm32f1xx_hal_rcc_ex.h 99 KB

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