stm32f1xx_hal_rcc_ex.h 97 KB

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