stm32l1xx_hal_rcc.h 104 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L1xx_HAL_RCC_H
  37. #define __STM32L1xx_HAL_RCC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l1xx_hal_def.h"
  43. /** @addtogroup STM32L1xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup RCC
  47. * @{
  48. */
  49. /** @addtogroup RCC_Private_Constants
  50. * @{
  51. */
  52. /** @defgroup RCC_Timeout RCC Timeout
  53. * @{
  54. */
  55. /* Disable Backup domain write protection state change timeout */
  56. #define RCC_DBP_TIMEOUT_VALUE (100U) /* 100 ms */
  57. /* LSE state change timeout */
  58. #define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
  59. #define CLOCKSWITCH_TIMEOUT_VALUE (5000U) /* 5 s */
  60. #define HSE_TIMEOUT_VALUE HSE_STARTUP_TIMEOUT
  61. #define MSI_TIMEOUT_VALUE (2U) /* 2 ms (minimum Tick + 1U) */
  62. #define HSI_TIMEOUT_VALUE (2U) /* 2 ms (minimum Tick + 1U) */
  63. #define LSI_TIMEOUT_VALUE (2U) /* 2 ms (minimum Tick + 1U) */
  64. #define PLL_TIMEOUT_VALUE (2U) /* 2 ms (minimum Tick + 1U) */
  65. /**
  66. * @}
  67. */
  68. /** @defgroup RCC_Register_Offset Register offsets
  69. * @{
  70. */
  71. #define RCC_OFFSET (RCC_BASE - PERIPH_BASE)
  72. #define RCC_CR_OFFSET 0x00
  73. #define RCC_CFGR_OFFSET 0x08
  74. #define RCC_CIR_OFFSET 0x0C
  75. #define RCC_CSR_OFFSET 0x34
  76. /**
  77. * @}
  78. */
  79. /** @defgroup RCC_BitAddress_AliasRegion BitAddress AliasRegion
  80. * @brief RCC registers bit address in the alias region
  81. * @{
  82. */
  83. #define RCC_CR_OFFSET_BB (RCC_OFFSET + RCC_CR_OFFSET)
  84. #define RCC_CFGR_OFFSET_BB (RCC_OFFSET + RCC_CFGR_OFFSET)
  85. #define RCC_CIR_OFFSET_BB (RCC_OFFSET + RCC_CIR_OFFSET)
  86. #define RCC_CSR_OFFSET_BB (RCC_OFFSET + RCC_CSR_OFFSET)
  87. /* --- CR Register ---*/
  88. /* Alias word address of HSION bit */
  89. #define RCC_HSION_BIT_NUMBER POSITION_VAL(RCC_CR_HSION)
  90. #define RCC_CR_HSION_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_HSION_BIT_NUMBER * 4U)))
  91. /* Alias word address of MSION bit */
  92. #define RCC_MSION_BIT_NUMBER POSITION_VAL(RCC_CR_MSION)
  93. #define RCC_CR_MSION_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_MSION_BIT_NUMBER * 4U)))
  94. /* Alias word address of HSEON bit */
  95. #define RCC_HSEON_BIT_NUMBER POSITION_VAL(RCC_CR_HSEON)
  96. #define RCC_CR_HSEON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_HSEON_BIT_NUMBER * 4U)))
  97. /* Alias word address of CSSON bit */
  98. #define RCC_CSSON_BIT_NUMBER POSITION_VAL(RCC_CR_CSSON)
  99. #define RCC_CR_CSSON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_CSSON_BIT_NUMBER * 4U)))
  100. /* Alias word address of PLLON bit */
  101. #define RCC_PLLON_BIT_NUMBER POSITION_VAL(RCC_CR_PLLON)
  102. #define RCC_CR_PLLON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_PLLON_BIT_NUMBER * 4U)))
  103. /* --- CSR Register ---*/
  104. /* Alias word address of LSION bit */
  105. #define RCC_LSION_BIT_NUMBER POSITION_VAL(RCC_CSR_LSION)
  106. #define RCC_CSR_LSION_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_LSION_BIT_NUMBER * 4U)))
  107. /* Alias word address of RMVF bit */
  108. #define RCC_RMVF_BIT_NUMBER POSITION_VAL(RCC_CSR_RMVF)
  109. #define RCC_CSR_RMVF_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_RMVF_BIT_NUMBER * 4U)))
  110. /* Alias word address of LSEON bit */
  111. #define RCC_LSEON_BIT_NUMBER POSITION_VAL(RCC_CSR_LSEON)
  112. #define RCC_CSR_LSEON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_LSEON_BIT_NUMBER * 4U)))
  113. /* Alias word address of LSEON bit */
  114. #define RCC_LSEBYP_BIT_NUMBER POSITION_VAL(RCC_CSR_LSEBYP)
  115. #define RCC_CSR_LSEBYP_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_LSEBYP_BIT_NUMBER * 4U)))
  116. /* Alias word address of RTCEN bit */
  117. #define RCC_RTCEN_BIT_NUMBER POSITION_VAL(RCC_CSR_RTCEN)
  118. #define RCC_CSR_RTCEN_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_RTCEN_BIT_NUMBER * 4U)))
  119. /* Alias word address of RTCRST bit */
  120. #define RCC_RTCRST_BIT_NUMBER POSITION_VAL(RCC_CSR_RTCRST)
  121. #define RCC_CSR_RTCRST_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_RTCRST_BIT_NUMBER * 4U)))
  122. /**
  123. * @}
  124. */
  125. /* CR register byte 2 (Bits[23:16]) base address */
  126. #define RCC_CR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + RCC_CR_OFFSET + 0x02U))
  127. /* CIR register byte 1 (Bits[15:8]) base address */
  128. #define RCC_CIR_BYTE1_ADDRESS ((uint32_t)(RCC_BASE + RCC_CIR_OFFSET + 0x01U))
  129. /* CIR register byte 2 (Bits[23:16]) base address */
  130. #define RCC_CIR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + RCC_CIR_OFFSET + 0x02U))
  131. /* Defines used for Flags */
  132. #define CR_REG_INDEX ((uint8_t)1U)
  133. #define CSR_REG_INDEX ((uint8_t)2U)
  134. #define RCC_FLAG_MASK ((uint8_t)0x1FU)
  135. /**
  136. * @}
  137. */
  138. /** @addtogroup RCC_Private_Macros
  139. * @{
  140. */
  141. #define IS_RCC_PLLSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLSOURCE_HSI) || \
  142. ((__SOURCE__) == RCC_PLLSOURCE_HSE))
  143. #define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
  144. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
  145. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
  146. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
  147. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE) || \
  148. (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_MSI) == RCC_OSCILLATORTYPE_MSI))
  149. #define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
  150. ((__HSE__) == RCC_HSE_BYPASS))
  151. #define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
  152. ((__LSE__) == RCC_LSE_BYPASS))
  153. #define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
  154. #define IS_RCC_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= 0x1FU)
  155. #define IS_RCC_MSICALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= 0xFFU)
  156. #define IS_RCC_MSI_CLOCK_RANGE(__RANGE__) (((__RANGE__) == RCC_MSIRANGE_0) || \
  157. ((__RANGE__) == RCC_MSIRANGE_1) || \
  158. ((__RANGE__) == RCC_MSIRANGE_2) || \
  159. ((__RANGE__) == RCC_MSIRANGE_3) || \
  160. ((__RANGE__) == RCC_MSIRANGE_4) || \
  161. ((__RANGE__) == RCC_MSIRANGE_5) || \
  162. ((__RANGE__) == RCC_MSIRANGE_6))
  163. #define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
  164. #define IS_RCC_MSI(__MSI__) (((__MSI__) == RCC_MSI_OFF) || ((__MSI__) == RCC_MSI_ON))
  165. #define IS_RCC_PLL(__PLL__) (((__PLL__) == RCC_PLL_NONE) || ((__PLL__) == RCC_PLL_OFF) || \
  166. ((__PLL__) == RCC_PLL_ON))
  167. #define IS_RCC_PLL_DIV(__DIV__) (((__DIV__) == RCC_PLL_DIV2) || \
  168. ((__DIV__) == RCC_PLL_DIV3) || ((__DIV__) == RCC_PLL_DIV4))
  169. #define IS_RCC_PLL_MUL(__MUL__) (((__MUL__) == RCC_PLL_MUL3) || ((__MUL__) == RCC_PLL_MUL4) || \
  170. ((__MUL__) == RCC_PLL_MUL6) || ((__MUL__) == RCC_PLL_MUL8) || \
  171. ((__MUL__) == RCC_PLL_MUL12) || ((__MUL__) == RCC_PLL_MUL16) || \
  172. ((__MUL__) == RCC_PLL_MUL24) || ((__MUL__) == RCC_PLL_MUL32) || \
  173. ((__MUL__) == RCC_PLL_MUL48))
  174. #define IS_RCC_CLOCKTYPE(CLK) ((((CLK) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK) || \
  175. (((CLK) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK) || \
  176. (((CLK) & RCC_CLOCKTYPE_PCLK1) == RCC_CLOCKTYPE_PCLK1) || \
  177. (((CLK) & RCC_CLOCKTYPE_PCLK2) == RCC_CLOCKTYPE_PCLK2))
  178. #define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_MSI) || \
  179. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
  180. ((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
  181. ((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
  182. #define IS_RCC_SYSCLKSOURCE_STATUS(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_STATUS_MSI) || \
  183. ((__SOURCE__) == RCC_SYSCLKSOURCE_STATUS_HSI) || \
  184. ((__SOURCE__) == RCC_SYSCLKSOURCE_STATUS_HSE) || \
  185. ((__SOURCE__) == RCC_SYSCLKSOURCE_STATUS_PLLCLK))
  186. #define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
  187. ((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
  188. ((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
  189. ((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
  190. ((__HCLK__) == RCC_SYSCLK_DIV512))
  191. #define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
  192. ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
  193. ((__PCLK__) == RCC_HCLK_DIV16))
  194. #define IS_RCC_MCO(__MCO__) ((__MCO__) == RCC_MCO)
  195. #define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1) || ((__DIV__) == RCC_MCODIV_2) || \
  196. ((__DIV__) == RCC_MCODIV_4) || ((__DIV__) == RCC_MCODIV_8) || \
  197. ((__DIV__) == RCC_MCODIV_16))
  198. #define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || ((__SOURCE__) == RCC_MCO1SOURCE_MSI) \
  199. || ((__SOURCE__) == RCC_MCO1SOURCE_HSI) || ((__SOURCE__) == RCC_MCO1SOURCE_LSE) \
  200. || ((__SOURCE__) == RCC_MCO1SOURCE_LSI) || ((__SOURCE__) == RCC_MCO1SOURCE_HSE) \
  201. || ((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || ((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK))
  202. #define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_NO_CLK) || \
  203. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
  204. ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
  205. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV2) || \
  206. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV4) || \
  207. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV8) || \
  208. ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV16))
  209. /**
  210. * @}
  211. */
  212. /* Exported types ------------------------------------------------------------*/
  213. /** @defgroup RCC_Exported_Types RCC Exported Types
  214. * @{
  215. */
  216. /**
  217. * @brief RCC PLL configuration structure definition
  218. */
  219. typedef struct
  220. {
  221. uint32_t PLLState; /*!< PLLState: The new state of the PLL.
  222. This parameter can be a value of @ref RCC_PLL_Config */
  223. uint32_t PLLSource; /*!< PLLSource: PLL entry clock source.
  224. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  225. uint32_t PLLMUL; /*!< PLLMUL: Multiplication factor for PLL VCO input clock
  226. This parameter must be a value of @ref RCC_PLL_Multiplication_Factor*/
  227. uint32_t PLLDIV; /*!< PLLDIV: Division factor for PLL VCO input clock
  228. This parameter must be a value of @ref RCC_PLL_Division_Factor*/
  229. } RCC_PLLInitTypeDef;
  230. /**
  231. * @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
  232. */
  233. typedef struct
  234. {
  235. uint32_t OscillatorType; /*!< The oscillators to be configured.
  236. This parameter can be a value of @ref RCC_Oscillator_Type */
  237. uint32_t HSEState; /*!< The new state of the HSE.
  238. This parameter can be a value of @ref RCC_HSE_Config */
  239. uint32_t LSEState; /*!< The new state of the LSE.
  240. This parameter can be a value of @ref RCC_LSE_Config */
  241. uint32_t HSIState; /*!< The new state of the HSI.
  242. This parameter can be a value of @ref RCC_HSI_Config */
  243. uint32_t HSICalibrationValue; /*!< The HSI calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
  244. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1FU */
  245. uint32_t LSIState; /*!< The new state of the LSI.
  246. This parameter can be a value of @ref RCC_LSI_Config */
  247. uint32_t MSIState; /*!< The new state of the MSI.
  248. This parameter can be a value of @ref RCC_MSI_Config */
  249. uint32_t MSICalibrationValue; /*!< The MSI calibration trimming value. (default is RCC_MSICALIBRATION_DEFAULT).
  250. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFU */
  251. uint32_t MSIClockRange; /*!< The MSI frequency range.
  252. This parameter can be a value of @ref RCC_MSI_Clock_Range */
  253. RCC_PLLInitTypeDef PLL; /*!< PLL structure parameters */
  254. } RCC_OscInitTypeDef;
  255. /**
  256. * @brief RCC System, AHB and APB busses clock configuration structure definition
  257. */
  258. typedef struct
  259. {
  260. uint32_t ClockType; /*!< The clock to be configured.
  261. This parameter can be a value of @ref RCC_System_Clock_Type */
  262. uint32_t SYSCLKSource; /*!< The clock source (SYSCLKS) used as system clock.
  263. This parameter can be a value of @ref RCC_System_Clock_Source */
  264. uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
  265. This parameter can be a value of @ref RCC_AHB_Clock_Source */
  266. uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
  267. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  268. uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
  269. This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
  270. } RCC_ClkInitTypeDef;
  271. /**
  272. * @}
  273. */
  274. /* Exported constants --------------------------------------------------------*/
  275. /** @defgroup RCC_Exported_Constants RCC Exported Constants
  276. * @{
  277. */
  278. /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
  279. * @{
  280. */
  281. #define RCC_PLLSOURCE_HSI RCC_CFGR_PLLSRC_HSI /*!< HSI clock selected as PLL entry clock source */
  282. #define RCC_PLLSOURCE_HSE RCC_CFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */
  283. /**
  284. * @}
  285. */
  286. /** @defgroup RCC_Oscillator_Type Oscillator Type
  287. * @{
  288. */
  289. #define RCC_OSCILLATORTYPE_NONE (0x00000000U)
  290. #define RCC_OSCILLATORTYPE_HSE (0x00000001U)
  291. #define RCC_OSCILLATORTYPE_HSI (0x00000002U)
  292. #define RCC_OSCILLATORTYPE_LSE (0x00000004U)
  293. #define RCC_OSCILLATORTYPE_LSI (0x00000008U)
  294. #define RCC_OSCILLATORTYPE_MSI (0x00000010U)
  295. /**
  296. * @}
  297. */
  298. /** @defgroup RCC_HSE_Config HSE Config
  299. * @{
  300. */
  301. #define RCC_HSE_OFF (0x00000000U) /*!< HSE clock deactivation */
  302. #define RCC_HSE_ON (0x00000001U) /*!< HSE clock activation */
  303. #define RCC_HSE_BYPASS (0x00000005U) /*!< External clock source for HSE clock */
  304. /**
  305. * @}
  306. */
  307. /** @defgroup RCC_LSE_Config LSE Config
  308. * @{
  309. */
  310. #define RCC_LSE_OFF (0x00000000U) /*!< LSE clock deactivation */
  311. #define RCC_LSE_ON (0x00000001U) /*!< LSE clock activation */
  312. #define RCC_LSE_BYPASS (0x00000005U) /*!< External clock source for LSE clock */
  313. /**
  314. * @}
  315. */
  316. /** @defgroup RCC_HSI_Config HSI Config
  317. * @{
  318. */
  319. #define RCC_HSI_OFF (0x00000000U) /*!< HSI clock deactivation */
  320. #define RCC_HSI_ON RCC_CR_HSION /*!< HSI clock activation */
  321. #define RCC_HSICALIBRATION_DEFAULT (0x10U) /* Default HSI calibration trimming value */
  322. /**
  323. * @}
  324. */
  325. /** @defgroup RCC_MSI_Clock_Range MSI Clock Range
  326. * @{
  327. */
  328. #define RCC_MSIRANGE_0 RCC_ICSCR_MSIRANGE_0 /*!< MSI = 65.536 KHz */
  329. #define RCC_MSIRANGE_1 RCC_ICSCR_MSIRANGE_1 /*!< MSI = 131.072 KHz */
  330. #define RCC_MSIRANGE_2 RCC_ICSCR_MSIRANGE_2 /*!< MSI = 262.144 KHz */
  331. #define RCC_MSIRANGE_3 RCC_ICSCR_MSIRANGE_3 /*!< MSI = 524.288 KHz */
  332. #define RCC_MSIRANGE_4 RCC_ICSCR_MSIRANGE_4 /*!< MSI = 1.048 MHz */
  333. #define RCC_MSIRANGE_5 RCC_ICSCR_MSIRANGE_5 /*!< MSI = 2.097 MHz */
  334. #define RCC_MSIRANGE_6 RCC_ICSCR_MSIRANGE_6 /*!< MSI = 4.194 MHz */
  335. /**
  336. * @}
  337. */
  338. /** @defgroup RCC_LSI_Config LSI Config
  339. * @{
  340. */
  341. #define RCC_LSI_OFF (0x00000000U) /*!< LSI clock deactivation */
  342. #define RCC_LSI_ON RCC_CSR_LSION /*!< LSI clock activation */
  343. /**
  344. * @}
  345. */
  346. /** @defgroup RCC_MSI_Config MSI Config
  347. * @{
  348. */
  349. #define RCC_MSI_OFF (0x00000000U)
  350. #define RCC_MSI_ON (0x00000001U)
  351. #define RCC_MSICALIBRATION_DEFAULT (0x00000000U) /* Default MSI calibration trimming value */
  352. /**
  353. * @}
  354. */
  355. /** @defgroup RCC_PLL_Config PLL Config
  356. * @{
  357. */
  358. #define RCC_PLL_NONE (0x00000000U) /*!< PLL is not configured */
  359. #define RCC_PLL_OFF (0x00000001U) /*!< PLL deactivation */
  360. #define RCC_PLL_ON (0x00000002U) /*!< PLL activation */
  361. /**
  362. * @}
  363. */
  364. /** @defgroup RCC_System_Clock_Type System Clock Type
  365. * @{
  366. */
  367. #define RCC_CLOCKTYPE_SYSCLK (0x00000001U) /*!< SYSCLK to configure */
  368. #define RCC_CLOCKTYPE_HCLK (0x00000002U) /*!< HCLK to configure */
  369. #define RCC_CLOCKTYPE_PCLK1 (0x00000004U) /*!< PCLK1 to configure */
  370. #define RCC_CLOCKTYPE_PCLK2 (0x00000008U) /*!< PCLK2 to configure */
  371. /**
  372. * @}
  373. */
  374. /** @defgroup RCC_System_Clock_Source System Clock Source
  375. * @{
  376. */
  377. #define RCC_SYSCLKSOURCE_MSI RCC_CFGR_SW_MSI /*!< MSI selected as system clock */
  378. #define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI /*!< HSI selected as system clock */
  379. #define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE /*!< HSE selected as system clock */
  380. #define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL /*!< PLL selected as system clock */
  381. /**
  382. * @}
  383. */
  384. /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
  385. * @{
  386. */
  387. #define RCC_SYSCLKSOURCE_STATUS_MSI RCC_CFGR_SWS_MSI /*!< MSI used as system clock */
  388. #define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  389. #define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  390. #define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  391. /**
  392. * @}
  393. */
  394. /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
  395. * @{
  396. */
  397. #define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1 /*!< SYSCLK not divided */
  398. #define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2 /*!< SYSCLK divided by 2 */
  399. #define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4 /*!< SYSCLK divided by 4 */
  400. #define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8 /*!< SYSCLK divided by 8 */
  401. #define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16 /*!< SYSCLK divided by 16 */
  402. #define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64 /*!< SYSCLK divided by 64 */
  403. #define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128 /*!< SYSCLK divided by 128 */
  404. #define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256 /*!< SYSCLK divided by 256 */
  405. #define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
  406. /**
  407. * @}
  408. */
  409. /** @defgroup RCC_APB1_APB2_Clock_Source APB1 APB2 Clock Source
  410. * @{
  411. */
  412. #define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1 /*!< HCLK not divided */
  413. #define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2 /*!< HCLK divided by 2 */
  414. #define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4 /*!< HCLK divided by 4 */
  415. #define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8 /*!< HCLK divided by 8 */
  416. #define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16 /*!< HCLK divided by 16 */
  417. /**
  418. * @}
  419. */
  420. /** @defgroup RCC_HAL_EC_RTC_HSE_DIV RTC HSE Prescaler
  421. * @{
  422. */
  423. #define RCC_RTC_HSE_DIV_2 0x00000000U /*!< HSE is divided by 2 for RTC clock */
  424. #define RCC_RTC_HSE_DIV_4 RCC_CR_RTCPRE_0 /*!< HSE is divided by 4 for RTC clock */
  425. #define RCC_RTC_HSE_DIV_8 RCC_CR_RTCPRE_1 /*!< HSE is divided by 8 for RTC clock */
  426. #define RCC_RTC_HSE_DIV_16 RCC_CR_RTCPRE /*!< HSE is divided by 16 for RTC clock */
  427. /**
  428. * @}
  429. */
  430. /** @defgroup RCC_RTC_LCD_Clock_Source RTC LCD Clock Source
  431. * @{
  432. */
  433. #define RCC_RTCCLKSOURCE_NO_CLK (0x00000000U) /*!< No clock */
  434. #define RCC_RTCCLKSOURCE_LSE RCC_CSR_RTCSEL_LSE /*!< LSE oscillator clock used as RTC clock */
  435. #define RCC_RTCCLKSOURCE_LSI RCC_CSR_RTCSEL_LSI /*!< LSI oscillator clock used as RTC clock */
  436. #define RCC_RTCCLKSOURCE_HSE_DIVX RCC_CSR_RTCSEL_HSE /*!< HSE oscillator clock divided by X used as RTC clock */
  437. #define RCC_RTCCLKSOURCE_HSE_DIV2 (RCC_RTC_HSE_DIV_2 | RCC_CSR_RTCSEL_HSE) /*!< HSE oscillator clock divided by 2 used as RTC clock */
  438. #define RCC_RTCCLKSOURCE_HSE_DIV4 (RCC_RTC_HSE_DIV_4 | RCC_CSR_RTCSEL_HSE) /*!< HSE oscillator clock divided by 4 used as RTC clock */
  439. #define RCC_RTCCLKSOURCE_HSE_DIV8 (RCC_RTC_HSE_DIV_8 | RCC_CSR_RTCSEL_HSE) /*!< HSE oscillator clock divided by 8 used as RTC clock */
  440. #define RCC_RTCCLKSOURCE_HSE_DIV16 (RCC_RTC_HSE_DIV_16 | RCC_CSR_RTCSEL_HSE) /*!< HSE oscillator clock divided by 16 used as RTC clock */
  441. /**
  442. * @}
  443. */
  444. /** @defgroup RCC_PLL_Division_Factor PLL Division Factor
  445. * @{
  446. */
  447. #define RCC_PLL_DIV2 RCC_CFGR_PLLDIV2
  448. #define RCC_PLL_DIV3 RCC_CFGR_PLLDIV3
  449. #define RCC_PLL_DIV4 RCC_CFGR_PLLDIV4
  450. /**
  451. * @}
  452. */
  453. /** @defgroup RCC_PLL_Multiplication_Factor PLL Multiplication Factor
  454. * @{
  455. */
  456. #define RCC_PLL_MUL3 RCC_CFGR_PLLMUL3
  457. #define RCC_PLL_MUL4 RCC_CFGR_PLLMUL4
  458. #define RCC_PLL_MUL6 RCC_CFGR_PLLMUL6
  459. #define RCC_PLL_MUL8 RCC_CFGR_PLLMUL8
  460. #define RCC_PLL_MUL12 RCC_CFGR_PLLMUL12
  461. #define RCC_PLL_MUL16 RCC_CFGR_PLLMUL16
  462. #define RCC_PLL_MUL24 RCC_CFGR_PLLMUL24
  463. #define RCC_PLL_MUL32 RCC_CFGR_PLLMUL32
  464. #define RCC_PLL_MUL48 RCC_CFGR_PLLMUL48
  465. /**
  466. * @}
  467. */
  468. /** @defgroup RCC_MCO_Index MCO Index
  469. * @{
  470. */
  471. #define RCC_MCO1 (0x00000000U)
  472. #define RCC_MCO RCC_MCO1 /*!< MCO1 to be compliant with other families with 2 MCOs*/
  473. /**
  474. * @}
  475. */
  476. /** @defgroup RCC_MCOx_Clock_Prescaler MCO Clock Prescaler
  477. * @{
  478. */
  479. #define RCC_MCODIV_1 ((uint32_t)RCC_CFGR_MCO_DIV1)
  480. #define RCC_MCODIV_2 ((uint32_t)RCC_CFGR_MCO_DIV2)
  481. #define RCC_MCODIV_4 ((uint32_t)RCC_CFGR_MCO_DIV4)
  482. #define RCC_MCODIV_8 ((uint32_t)RCC_CFGR_MCO_DIV8)
  483. #define RCC_MCODIV_16 ((uint32_t)RCC_CFGR_MCO_DIV16)
  484. /**
  485. * @}
  486. */
  487. /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
  488. * @{
  489. */
  490. #define RCC_MCO1SOURCE_NOCLOCK RCC_CFGR_MCO_NOCLOCK
  491. #define RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCO_SYSCLK
  492. #define RCC_MCO1SOURCE_MSI RCC_CFGR_MCO_MSI
  493. #define RCC_MCO1SOURCE_HSI RCC_CFGR_MCO_HSI
  494. #define RCC_MCO1SOURCE_LSE RCC_CFGR_MCO_LSE
  495. #define RCC_MCO1SOURCE_LSI RCC_CFGR_MCO_LSI
  496. #define RCC_MCO1SOURCE_HSE RCC_CFGR_MCO_HSE
  497. #define RCC_MCO1SOURCE_PLLCLK RCC_CFGR_MCO_PLL
  498. /**
  499. * @}
  500. */
  501. /** @defgroup RCC_Interrupt Interrupts
  502. * @{
  503. */
  504. #define RCC_IT_LSIRDY ((uint8_t)RCC_CIR_LSIRDYF) /*!< LSI Ready Interrupt flag */
  505. #define RCC_IT_LSERDY ((uint8_t)RCC_CIR_LSERDYF) /*!< LSE Ready Interrupt flag */
  506. #define RCC_IT_HSIRDY ((uint8_t)RCC_CIR_HSIRDYF) /*!< HSI Ready Interrupt flag */
  507. #define RCC_IT_HSERDY ((uint8_t)RCC_CIR_HSERDYF) /*!< HSE Ready Interrupt flag */
  508. #define RCC_IT_PLLRDY ((uint8_t)RCC_CIR_PLLRDYF) /*!< PLL Ready Interrupt flag */
  509. #define RCC_IT_MSIRDY ((uint8_t)RCC_CIR_MSIRDYF) /*!< MSI Ready Interrupt flag */
  510. #define RCC_IT_LSECSS ((uint8_t)RCC_CIR_LSECSSF) /*!< LSE Clock Security System Interrupt flag */
  511. #define RCC_IT_CSS ((uint8_t)RCC_CIR_CSSF) /*!< Clock Security System Interrupt flag */
  512. /**
  513. * @}
  514. */
  515. /** @defgroup RCC_Flag Flags
  516. * Elements values convention: XXXYYYYYb
  517. * - YYYYY : Flag position in the register
  518. * - XXX : Register index
  519. * - 001: CR register
  520. * - 010: CSR register
  521. * @{
  522. */
  523. /* Flags in the CR register */
  524. #define RCC_FLAG_HSIRDY ((uint8_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_HSIRDY))) /*!< Internal High Speed clock ready flag */
  525. #define RCC_FLAG_MSIRDY ((uint8_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_MSIRDY))) /*!< MSI clock ready flag */
  526. #define RCC_FLAG_HSERDY ((uint8_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_HSERDY))) /*!< External High Speed clock ready flag */
  527. #define RCC_FLAG_PLLRDY ((uint8_t)((CR_REG_INDEX << 5U) | POSITION_VAL(RCC_CR_PLLRDY))) /*!< PLL clock ready flag */
  528. /* Flags in the CSR register */
  529. #define RCC_FLAG_LSIRDY ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_LSIRDY))) /*!< Internal Low Speed oscillator Ready */
  530. #define RCC_FLAG_LSECSS ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_LSECSSD))) /*!< CSS on LSE failure Detection */
  531. #define RCC_FLAG_OBLRST ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_OBLRSTF))) /*!< Options bytes loading reset flag */
  532. #define RCC_FLAG_PINRST ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_PINRSTF))) /*!< PIN reset flag */
  533. #define RCC_FLAG_PORRST ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_PORRSTF))) /*!< POR/PDR reset flag */
  534. #define RCC_FLAG_SFTRST ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_SFTRSTF))) /*!< Software Reset flag */
  535. #define RCC_FLAG_IWDGRST ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_IWDGRSTF))) /*!< Independent Watchdog reset flag */
  536. #define RCC_FLAG_WWDGRST ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_WWDGRSTF))) /*!< Window watchdog reset flag */
  537. #define RCC_FLAG_LPWRRST ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_LPWRRSTF))) /*!< Low-Power reset flag */
  538. #define RCC_FLAG_LSERDY ((uint8_t)((CSR_REG_INDEX << 5U) | POSITION_VAL(RCC_CSR_LSERDY))) /*!< External Low Speed oscillator Ready */
  539. /**
  540. * @}
  541. */
  542. /**
  543. * @}
  544. */
  545. /* Exported macro ------------------------------------------------------------*/
  546. /** @defgroup RCC_Exported_Macros RCC Exported Macros
  547. * @{
  548. */
  549. /** @defgroup RCC_Peripheral_Clock_Enable_Disable Peripheral Clock Enable Disable
  550. * @brief Enable or disable the AHB1 peripheral clock.
  551. * @note After reset, the peripheral clock (used for registers read/write access)
  552. * is disabled and the application software has to enable this clock before
  553. * using it.
  554. * @{
  555. */
  556. #define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
  557. __IO uint32_t tmpreg; \
  558. SET_BIT(RCC->AHBENR, RCC_AHBENR_GPIOAEN);\
  559. /* Delay after an RCC peripheral clock enabling */\
  560. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_GPIOAEN);\
  561. UNUSED(tmpreg); \
  562. } while(0U)
  563. #define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
  564. __IO uint32_t tmpreg; \
  565. SET_BIT(RCC->AHBENR, RCC_AHBENR_GPIOBEN);\
  566. /* Delay after an RCC peripheral clock enabling */\
  567. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_GPIOBEN);\
  568. UNUSED(tmpreg); \
  569. } while(0U)
  570. #define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
  571. __IO uint32_t tmpreg; \
  572. SET_BIT(RCC->AHBENR, RCC_AHBENR_GPIOCEN);\
  573. /* Delay after an RCC peripheral clock enabling */\
  574. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_GPIOCEN);\
  575. UNUSED(tmpreg); \
  576. } while(0U)
  577. #define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
  578. __IO uint32_t tmpreg; \
  579. SET_BIT(RCC->AHBENR, RCC_AHBENR_GPIODEN);\
  580. /* Delay after an RCC peripheral clock enabling */\
  581. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_GPIODEN);\
  582. UNUSED(tmpreg); \
  583. } while(0U)
  584. #define __HAL_RCC_GPIOH_CLK_ENABLE() do { \
  585. __IO uint32_t tmpreg; \
  586. SET_BIT(RCC->AHBENR, RCC_AHBENR_GPIOHEN);\
  587. /* Delay after an RCC peripheral clock enabling */\
  588. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_GPIOHEN);\
  589. UNUSED(tmpreg); \
  590. } while(0U)
  591. #define __HAL_RCC_CRC_CLK_ENABLE() do { \
  592. __IO uint32_t tmpreg; \
  593. SET_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN);\
  594. /* Delay after an RCC peripheral clock enabling */\
  595. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN);\
  596. UNUSED(tmpreg); \
  597. } while(0U)
  598. #define __HAL_RCC_FLITF_CLK_ENABLE() do { \
  599. __IO uint32_t tmpreg; \
  600. SET_BIT(RCC->AHBENR, RCC_AHBENR_FLITFEN);\
  601. /* Delay after an RCC peripheral clock enabling */\
  602. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FLITFEN);\
  603. UNUSED(tmpreg); \
  604. } while(0U)
  605. #define __HAL_RCC_DMA1_CLK_ENABLE() do { \
  606. __IO uint32_t tmpreg; \
  607. SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN);\
  608. /* Delay after an RCC peripheral clock enabling */\
  609. tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN);\
  610. UNUSED(tmpreg); \
  611. } while(0U)
  612. #define __HAL_RCC_GPIOA_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIOAEN))
  613. #define __HAL_RCC_GPIOB_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIOBEN))
  614. #define __HAL_RCC_GPIOC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIOCEN))
  615. #define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIODEN))
  616. #define __HAL_RCC_GPIOH_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_GPIOHEN))
  617. #define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_CRCEN))
  618. #define __HAL_RCC_FLITF_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_FLITFEN))
  619. #define __HAL_RCC_DMA1_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_DMA1EN))
  620. /**
  621. * @}
  622. */
  623. /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Clock Enable Disable
  624. * @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  625. * @note After reset, the peripheral clock (used for registers read/write access)
  626. * is disabled and the application software has to enable this clock before
  627. * using it.
  628. * @{
  629. */
  630. #define __HAL_RCC_TIM2_CLK_ENABLE() do { \
  631. __IO uint32_t tmpreg; \
  632. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  633. /* Delay after an RCC peripheral clock enabling */\
  634. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
  635. UNUSED(tmpreg); \
  636. } while(0U)
  637. #define __HAL_RCC_TIM3_CLK_ENABLE() do { \
  638. __IO uint32_t tmpreg; \
  639. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  640. /* Delay after an RCC peripheral clock enabling */\
  641. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
  642. UNUSED(tmpreg); \
  643. } while(0U)
  644. #define __HAL_RCC_TIM4_CLK_ENABLE() do { \
  645. __IO uint32_t tmpreg; \
  646. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  647. /* Delay after an RCC peripheral clock enabling */\
  648. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM4EN);\
  649. UNUSED(tmpreg); \
  650. } while(0U)
  651. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  652. __IO uint32_t tmpreg; \
  653. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  654. /* Delay after an RCC peripheral clock enabling */\
  655. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  656. UNUSED(tmpreg); \
  657. } while(0U)
  658. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  659. __IO uint32_t tmpreg; \
  660. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  661. /* Delay after an RCC peripheral clock enabling */\
  662. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  663. UNUSED(tmpreg); \
  664. } while(0U)
  665. #define __HAL_RCC_WWDG_CLK_ENABLE() do { \
  666. __IO uint32_t tmpreg; \
  667. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
  668. /* Delay after an RCC peripheral clock enabling */\
  669. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
  670. UNUSED(tmpreg); \
  671. } while(0U)
  672. #define __HAL_RCC_SPI2_CLK_ENABLE() do { \
  673. __IO uint32_t tmpreg; \
  674. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  675. /* Delay after an RCC peripheral clock enabling */\
  676. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
  677. UNUSED(tmpreg); \
  678. } while(0U)
  679. #define __HAL_RCC_USART2_CLK_ENABLE() do { \
  680. __IO uint32_t tmpreg; \
  681. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
  682. /* Delay after an RCC peripheral clock enabling */\
  683. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
  684. UNUSED(tmpreg); \
  685. } while(0U)
  686. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  687. __IO uint32_t tmpreg; \
  688. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  689. /* Delay after an RCC peripheral clock enabling */\
  690. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  691. UNUSED(tmpreg); \
  692. } while(0U)
  693. #define __HAL_RCC_I2C1_CLK_ENABLE() do { \
  694. __IO uint32_t tmpreg; \
  695. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
  696. /* Delay after an RCC peripheral clock enabling */\
  697. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
  698. UNUSED(tmpreg); \
  699. } while(0U)
  700. #define __HAL_RCC_I2C2_CLK_ENABLE() do { \
  701. __IO uint32_t tmpreg; \
  702. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  703. /* Delay after an RCC peripheral clock enabling */\
  704. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
  705. UNUSED(tmpreg); \
  706. } while(0U)
  707. #define __HAL_RCC_USB_CLK_ENABLE() do { \
  708. __IO uint32_t tmpreg; \
  709. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USBEN);\
  710. /* Delay after an RCC peripheral clock enabling */\
  711. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USBEN);\
  712. UNUSED(tmpreg); \
  713. } while(0U)
  714. #define __HAL_RCC_PWR_CLK_ENABLE() do { \
  715. __IO uint32_t tmpreg; \
  716. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
  717. /* Delay after an RCC peripheral clock enabling */\
  718. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
  719. UNUSED(tmpreg); \
  720. } while(0U)
  721. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  722. __IO uint32_t tmpreg; \
  723. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  724. /* Delay after an RCC peripheral clock enabling */\
  725. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  726. UNUSED(tmpreg); \
  727. } while(0U)
  728. #define __HAL_RCC_COMP_CLK_ENABLE() do { \
  729. __IO uint32_t tmpreg; \
  730. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_COMPEN);\
  731. /* Delay after an RCC peripheral clock enabling */\
  732. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_COMPEN);\
  733. UNUSED(tmpreg); \
  734. } while(0U)
  735. #define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
  736. #define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
  737. #define __HAL_RCC_TIM4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
  738. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  739. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  740. #define __HAL_RCC_WWDG_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_WWDGEN))
  741. #define __HAL_RCC_SPI2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI2EN))
  742. #define __HAL_RCC_USART2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART2EN))
  743. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  744. #define __HAL_RCC_I2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C1EN))
  745. #define __HAL_RCC_I2C2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN))
  746. #define __HAL_RCC_USB_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USBEN))
  747. #define __HAL_RCC_PWR_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN))
  748. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  749. #define __HAL_RCC_COMP_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_COMPEN))
  750. /**
  751. * @}
  752. */
  753. /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Clock Enable Disable
  754. * @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  755. * @note After reset, the peripheral clock (used for registers read/write access)
  756. * is disabled and the application software has to enable this clock before
  757. * using it.
  758. * @{
  759. */
  760. #define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
  761. __IO uint32_t tmpreg; \
  762. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
  763. /* Delay after an RCC peripheral clock enabling */\
  764. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
  765. UNUSED(tmpreg); \
  766. } while(0U)
  767. #define __HAL_RCC_TIM9_CLK_ENABLE() do { \
  768. __IO uint32_t tmpreg; \
  769. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
  770. /* Delay after an RCC peripheral clock enabling */\
  771. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
  772. UNUSED(tmpreg); \
  773. } while(0U)
  774. #define __HAL_RCC_TIM10_CLK_ENABLE() do { \
  775. __IO uint32_t tmpreg; \
  776. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  777. /* Delay after an RCC peripheral clock enabling */\
  778. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM10EN);\
  779. UNUSED(tmpreg); \
  780. } while(0U)
  781. #define __HAL_RCC_TIM11_CLK_ENABLE() do { \
  782. __IO uint32_t tmpreg; \
  783. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
  784. /* Delay after an RCC peripheral clock enabling */\
  785. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
  786. UNUSED(tmpreg); \
  787. } while(0U)
  788. #define __HAL_RCC_ADC1_CLK_ENABLE() do { \
  789. __IO uint32_t tmpreg; \
  790. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
  791. /* Delay after an RCC peripheral clock enabling */\
  792. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
  793. UNUSED(tmpreg); \
  794. } while(0U)
  795. #define __HAL_RCC_SPI1_CLK_ENABLE() do { \
  796. __IO uint32_t tmpreg; \
  797. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
  798. /* Delay after an RCC peripheral clock enabling */\
  799. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
  800. UNUSED(tmpreg); \
  801. } while(0U)
  802. #define __HAL_RCC_USART1_CLK_ENABLE() do { \
  803. __IO uint32_t tmpreg; \
  804. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
  805. /* Delay after an RCC peripheral clock enabling */\
  806. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
  807. UNUSED(tmpreg); \
  808. } while(0U)
  809. #define __HAL_RCC_SYSCFG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SYSCFGEN))
  810. #define __HAL_RCC_TIM9_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM9EN))
  811. #define __HAL_RCC_TIM10_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM10EN))
  812. #define __HAL_RCC_TIM11_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM11EN))
  813. #define __HAL_RCC_ADC1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC1EN))
  814. #define __HAL_RCC_SPI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI1EN))
  815. #define __HAL_RCC_USART1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
  816. /**
  817. * @}
  818. */
  819. /** @defgroup RCC_Peripheral_Clock_Force_Release RCC Peripheral Clock Force Release
  820. * @brief Force or release AHB peripheral reset.
  821. * @{
  822. */
  823. #define __HAL_RCC_AHB_FORCE_RESET() (RCC->AHBRSTR = 0xFFFFFFFFU)
  824. #define __HAL_RCC_GPIOA_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIOARST))
  825. #define __HAL_RCC_GPIOB_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIOBRST))
  826. #define __HAL_RCC_GPIOC_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIOCRST))
  827. #define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIODRST))
  828. #define __HAL_RCC_GPIOH_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_GPIOHRST))
  829. #define __HAL_RCC_CRC_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_CRCRST))
  830. #define __HAL_RCC_FLITF_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_FLITFRST))
  831. #define __HAL_RCC_DMA1_FORCE_RESET() (RCC->AHBRSTR |= (RCC_AHBRSTR_DMA1RST))
  832. #define __HAL_RCC_AHB_RELEASE_RESET() (RCC->AHBRSTR = 0x00000000U)
  833. #define __HAL_RCC_GPIOA_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIOARST))
  834. #define __HAL_RCC_GPIOB_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIOBRST))
  835. #define __HAL_RCC_GPIOC_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIOCRST))
  836. #define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIODRST))
  837. #define __HAL_RCC_GPIOH_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_GPIOHRST))
  838. #define __HAL_RCC_CRC_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_CRCRST))
  839. #define __HAL_RCC_FLITF_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_FLITFRST))
  840. #define __HAL_RCC_DMA1_RELEASE_RESET() (RCC->AHBRSTR &= ~(RCC_AHBRSTR_DMA1RST))
  841. /**
  842. * @}
  843. */
  844. /** @defgroup RCC_APB1_Force_Release_Reset APB1 Force Release Reset
  845. * @brief Force or release APB1 peripheral reset.
  846. * @{
  847. */
  848. #define __HAL_RCC_APB1_FORCE_RESET() (RCC->APB1RSTR = 0xFFFFFFFFU)
  849. #define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
  850. #define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
  851. #define __HAL_RCC_TIM4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM4RST))
  852. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  853. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  854. #define __HAL_RCC_WWDG_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
  855. #define __HAL_RCC_SPI2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
  856. #define __HAL_RCC_USART2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
  857. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  858. #define __HAL_RCC_I2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
  859. #define __HAL_RCC_I2C2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
  860. #define __HAL_RCC_USB_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USBRST))
  861. #define __HAL_RCC_PWR_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
  862. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  863. #define __HAL_RCC_COMP_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_COMPRST))
  864. #define __HAL_RCC_APB1_RELEASE_RESET() (RCC->APB1RSTR = 0x00000000U)
  865. #define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
  866. #define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
  867. #define __HAL_RCC_TIM4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM4RST))
  868. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  869. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  870. #define __HAL_RCC_WWDG_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
  871. #define __HAL_RCC_SPI2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI2RST))
  872. #define __HAL_RCC_USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
  873. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  874. #define __HAL_RCC_I2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C1RST))
  875. #define __HAL_RCC_I2C2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C2RST))
  876. #define __HAL_RCC_USB_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USBRST))
  877. #define __HAL_RCC_PWR_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_PWRRST))
  878. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  879. #define __HAL_RCC_COMP_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_COMPRST))
  880. /**
  881. * @}
  882. */
  883. /** @defgroup RCC_APB2_Force_Release_Reset APB2 Force Release Reset
  884. * @brief Force or release APB1 peripheral reset.
  885. * @{
  886. */
  887. #define __HAL_RCC_APB2_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFFU)
  888. #define __HAL_RCC_SYSCFG_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SYSCFGRST))
  889. #define __HAL_RCC_TIM9_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM9RST))
  890. #define __HAL_RCC_TIM10_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM10RST))
  891. #define __HAL_RCC_TIM11_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM11RST))
  892. #define __HAL_RCC_ADC1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_ADC1RST))
  893. #define __HAL_RCC_SPI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
  894. #define __HAL_RCC_USART1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
  895. #define __HAL_RCC_APB2_RELEASE_RESET() (RCC->APB2RSTR = 0x00000000U)
  896. #define __HAL_RCC_SYSCFG_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SYSCFGRST))
  897. #define __HAL_RCC_TIM9_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM9RST))
  898. #define __HAL_RCC_TIM10_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM10RST))
  899. #define __HAL_RCC_TIM11_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM11RST))
  900. #define __HAL_RCC_ADC1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_ADC1RST))
  901. #define __HAL_RCC_SPI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI1RST))
  902. #define __HAL_RCC_USART1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART1RST))
  903. /**
  904. * @}
  905. */
  906. /** @defgroup RCC_Peripheral_Clock_Sleep_Enable_Disable RCC Peripheral Clock Sleep Enable Disable
  907. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  908. * power consumption.
  909. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  910. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  911. * @{
  912. */
  913. #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_GPIOALPEN))
  914. #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_GPIOBLPEN))
  915. #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_GPIOCLPEN))
  916. #define __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_GPIODLPEN))
  917. #define __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_GPIOHLPEN))
  918. #define __HAL_RCC_CRC_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_CRCLPEN))
  919. #define __HAL_RCC_FLITF_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_FLITFLPEN))
  920. #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE() (RCC->AHBLPENR |= (RCC_AHBLPENR_DMA1LPEN))
  921. #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_GPIOALPEN))
  922. #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_GPIOBLPEN))
  923. #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_GPIOCLPEN))
  924. #define __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_GPIODLPEN))
  925. #define __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_GPIOHLPEN))
  926. #define __HAL_RCC_CRC_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_CRCLPEN))
  927. #define __HAL_RCC_FLITF_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_FLITFLPEN))
  928. #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE() (RCC->AHBLPENR &= ~(RCC_AHBLPENR_DMA1LPEN))
  929. /** @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  930. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  931. * power consumption.
  932. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  933. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  934. */
  935. #define __HAL_RCC_TIM2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM2LPEN))
  936. #define __HAL_RCC_TIM3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM3LPEN))
  937. #define __HAL_RCC_TIM4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM4LPEN))
  938. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  939. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  940. #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_WWDGLPEN))
  941. #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI2LPEN))
  942. #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART2LPEN))
  943. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  944. #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C1LPEN))
  945. #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C2LPEN))
  946. #define __HAL_RCC_USB_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USBLPEN))
  947. #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_PWRLPEN))
  948. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  949. #define __HAL_RCC_COMP_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_COMPLPEN))
  950. #define __HAL_RCC_TIM2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM2LPEN))
  951. #define __HAL_RCC_TIM3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM3LPEN))
  952. #define __HAL_RCC_TIM4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM4LPEN))
  953. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  954. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  955. #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_WWDGLPEN))
  956. #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI2LPEN))
  957. #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART2LPEN))
  958. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  959. #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C1LPEN))
  960. #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C2LPEN))
  961. #define __HAL_RCC_USB_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USBLPEN))
  962. #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_PWRLPEN))
  963. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  964. #define __HAL_RCC_COMP_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_COMPLPEN))
  965. /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  966. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  967. * power consumption.
  968. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  969. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  970. */
  971. #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SYSCFGLPEN))
  972. #define __HAL_RCC_TIM9_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM9LPEN))
  973. #define __HAL_RCC_TIM10_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM10LPEN))
  974. #define __HAL_RCC_TIM11_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM11LPEN))
  975. #define __HAL_RCC_ADC1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC1LPEN))
  976. #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI1LPEN))
  977. #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_USART1LPEN))
  978. #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SYSCFGLPEN))
  979. #define __HAL_RCC_TIM9_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM9LPEN))
  980. #define __HAL_RCC_TIM10_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM10LPEN))
  981. #define __HAL_RCC_TIM11_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM11LPEN))
  982. #define __HAL_RCC_ADC1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC1LPEN))
  983. #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI1LPEN))
  984. #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_USART1LPEN))
  985. /**
  986. * @}
  987. */
  988. /** @defgroup RCC_AHB_Peripheral_Clock_Enable_Disable_Status AHB Peripheral Clock Enable Disable Status
  989. * @brief Get the enable or disable status of the AHB peripheral clock.
  990. * @note After reset, the peripheral clock (used for registers read/write access)
  991. * is disabled and the application software has to enable this clock before
  992. * using it.
  993. * @{
  994. */
  995. #define __HAL_RCC_GPIOA_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOAEN)) != RESET)
  996. #define __HAL_RCC_GPIOB_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOBEN)) != RESET)
  997. #define __HAL_RCC_GPIOC_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOCEN)) != RESET)
  998. #define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIODEN)) != RESET)
  999. #define __HAL_RCC_GPIOH_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOHEN)) != RESET)
  1000. #define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_CRCEN)) != RESET)
  1001. #define __HAL_RCC_FLITF_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_FLITFEN)) != RESET)
  1002. #define __HAL_RCC_DMA1_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA1EN)) != RESET)
  1003. #define __HAL_RCC_GPIOA_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOAEN)) == RESET)
  1004. #define __HAL_RCC_GPIOB_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOBEN)) == RESET)
  1005. #define __HAL_RCC_GPIOC_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOCEN)) == RESET)
  1006. #define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIODEN)) == RESET)
  1007. #define __HAL_RCC_GPIOH_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_GPIOHEN)) == RESET)
  1008. #define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_CRCEN)) == RESET)
  1009. #define __HAL_RCC_FLITF_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_FLITFEN)) == RESET)
  1010. #define __HAL_RCC_DMA1_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA1EN)) == RESET)
  1011. /**
  1012. * @}
  1013. */
  1014. /** @defgroup RCC_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
  1015. * @brief Get the enable or disable status of the APB1 peripheral clock.
  1016. * @note After reset, the peripheral clock (used for registers read/write access)
  1017. * is disabled and the application software has to enable this clock before
  1018. * using it.
  1019. * @{
  1020. */
  1021. #define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
  1022. #define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
  1023. #define __HAL_RCC_TIM4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) != RESET)
  1024. #define __HAL_RCC_TIM6_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) != RESET)
  1025. #define __HAL_RCC_TIM7_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) != RESET)
  1026. #define __HAL_RCC_WWDG_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) != RESET)
  1027. #define __HAL_RCC_SPI2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) != RESET)
  1028. #define __HAL_RCC_USART2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) != RESET)
  1029. #define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
  1030. #define __HAL_RCC_I2C1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C1EN)) != RESET)
  1031. #define __HAL_RCC_I2C2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) != RESET)
  1032. #define __HAL_RCC_USB_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USBEN)) != RESET)
  1033. #define __HAL_RCC_PWR_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) != RESET)
  1034. #define __HAL_RCC_DAC_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) != RESET)
  1035. #define __HAL_RCC_COMP_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_COMPEN)) != RESET)
  1036. #define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
  1037. #define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
  1038. #define __HAL_RCC_TIM4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM4EN)) == RESET)
  1039. #define __HAL_RCC_TIM6_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM6EN)) == RESET)
  1040. #define __HAL_RCC_TIM7_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM7EN)) == RESET)
  1041. #define __HAL_RCC_WWDG_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) == RESET)
  1042. #define __HAL_RCC_SPI2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) == RESET)
  1043. #define __HAL_RCC_USART2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) == RESET)
  1044. #define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
  1045. #define __HAL_RCC_I2C1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C1EN)) == RESET)
  1046. #define __HAL_RCC_I2C2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) == RESET)
  1047. #define __HAL_RCC_USB_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USBEN)) == RESET)
  1048. #define __HAL_RCC_PWR_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) == RESET)
  1049. #define __HAL_RCC_DAC_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_DACEN)) == RESET)
  1050. #define __HAL_RCC_COMP_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_COMPEN)) == RESET)
  1051. /**
  1052. * @}
  1053. */
  1054. /** @defgroup RCC_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
  1055. * @brief Get the enable or disable status of the APB2 peripheral clock.
  1056. * @note After reset, the peripheral clock (used for registers read/write access)
  1057. * is disabled and the application software has to enable this clock before
  1058. * using it.
  1059. * @{
  1060. */
  1061. #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SYSCFGEN)) != RESET)
  1062. #define __HAL_RCC_TIM9_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM9EN)) != RESET)
  1063. #define __HAL_RCC_TIM10_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) != RESET)
  1064. #define __HAL_RCC_TIM11_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM11EN)) != RESET)
  1065. #define __HAL_RCC_ADC1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC1EN)) != RESET)
  1066. #define __HAL_RCC_SPI1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI1EN)) != RESET)
  1067. #define __HAL_RCC_USART1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART1EN)) != RESET)
  1068. #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SYSCFGEN)) == RESET)
  1069. #define __HAL_RCC_TIM9_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM9EN)) == RESET)
  1070. #define __HAL_RCC_TIM10_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM10EN)) == RESET)
  1071. #define __HAL_RCC_TIM11_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM11EN)) == RESET)
  1072. #define __HAL_RCC_ADC1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC1EN)) == RESET)
  1073. #define __HAL_RCC_SPI1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI1EN)) == RESET)
  1074. #define __HAL_RCC_USART1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART1EN)) == RESET)
  1075. /**
  1076. * @}
  1077. */
  1078. /** @defgroup RCC_AHB_Clock_Sleep_Enable_Disable_Status AHB Peripheral Clock Sleep Enable Disable Status
  1079. * @brief Get the enable or disable status of the AHB peripheral clock during Low Power (Sleep) mode.
  1080. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1081. * power consumption.
  1082. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1083. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1084. * @{
  1085. */
  1086. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOALPEN)) != RESET)
  1087. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOBLPEN)) != RESET)
  1088. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOCLPEN)) != RESET)
  1089. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIODLPEN)) != RESET)
  1090. #define __HAL_RCC_GPIOH_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOHLPEN)) != RESET)
  1091. #define __HAL_RCC_CRC_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_CRCLPEN)) != RESET)
  1092. #define __HAL_RCC_FLITF_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_FLITFLPEN)) != RESET)
  1093. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_ENABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_DMA1LPEN)) != RESET)
  1094. #define __HAL_RCC_GPIOA_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOALPEN)) == RESET)
  1095. #define __HAL_RCC_GPIOB_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOBLPEN)) == RESET)
  1096. #define __HAL_RCC_GPIOC_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOCLPEN)) == RESET)
  1097. #define __HAL_RCC_GPIOD_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIODLPEN)) == RESET)
  1098. #define __HAL_RCC_GPIOH_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_GPIOHLPEN)) == RESET)
  1099. #define __HAL_RCC_CRC_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_CRCLPEN)) == RESET)
  1100. #define __HAL_RCC_FLITF_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_FLITFLPEN)) == RESET)
  1101. #define __HAL_RCC_DMA1_IS_CLK_SLEEP_DISABLED() ((RCC->AHBLPENR & (RCC_AHBLPENR_DMA1LPEN)) == RESET)
  1102. /**
  1103. * @}
  1104. */
  1105. /** @defgroup RCC_APB1_Clock_Sleep_Enable_Disable_Status APB1 Peripheral Clock Sleep Enable Disable Status
  1106. * @brief Get the enable or disable status of the APB1 peripheral clock during Low Power (Sleep) mode.
  1107. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1108. * power consumption.
  1109. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1110. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1111. * @{
  1112. */
  1113. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM2LPEN)) != RESET)
  1114. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM3LPEN)) != RESET)
  1115. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM4LPEN)) != RESET)
  1116. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM6LPEN)) != RESET)
  1117. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM7LPEN)) != RESET)
  1118. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_WWDGLPEN)) != RESET)
  1119. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_SPI2LPEN)) != RESET)
  1120. #define __HAL_RCC_USART2_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_USART2LPEN)) != RESET)
  1121. #define __HAL_RCC_USART3_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_USART3LPEN)) != RESET)
  1122. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_I2C1LPEN)) != RESET)
  1123. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_I2C2LPEN)) != RESET)
  1124. #define __HAL_RCC_USB_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_USBLPEN)) != RESET)
  1125. #define __HAL_RCC_PWR_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_PWRLPEN)) != RESET)
  1126. #define __HAL_RCC_DAC_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_DACLPEN)) != RESET)
  1127. #define __HAL_RCC_COMP_IS_CLK_SLEEP_ENABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_COMPLPEN)) != RESET)
  1128. #define __HAL_RCC_TIM2_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM2LPEN)) == RESET)
  1129. #define __HAL_RCC_TIM3_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM3LPEN)) == RESET)
  1130. #define __HAL_RCC_TIM4_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM4LPEN)) == RESET)
  1131. #define __HAL_RCC_TIM6_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM6LPEN)) == RESET)
  1132. #define __HAL_RCC_TIM7_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_TIM7LPEN)) == RESET)
  1133. #define __HAL_RCC_WWDG_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_WWDGLPEN)) == RESET)
  1134. #define __HAL_RCC_SPI2_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_SPI2LPEN)) == RESET)
  1135. #define __HAL_RCC_USART2_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_USART2LPEN)) == RESET)
  1136. #define __HAL_RCC_USART3_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_USART3LPEN)) == RESET)
  1137. #define __HAL_RCC_I2C1_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_I2C1LPEN)) == RESET)
  1138. #define __HAL_RCC_I2C2_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_I2C2LPEN)) == RESET)
  1139. #define __HAL_RCC_USB_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_USBLPEN)) == RESET)
  1140. #define __HAL_RCC_PWR_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_PWRLPEN)) == RESET)
  1141. #define __HAL_RCC_DAC_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_DACLPEN)) == RESET)
  1142. #define __HAL_RCC_COMP_IS_CLK_SLEEP_DISABLED() ((RCC->APB1LPENR & (RCC_APB1LPENR_COMPLPEN)) == RESET)
  1143. /**
  1144. * @}
  1145. */
  1146. /** @defgroup RCC_APB2_Clock_Sleep_Enable_Disable_Status APB2 Peripheral Clock Sleep Enable Disable Status
  1147. * @brief Get the enable or disable status of the APB2 peripheral clock during Low Power (Sleep) mode.
  1148. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1149. * power consumption.
  1150. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1151. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1152. * @{
  1153. */
  1154. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_SYSCFGLPEN)) != RESET)
  1155. #define __HAL_RCC_TIM9_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_TIM9LPEN)) != RESET)
  1156. #define __HAL_RCC_TIM10_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_TIM10LPEN)) != RESET)
  1157. #define __HAL_RCC_TIM11_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_TIM11LPEN)) != RESET)
  1158. #define __HAL_RCC_ADC1_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_ADC1LPEN)) != RESET)
  1159. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_SPI1LPEN)) != RESET)
  1160. #define __HAL_RCC_USART1_IS_CLK_SLEEP_ENABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_USART1LPEN)) != RESET)
  1161. #define __HAL_RCC_SYSCFG_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_SYSCFGLPEN)) == RESET)
  1162. #define __HAL_RCC_TIM9_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_TIM9LPEN)) == RESET)
  1163. #define __HAL_RCC_TIM10_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_TIM10LPEN)) == RESET)
  1164. #define __HAL_RCC_TIM11_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_TIM11LPEN)) == RESET)
  1165. #define __HAL_RCC_ADC1_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_ADC1LPEN)) == RESET)
  1166. #define __HAL_RCC_SPI1_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_SPI1LPEN)) == RESET)
  1167. #define __HAL_RCC_USART1_IS_CLK_SLEEP_DISABLED() ((RCC->APB2LPENR & (RCC_APB2LPENR_USART1LPEN)) == RESET)
  1168. /**
  1169. * @}
  1170. */
  1171. /** @defgroup RCC_HSI_Configuration HSI Configuration
  1172. * @{
  1173. */
  1174. /** @brief Macros to enable or disable the Internal High Speed oscillator (HSI).
  1175. * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
  1176. * @note HSI can not be stopped if it is used as system clock source. In this case,
  1177. * you have to select another source of the system clock then stop the HSI.
  1178. * @note After enabling the HSI, the application software should wait on HSIRDY
  1179. * flag to be set indicating that HSI clock is stable and can be used as
  1180. * system clock source.
  1181. * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
  1182. * clock cycles.
  1183. */
  1184. #define __HAL_RCC_HSI_ENABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = ENABLE)
  1185. #define __HAL_RCC_HSI_DISABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = DISABLE)
  1186. /** @brief Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
  1187. * @note The calibration is used to compensate for the variations in voltage
  1188. * and temperature that influence the frequency of the internal HSI RC.
  1189. * @param _HSICALIBRATIONVALUE_ specifies the calibration trimming value.
  1190. * (default is RCC_HSICALIBRATION_DEFAULT).
  1191. * This parameter must be a number between 0 and 0x1F.
  1192. */
  1193. #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(_HSICALIBRATIONVALUE_) \
  1194. (MODIFY_REG(RCC->ICSCR, RCC_ICSCR_HSITRIM, (uint32_t)(_HSICALIBRATIONVALUE_) << POSITION_VAL(RCC_ICSCR_HSITRIM)))
  1195. /**
  1196. * @}
  1197. */
  1198. /** @defgroup RCC_LSI_Configuration LSI Configuration
  1199. * @{
  1200. */
  1201. /** @brief Macro to enable the Internal Low Speed oscillator (LSI).
  1202. * @note After enabling the LSI, the application software should wait on
  1203. * LSIRDY flag to be set indicating that LSI clock is stable and can
  1204. * be used to clock the IWDG and/or the RTC.
  1205. */
  1206. #define __HAL_RCC_LSI_ENABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = ENABLE)
  1207. /** @brief Macro to disable the Internal Low Speed oscillator (LSI).
  1208. * @note LSI can not be disabled if the IWDG is running.
  1209. * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
  1210. * clock cycles.
  1211. */
  1212. #define __HAL_RCC_LSI_DISABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = DISABLE)
  1213. /**
  1214. * @}
  1215. */
  1216. /** @defgroup RCC_HSE_Configuration HSE Configuration
  1217. * @{
  1218. */
  1219. /**
  1220. * @brief Macro to configure the External High Speed oscillator (HSE).
  1221. * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
  1222. * supported by this macro. User should request a transition to HSE Off
  1223. * first and then HSE On or HSE Bypass.
  1224. * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
  1225. * software should wait on HSERDY flag to be set indicating that HSE clock
  1226. * is stable and can be used to clock the PLL and/or system clock.
  1227. * @note HSE state can not be changed if it is used directly or through the
  1228. * PLL as system clock. In this case, you have to select another source
  1229. * of the system clock then change the HSE state (ex. disable it).
  1230. * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
  1231. * @note This function reset the CSSON bit, so if the clock security system(CSS)
  1232. * was previously enabled you have to enable it again after calling this
  1233. * function.
  1234. * @param __STATE__ specifies the new state of the HSE.
  1235. * This parameter can be one of the following values:
  1236. * @arg @ref RCC_HSE_OFF turn OFF the HSE oscillator, HSERDY flag goes low after
  1237. * 6 HSE oscillator clock cycles.
  1238. * @arg @ref RCC_HSE_ON turn ON the HSE oscillator
  1239. * @arg @ref RCC_HSE_BYPASS HSE oscillator bypassed with external clock
  1240. */
  1241. #define __HAL_RCC_HSE_CONFIG(__STATE__) \
  1242. do{ \
  1243. if ((__STATE__) == RCC_HSE_ON) \
  1244. { \
  1245. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  1246. } \
  1247. else if ((__STATE__) == RCC_HSE_OFF) \
  1248. { \
  1249. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  1250. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  1251. } \
  1252. else if ((__STATE__) == RCC_HSE_BYPASS) \
  1253. { \
  1254. SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
  1255. SET_BIT(RCC->CR, RCC_CR_HSEON); \
  1256. } \
  1257. else \
  1258. { \
  1259. CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
  1260. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
  1261. } \
  1262. }while(0U)
  1263. /**
  1264. * @}
  1265. */
  1266. /** @defgroup RCC_LSE_Configuration LSE Configuration
  1267. * @{
  1268. */
  1269. /**
  1270. * @brief Macro to configure the External Low Speed oscillator (LSE).
  1271. * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro.
  1272. * @note As the LSE is in the Backup domain and write access is denied to
  1273. * this domain after reset, you have to enable write access using
  1274. * @ref HAL_PWR_EnableBkUpAccess() function before to configure the LSE
  1275. * (to be done once after reset).
  1276. * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
  1277. * software should wait on LSERDY flag to be set indicating that LSE clock
  1278. * is stable and can be used to clock the RTC.
  1279. * @param __STATE__ specifies the new state of the LSE.
  1280. * This parameter can be one of the following values:
  1281. * @arg @ref RCC_LSE_OFF turn OFF the LSE oscillator, LSERDY flag goes low after
  1282. * 6 LSE oscillator clock cycles.
  1283. * @arg @ref RCC_LSE_ON turn ON the LSE oscillator.
  1284. * @arg @ref RCC_LSE_BYPASS LSE oscillator bypassed with external clock.
  1285. */
  1286. #define __HAL_RCC_LSE_CONFIG(__STATE__) \
  1287. do{ \
  1288. if ((__STATE__) == RCC_LSE_ON) \
  1289. { \
  1290. SET_BIT(RCC->CSR, RCC_CSR_LSEON); \
  1291. } \
  1292. else if ((__STATE__) == RCC_LSE_OFF) \
  1293. { \
  1294. CLEAR_BIT(RCC->CSR, RCC_CSR_LSEON); \
  1295. CLEAR_BIT(RCC->CSR, RCC_CSR_LSEBYP); \
  1296. } \
  1297. else if ((__STATE__) == RCC_LSE_BYPASS) \
  1298. { \
  1299. SET_BIT(RCC->CSR, RCC_CSR_LSEBYP); \
  1300. SET_BIT(RCC->CSR, RCC_CSR_LSEON); \
  1301. } \
  1302. else \
  1303. { \
  1304. CLEAR_BIT(RCC->CSR, RCC_CSR_LSEON); \
  1305. CLEAR_BIT(RCC->CSR, RCC_CSR_LSEBYP); \
  1306. } \
  1307. }while(0U)
  1308. /**
  1309. * @}
  1310. */
  1311. /** @defgroup RCC_MSI_Configuration MSI Configuration
  1312. * @{
  1313. */
  1314. /** @brief Macro to enable Internal Multi Speed oscillator (MSI).
  1315. * @note After enabling the MSI, the application software should wait on MSIRDY
  1316. * flag to be set indicating that MSI clock is stable and can be used as
  1317. * system clock source.
  1318. */
  1319. #define __HAL_RCC_MSI_ENABLE() (*(__IO uint32_t *) RCC_CR_MSION_BB = ENABLE)
  1320. /** @brief Macro to disable the Internal Multi Speed oscillator (MSI).
  1321. * @note The MSI is stopped by hardware when entering STOP and STANDBY modes.
  1322. * It is used (enabled by hardware) as system clock source after startup
  1323. * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
  1324. * of the HSE used directly or indirectly as system clock (if the Clock
  1325. * Security System CSS is enabled).
  1326. * @note MSI can not be stopped if it is used as system clock source. In this case,
  1327. * you have to select another source of the system clock then stop the MSI.
  1328. * @note When the MSI is stopped, MSIRDY flag goes low after 6 MSI oscillator
  1329. * clock cycles.
  1330. */
  1331. #define __HAL_RCC_MSI_DISABLE() (*(__IO uint32_t *) RCC_CR_MSION_BB = DISABLE)
  1332. /** @brief Macro adjusts Internal Multi Speed oscillator (MSI) calibration value.
  1333. * @note The calibration is used to compensate for the variations in voltage
  1334. * and temperature that influence the frequency of the internal MSI RC.
  1335. * @param _MSICALIBRATIONVALUE_ specifies the calibration trimming value.
  1336. * (default is RCC_MSICALIBRATION_DEFAULT).
  1337. * This parameter must be a number between 0 and 0xFF.
  1338. */
  1339. #define __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(_MSICALIBRATIONVALUE_) \
  1340. (MODIFY_REG(RCC->ICSCR, RCC_ICSCR_MSITRIM, (uint32_t)(_MSICALIBRATIONVALUE_) << POSITION_VAL(RCC_ICSCR_MSITRIM)))
  1341. /* @brief Macro to configures the Internal Multi Speed oscillator (MSI) clock range.
  1342. * @note After restart from Reset or wakeup from STANDBY, the MSI clock is
  1343. * around 2.097 MHz. The MSI clock does not change after wake-up from
  1344. * STOP mode.
  1345. * @note The MSI clock range can be modified on the fly.
  1346. * @param _MSIRANGEVALUE_ specifies the MSI Clock range.
  1347. * This parameter must be one of the following values:
  1348. * @arg @ref RCC_MSIRANGE_0 MSI clock is around 65.536 KHz
  1349. * @arg @ref RCC_MSIRANGE_1 MSI clock is around 131.072 KHz
  1350. * @arg @ref RCC_MSIRANGE_2 MSI clock is around 262.144 KHz
  1351. * @arg @ref RCC_MSIRANGE_3 MSI clock is around 524.288 KHz
  1352. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1.048 MHz
  1353. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2.097 MHz (default after Reset or wake-up from STANDBY)
  1354. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4.194 MHz
  1355. */
  1356. #define __HAL_RCC_MSI_RANGE_CONFIG(_MSIRANGEVALUE_) (MODIFY_REG(RCC->ICSCR, \
  1357. RCC_ICSCR_MSIRANGE, (uint32_t)(_MSIRANGEVALUE_)))
  1358. /** @brief Macro to get the Internal Multi Speed oscillator (MSI) clock range in run mode
  1359. * @retval MSI clock range.
  1360. * This parameter must be one of the following values:
  1361. * @arg @ref RCC_MSIRANGE_0 MSI clock is around 65.536 KHz
  1362. * @arg @ref RCC_MSIRANGE_1 MSI clock is around 131.072 KHz
  1363. * @arg @ref RCC_MSIRANGE_2 MSI clock is around 262.144 KHz
  1364. * @arg @ref RCC_MSIRANGE_3 MSI clock is around 524.288 KHz
  1365. * @arg @ref RCC_MSIRANGE_4 MSI clock is around 1.048 MHz
  1366. * @arg @ref RCC_MSIRANGE_5 MSI clock is around 2.097 MHz (default after Reset or wake-up from STANDBY)
  1367. * @arg @ref RCC_MSIRANGE_6 MSI clock is around 4.194 MHz
  1368. */
  1369. #define __HAL_RCC_GET_MSI_RANGE() (uint32_t)(READ_BIT(RCC->ICSCR, RCC_ICSCR_MSIRANGE))
  1370. /**
  1371. * @}
  1372. */
  1373. /** @defgroup RCC_PLL_Configuration PLL Configuration
  1374. * @{
  1375. */
  1376. /** @brief Macro to enable the main PLL.
  1377. * @note After enabling the main PLL, the application software should wait on
  1378. * PLLRDY flag to be set indicating that PLL clock is stable and can
  1379. * be used as system clock source.
  1380. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  1381. */
  1382. #define __HAL_RCC_PLL_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
  1383. /** @brief Macro to disable the main PLL.
  1384. * @note The main PLL can not be disabled if it is used as system clock source
  1385. */
  1386. #define __HAL_RCC_PLL_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = DISABLE)
  1387. /** @brief Macro to configure the main PLL clock source, multiplication and division factors.
  1388. * @note This function must be used only when the main PLL is disabled.
  1389. *
  1390. * @param __RCC_PLLSOURCE__ specifies the PLL entry clock source.
  1391. * This parameter can be one of the following values:
  1392. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
  1393. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
  1394. * @param __PLLMUL__ specifies the multiplication factor for PLL VCO output clock
  1395. * This parameter can be one of the following values:
  1396. * @arg @ref RCC_PLL_MUL3 PLLVCO = PLL clock entry x 3
  1397. * @arg @ref RCC_PLL_MUL4 PLLVCO = PLL clock entry x 4
  1398. * @arg @ref RCC_PLL_MUL6 PLLVCO = PLL clock entry x 6
  1399. * @arg @ref RCC_PLL_MUL8 PLLVCO = PLL clock entry x 8
  1400. * @arg @ref RCC_PLL_MUL12 PLLVCO = PLL clock entry x 12
  1401. * @arg @ref RCC_PLL_MUL16 PLLVCO = PLL clock entry x 16
  1402. * @arg @ref RCC_PLL_MUL24 PLLVCO = PLL clock entry x 24
  1403. * @arg @ref RCC_PLL_MUL32 PLLVCO = PLL clock entry x 32
  1404. * @arg @ref RCC_PLL_MUL48 PLLVCO = PLL clock entry x 48
  1405. * @note The PLL VCO clock frequency must not exceed 96 MHz when the product is in
  1406. * Range 1, 48 MHz when the product is in Range 2 and 24 MHz when the product is
  1407. * in Range 3.
  1408. *
  1409. * @param __PLLDIV__ specifies the division factor for PLL VCO input clock
  1410. * This parameter can be one of the following values:
  1411. * @arg @ref RCC_PLL_DIV2 PLL clock output = PLLVCO / 2
  1412. * @arg @ref RCC_PLL_DIV3 PLL clock output = PLLVCO / 3
  1413. * @arg @ref RCC_PLL_DIV4 PLL clock output = PLLVCO / 4
  1414. *
  1415. */
  1416. #define __HAL_RCC_PLL_CONFIG(__RCC_PLLSOURCE__, __PLLMUL__, __PLLDIV__)\
  1417. MODIFY_REG(RCC->CFGR, (RCC_CFGR_PLLSRC|RCC_CFGR_PLLMUL|RCC_CFGR_PLLDIV),((__RCC_PLLSOURCE__) | (__PLLMUL__) | (__PLLDIV__)))
  1418. /** @brief Get oscillator clock selected as PLL input clock
  1419. * @retval The clock source used for PLL entry. The returned value can be one
  1420. * of the following:
  1421. * @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL input clock
  1422. * @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL input clock
  1423. */
  1424. #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLSRC)))
  1425. /**
  1426. * @}
  1427. */
  1428. /** @defgroup RCC_Get_Clock_source Get Clock source
  1429. * @{
  1430. */
  1431. /**
  1432. * @brief Macro to configure the system clock source.
  1433. * @param __SYSCLKSOURCE__ specifies the system clock source.
  1434. * This parameter can be one of the following values:
  1435. * @arg @ref RCC_SYSCLKSOURCE_MSI MSI oscillator is used as system clock source.
  1436. * @arg @ref RCC_SYSCLKSOURCE_HSI HSI oscillator is used as system clock source.
  1437. * @arg @ref RCC_SYSCLKSOURCE_HSE HSE oscillator is used as system clock source.
  1438. * @arg @ref RCC_SYSCLKSOURCE_PLLCLK PLL output is used as system clock source.
  1439. */
  1440. #define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
  1441. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__SYSCLKSOURCE__))
  1442. /** @brief Macro to get the clock source used as system clock.
  1443. * @retval The clock source used as system clock. The returned value can be one
  1444. * of the following:
  1445. * @arg @ref RCC_SYSCLKSOURCE_STATUS_MSI MSI used as system clock
  1446. * @arg @ref RCC_SYSCLKSOURCE_STATUS_HSI HSI used as system clock
  1447. * @arg @ref RCC_SYSCLKSOURCE_STATUS_HSE HSE used as system clock
  1448. * @arg @ref RCC_SYSCLKSOURCE_STATUS_PLLCLK PLL used as system clock
  1449. */
  1450. #define __HAL_RCC_GET_SYSCLK_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR,RCC_CFGR_SWS)))
  1451. /**
  1452. * @}
  1453. */
  1454. /** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
  1455. * @{
  1456. */
  1457. /** @brief Macro to configure the MCO clock.
  1458. * @param __MCOCLKSOURCE__ specifies the MCO clock source.
  1459. * This parameter can be one of the following values:
  1460. * @arg @ref RCC_MCO1SOURCE_NOCLOCK No clock selected as MCO clock
  1461. * @arg @ref RCC_MCO1SOURCE_SYSCLK System Clock selected as MCO clock
  1462. * @arg @ref RCC_MCO1SOURCE_HSI HSI oscillator clock selected as MCO clock
  1463. * @arg @ref RCC_MCO1SOURCE_MSI MSI oscillator clock selected as MCO clock
  1464. * @arg @ref RCC_MCO1SOURCE_HSE HSE oscillator clock selected as MCO clock
  1465. * @arg @ref RCC_MCO1SOURCE_PLLCLK PLL clock selected as MCO clock
  1466. * @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO clock
  1467. * @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO clock
  1468. * @param __MCODIV__ specifies the MCO clock prescaler.
  1469. * This parameter can be one of the following values:
  1470. * @arg @ref RCC_MCODIV_1 MCO clock source is divided by 1
  1471. * @arg @ref RCC_MCODIV_2 MCO clock source is divided by 2
  1472. * @arg @ref RCC_MCODIV_4 MCO clock source is divided by 4
  1473. * @arg @ref RCC_MCODIV_8 MCO clock source is divided by 8
  1474. * @arg @ref RCC_MCODIV_16 MCO clock source is divided by 16
  1475. */
  1476. #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
  1477. MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
  1478. /**
  1479. * @}
  1480. */
  1481. /** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
  1482. * @{
  1483. */
  1484. /** @brief Macro to configure the RTC clock (RTCCLK).
  1485. * @note As the RTC clock configuration bits are in the Backup domain and write
  1486. * access is denied to this domain after reset, you have to enable write
  1487. * access using the Power Backup Access macro before to configure
  1488. * the RTC clock source (to be done once after reset).
  1489. * @note Once the RTC clock is configured it cannot be changed unless the
  1490. * Backup domain is reset using @ref __HAL_RCC_BACKUPRESET_FORCE() macro, or by
  1491. * a Power On Reset (POR).
  1492. * @note RTC prescaler cannot be modified if HSE is enabled (HSEON = 1).
  1493. *
  1494. * @param __RTC_CLKSOURCE__ specifies the RTC clock source.
  1495. * This parameter can be one of the following values:
  1496. * @arg @ref RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock
  1497. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock
  1498. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
  1499. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV2 HSE divided by 2 selected as RTC clock
  1500. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV4 HSE divided by 4 selected as RTC clock
  1501. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV8 HSE divided by 8 selected as RTC clock
  1502. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIV16 HSE divided by 16 selected as RTC clock
  1503. * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
  1504. * work in STOP and STANDBY modes, and can be used as wakeup source.
  1505. * However, when the HSE clock is used as RTC clock source, the RTC
  1506. * cannot be used in STOP and STANDBY modes.
  1507. * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
  1508. * RTC clock source).
  1509. */
  1510. #define __HAL_RCC_RTC_CLKPRESCALER(__RTC_CLKSOURCE__) do { \
  1511. if(((__RTC_CLKSOURCE__) & RCC_CSR_RTCSEL_HSE) == RCC_CSR_RTCSEL_HSE) \
  1512. { \
  1513. MODIFY_REG(RCC->CR, RCC_CR_RTCPRE, ((__RTC_CLKSOURCE__) & RCC_CR_RTCPRE)); \
  1514. } \
  1515. } while (0U)
  1516. #define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) do { \
  1517. __HAL_RCC_RTC_CLKPRESCALER(__RTC_CLKSOURCE__); \
  1518. RCC->CSR |= ((__RTC_CLKSOURCE__) & RCC_CSR_RTCSEL); \
  1519. } while (0U)
  1520. /** @brief Macro to get the RTC clock source.
  1521. * @retval The clock source can be one of the following values:
  1522. * @arg @ref RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock
  1523. * @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock
  1524. * @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
  1525. * @arg @ref RCC_RTCCLKSOURCE_HSE_DIVX HSE divided by X selected as RTC clock (X can be retrieved thanks to @ref __HAL_RCC_GET_RTC_HSE_PRESCALER()
  1526. */
  1527. #define __HAL_RCC_GET_RTC_SOURCE() (READ_BIT(RCC->CSR, RCC_CSR_RTCSEL))
  1528. /**
  1529. * @brief Get the RTC and LCD HSE clock divider (RTCCLK / LCDCLK).
  1530. *
  1531. * @retval Returned value can be one of the following values:
  1532. * @arg @ref RCC_RTC_HSE_DIV_2 HSE divided by 2 selected as RTC clock
  1533. * @arg @ref RCC_RTC_HSE_DIV_4 HSE divided by 4 selected as RTC clock
  1534. * @arg @ref RCC_RTC_HSE_DIV_8 HSE divided by 8 selected as RTC clock
  1535. * @arg @ref RCC_RTC_HSE_DIV_16 HSE divided by 16 selected as RTC clock
  1536. *
  1537. */
  1538. #define __HAL_RCC_GET_RTC_HSE_PRESCALER() ((uint32_t)(READ_BIT(RCC->CR, RCC_CR_RTCPRE)))
  1539. /** @brief Macro to enable the the RTC clock.
  1540. * @note These macros must be used only after the RTC clock source was selected.
  1541. */
  1542. #define __HAL_RCC_RTC_ENABLE() (*(__IO uint32_t *) RCC_CSR_RTCEN_BB = ENABLE)
  1543. /** @brief Macro to disable the the RTC clock.
  1544. * @note These macros must be used only after the RTC clock source was selected.
  1545. */
  1546. #define __HAL_RCC_RTC_DISABLE() (*(__IO uint32_t *) RCC_CSR_RTCEN_BB = DISABLE)
  1547. /** @brief Macro to force the Backup domain reset.
  1548. * @note This function resets the RTC peripheral (including the backup registers)
  1549. * and the RTC clock source selection in RCC_CSR register.
  1550. * @note The BKPSRAM is not affected by this reset.
  1551. */
  1552. #define __HAL_RCC_BACKUPRESET_FORCE() (*(__IO uint32_t *) RCC_CSR_RTCRST_BB = ENABLE)
  1553. /** @brief Macros to release the Backup domain reset.
  1554. */
  1555. #define __HAL_RCC_BACKUPRESET_RELEASE() (*(__IO uint32_t *) RCC_CSR_RTCRST_BB = DISABLE)
  1556. /**
  1557. * @}
  1558. */
  1559. /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
  1560. * @brief macros to manage the specified RCC Flags and interrupts.
  1561. * @{
  1562. */
  1563. /** @brief Enable RCC interrupt.
  1564. * @param __INTERRUPT__ specifies the RCC interrupt sources to be enabled.
  1565. * This parameter can be any combination of the following values:
  1566. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  1567. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  1568. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  1569. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  1570. * @arg @ref RCC_IT_PLLRDY main PLL ready interrupt
  1571. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  1572. * @arg @ref RCC_IT_LSECSS LSE CSS interrupt (not available for STM32L100xB || STM32L151xB || STM32L152xB devices)
  1573. */
  1574. #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS |= (__INTERRUPT__))
  1575. /** @brief Disable RCC interrupt.
  1576. * @param __INTERRUPT__ specifies the RCC interrupt sources to be disabled.
  1577. * This parameter can be any combination of the following values:
  1578. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt
  1579. * @arg @ref RCC_IT_LSERDY LSE ready interrupt
  1580. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt
  1581. * @arg @ref RCC_IT_HSERDY HSE ready interrupt
  1582. * @arg @ref RCC_IT_PLLRDY main PLL ready interrupt
  1583. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  1584. * @arg @ref RCC_IT_LSECSS LSE CSS interrupt (not available for STM32L100xB || STM32L151xB || STM32L152xB devices)
  1585. */
  1586. #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS &= (uint8_t)(~(__INTERRUPT__)))
  1587. /** @brief Clear the RCC's interrupt pending bits.
  1588. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  1589. * This parameter can be any combination of the following values:
  1590. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt.
  1591. * @arg @ref RCC_IT_LSERDY LSE ready interrupt.
  1592. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt.
  1593. * @arg @ref RCC_IT_HSERDY HSE ready interrupt.
  1594. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt.
  1595. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  1596. * @arg @ref RCC_IT_LSECSS LSE CSS interrupt (not available for STM32L100xB || STM32L151xB || STM32L152xB devices)
  1597. * @arg @ref RCC_IT_CSS Clock Security System interrupt
  1598. */
  1599. #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE2_ADDRESS = (__INTERRUPT__))
  1600. /** @brief Check the RCC's interrupt has occurred or not.
  1601. * @param __INTERRUPT__ specifies the RCC interrupt source to check.
  1602. * This parameter can be one of the following values:
  1603. * @arg @ref RCC_IT_LSIRDY LSI ready interrupt.
  1604. * @arg @ref RCC_IT_LSERDY LSE ready interrupt.
  1605. * @arg @ref RCC_IT_HSIRDY HSI ready interrupt.
  1606. * @arg @ref RCC_IT_HSERDY HSE ready interrupt.
  1607. * @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt.
  1608. * @arg @ref RCC_IT_MSIRDY MSI ready interrupt
  1609. * @arg @ref RCC_IT_LSECSS LSE CSS interrupt (not available for STM32L100xB || STM32L151xB || STM32L152xB devices)
  1610. * @arg @ref RCC_IT_CSS Clock Security System interrupt
  1611. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  1612. */
  1613. #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIR & (__INTERRUPT__)) == (__INTERRUPT__))
  1614. /** @brief Set RMVF bit to clear the reset flags.
  1615. * The reset flags are RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST,
  1616. * RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST
  1617. */
  1618. #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
  1619. /** @brief Check RCC flag is set or not.
  1620. * @param __FLAG__ specifies the flag to check.
  1621. * This parameter can be one of the following values:
  1622. * @arg @ref RCC_FLAG_HSIRDY HSI oscillator clock ready.
  1623. * @arg @ref RCC_FLAG_MSIRDY MSI oscillator clock ready.
  1624. * @arg @ref RCC_FLAG_HSERDY HSE oscillator clock ready.
  1625. * @arg @ref RCC_FLAG_PLLRDY Main PLL clock ready.
  1626. * @arg @ref RCC_FLAG_LSERDY LSE oscillator clock ready.
  1627. * @arg @ref RCC_FLAG_LSECSS CSS on LSE failure Detection (*)
  1628. * @arg @ref RCC_FLAG_LSIRDY LSI oscillator clock ready.
  1629. * @arg @ref RCC_FLAG_OBLRST Option Byte Load reset
  1630. * @arg @ref RCC_FLAG_PINRST Pin reset.
  1631. * @arg @ref RCC_FLAG_PORRST POR/PDR reset.
  1632. * @arg @ref RCC_FLAG_SFTRST Software reset.
  1633. * @arg @ref RCC_FLAG_IWDGRST Independent Watchdog reset.
  1634. * @arg @ref RCC_FLAG_WWDGRST Window Watchdog reset.
  1635. * @arg @ref RCC_FLAG_LPWRRST Low Power reset.
  1636. * @note (*) This bit is available in high and medium+ density devices only.
  1637. * @retval The new state of __FLAG__ (TRUE or FALSE).
  1638. */
  1639. #define __HAL_RCC_GET_FLAG(__FLAG__) (((((__FLAG__) >> 5U) == CR_REG_INDEX)? RCC->CR :RCC->CSR) & (1U << ((__FLAG__) & RCC_FLAG_MASK)))
  1640. /**
  1641. * @}
  1642. */
  1643. /**
  1644. * @}
  1645. */
  1646. /* Include RCC HAL Extension module */
  1647. #include "stm32l1xx_hal_rcc_ex.h"
  1648. /* Exported functions --------------------------------------------------------*/
  1649. /** @addtogroup RCC_Exported_Functions
  1650. * @{
  1651. */
  1652. /** @addtogroup RCC_Exported_Functions_Group1
  1653. * @{
  1654. */
  1655. /* Initialization and de-initialization functions ******************************/
  1656. void HAL_RCC_DeInit(void);
  1657. HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  1658. HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
  1659. /**
  1660. * @}
  1661. */
  1662. /** @addtogroup RCC_Exported_Functions_Group2
  1663. * @{
  1664. */
  1665. /* Peripheral Control functions ************************************************/
  1666. void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
  1667. void HAL_RCC_EnableCSS(void);
  1668. /* CSS NMI IRQ handler */
  1669. void HAL_RCC_NMI_IRQHandler(void);
  1670. /* User Callbacks in non blocking mode (IT mode) */
  1671. void HAL_RCC_CSSCallback(void);
  1672. void HAL_RCC_DisableCSS(void);
  1673. uint32_t HAL_RCC_GetSysClockFreq(void);
  1674. uint32_t HAL_RCC_GetHCLKFreq(void);
  1675. uint32_t HAL_RCC_GetPCLK1Freq(void);
  1676. uint32_t HAL_RCC_GetPCLK2Freq(void);
  1677. void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
  1678. void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
  1679. /**
  1680. * @}
  1681. */
  1682. /**
  1683. * @}
  1684. */
  1685. /**
  1686. * @}
  1687. */
  1688. /**
  1689. * @}
  1690. */
  1691. #ifdef __cplusplus
  1692. }
  1693. #endif
  1694. #endif /* __STM32L1xx_HAL_RCC_H */
  1695. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/