stm32f4xx_hal_rcc_ex.h 161 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_rcc_ex.h
  4. * @author MCD Application Team
  5. * @version V1.3.0
  6. * @date 09-March-2015
  7. * @brief Header file of RCC HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_HAL_RCC_EX_H
  39. #define __STM32F4xx_HAL_RCC_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f4xx_hal_def.h"
  45. /** @addtogroup STM32F4xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup RCCEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup RCCEx_Exported_Types RCCEx Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief RCC PLL configuration structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t PLLState; /*!< The new state of the PLL.
  61. This parameter can be a value of @ref RCC_PLL_Config */
  62. uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
  63. This parameter must be a value of @ref RCC_PLL_Clock_Source */
  64. uint32_t PLLM; /*!< PLLM: Division factor for PLL VCO input clock.
  65. This parameter must be a number between Min_Data = 0 and Max_Data = 63 */
  66. uint32_t PLLN; /*!< PLLN: Multiplication factor for PLL VCO output clock.
  67. This parameter must be a number between Min_Data = 192 and Max_Data = 432 */
  68. uint32_t PLLP; /*!< PLLP: Division factor for main system clock (SYSCLK).
  69. This parameter must be a value of @ref RCC_PLLP_Clock_Divider */
  70. uint32_t PLLQ; /*!< PLLQ: Division factor for OTG FS, SDIO and RNG clocks.
  71. This parameter must be a number between Min_Data = 4 and Max_Data = 15 */
  72. #if defined(STM32F446xx)
  73. uint32_t PLLR; /*!< PLLR: PLL division factor for I2S, SAI, SYSTEM, SPDIFRX clocks.
  74. This parameter is only available in STM32F446xx devices.
  75. This parameter must be a number between Min_Data = 2 and Max_Data = 7 */
  76. #endif /* STM32F446xx */
  77. }RCC_PLLInitTypeDef;
  78. #if defined(STM32F446xx)
  79. /**
  80. * @brief PLLI2S Clock structure definition
  81. */
  82. typedef struct
  83. {
  84. uint32_t PLLI2SM; /*!< Specifies division factor for PLL VCO input clock.
  85. This parameter must be a number between Min_Data = 2 and Max_Data = 63 */
  86. uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  87. This parameter must be a number between Min_Data = 192 and Max_Data = 432 */
  88. uint32_t PLLI2SP; /*!< Specifies division factor for SPDIFRX Clock.
  89. This parameter must be a value of @ref RCCEx_PLLI2SP_Clock_Divider */
  90. uint32_t PLLI2SQ; /*!< Specifies the division factor for SAI clock.
  91. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  92. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  93. uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock.
  94. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  95. This parameter will be used only when PLLI2S is selected as Clock Source I2S */
  96. }RCC_PLLI2SInitTypeDef;
  97. /**
  98. * @brief PLLSAI Clock structure definition
  99. */
  100. typedef struct
  101. {
  102. uint32_t PLLSAIM; /*!< Spcifies division factor for PLL VCO input clock.
  103. This parameter must be a number between Min_Data = 2 and Max_Data = 63 */
  104. uint32_t PLLSAIN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  105. This parameter must be a number between Min_Data = 192 and Max_Data = 432 */
  106. uint32_t PLLSAIP; /*!< Specifies division factor for OTG FS, SDIO and RNG clocks.
  107. This parameter must be a value of @ref RCCEx_PLLSAIP_Clock_Divider */
  108. uint32_t PLLSAIQ; /*!< Specifies the division factor for SAI clock.
  109. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  110. This parameter will be used only when PLLSAI is selected as Clock Source SAI */
  111. }RCC_PLLSAIInitTypeDef;
  112. /**
  113. * @brief RCC extended clocks structure definition
  114. */
  115. typedef struct
  116. {
  117. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  118. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  119. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters.
  120. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  121. RCC_PLLSAIInitTypeDef PLLSAI; /*!< PLL SAI structure parameters.
  122. This parameter will be used only when PLLI2S is selected as Clock Source SAI or LTDC */
  123. uint32_t PLLI2SDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  124. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  125. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  126. uint32_t PLLSAIDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  127. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  128. This parameter will be used only when PLLSAI is selected as Clock Source SAI */
  129. uint32_t Sai1ClockSelection; /*!< Specifies SAI1 Clock Source Selection.
  130. This parameter can be a value of @ref RCCEx_SAI1_Clock_Source */
  131. uint32_t Sai2ClockSelection; /*!< Specifies SAI2 Clock Source Selection.
  132. This parameter can be a value of @ref RCCEx_SAI2_Clock_Source */
  133. uint32_t I2sApb1ClockSelection; /*!< Specifies I2S APB1 Clock Source Selection.
  134. This parameter can be a value of @ref RCCEx_I2SAPB1_Clock_Source */
  135. uint32_t I2sApb2ClockSelection; /*!< Specifies I2S APB2 Clock Source Selection.
  136. This parameter can be a value of @ref RCCEx_I2SAPB2_Clock_Source */
  137. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Source Selection.
  138. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  139. uint32_t SdioClockSelection; /*!< Specifies SDIO Clock Source Selection.
  140. This parameter can be a value of @ref RCCEx_SDIO_Clock_Source */
  141. uint32_t CecClockSelection; /*!< Specifies CEC Clock Source Selection.
  142. This parameter can be a value of @ref RCCEx_CEC_Clock_Source */
  143. uint32_t Fmpi2c1ClockSelection; /*!< Specifies FMPI2C1 Clock Source Selection.
  144. This parameter can be a value of @ref RCCEx_FMPI2C1_Clock_Source */
  145. uint32_t SpdifClockSelection; /*!< Specifies SPDIFRX Clock Source Selection.
  146. This parameter can be a value of @ref RCCEx_SPDIFRX_Clock_Source */
  147. uint32_t Clk48ClockSelection; /*!< Specifies CK48 Clock Selection this clock used OTG FS, SDIO and RNG clocks.
  148. This parameter can be a value of @ref RCCEx_CK48_Clock_Source */
  149. uint8_t TIMPresSelection; /*!< Specifies TIM Clock Source Selection.
  150. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */
  151. }RCC_PeriphCLKInitTypeDef;
  152. #endif /* STM32F446xx */
  153. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  154. /**
  155. * @brief PLLI2S Clock structure definition
  156. */
  157. typedef struct
  158. {
  159. uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  160. This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  161. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  162. uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock.
  163. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  164. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  165. uint32_t PLLI2SQ; /*!< Specifies the division factor for SAI1 clock.
  166. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  167. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  168. }RCC_PLLI2SInitTypeDef;
  169. /**
  170. * @brief PLLSAI Clock structure definition
  171. */
  172. typedef struct
  173. {
  174. uint32_t PLLSAIN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  175. This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  176. This parameter will be used only when PLLSAI is selected as Clock Source SAI or LTDC */
  177. uint32_t PLLSAIQ; /*!< Specifies the division factor for SAI1 clock.
  178. This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  179. This parameter will be used only when PLLSAI is selected as Clock Source SAI or LTDC */
  180. uint32_t PLLSAIR; /*!< specifies the division factor for LTDC clock
  181. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  182. This parameter will be used only when PLLSAI is selected as Clock Source LTDC */
  183. }RCC_PLLSAIInitTypeDef;
  184. /**
  185. * @brief RCC extended clocks structure definition
  186. */
  187. typedef struct
  188. {
  189. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  190. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  191. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters.
  192. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  193. RCC_PLLSAIInitTypeDef PLLSAI; /*!< PLL SAI structure parameters.
  194. This parameter will be used only when PLLI2S is selected as Clock Source SAI or LTDC */
  195. uint32_t PLLI2SDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  196. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  197. This parameter will be used only when PLLI2S is selected as Clock Source SAI */
  198. uint32_t PLLSAIDivQ; /*!< Specifies the PLLI2S division factor for SAI1 clock.
  199. This parameter must be a number between Min_Data = 1 and Max_Data = 32
  200. This parameter will be used only when PLLSAI is selected as Clock Source SAI */
  201. uint32_t PLLSAIDivR; /*!< Specifies the PLLSAI division factor for LTDC clock.
  202. This parameter must be one value of @ref RCCEx_PLLSAI_DIVR */
  203. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection.
  204. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  205. uint8_t TIMPresSelection; /*!< Specifies TIM Clock Prescalers Selection.
  206. This parameter can be a value of @ref RCCEx_TIM_PRescaler_Selection */
  207. }RCC_PeriphCLKInitTypeDef;
  208. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  209. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) ||\
  210. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  211. /**
  212. * @brief PLLI2S Clock structure definition
  213. */
  214. typedef struct
  215. {
  216. #if defined(STM32F411xE)
  217. uint32_t PLLI2SM; /*!< PLLM: Division factor for PLLI2S VCO input clock.
  218. This parameter must be a number between Min_Data = 2 and Max_Data = 62 */
  219. #endif /* STM32F411xE */
  220. uint32_t PLLI2SN; /*!< Specifies the multiplication factor for PLLI2S VCO output clock.
  221. This parameter must be a number between Min_Data = 192 and Max_Data = 432
  222. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  223. uint32_t PLLI2SR; /*!< Specifies the division factor for I2S clock.
  224. This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  225. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  226. }RCC_PLLI2SInitTypeDef;
  227. /**
  228. * @brief RCC extended clocks structure definition
  229. */
  230. typedef struct
  231. {
  232. uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
  233. This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
  234. RCC_PLLI2SInitTypeDef PLLI2S; /*!< PLL I2S structure parameters.
  235. This parameter will be used only when PLLI2S is selected as Clock Source I2S or SAI */
  236. uint32_t RTCClockSelection; /*!< Specifies RTC Clock Prescalers Selection.
  237. This parameter can be a value of @ref RCC_RTC_Clock_Source */
  238. }RCC_PeriphCLKInitTypeDef;
  239. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */
  240. /**
  241. * @}
  242. */
  243. /* Exported constants --------------------------------------------------------*/
  244. /** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
  245. * @{
  246. */
  247. /** @defgroup RCCEx_Periph_Clock_Selection RCC Periph Clock Selection
  248. * @{
  249. */
  250. /*------------------------------- Peripheral Clock source for STM32F446xx -----------------------------*/
  251. #if defined(STM32F446xx)
  252. #define RCC_PERIPHCLK_I2S_APB1 ((uint32_t)0x00000001)
  253. #define RCC_PERIPHCLK_I2S_APB2 ((uint32_t)0x00000002)
  254. #define RCC_PERIPHCLK_SAI1 ((uint32_t)0x00000004)
  255. #define RCC_PERIPHCLK_SAI2 ((uint32_t)0x00000008)
  256. #define RCC_PERIPHCLK_TIM ((uint32_t)0x00000010)
  257. #define RCC_PERIPHCLK_RTC ((uint32_t)0x00000020)
  258. #define RCC_PERIPHCLK_CEC ((uint32_t)0x00000040)
  259. #define RCC_PERIPHCLK_FMPI2C1 ((uint32_t)0x00000080)
  260. #define RCC_PERIPHCLK_CK48 ((uint32_t)0x00000100)
  261. #define RCC_PERIPHCLK_SDIO ((uint32_t)0x00000200)
  262. #define RCC_PERIPHCLK_SPDIFRX ((uint32_t)0x00000400)
  263. #define RCC_PERIPHCLK_PLLI2S ((uint32_t)0x00000800)
  264. #endif /* STM32F446xx */
  265. /*-----------------------------------------------------------------------------------------------------*/
  266. /*--------------- Peripheral Clock source for STM32F42xxx/STM32F43xxx ---------------------*/
  267. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  268. #define RCC_PERIPHCLK_I2S ((uint32_t)0x00000001)
  269. #define RCC_PERIPHCLK_SAI_PLLI2S ((uint32_t)0x00000002)
  270. #define RCC_PERIPHCLK_SAI_PLLSAI ((uint32_t)0x00000004)
  271. #define RCC_PERIPHCLK_LTDC ((uint32_t)0x00000008)
  272. #define RCC_PERIPHCLK_TIM ((uint32_t)0x00000010)
  273. #define RCC_PERIPHCLK_RTC ((uint32_t)0x00000020)
  274. #define RCC_PERIPHCLK_PLLI2S ((uint32_t)0x00000040)
  275. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  276. /*-----------------------------------------------------------------------------------------------------*/
  277. /*------------------------ Peripheral Clock source for STM32F40xxx/STM32F41xxx ------------------------*/
  278. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) ||\
  279. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  280. #define RCC_PERIPHCLK_I2S ((uint32_t)0x00000001)
  281. #define RCC_PERIPHCLK_RTC ((uint32_t)0x00000002)
  282. #define RCC_PERIPHCLK_PLLI2S ((uint32_t)0x00000004)
  283. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */
  284. /*-----------------------------------------------------------------------------------------------------*/
  285. /**
  286. * @}
  287. */
  288. /** @defgroup RCCEx_PLLSAI_DIVR RCC PLLSAI DIVR
  289. * @{
  290. */
  291. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx)
  292. #define RCC_PLLSAIDIVR_2 ((uint32_t)0x00000000)
  293. #define RCC_PLLSAIDIVR_4 ((uint32_t)0x00010000)
  294. #define RCC_PLLSAIDIVR_8 ((uint32_t)0x00020000)
  295. #define RCC_PLLSAIDIVR_16 ((uint32_t)0x00030000)
  296. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx */
  297. /**
  298. * @}
  299. */
  300. /** @defgroup RCCEx_PLLI2SP_Clock_Divider RCC PLLI2SP Clock Divider
  301. * @{
  302. */
  303. #if defined(STM32F446xx)
  304. #define RCC_PLLI2SP_DIV2 ((uint32_t)0x00000002)
  305. #define RCC_PLLI2SP_DIV4 ((uint32_t)0x00000004)
  306. #define RCC_PLLI2SP_DIV6 ((uint32_t)0x00000006)
  307. #define RCC_PLLI2SP_DIV8 ((uint32_t)0x00000008)
  308. #endif /* STM32F446xx */
  309. /**
  310. * @}
  311. */
  312. /** @defgroup RCCEx_PLLSAIP_Clock_Divider RCC PLLSAIP Clock Divider
  313. * @{
  314. */
  315. #if defined(STM32F446xx)
  316. #define RCC_PLLSAIP_DIV2 ((uint32_t)0x00000002)
  317. #define RCC_PLLSAIP_DIV4 ((uint32_t)0x00000004)
  318. #define RCC_PLLSAIP_DIV6 ((uint32_t)0x00000006)
  319. #define RCC_PLLSAIP_DIV8 ((uint32_t)0x00000008)
  320. #endif /* STM32F446xx */
  321. /**
  322. * @}
  323. */
  324. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  325. /** @defgroup RCCEx_SAI_BlockA_Clock_Source RCC SAI BlockA Clock Source
  326. * @{
  327. */
  328. #define RCC_SAIACLKSOURCE_PLLSAI ((uint32_t)0x00000000)
  329. #define RCC_SAIACLKSOURCE_PLLI2S ((uint32_t)0x00100000)
  330. #define RCC_SAIACLKSOURCE_EXT ((uint32_t)0x00200000)
  331. /**
  332. * @}
  333. */
  334. /** @defgroup RCCEx_SAI_BlockB_Clock_Source RCC SAI BlockB Clock Source
  335. * @{
  336. */
  337. #define RCC_SAIBCLKSOURCE_PLLSAI ((uint32_t)0x00000000)
  338. #define RCC_SAIBCLKSOURCE_PLLI2S ((uint32_t)0x00400000)
  339. #define RCC_SAIBCLKSOURCE_EXT ((uint32_t)0x00800000)
  340. /**
  341. * @}
  342. */
  343. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  344. #if defined(STM32F446xx)
  345. /** @defgroup RCCEx_SAI1_Clock_Source RCC SAI1 Clock Source
  346. * @{
  347. */
  348. #define RCC_SAI1CLKSOURCE_PLLSAI ((uint32_t)0x00000000)
  349. #define RCC_SAI1CLKSOURCE_PLLI2S ((uint32_t)RCC_DCKCFGR_SAI1SRC_0)
  350. #define RCC_SAI1CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_SAI1SRC_1)
  351. #define RCC_SAI1CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_SAI1SRC)
  352. /**
  353. * @}
  354. */
  355. /** @defgroup RCCEx_SAI2_Clock_Source RCC SAI2 Clock Source
  356. * @{
  357. */
  358. #define RCC_SAI2CLKSOURCE_PLLSAI ((uint32_t)0x00000000)
  359. #define RCC_SAI2CLKSOURCE_PLLI2S ((uint32_t)RCC_DCKCFGR_SAI2SRC_0)
  360. #define RCC_SAI2CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_SAI2SRC_1)
  361. #define RCC_SAI2CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_SAI2SRC)
  362. /**
  363. * @}
  364. */
  365. /** @defgroup RCCEx_I2SAPB1_Clock_Source RCC I2S APB1 Clock Source
  366. * @{
  367. */
  368. #define RCC_I2SAPB1CLKSOURCE_PLLI2S ((uint32_t)0x00000000)
  369. #define RCC_I2SAPB1CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_I2S1SRC_0)
  370. #define RCC_I2SAPB1CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_I2S1SRC_1)
  371. #define RCC_I2SAPB1CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_I2S1SRC)
  372. /**
  373. * @}
  374. */
  375. /** @defgroup RCCEx_I2SAPB2_Clock_Source RCC I2S APB2 Clock Source
  376. * @{
  377. */
  378. #define RCC_I2SAPB2CLKSOURCE_PLLI2S ((uint32_t)0x00000000)
  379. #define RCC_I2SAPB2CLKSOURCE_EXT ((uint32_t)RCC_DCKCFGR_I2S2SRC_0)
  380. #define RCC_I2SAPB2CLKSOURCE_PLLR ((uint32_t)RCC_DCKCFGR_I2S2SRC_1)
  381. #define RCC_I2SAPB2CLKSOURCE_PLLSRC ((uint32_t)RCC_DCKCFGR_I2S2SRC)
  382. /**
  383. * @}
  384. */
  385. /** @defgroup RCCEx_FMPI2C1_Clock_Source RCC FMPI2C1 Clock Source
  386. * @{
  387. */
  388. #define RCC_FMPI2C1CLKSOURCE_APB ((uint32_t)0x00000000)
  389. #define RCC_FMPI2C1CLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_0)
  390. #define RCC_FMPI2C1CLKSOURCE_HSI ((uint32_t)RCC_DCKCFGR2_FMPI2C1SEL_1)
  391. /**
  392. * @}
  393. */
  394. /** @defgroup RCCEx_CEC_Clock_Source RCC CEC Clock Source
  395. * @{
  396. */
  397. #define RCC_CECCLKSOURCE_HSI ((uint32_t)0x00000000)
  398. #define RCC_CECCLKSOURCE_LSE ((uint32_t)RCC_DCKCFGR2_CECSEL)
  399. /**
  400. * @}
  401. */
  402. /** @defgroup RCCEx_CK48_Clock_Source RCC CK48 Clock Source
  403. * @{
  404. */
  405. #define RCC_CK48CLKSOURCE_PLLQ ((uint32_t)0x00000000)
  406. #define RCC_CK48CLKSOURCE_PLLSAIP ((uint32_t)RCC_DCKCFGR2_CK48MSEL)
  407. /**
  408. * @}
  409. */
  410. /** @defgroup RCCEx_SDIO_Clock_Source RCC SDIO Clock Source
  411. * @{
  412. */
  413. #define RCC_SDIOCLKSOURCE_CK48 ((uint32_t)0x00000000)
  414. #define RCC_SDIOCLKSOURCE_SYSCLK ((uint32_t)RCC_DCKCFGR2_SDIOSEL)
  415. /**
  416. * @}
  417. */
  418. /** @defgroup RCCEx_SPDIFRX_Clock_Source RCC SPDIFRX Clock Source
  419. * @{
  420. */
  421. #define RCC_SPDIFRXCLKSOURCE_PLLR ((uint32_t)0x00000000)
  422. #define RCC_SPDIFRXCLKSOURCE_PLLI2SP ((uint32_t)RCC_DCKCFGR2_SPDIFRXSEL)
  423. /**
  424. * @}
  425. */
  426. #endif /* STM32F446xx */
  427. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  428. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  429. /** @defgroup RCCEx_TIM_PRescaler_Selection RCC TIM PRescaler Selection
  430. * @{
  431. */
  432. #define RCC_TIMPRES_DESACTIVATED ((uint8_t)0x00)
  433. #define RCC_TIMPRES_ACTIVATED ((uint8_t)0x01)
  434. /**
  435. * @}
  436. */
  437. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx) || STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx */
  438. #if defined(STM32F411xE) || defined(STM32F446xx)
  439. /** @defgroup RCCEx_LSE_Dual_Mode_Selection RCC LSE Dual Mode Selection
  440. * @{
  441. */
  442. #define RCC_LSE_LOWPOWER_MODE ((uint8_t)0x00)
  443. #define RCC_LSE_HIGHDRIVE_MODE ((uint8_t)0x01)
  444. /**
  445. * @}
  446. */
  447. #endif /* STM32F411xE || STM32F446xx */
  448. /**
  449. * @}
  450. */
  451. /* Exported macro ------------------------------------------------------------*/
  452. /** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
  453. * @{
  454. */
  455. /*------------------------------- STM32F42xxx/STM32F43xxx ----------------------------------*/
  456. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
  457. /** @brief Enables or disables the AHB1 peripheral clock.
  458. * @note After reset, the peripheral clock (used for registers read/write access)
  459. * is disabled and the application software has to enable this clock before
  460. * using it.
  461. */
  462. #define __HAL_RCC_GPIOI_CLK_ENABLE() do { \
  463. __IO uint32_t tmpreg; \
  464. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  465. /* Delay after an RCC peripheral clock enabling */ \
  466. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  467. UNUSED(tmpreg); \
  468. } while(0)
  469. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  470. __IO uint32_t tmpreg; \
  471. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  472. /* Delay after an RCC peripheral clock enabling */ \
  473. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  474. UNUSED(tmpreg); \
  475. } while(0)
  476. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  477. __IO uint32_t tmpreg; \
  478. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  479. /* Delay after an RCC peripheral clock enabling */ \
  480. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  481. UNUSED(tmpreg); \
  482. } while(0)
  483. #define __HAL_RCC_GPIOJ_CLK_ENABLE() do { \
  484. __IO uint32_t tmpreg; \
  485. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOJEN);\
  486. /* Delay after an RCC peripheral clock enabling */ \
  487. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOJEN);\
  488. UNUSED(tmpreg); \
  489. } while(0)
  490. #define __HAL_RCC_GPIOK_CLK_ENABLE() do { \
  491. __IO uint32_t tmpreg; \
  492. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOKEN);\
  493. /* Delay after an RCC peripheral clock enabling */ \
  494. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOKEN);\
  495. UNUSED(tmpreg); \
  496. } while(0)
  497. #define __HAL_RCC_DMA2D_CLK_ENABLE() do { \
  498. __IO uint32_t tmpreg; \
  499. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN);\
  500. /* Delay after an RCC peripheral clock enabling */ \
  501. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2DEN);\
  502. UNUSED(tmpreg); \
  503. } while(0)
  504. #define __HAL_RCC_ETHMAC_CLK_ENABLE() do { \
  505. __IO uint32_t tmpreg; \
  506. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  507. /* Delay after an RCC peripheral clock enabling */ \
  508. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  509. UNUSED(tmpreg); \
  510. } while(0)
  511. #define __HAL_RCC_ETHMACTX_CLK_ENABLE() do { \
  512. __IO uint32_t tmpreg; \
  513. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  514. /* Delay after an RCC peripheral clock enabling */ \
  515. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  516. UNUSED(tmpreg); \
  517. } while(0)
  518. #define __HAL_RCC_ETHMACRX_CLK_ENABLE() do { \
  519. __IO uint32_t tmpreg; \
  520. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  521. /* Delay after an RCC peripheral clock enabling */ \
  522. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  523. UNUSED(tmpreg); \
  524. } while(0)
  525. #define __HAL_RCC_ETHMACPTP_CLK_ENABLE() do { \
  526. __IO uint32_t tmpreg; \
  527. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  528. /* Delay after an RCC peripheral clock enabling */ \
  529. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  530. UNUSED(tmpreg); \
  531. } while(0)
  532. #define __HAL_RCC_USB_OTG_HS_CLK_ENABLE() do { \
  533. __IO uint32_t tmpreg; \
  534. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  535. /* Delay after an RCC peripheral clock enabling */ \
  536. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  537. UNUSED(tmpreg); \
  538. } while(0)
  539. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE() do { \
  540. __IO uint32_t tmpreg; \
  541. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  542. /* Delay after an RCC peripheral clock enabling */ \
  543. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  544. UNUSED(tmpreg); \
  545. } while(0)
  546. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  547. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  548. #define __HAL_RCC_GPIOI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOIEN))
  549. #define __HAL_RCC_GPIOJ_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOJEN))
  550. #define __HAL_RCC_GPIOK_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOKEN))
  551. #define __HAL_RCC_DMA2D_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA2DEN))
  552. #define __HAL_RCC_ETHMAC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACEN))
  553. #define __HAL_RCC_ETHMACTX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACTXEN))
  554. #define __HAL_RCC_ETHMACRX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACRXEN))
  555. #define __HAL_RCC_ETHMACPTP_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACPTPEN))
  556. #define __HAL_RCC_USB_OTG_HS_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSEN))
  557. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSULPIEN))
  558. /**
  559. * @brief Enable ETHERNET clock.
  560. */
  561. #define __HAL_RCC_ETH_CLK_ENABLE() do { \
  562. __HAL_RCC_ETHMAC_CLK_ENABLE(); \
  563. __HAL_RCC_ETHMACTX_CLK_ENABLE(); \
  564. __HAL_RCC_ETHMACRX_CLK_ENABLE(); \
  565. } while(0)
  566. /**
  567. * @brief Disable ETHERNET clock.
  568. */
  569. #define __HAL_RCC_ETH_CLK_DISABLE() do { \
  570. __HAL_RCC_ETHMACTX_CLK_DISABLE(); \
  571. __HAL_RCC_ETHMACRX_CLK_DISABLE(); \
  572. __HAL_RCC_ETHMAC_CLK_DISABLE(); \
  573. } while(0)
  574. /** @brief Enable or disable the AHB2 peripheral clock.
  575. * @note After reset, the peripheral clock (used for registers read/write access)
  576. * is disabled and the application software has to enable this clock before
  577. * using it.
  578. */
  579. #define __HAL_RCC_DCMI_CLK_ENABLE() do { \
  580. __IO uint32_t tmpreg; \
  581. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  582. /* Delay after an RCC peripheral clock enabling */ \
  583. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  584. UNUSED(tmpreg); \
  585. } while(0)
  586. #define __HAL_RCC_DCMI_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_DCMIEN))
  587. #if defined(STM32F437xx)|| defined(STM32F439xx)
  588. #define __HAL_RCC_CRYP_CLK_ENABLE() do { \
  589. __IO uint32_t tmpreg; \
  590. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  591. /* Delay after an RCC peripheral clock enabling */ \
  592. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  593. UNUSED(tmpreg); \
  594. } while(0)
  595. #define __HAL_RCC_HASH_CLK_ENABLE() do { \
  596. __IO uint32_t tmpreg; \
  597. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  598. /* Delay after an RCC peripheral clock enabling */ \
  599. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  600. UNUSED(tmpreg); \
  601. } while(0)
  602. #define __HAL_RCC_CRYP_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_CRYPEN))
  603. #define __HAL_RCC_HASH_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_HASHEN))
  604. #endif /* STM32F437xx || STM32F439xx */
  605. /** @brief Enables or disables the AHB3 peripheral clock.
  606. * @note After reset, the peripheral clock (used for registers read/write access)
  607. * is disabled and the application software has to enable this clock before
  608. * using it.
  609. */
  610. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  611. __IO uint32_t tmpreg; \
  612. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  613. /* Delay after an RCC peripheral clock enabling */ \
  614. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  615. UNUSED(tmpreg); \
  616. } while(0)
  617. #define __HAL_RCC_FMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FMCEN))
  618. /** @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  619. * @note After reset, the peripheral clock (used for registers read/write access)
  620. * is disabled and the application software has to enable this clock before
  621. * using it.
  622. */
  623. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  624. __IO uint32_t tmpreg; \
  625. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  626. /* Delay after an RCC peripheral clock enabling */ \
  627. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  628. UNUSED(tmpreg); \
  629. } while(0)
  630. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  631. __IO uint32_t tmpreg; \
  632. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  633. /* Delay after an RCC peripheral clock enabling */ \
  634. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  635. UNUSED(tmpreg); \
  636. } while(0)
  637. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  638. __IO uint32_t tmpreg; \
  639. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  640. /* Delay after an RCC peripheral clock enabling */ \
  641. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  642. UNUSED(tmpreg); \
  643. } while(0)
  644. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  645. __IO uint32_t tmpreg; \
  646. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  647. /* Delay after an RCC peripheral clock enabling */ \
  648. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  649. UNUSED(tmpreg); \
  650. } while(0)
  651. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  652. __IO uint32_t tmpreg; \
  653. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  654. /* Delay after an RCC peripheral clock enabling */ \
  655. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  656. UNUSED(tmpreg); \
  657. } while(0)
  658. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  659. __IO uint32_t tmpreg; \
  660. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  661. /* Delay after an RCC peripheral clock enabling */ \
  662. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  663. UNUSED(tmpreg); \
  664. } while(0)
  665. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  666. __IO uint32_t tmpreg; \
  667. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  668. /* Delay after an RCC peripheral clock enabling */ \
  669. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  670. UNUSED(tmpreg); \
  671. } while(0)
  672. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  673. __IO uint32_t tmpreg; \
  674. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  675. /* Delay after an RCC peripheral clock enabling */ \
  676. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  677. UNUSED(tmpreg); \
  678. } while(0)
  679. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  680. __IO uint32_t tmpreg; \
  681. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  682. /* Delay after an RCC peripheral clock enabling */ \
  683. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  684. UNUSED(tmpreg); \
  685. } while(0)
  686. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  687. __IO uint32_t tmpreg; \
  688. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  689. /* Delay after an RCC peripheral clock enabling */ \
  690. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  691. UNUSED(tmpreg); \
  692. } while(0)
  693. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  694. __IO uint32_t tmpreg; \
  695. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  696. /* Delay after an RCC peripheral clock enabling */ \
  697. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  698. UNUSED(tmpreg); \
  699. } while(0)
  700. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  701. __IO uint32_t tmpreg; \
  702. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  703. /* Delay after an RCC peripheral clock enabling */ \
  704. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  705. UNUSED(tmpreg); \
  706. } while(0)
  707. #define __HAL_RCC_UART7_CLK_ENABLE() do { \
  708. __IO uint32_t tmpreg; \
  709. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART7EN);\
  710. /* Delay after an RCC peripheral clock enabling */ \
  711. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART7EN);\
  712. UNUSED(tmpreg); \
  713. } while(0)
  714. #define __HAL_RCC_UART8_CLK_ENABLE() do { \
  715. __IO uint32_t tmpreg; \
  716. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART8EN);\
  717. /* Delay after an RCC peripheral clock enabling */ \
  718. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART8EN);\
  719. UNUSED(tmpreg); \
  720. } while(0)
  721. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  722. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  723. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  724. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  725. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  726. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  727. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  728. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  729. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  730. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  731. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  732. #define __HAL_RCC_UART7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART7EN))
  733. #define __HAL_RCC_UART8_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART8EN))
  734. /** @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  735. * @note After reset, the peripheral clock (used for registers read/write access)
  736. * is disabled and the application software has to enable this clock before
  737. * using it.
  738. */
  739. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  740. __IO uint32_t tmpreg; \
  741. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  742. /* Delay after an RCC peripheral clock enabling */ \
  743. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  744. UNUSED(tmpreg); \
  745. } while(0)
  746. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  747. __IO uint32_t tmpreg; \
  748. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  749. /* Delay after an RCC peripheral clock enabling */ \
  750. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  751. UNUSED(tmpreg); \
  752. } while(0)
  753. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  754. __IO uint32_t tmpreg; \
  755. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  756. /* Delay after an RCC peripheral clock enabling */ \
  757. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  758. UNUSED(tmpreg); \
  759. } while(0)
  760. #define __HAL_RCC_SPI5_CLK_ENABLE() do { \
  761. __IO uint32_t tmpreg; \
  762. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  763. /* Delay after an RCC peripheral clock enabling */ \
  764. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  765. UNUSED(tmpreg); \
  766. } while(0)
  767. #define __HAL_RCC_SPI6_CLK_ENABLE() do { \
  768. __IO uint32_t tmpreg; \
  769. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN);\
  770. /* Delay after an RCC peripheral clock enabling */ \
  771. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI6EN);\
  772. UNUSED(tmpreg); \
  773. } while(0)
  774. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  775. __IO uint32_t tmpreg; \
  776. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  777. /* Delay after an RCC peripheral clock enabling */ \
  778. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  779. UNUSED(tmpreg); \
  780. } while(0)
  781. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  782. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  783. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  784. #define __HAL_RCC_SPI5_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI5EN))
  785. #define __HAL_RCC_SPI6_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI6EN))
  786. #define __HAL_RCC_SAI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SAI1EN))
  787. #if defined(STM32F429xx)|| defined(STM32F439xx)
  788. #define __HAL_RCC_LTDC_CLK_ENABLE() (RCC->APB2ENR |= (RCC_APB2ENR_LTDCEN))
  789. #define __HAL_RCC_LTDC_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_LTDCEN))
  790. #endif /* STM32F429xx || STM32F439xx */
  791. /** @brief Force or release AHB1 peripheral reset.
  792. */
  793. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  794. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  795. #define __HAL_RCC_GPIOI_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOIRST))
  796. #define __HAL_RCC_ETHMAC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_ETHMACRST))
  797. #define __HAL_RCC_USB_OTG_HS_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHRST))
  798. #define __HAL_RCC_GPIOJ_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOJRST))
  799. #define __HAL_RCC_GPIOK_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOKRST))
  800. #define __HAL_RCC_DMA2D_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA2DRST))
  801. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  802. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  803. #define __HAL_RCC_GPIOI_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOIRST))
  804. #define __HAL_RCC_ETHMAC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_ETHMACRST))
  805. #define __HAL_RCC_USB_OTG_HS_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHRST))
  806. #define __HAL_RCC_GPIOJ_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOJRST))
  807. #define __HAL_RCC_GPIOK_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOKRST))
  808. #define __HAL_RCC_DMA2D_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA2DRST))
  809. /** @brief Force or release AHB2 peripheral reset.
  810. */
  811. #define __HAL_RCC_DCMI_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_DCMIRST))
  812. #define __HAL_RCC_DCMI_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_DCMIRST))
  813. #if defined(STM32F437xx)|| defined(STM32F439xx)
  814. #define __HAL_RCC_CRYP_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_CRYPRST))
  815. #define __HAL_RCC_HASH_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_HASHRST))
  816. #define __HAL_RCC_CRYP_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_CRYPRST))
  817. #define __HAL_RCC_HASH_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_HASHRST))
  818. #endif /* STM32F437xx || STM32F439xx */
  819. /** @brief Force or release AHB3 peripheral reset
  820. */
  821. #define __HAL_RCC_FMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FMCRST))
  822. #define __HAL_RCC_FMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FMCRST))
  823. /** @brief Force or release APB1 peripheral reset.
  824. */
  825. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  826. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  827. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  828. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  829. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  830. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  831. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  832. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  833. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  834. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  835. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  836. #define __HAL_RCC_UART7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART7RST))
  837. #define __HAL_RCC_UART8_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART8RST))
  838. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  839. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  840. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  841. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  842. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  843. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  844. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  845. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  846. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  847. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  848. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  849. #define __HAL_RCC_UART7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART7RST))
  850. #define __HAL_RCC_UART8_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART8RST))
  851. /** @brief Force or release APB2 peripheral reset.
  852. */
  853. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  854. #define __HAL_RCC_SPI5_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI5RST))
  855. #define __HAL_RCC_SPI6_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI6RST))
  856. #define __HAL_RCC_SAI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SAI1RST))
  857. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  858. #define __HAL_RCC_SPI5_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI5RST))
  859. #define __HAL_RCC_SPI6_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI6RST))
  860. #define __HAL_RCC_SAI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SAI1RST))
  861. #if defined(STM32F429xx)|| defined(STM32F439xx)
  862. #define __HAL_RCC_LTDC_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_LTDCRST))
  863. #define __HAL_RCC_LTDC_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_LTDCRST))
  864. #endif /* STM32F429xx|| STM32F439xx */
  865. /** @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  866. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  867. * power consumption.
  868. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  869. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  870. */
  871. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  872. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  873. #define __HAL_RCC_GPIOI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOILPEN))
  874. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  875. #define __HAL_RCC_ETHMAC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACLPEN))
  876. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACTXLPEN))
  877. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACRXLPEN))
  878. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACPTPLPEN))
  879. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSLPEN))
  880. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSULPILPEN))
  881. #define __HAL_RCC_GPIOJ_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOJLPEN))
  882. #define __HAL_RCC_GPIOK_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOKLPEN))
  883. #define __HAL_RCC_SRAM3_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM3LPEN))
  884. #define __HAL_RCC_DMA2D_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA2DLPEN))
  885. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  886. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  887. #define __HAL_RCC_GPIOI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOILPEN))
  888. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  889. #define __HAL_RCC_ETHMAC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACLPEN))
  890. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACTXLPEN))
  891. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACRXLPEN))
  892. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACPTPLPEN))
  893. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSLPEN))
  894. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSULPILPEN))
  895. #define __HAL_RCC_GPIOJ_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOJLPEN))
  896. #define __HAL_RCC_GPIOK_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOKLPEN))
  897. #define __HAL_RCC_DMA2D_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA2DLPEN))
  898. /** @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  899. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  900. * power consumption.
  901. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  902. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  903. */
  904. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_DCMILPEN))
  905. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_DCMILPEN))
  906. #if defined(STM32F437xx)|| defined(STM32F439xx)
  907. #define __HAL_RCC_CRYP_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_CRYPLPEN))
  908. #define __HAL_RCC_HASH_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_HASHLPEN))
  909. #define __HAL_RCC_CRYP_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_CRYPLPEN))
  910. #define __HAL_RCC_HASH_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_HASHLPEN))
  911. #endif /* STM32F437xx || STM32F439xx */
  912. /** @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  913. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  914. * power consumption.
  915. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  916. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  917. */
  918. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FMCLPEN))
  919. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FMCLPEN))
  920. /** @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  921. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  922. * power consumption.
  923. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  924. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  925. */
  926. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  927. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  928. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  929. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  930. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  931. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  932. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  933. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  934. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  935. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  936. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  937. #define __HAL_RCC_UART7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART7LPEN))
  938. #define __HAL_RCC_UART8_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART8LPEN))
  939. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  940. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  941. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  942. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  943. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  944. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  945. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  946. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  947. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  948. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  949. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  950. #define __HAL_RCC_UART7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART7LPEN))
  951. #define __HAL_RCC_UART8_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART8LPEN))
  952. /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  953. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  954. * power consumption.
  955. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  956. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  957. */
  958. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  959. #define __HAL_RCC_ADC2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC2LPEN))
  960. #define __HAL_RCC_ADC3_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC3LPEN))
  961. #define __HAL_RCC_SPI5_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI5LPEN))
  962. #define __HAL_RCC_SPI6_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI6LPEN))
  963. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SAI1LPEN))
  964. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  965. #define __HAL_RCC_ADC2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC2LPEN))
  966. #define __HAL_RCC_ADC3_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC3LPEN))
  967. #define __HAL_RCC_SPI5_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI5LPEN))
  968. #define __HAL_RCC_SPI6_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI6LPEN))
  969. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SAI1LPEN))
  970. #if defined(STM32F429xx)|| defined(STM32F439xx)
  971. #define __HAL_RCC_LTDC_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_LTDCLPEN))
  972. #define __HAL_RCC_LTDC_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_LTDCLPEN))
  973. #endif /* STM32F429xx || STM32F439xx */
  974. #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx */
  975. /*---------------------------------------------------------------------------------------------*/
  976. /*----------------------------------- STM32F40xxx/STM32F41xxx----------------------------------*/
  977. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)
  978. /** @brief Enables or disables the AHB1 peripheral clock.
  979. * @note After reset, the peripheral clock (used for registers read/write access)
  980. * is disabled and the application software has to enable this clock before
  981. * using it.
  982. */
  983. #define __HAL_RCC_GPIOI_CLK_ENABLE() do { \
  984. __IO uint32_t tmpreg; \
  985. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  986. /* Delay after an RCC peripheral clock enabling */ \
  987. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);\
  988. UNUSED(tmpreg); \
  989. } while(0)
  990. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  991. __IO uint32_t tmpreg; \
  992. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  993. /* Delay after an RCC peripheral clock enabling */ \
  994. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  995. UNUSED(tmpreg); \
  996. } while(0)
  997. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  998. __IO uint32_t tmpreg; \
  999. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  1000. /* Delay after an RCC peripheral clock enabling */ \
  1001. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  1002. UNUSED(tmpreg); \
  1003. } while(0)
  1004. #define __HAL_RCC_USB_OTG_HS_CLK_ENABLE() do { \
  1005. __IO uint32_t tmpreg; \
  1006. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  1007. /* Delay after an RCC peripheral clock enabling */ \
  1008. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  1009. UNUSED(tmpreg); \
  1010. } while(0)
  1011. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE() do { \
  1012. __IO uint32_t tmpreg; \
  1013. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  1014. /* Delay after an RCC peripheral clock enabling */ \
  1015. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  1016. UNUSED(tmpreg); \
  1017. } while(0)
  1018. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  1019. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  1020. #define __HAL_RCC_GPIOI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOIEN))
  1021. #define __HAL_RCC_USB_OTG_HS_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSEN))
  1022. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSULPIEN))
  1023. #if defined(STM32F407xx)|| defined(STM32F417xx)
  1024. /**
  1025. * @brief Enable ETHERNET clock.
  1026. */
  1027. #define __HAL_RCC_ETHMAC_CLK_ENABLE() do { \
  1028. __IO uint32_t tmpreg; \
  1029. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  1030. /* Delay after an RCC peripheral clock enabling */ \
  1031. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACEN);\
  1032. UNUSED(tmpreg); \
  1033. } while(0)
  1034. #define __HAL_RCC_ETHMACTX_CLK_ENABLE() do { \
  1035. __IO uint32_t tmpreg; \
  1036. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  1037. /* Delay after an RCC peripheral clock enabling */ \
  1038. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACTXEN);\
  1039. UNUSED(tmpreg); \
  1040. } while(0)
  1041. #define __HAL_RCC_ETHMACRX_CLK_ENABLE() do { \
  1042. __IO uint32_t tmpreg; \
  1043. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  1044. /* Delay after an RCC peripheral clock enabling */ \
  1045. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACRXEN);\
  1046. UNUSED(tmpreg); \
  1047. } while(0)
  1048. #define __HAL_RCC_ETHMACPTP_CLK_ENABLE() do { \
  1049. __IO uint32_t tmpreg; \
  1050. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  1051. /* Delay after an RCC peripheral clock enabling */ \
  1052. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_ETHMACPTPEN);\
  1053. UNUSED(tmpreg); \
  1054. } while(0)
  1055. #define __HAL_RCC_ETH_CLK_ENABLE() do { \
  1056. __HAL_RCC_ETHMAC_CLK_ENABLE(); \
  1057. __HAL_RCC_ETHMACTX_CLK_ENABLE(); \
  1058. __HAL_RCC_ETHMACRX_CLK_ENABLE(); \
  1059. } while(0)
  1060. /**
  1061. * @brief Disable ETHERNET clock.
  1062. */
  1063. #define __HAL_RCC_ETHMAC_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACEN))
  1064. #define __HAL_RCC_ETHMACTX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACTXEN))
  1065. #define __HAL_RCC_ETHMACRX_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACRXEN))
  1066. #define __HAL_RCC_ETHMACPTP_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_ETHMACPTPEN))
  1067. #define __HAL_RCC_ETH_CLK_DISABLE() do { \
  1068. __HAL_RCC_ETHMACTX_CLK_DISABLE(); \
  1069. __HAL_RCC_ETHMACRX_CLK_DISABLE(); \
  1070. __HAL_RCC_ETHMAC_CLK_DISABLE(); \
  1071. } while(0)
  1072. #endif /* STM32F407xx || STM32F417xx */
  1073. /** @brief Enable or disable the AHB2 peripheral clock.
  1074. * @note After reset, the peripheral clock (used for registers read/write access)
  1075. * is disabled and the application software has to enable this clock before
  1076. * using it.
  1077. */
  1078. #if defined(STM32F407xx)|| defined(STM32F417xx)
  1079. #define __HAL_RCC_DCMI_CLK_ENABLE() do { \
  1080. __IO uint32_t tmpreg; \
  1081. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  1082. /* Delay after an RCC peripheral clock enabling */ \
  1083. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  1084. UNUSED(tmpreg); \
  1085. } while(0)
  1086. #define __HAL_RCC_DCMI_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_DCMIEN))
  1087. #endif /* STM32F407xx || STM32F417xx */
  1088. #if defined(STM32F415xx) || defined(STM32F417xx)
  1089. #define __HAL_RCC_CRYP_CLK_ENABLE() do { \
  1090. __IO uint32_t tmpreg; \
  1091. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  1092. /* Delay after an RCC peripheral clock enabling */ \
  1093. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_CRYPEN);\
  1094. UNUSED(tmpreg); \
  1095. } while(0)
  1096. #define __HAL_RCC_HASH_CLK_ENABLE() do { \
  1097. __IO uint32_t tmpreg; \
  1098. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  1099. /* Delay after an RCC peripheral clock enabling */ \
  1100. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_HASHEN);\
  1101. UNUSED(tmpreg); \
  1102. } while(0)
  1103. #define __HAL_RCC_CRYP_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_CRYPEN))
  1104. #define __HAL_RCC_HASH_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_HASHEN))
  1105. #endif /* STM32F415xx || STM32F417xx */
  1106. /** @brief Enables or disables the AHB3 peripheral clock.
  1107. * @note After reset, the peripheral clock (used for registers read/write access)
  1108. * is disabled and the application software has to enable this clock before
  1109. * using it.
  1110. */
  1111. #define __HAL_RCC_FSMC_CLK_ENABLE() do { \
  1112. __IO uint32_t tmpreg; \
  1113. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  1114. /* Delay after an RCC peripheral clock enabling */ \
  1115. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);\
  1116. UNUSED(tmpreg); \
  1117. } while(0)
  1118. #define __HAL_RCC_FSMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FSMCEN))
  1119. /** @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  1120. * @note After reset, the peripheral clock (used for registers read/write access)
  1121. * is disabled and the application software has to enable this clock before
  1122. * using it.
  1123. */
  1124. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  1125. __IO uint32_t tmpreg; \
  1126. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  1127. /* Delay after an RCC peripheral clock enabling */ \
  1128. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  1129. UNUSED(tmpreg); \
  1130. } while(0)
  1131. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  1132. __IO uint32_t tmpreg; \
  1133. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  1134. /* Delay after an RCC peripheral clock enabling */ \
  1135. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  1136. UNUSED(tmpreg); \
  1137. } while(0)
  1138. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  1139. __IO uint32_t tmpreg; \
  1140. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  1141. /* Delay after an RCC peripheral clock enabling */ \
  1142. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  1143. UNUSED(tmpreg); \
  1144. } while(0)
  1145. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  1146. __IO uint32_t tmpreg; \
  1147. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  1148. /* Delay after an RCC peripheral clock enabling */ \
  1149. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  1150. UNUSED(tmpreg); \
  1151. } while(0)
  1152. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  1153. __IO uint32_t tmpreg; \
  1154. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1155. /* Delay after an RCC peripheral clock enabling */ \
  1156. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1157. UNUSED(tmpreg); \
  1158. } while(0)
  1159. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  1160. __IO uint32_t tmpreg; \
  1161. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  1162. /* Delay after an RCC peripheral clock enabling */ \
  1163. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  1164. UNUSED(tmpreg); \
  1165. } while(0)
  1166. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  1167. __IO uint32_t tmpreg; \
  1168. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  1169. /* Delay after an RCC peripheral clock enabling */ \
  1170. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  1171. UNUSED(tmpreg); \
  1172. } while(0)
  1173. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  1174. __IO uint32_t tmpreg; \
  1175. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  1176. /* Delay after an RCC peripheral clock enabling */ \
  1177. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  1178. UNUSED(tmpreg); \
  1179. } while(0)
  1180. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  1181. __IO uint32_t tmpreg; \
  1182. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  1183. /* Delay after an RCC peripheral clock enabling */ \
  1184. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  1185. UNUSED(tmpreg); \
  1186. } while(0)
  1187. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  1188. __IO uint32_t tmpreg; \
  1189. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  1190. /* Delay after an RCC peripheral clock enabling */ \
  1191. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  1192. UNUSED(tmpreg); \
  1193. } while(0)
  1194. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  1195. __IO uint32_t tmpreg; \
  1196. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  1197. /* Delay after an RCC peripheral clock enabling */ \
  1198. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  1199. UNUSED(tmpreg); \
  1200. } while(0)
  1201. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  1202. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  1203. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  1204. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  1205. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  1206. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  1207. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  1208. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  1209. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  1210. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  1211. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  1212. /** @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  1213. * @note After reset, the peripheral clock (used for registers read/write access)
  1214. * is disabled and the application software has to enable this clock before
  1215. * using it.
  1216. */
  1217. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  1218. __IO uint32_t tmpreg; \
  1219. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1220. /* Delay after an RCC peripheral clock enabling */ \
  1221. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1222. UNUSED(tmpreg); \
  1223. } while(0)
  1224. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  1225. __IO uint32_t tmpreg; \
  1226. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1227. /* Delay after an RCC peripheral clock enabling */ \
  1228. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1229. UNUSED(tmpreg); \
  1230. } while(0)
  1231. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  1232. __IO uint32_t tmpreg; \
  1233. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1234. /* Delay after an RCC peripheral clock enabling */ \
  1235. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1236. UNUSED(tmpreg); \
  1237. } while(0)
  1238. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  1239. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  1240. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  1241. /** @brief Force or release AHB1 peripheral reset.
  1242. */
  1243. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  1244. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  1245. #define __HAL_RCC_GPIOI_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOIRST))
  1246. #define __HAL_RCC_ETHMAC_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_ETHMACRST))
  1247. #define __HAL_RCC_USB_OTG_HS_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHRST))
  1248. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  1249. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  1250. #define __HAL_RCC_GPIOI_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOIRST))
  1251. #define __HAL_RCC_ETHMAC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_ETHMACRST))
  1252. #define __HAL_RCC_USB_OTG_HS_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHRST))
  1253. /** @brief Force or release AHB2 peripheral reset.
  1254. */
  1255. #if defined(STM32F407xx)|| defined(STM32F417xx)
  1256. #define __HAL_RCC_DCMI_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_DCMIRST))
  1257. #define __HAL_RCC_DCMI_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_DCMIRST))
  1258. #endif /* STM32F407xx || STM32F417xx */
  1259. #if defined(STM32F415xx) || defined(STM32F417xx)
  1260. #define __HAL_RCC_CRYP_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_CRYPRST))
  1261. #define __HAL_RCC_HASH_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_HASHRST))
  1262. #define __HAL_RCC_CRYP_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_CRYPRST))
  1263. #define __HAL_RCC_HASH_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_HASHRST))
  1264. #endif /* STM32F415xx || STM32F417xx */
  1265. /** @brief Force or release AHB3 peripheral reset
  1266. */
  1267. #define __HAL_RCC_FSMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FSMCRST))
  1268. #define __HAL_RCC_FSMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FSMCRST))
  1269. /** @brief Force or release APB1 peripheral reset.
  1270. */
  1271. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  1272. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  1273. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  1274. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  1275. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  1276. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  1277. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  1278. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  1279. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  1280. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  1281. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  1282. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  1283. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  1284. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  1285. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  1286. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  1287. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  1288. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  1289. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  1290. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  1291. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  1292. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  1293. /** @brief Force or release APB2 peripheral reset.
  1294. */
  1295. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  1296. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  1297. /** @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  1298. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1299. * power consumption.
  1300. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1301. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1302. */
  1303. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  1304. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  1305. #define __HAL_RCC_GPIOI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOILPEN))
  1306. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  1307. #define __HAL_RCC_ETHMAC_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACLPEN))
  1308. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACTXLPEN))
  1309. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACRXLPEN))
  1310. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_ETHMACPTPLPEN))
  1311. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSLPEN))
  1312. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSULPILPEN))
  1313. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  1314. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  1315. #define __HAL_RCC_GPIOI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOILPEN))
  1316. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  1317. #define __HAL_RCC_ETHMAC_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACLPEN))
  1318. #define __HAL_RCC_ETHMACTX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACTXLPEN))
  1319. #define __HAL_RCC_ETHMACRX_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACRXLPEN))
  1320. #define __HAL_RCC_ETHMACPTP_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_ETHMACPTPLPEN))
  1321. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSLPEN))
  1322. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSULPILPEN))
  1323. /** @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  1324. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1325. * power consumption.
  1326. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1327. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1328. */
  1329. #if defined(STM32F407xx)|| defined(STM32F417xx)
  1330. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_DCMILPEN))
  1331. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_DCMILPEN))
  1332. #endif /* STM32F407xx || STM32F417xx */
  1333. #if defined(STM32F415xx) || defined(STM32F417xx)
  1334. #define __HAL_RCC_CRYP_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_CRYPLPEN))
  1335. #define __HAL_RCC_HASH_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_HASHLPEN))
  1336. #define __HAL_RCC_CRYP_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_CRYPLPEN))
  1337. #define __HAL_RCC_HASH_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_HASHLPEN))
  1338. #endif /* STM32F415xx || STM32F417xx */
  1339. /** @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  1340. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1341. * power consumption.
  1342. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1343. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1344. */
  1345. #define __HAL_RCC_FSMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FSMCLPEN))
  1346. #define __HAL_RCC_FSMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FSMCLPEN))
  1347. /** @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  1348. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1349. * power consumption.
  1350. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1351. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1352. */
  1353. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  1354. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  1355. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  1356. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  1357. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  1358. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  1359. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  1360. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  1361. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  1362. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  1363. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  1364. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  1365. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  1366. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  1367. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  1368. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  1369. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  1370. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  1371. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  1372. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  1373. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  1374. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  1375. /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1376. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1377. * power consumption.
  1378. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1379. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1380. */
  1381. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  1382. #define __HAL_RCC_ADC2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC2LPEN))
  1383. #define __HAL_RCC_ADC3_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC3LPEN))
  1384. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  1385. #define __HAL_RCC_ADC2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC2LPEN))
  1386. #define __HAL_RCC_ADC3_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC3LPEN))
  1387. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  1388. /*---------------------------------------------------------------------------------------------*/
  1389. /*------------------------------------------ STM32F411xx --------------------------------------*/
  1390. #if defined(STM32F411xE)
  1391. /** @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  1392. */
  1393. #define __HAL_RCC_SPI5_CLK_ENABLE() do { \
  1394. __IO uint32_t tmpreg; \
  1395. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  1396. /* Delay after an RCC peripheral clock enabling */ \
  1397. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI5EN);\
  1398. UNUSED(tmpreg); \
  1399. } while(0)
  1400. #define __HAL_RCC_SPI5_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI5EN))
  1401. /** @brief Force or release APB2 peripheral reset.
  1402. */
  1403. #define __HAL_RCC_SPI5_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI5RST))
  1404. #define __HAL_RCC_SPI5_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI5RST))
  1405. /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1406. */
  1407. #define __HAL_RCC_SPI5_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI5LPEN))
  1408. #define __HAL_RCC_SPI5_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI5LPEN))
  1409. #endif /* STM32F411xE */
  1410. /*---------------------------------------------------------------------------------------------*/
  1411. /*----------------------------------------- STM32F446xx ---------------------------------------*/
  1412. #if defined(STM32F446xx)
  1413. /** @brief Enables or disables the AHB1 peripheral clock.
  1414. * @note After reset, the peripheral clock (used for registers read/write access)
  1415. * is disabled and the application software has to enable this clock before
  1416. * using it.
  1417. */
  1418. #define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
  1419. __IO uint32_t tmpreg; \
  1420. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  1421. /* Delay after an RCC peripheral clock enabling */ \
  1422. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOFEN);\
  1423. UNUSED(tmpreg); \
  1424. } while(0)
  1425. #define __HAL_RCC_GPIOG_CLK_ENABLE() do { \
  1426. __IO uint32_t tmpreg; \
  1427. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  1428. /* Delay after an RCC peripheral clock enabling */ \
  1429. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOGEN);\
  1430. UNUSED(tmpreg); \
  1431. } while(0)
  1432. #define __HAL_RCC_USB_OTG_HS_CLK_ENABLE() do { \
  1433. __IO uint32_t tmpreg; \
  1434. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  1435. /* Delay after an RCC peripheral clock enabling */ \
  1436. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSEN);\
  1437. UNUSED(tmpreg); \
  1438. } while(0)
  1439. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE() do { \
  1440. __IO uint32_t tmpreg; \
  1441. SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  1442. /* Delay after an RCC peripheral clock enabling */ \
  1443. tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_OTGHSULPIEN);\
  1444. UNUSED(tmpreg); \
  1445. } while(0)
  1446. #define __HAL_RCC_GPIOF_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOFEN))
  1447. #define __HAL_RCC_GPIOG_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOGEN))
  1448. #define __HAL_RCC_USB_OTG_HS_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSEN))
  1449. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_DISABLE() (RCC->AHB1ENR &= ~(RCC_AHB1ENR_OTGHSULPIEN))
  1450. /** @brief Enable or disable the AHB2 peripheral clock.
  1451. * @note After reset, the peripheral clock (used for registers read/write access)
  1452. * is disabled and the application software has to enable this clock before
  1453. * using it.
  1454. */
  1455. #define __HAL_RCC_DCMI_CLK_ENABLE() do { \
  1456. __IO uint32_t tmpreg; \
  1457. SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  1458. /* Delay after an RCC peripheral clock enabling */ \
  1459. tmpreg = READ_BIT(RCC->AHB2ENR, RCC_AHB2ENR_DCMIEN);\
  1460. UNUSED(tmpreg); \
  1461. } while(0)
  1462. #define __HAL_RCC_DCMI_CLK_DISABLE() (RCC->AHB2ENR &= ~(RCC_AHB2ENR_DCMIEN))
  1463. /** @brief Enables or disables the AHB3 peripheral clock.
  1464. * @note After reset, the peripheral clock (used for registers read/write access)
  1465. * is disabled and the application software has to enable this clock before
  1466. * using it.
  1467. */
  1468. #define __HAL_RCC_FMC_CLK_ENABLE() do { \
  1469. __IO uint32_t tmpreg; \
  1470. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  1471. /* Delay after an RCC peripheral clock enabling */ \
  1472. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);\
  1473. UNUSED(tmpreg); \
  1474. } while(0)
  1475. #define __HAL_RCC_QSPI_CLK_ENABLE() do { \
  1476. __IO uint32_t tmpreg; \
  1477. SET_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  1478. /* Delay after an RCC peripheral clock enabling */ \
  1479. tmpreg = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_QSPIEN);\
  1480. UNUSED(tmpreg); \
  1481. } while(0)
  1482. #define __HAL_RCC_FMC_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_FMCEN))
  1483. #define __HAL_RCC_QSPI_CLK_DISABLE() (RCC->AHB3ENR &= ~(RCC_AHB3ENR_QSPIEN))
  1484. /** @brief Enable or disable the Low Speed APB (APB1) peripheral clock.
  1485. * @note After reset, the peripheral clock (used for registers read/write access)
  1486. * is disabled and the application software has to enable this clock before
  1487. * using it.
  1488. */
  1489. #define __HAL_RCC_TIM6_CLK_ENABLE() do { \
  1490. __IO uint32_t tmpreg; \
  1491. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  1492. /* Delay after an RCC peripheral clock enabling */ \
  1493. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\
  1494. UNUSED(tmpreg); \
  1495. } while(0)
  1496. #define __HAL_RCC_TIM7_CLK_ENABLE() do { \
  1497. __IO uint32_t tmpreg; \
  1498. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  1499. /* Delay after an RCC peripheral clock enabling */ \
  1500. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM7EN);\
  1501. UNUSED(tmpreg); \
  1502. } while(0)
  1503. #define __HAL_RCC_TIM12_CLK_ENABLE() do { \
  1504. __IO uint32_t tmpreg; \
  1505. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  1506. /* Delay after an RCC peripheral clock enabling */ \
  1507. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM12EN);\
  1508. UNUSED(tmpreg); \
  1509. } while(0)
  1510. #define __HAL_RCC_TIM13_CLK_ENABLE() do { \
  1511. __IO uint32_t tmpreg; \
  1512. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  1513. /* Delay after an RCC peripheral clock enabling */ \
  1514. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM13EN);\
  1515. UNUSED(tmpreg); \
  1516. } while(0)
  1517. #define __HAL_RCC_TIM14_CLK_ENABLE() do { \
  1518. __IO uint32_t tmpreg; \
  1519. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1520. /* Delay after an RCC peripheral clock enabling */ \
  1521. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM14EN);\
  1522. UNUSED(tmpreg); \
  1523. } while(0)
  1524. #define __HAL_RCC_SPDIFRX_CLK_ENABLE() do { \
  1525. __IO uint32_t tmpreg; \
  1526. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPDIFRXEN);\
  1527. /* Delay after an RCC peripheral clock enabling */ \
  1528. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPDIFRXEN);\
  1529. UNUSED(tmpreg); \
  1530. } while(0)
  1531. #define __HAL_RCC_USART3_CLK_ENABLE() do { \
  1532. __IO uint32_t tmpreg; \
  1533. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  1534. /* Delay after an RCC peripheral clock enabling */ \
  1535. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
  1536. UNUSED(tmpreg); \
  1537. } while(0)
  1538. #define __HAL_RCC_UART4_CLK_ENABLE() do { \
  1539. __IO uint32_t tmpreg; \
  1540. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  1541. /* Delay after an RCC peripheral clock enabling */ \
  1542. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART4EN);\
  1543. UNUSED(tmpreg); \
  1544. } while(0)
  1545. #define __HAL_RCC_UART5_CLK_ENABLE() do { \
  1546. __IO uint32_t tmpreg; \
  1547. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  1548. /* Delay after an RCC peripheral clock enabling */ \
  1549. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_UART5EN);\
  1550. UNUSED(tmpreg); \
  1551. } while(0)
  1552. #define __HAL_RCC_FMPI2C1_CLK_ENABLE() do { \
  1553. __IO uint32_t tmpreg; \
  1554. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  1555. /* Delay after an RCC peripheral clock enabling */ \
  1556. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_FMPI2C1EN);\
  1557. UNUSED(tmpreg); \
  1558. } while(0)
  1559. #define __HAL_RCC_CAN1_CLK_ENABLE() do { \
  1560. __IO uint32_t tmpreg; \
  1561. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  1562. /* Delay after an RCC peripheral clock enabling */ \
  1563. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN1EN);\
  1564. UNUSED(tmpreg); \
  1565. } while(0)
  1566. #define __HAL_RCC_CAN2_CLK_ENABLE() do { \
  1567. __IO uint32_t tmpreg; \
  1568. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  1569. /* Delay after an RCC peripheral clock enabling */ \
  1570. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CAN2EN);\
  1571. UNUSED(tmpreg); \
  1572. } while(0)
  1573. #define __HAL_RCC_CEC_CLK_ENABLE() do { \
  1574. __IO uint32_t tmpreg; \
  1575. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  1576. /* Delay after an RCC peripheral clock enabling */ \
  1577. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_CECEN);\
  1578. UNUSED(tmpreg); \
  1579. } while(0)
  1580. #define __HAL_RCC_DAC_CLK_ENABLE() do { \
  1581. __IO uint32_t tmpreg; \
  1582. SET_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  1583. /* Delay after an RCC peripheral clock enabling */ \
  1584. tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_DACEN);\
  1585. UNUSED(tmpreg); \
  1586. } while(0)
  1587. #define __HAL_RCC_TIM6_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM6EN))
  1588. #define __HAL_RCC_TIM7_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM7EN))
  1589. #define __HAL_RCC_TIM12_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM12EN))
  1590. #define __HAL_RCC_TIM13_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM13EN))
  1591. #define __HAL_RCC_TIM14_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM14EN))
  1592. #define __HAL_RCC_SPDIFRX_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPDIFRXEN))
  1593. #define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
  1594. #define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
  1595. #define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
  1596. #define __HAL_RCC_FMPI2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_FMPI2C1EN))
  1597. #define __HAL_RCC_CAN1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN))
  1598. #define __HAL_RCC_CAN2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CAN2EN))
  1599. #define __HAL_RCC_CEC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_CECEN))
  1600. #define __HAL_RCC_DAC_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_DACEN))
  1601. /** @brief Enable or disable the High Speed APB (APB2) peripheral clock.
  1602. * @note After reset, the peripheral clock (used for registers read/write access)
  1603. * is disabled and the application software has to enable this clock before
  1604. * using it.
  1605. */
  1606. #define __HAL_RCC_TIM8_CLK_ENABLE() do { \
  1607. __IO uint32_t tmpreg; \
  1608. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1609. /* Delay after an RCC peripheral clock enabling */ \
  1610. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM8EN);\
  1611. UNUSED(tmpreg); \
  1612. } while(0)
  1613. #define __HAL_RCC_ADC2_CLK_ENABLE() do { \
  1614. __IO uint32_t tmpreg; \
  1615. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1616. /* Delay after an RCC peripheral clock enabling */ \
  1617. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC2EN);\
  1618. UNUSED(tmpreg); \
  1619. } while(0)
  1620. #define __HAL_RCC_ADC3_CLK_ENABLE() do { \
  1621. __IO uint32_t tmpreg; \
  1622. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1623. /* Delay after an RCC peripheral clock enabling */ \
  1624. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC3EN);\
  1625. UNUSED(tmpreg); \
  1626. } while(0)
  1627. #define __HAL_RCC_SAI1_CLK_ENABLE() do { \
  1628. __IO uint32_t tmpreg; \
  1629. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  1630. /* Delay after an RCC peripheral clock enabling */ \
  1631. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI1EN);\
  1632. UNUSED(tmpreg); \
  1633. } while(0)
  1634. #define __HAL_RCC_SAI2_CLK_ENABLE() do { \
  1635. __IO uint32_t tmpreg; \
  1636. SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN);\
  1637. /* Delay after an RCC peripheral clock enabling */ \
  1638. tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SAI2EN);\
  1639. UNUSED(tmpreg); \
  1640. } while(0)
  1641. #define __HAL_RCC_TIM8_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM8EN))
  1642. #define __HAL_RCC_ADC2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC2EN))
  1643. #define __HAL_RCC_ADC3_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC3EN))
  1644. #define __HAL_RCC_SAI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SAI1EN))
  1645. #define __HAL_RCC_SAI2_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SAI2EN))
  1646. /** @brief Force or release AHB1 peripheral reset.
  1647. */
  1648. #define __HAL_RCC_GPIOF_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOFRST))
  1649. #define __HAL_RCC_GPIOG_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOGRST))
  1650. #define __HAL_RCC_USB_OTG_HS_FORCE_RESET() (RCC->AHB1RSTR |= (RCC_AHB1RSTR_OTGHRST))
  1651. #define __HAL_RCC_GPIOF_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOFRST))
  1652. #define __HAL_RCC_GPIOG_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOGRST))
  1653. #define __HAL_RCC_USB_OTG_HS_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_OTGHRST))
  1654. /** @brief Force or release AHB2 peripheral reset.
  1655. */
  1656. #define __HAL_RCC_DCMI_FORCE_RESET() (RCC->AHB2RSTR |= (RCC_AHB2RSTR_DCMIRST))
  1657. #define __HAL_RCC_DCMI_RELEASE_RESET() (RCC->AHB2RSTR &= ~(RCC_AHB2RSTR_DCMIRST))
  1658. /** @brief Force or release AHB3 peripheral reset
  1659. */
  1660. #define __HAL_RCC_FMC_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_FMCRST))
  1661. #define __HAL_RCC_QSPI_FORCE_RESET() (RCC->AHB3RSTR |= (RCC_AHB3RSTR_QSPIRST))
  1662. #define __HAL_RCC_FMC_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_FMCRST))
  1663. #define __HAL_RCC_QSPI_RELEASE_RESET() (RCC->AHB3RSTR &= ~(RCC_AHB3RSTR_QSPIRST))
  1664. /** @brief Force or release APB1 peripheral reset.
  1665. */
  1666. #define __HAL_RCC_TIM6_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM6RST))
  1667. #define __HAL_RCC_TIM7_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM7RST))
  1668. #define __HAL_RCC_TIM12_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM12RST))
  1669. #define __HAL_RCC_TIM13_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM13RST))
  1670. #define __HAL_RCC_TIM14_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM14RST))
  1671. #define __HAL_RCC_SPDIFRX_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPDIFRXRST))
  1672. #define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
  1673. #define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
  1674. #define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
  1675. #define __HAL_RCC_FMPI2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_FMPI2C1RST))
  1676. #define __HAL_RCC_CAN1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN1RST))
  1677. #define __HAL_RCC_CAN2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CAN2RST))
  1678. #define __HAL_RCC_CEC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_CECRST))
  1679. #define __HAL_RCC_DAC_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_DACRST))
  1680. #define __HAL_RCC_TIM6_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM6RST))
  1681. #define __HAL_RCC_TIM7_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM7RST))
  1682. #define __HAL_RCC_TIM12_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM12RST))
  1683. #define __HAL_RCC_TIM13_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM13RST))
  1684. #define __HAL_RCC_TIM14_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM14RST))
  1685. #define __HAL_RCC_SPDIFRX_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPDIFRXRST))
  1686. #define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
  1687. #define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
  1688. #define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
  1689. #define __HAL_RCC_FMPI2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_FMPI2C1RST))
  1690. #define __HAL_RCC_CAN1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN1RST))
  1691. #define __HAL_RCC_CAN2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CAN2RST))
  1692. #define __HAL_RCC_CEC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_CECRST))
  1693. #define __HAL_RCC_DAC_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_DACRST))
  1694. /** @brief Force or release APB2 peripheral reset.
  1695. */
  1696. #define __HAL_RCC_TIM8_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM8RST))
  1697. #define __HAL_RCC_SAI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SAI1RST))
  1698. #define __HAL_RCC_SAI2_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SAI2RST))
  1699. #define __HAL_RCC_TIM8_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM8RST))
  1700. #define __HAL_RCC_SAI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SAI1RST))
  1701. #define __HAL_RCC_SAI2_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SAI2RST))
  1702. /** @brief Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
  1703. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1704. * power consumption.
  1705. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1706. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1707. */
  1708. #define __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOFLPEN))
  1709. #define __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOGLPEN))
  1710. #define __HAL_RCC_SRAM2_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_SRAM2LPEN))
  1711. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSLPEN))
  1712. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_ENABLE() (RCC->AHB1LPENR |= (RCC_AHB1LPENR_OTGHSULPILPEN))
  1713. #define __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOFLPEN))
  1714. #define __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOGLPEN))
  1715. #define __HAL_RCC_SRAM2_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_SRAM2LPEN))
  1716. #define __HAL_RCC_USB_OTG_HS_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSLPEN))
  1717. #define __HAL_RCC_USB_OTG_HS_ULPI_CLK_SLEEP_DISABLE() (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_OTGHSULPILPEN))
  1718. /** @brief Enable or disable the AHB2 peripheral clock during Low Power (Sleep) mode.
  1719. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1720. * power consumption.
  1721. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1722. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1723. */
  1724. #define __HAL_RCC_DCMI_CLK_SLEEP_ENABLE() (RCC->AHB2LPENR |= (RCC_AHB2LPENR_DCMILPEN))
  1725. #define __HAL_RCC_DCMI_CLK_SLEEP_DISABLE() (RCC->AHB2LPENR &= ~(RCC_AHB2LPENR_DCMILPEN))
  1726. /** @brief Enable or disable the AHB3 peripheral clock during Low Power (Sleep) mode.
  1727. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1728. * power consumption.
  1729. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1730. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1731. */
  1732. #define __HAL_RCC_FMC_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_FMCLPEN))
  1733. #define __HAL_RCC_QSPI_CLK_SLEEP_ENABLE() (RCC->AHB3LPENR |= (RCC_AHB3LPENR_QSPILPEN))
  1734. #define __HAL_RCC_FMC_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_FMCLPEN))
  1735. #define __HAL_RCC_QSPI_CLK_SLEEP_DISABLE() (RCC->AHB3LPENR &= ~(RCC_AHB3LPENR_QSPILPEN))
  1736. /** @brief Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
  1737. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1738. * power consumption.
  1739. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1740. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1741. */
  1742. #define __HAL_RCC_TIM6_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM6LPEN))
  1743. #define __HAL_RCC_TIM7_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM7LPEN))
  1744. #define __HAL_RCC_TIM12_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM12LPEN))
  1745. #define __HAL_RCC_TIM13_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM13LPEN))
  1746. #define __HAL_RCC_TIM14_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM14LPEN))
  1747. #define __HAL_RCC_SPDIFRX_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPDIFRXLPEN))
  1748. #define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
  1749. #define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
  1750. #define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
  1751. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_FMPI2C1LPEN))
  1752. #define __HAL_RCC_CAN1_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN1LPEN))
  1753. #define __HAL_RCC_CAN2_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CAN2LPEN))
  1754. #define __HAL_RCC_CEC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_CECLPEN))
  1755. #define __HAL_RCC_DAC_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_DACLPEN))
  1756. #define __HAL_RCC_TIM6_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM6LPEN))
  1757. #define __HAL_RCC_TIM7_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM7LPEN))
  1758. #define __HAL_RCC_TIM12_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM12LPEN))
  1759. #define __HAL_RCC_TIM13_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM13LPEN))
  1760. #define __HAL_RCC_TIM14_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM14LPEN))
  1761. #define __HAL_RCC_SPDIFRX_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPDIFRXLPEN))
  1762. #define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
  1763. #define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
  1764. #define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))
  1765. #define __HAL_RCC_FMPI2C1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_FMPI2C1LPEN))
  1766. #define __HAL_RCC_CAN1_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN1LPEN))
  1767. #define __HAL_RCC_CAN2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CAN2LPEN))
  1768. #define __HAL_RCC_CEC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_CECLPEN))
  1769. #define __HAL_RCC_DAC_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_DACLPEN))
  1770. /** @brief Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
  1771. * @note Peripheral clock gating in SLEEP mode can be used to further reduce
  1772. * power consumption.
  1773. * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
  1774. * @note By default, all peripheral clocks are enabled during SLEEP mode.
  1775. */
  1776. #define __HAL_RCC_TIM8_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM8LPEN))
  1777. #define __HAL_RCC_ADC2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC2LPEN))
  1778. #define __HAL_RCC_ADC3_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC3LPEN))
  1779. #define __HAL_RCC_SAI1_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SAI1LPEN))
  1780. #define __HAL_RCC_SAI2_CLK_SLEEP_ENABLE() (RCC->APB2LPENR |= (RCC_APB2LPENR_SAI2LPEN))
  1781. #define __HAL_RCC_TIM8_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM8LPEN))
  1782. #define __HAL_RCC_ADC2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC2LPEN))
  1783. #define __HAL_RCC_ADC3_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC3LPEN))
  1784. #define __HAL_RCC_SAI1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SAI1LPEN))
  1785. #define __HAL_RCC_SAI2_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SAI2LPEN))
  1786. #endif /* STM32F446xx */
  1787. /*------------------------------------------------------------------------------------------------------------*/
  1788. /*------------------------------------------------- PLL Configuration ----------------------------------------*/
  1789. #if defined(STM32F446xx)
  1790. /** @brief Macro to configure the main PLL clock source, multiplication and division factors.
  1791. * @note This function must be used only when the main PLL is disabled.
  1792. * @param __RCC_PLLSource__: specifies the PLL entry clock source.
  1793. * This parameter can be one of the following values:
  1794. * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
  1795. * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
  1796. * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.
  1797. * @param __PLLM__: specifies the division factor for PLL VCO input clock
  1798. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  1799. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  1800. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  1801. * of 2 MHz to limit PLL jitter.
  1802. * @param __PLLN__: specifies the multiplication factor for PLL VCO output clock
  1803. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1804. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  1805. * output frequency is between 192 and 432 MHz.
  1806. *
  1807. * @param __PLLP__: specifies the division factor for main system clock (SYSCLK)
  1808. * This parameter must be a number in the range {2, 4, 6, or 8}.
  1809. *
  1810. * @param __PLLQ__: specifies the division factor for OTG FS, SDIO and RNG clocks
  1811. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  1812. * @note If the USB OTG FS is used in your application, you have to set the
  1813. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  1814. * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work
  1815. * correctly.
  1816. *
  1817. * @param __PLLR__: PLL division factor for I2S, SAI, SYSTEM, SPDIFRX clocks.
  1818. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  1819. * @note This parameter is only available in STM32F446xx devices.
  1820. *
  1821. */
  1822. #define __HAL_RCC_PLL_CONFIG(__RCC_PLLSource__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__,__PLLR__) \
  1823. (RCC->PLLCFGR = ((__RCC_PLLSource__) | (__PLLM__) | \
  1824. ((__PLLN__) << POSITION_VAL(RCC_PLLCFGR_PLLN)) | \
  1825. ((((__PLLP__) >> 1) -1) << POSITION_VAL(RCC_PLLCFGR_PLLP)) | \
  1826. ((__PLLQ__) << POSITION_VAL(RCC_PLLCFGR_PLLQ)) | \
  1827. ((__PLLR__) << POSITION_VAL(RCC_PLLCFGR_PLLR))))
  1828. #else
  1829. /** @brief Macro to configure the main PLL clock source, multiplication and division factors.
  1830. * @note This function must be used only when the main PLL is disabled.
  1831. * @param __RCC_PLLSource__: specifies the PLL entry clock source.
  1832. * This parameter can be one of the following values:
  1833. * @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
  1834. * @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
  1835. * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.
  1836. * @param __PLLM__: specifies the division factor for PLL VCO input clock
  1837. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  1838. * @note You have to set the PLLM parameter correctly to ensure that the VCO input
  1839. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  1840. * of 2 MHz to limit PLL jitter.
  1841. * @param __PLLN__: specifies the multiplication factor for PLL VCO output clock
  1842. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1843. * @note You have to set the PLLN parameter correctly to ensure that the VCO
  1844. * output frequency is between 192 and 432 MHz.
  1845. *
  1846. * @param __PLLP__: specifies the division factor for main system clock (SYSCLK)
  1847. * This parameter must be a number in the range {2, 4, 6, or 8}.
  1848. *
  1849. * @param __PLLQ__: specifies the division factor for OTG FS, SDIO and RNG clocks
  1850. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  1851. * @note If the USB OTG FS is used in your application, you have to set the
  1852. * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
  1853. * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work
  1854. * correctly.
  1855. *
  1856. */
  1857. #define __HAL_RCC_PLL_CONFIG(__RCC_PLLSource__, __PLLM__, __PLLN__, __PLLP__, __PLLQ__) \
  1858. (RCC->PLLCFGR = (0x20000000 | (__RCC_PLLSource__) | (__PLLM__)| \
  1859. ((__PLLN__) << POSITION_VAL(RCC_PLLCFGR_PLLN)) | \
  1860. ((((__PLLP__) >> 1) -1) << POSITION_VAL(RCC_PLLCFGR_PLLP)) | \
  1861. ((__PLLQ__) << POSITION_VAL(RCC_PLLCFGR_PLLQ))))
  1862. #endif /* STM32F446xx */
  1863. /*-------------------------------------------------------------------------------------------------------*/
  1864. /*------------------------------------------- PLLI2S Configuration --------------------------------------*/
  1865. #if defined(STM32F446xx)
  1866. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  1867. * @note This macro must be used only when the PLLI2S is disabled.
  1868. * @note PLLI2S clock source is common with the main PLL (configured in
  1869. * HAL_RCC_ClockConfig() API).
  1870. * @param __PLLI2SM__: specifies the division factor for PLLI2S VCO input clock
  1871. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  1872. * @note You have to set the PLLI2SM parameter correctly to ensure that the VCO input
  1873. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  1874. * of 1 MHz to limit PLLI2S jitter.
  1875. * @note The PLLI2SM parameter is only used with STM32F411xE and STM32F446xx Devices
  1876. *
  1877. * @param __PLLI2SN__: specifies the multiplication factor for PLLI2S VCO output clock
  1878. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1879. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  1880. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  1881. *
  1882. * @param __PLLI2SP__: specifies division factor for SPDIFRX Clock.
  1883. * This parameter must be a number in the range {2, 4, 6, or 8}.
  1884. * @note the PLLI2SP parameter is only available with STM32F446xx Devices
  1885. *
  1886. * @param __PLLI2SR__: specifies the division factor for I2S clock
  1887. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  1888. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  1889. * on the I2S clock frequency.
  1890. *
  1891. * @param __PLLI2SQ__: specifies the division factor for SAI clock
  1892. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  1893. * @note the PLLI2SQ parameter is only available with STM32F427/437/429x/439xx Devices
  1894. *
  1895. */
  1896. #define __HAL_RCC_PLLI2S_CONFIG(__PLLI2SM__, __PLLI2SN__, __PLLI2SP__, __PLLI2SQ__, __PLLI2SR__) \
  1897. (RCC->PLLI2SCFGR = ((__PLLI2SM__) |\
  1898. ((__PLLI2SN__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SN)) |\
  1899. ((((__PLLI2SP__) >> 1) -1) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SP)) |\
  1900. ((__PLLI2SQ__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SQ)) |\
  1901. ((__PLLI2SR__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SR))))
  1902. #else
  1903. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  1904. * @note This macro must be used only when the PLLI2S is disabled.
  1905. * @note PLLI2S clock source is common with the main PLL (configured in
  1906. * HAL_RCC_ClockConfig() API).
  1907. * @param __PLLI2SN__: specifies the multiplication factor for PLLI2S VCO output clock
  1908. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1909. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  1910. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  1911. * @param __PLLI2SR__: specifies the division factor for I2S clock
  1912. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  1913. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  1914. * on the I2S clock frequency.
  1915. *
  1916. */
  1917. #define __HAL_RCC_PLLI2S_CONFIG(__PLLI2SN__, __PLLI2SR__) \
  1918. (RCC->PLLI2SCFGR = (((__PLLI2SN__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SN)) | \
  1919. ((__PLLI2SR__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SR))))
  1920. #endif /* STM32F446xx */
  1921. #if defined(STM32F411xE)
  1922. /** @brief Macro to configure the PLLI2S clock multiplication and division factors .
  1923. * @note This macro must be used only when the PLLI2S is disabled.
  1924. * @note This macro must be used only when the PLLI2S is disabled.
  1925. * @note PLLI2S clock source is common with the main PLL (configured in
  1926. * HAL_RCC_ClockConfig() API).
  1927. * @param __PLLI2SM__: specifies the division factor for PLLI2S VCO input clock
  1928. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  1929. * @note The PLLI2SM parameter is only used with STM32F411xE Devices
  1930. * @note You have to set the PLLI2SM parameter correctly to ensure that the VCO input
  1931. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  1932. * of 2 MHz to limit PLLI2S jitter.
  1933. * @param __PLLI2SN__: specifies the multiplication factor for PLLI2S VCO output clock
  1934. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1935. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  1936. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  1937. * @param __PLLI2SR__: specifies the division factor for I2S clock
  1938. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  1939. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  1940. * on the I2S clock frequency.
  1941. */
  1942. #define __HAL_RCC_PLLI2S_I2SCLK_CONFIG(__PLLI2SM__, __PLLI2SN__, __PLLI2SR__) (RCC->PLLI2SCFGR = ((__PLLI2SM__) |\
  1943. ((__PLLI2SN__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SN)) |\
  1944. ((__PLLI2SR__) << POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SR))))
  1945. #endif /* STM32F411xE */
  1946. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  1947. /** @brief Macro used by the SAI HAL driver to configure the PLLI2S clock multiplication and division factors.
  1948. * @note This macro must be used only when the PLLI2S is disabled.
  1949. * @note PLLI2S clock source is common with the main PLL (configured in
  1950. * HAL_RCC_ClockConfig() API)
  1951. * @param __PLLI2SN__: specifies the multiplication factor for PLLI2S VCO output clock.
  1952. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1953. * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
  1954. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  1955. * @param __PLLI2SQ__: specifies the division factor for SAI1 clock.
  1956. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  1957. * @note the PLLI2SQ parameter is only available with STM32F427xx/437xx/429xx/439xx Devices
  1958. * and can be configured using the __HAL_RCC_PLLI2S_PLLSAICLK_CONFIG() macro
  1959. * @param __PLLI2SR__: specifies the division factor for I2S clock
  1960. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  1961. * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
  1962. * on the I2S clock frequency.
  1963. */
  1964. #define __HAL_RCC_PLLI2S_SAICLK_CONFIG(__PLLI2SN__, __PLLI2SQ__, __PLLI2SR__) (RCC->PLLI2SCFGR = ((__PLLI2SN__) << 6) |\
  1965. ((__PLLI2SQ__) << 24) |\
  1966. ((__PLLI2SR__) << 28))
  1967. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  1968. /*----------------------------------------------------------------------------------------------------------------*/
  1969. /*--------------------------------------------------- PLLSAI Configuration ---------------------------------------*/
  1970. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx)
  1971. /** @brief Macros to Enable or Disable the PLLISAI.
  1972. * @note The PLLSAI is only available with STM32F429x/439x Devices.
  1973. * @note The PLLSAI is disabled by hardware when entering STOP and STANDBY modes.
  1974. */
  1975. #define __HAL_RCC_PLLSAI_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLSAION_BB = ENABLE)
  1976. #define __HAL_RCC_PLLSAI_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLSAION_BB = DISABLE)
  1977. #if defined(STM32F446xx)
  1978. /** @brief Macro to configure the PLLSAI clock multiplication and division factors.
  1979. *
  1980. * @param __PLLSAIM__: specifies the division factor for PLLSAI VCO input clock
  1981. * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
  1982. * @note You have to set the PLLSAIM parameter correctly to ensure that the VCO input
  1983. * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
  1984. * of 1 MHz to limit PLLI2S jitter.
  1985. * @note The PLLSAIM parameter is only used with STM32F446xx Devices
  1986. *
  1987. * @param __PLLSAIN__: specifies the multiplication factor for PLLSAI VCO output clock.
  1988. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  1989. * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
  1990. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  1991. *
  1992. * @param __PLLSAIP__: specifies division factor for OTG FS, SDIO and RNG clocks.
  1993. * This parameter must be a number in the range {2, 4, 6, or 8}.
  1994. * @note the PLLSAIP parameter is only available with STM32F446xx Devices
  1995. *
  1996. * @param __PLLSAIQ__: specifies the division factor for SAI clock
  1997. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  1998. *
  1999. * @param __PLLSAIR__: specifies the division factor for LTDC clock
  2000. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  2001. * @note the PLLI2SR parameter is only available with STM32F427/437/429/439xx Devices
  2002. */
  2003. #define __HAL_RCC_PLLSAI_CONFIG(__PLLSAIM__, __PLLSAIN__, __PLLSAIP__, __PLLSAIQ__, __PLLSAIR__) \
  2004. (RCC->PLLSAICFGR = ((__PLLSAIM__) | \
  2005. ((__PLLSAIN__) << POSITION_VAL(RCC_PLLSAICFGR_PLLSAIN)) | \
  2006. ((((__PLLSAIP__) >> 1) -1) << POSITION_VAL(RCC_PLLSAICFGR_PLLSAIP)) | \
  2007. ((__PLLSAIQ__) << POSITION_VAL(RCC_PLLSAICFGR_PLLSAIQ))))
  2008. #endif /* STM32F446xx */
  2009. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  2010. /** @brief Macro to configure the PLLSAI clock multiplication and division factors.
  2011. *
  2012. * @param __PLLSAIN__: specifies the multiplication factor for PLLSAI VCO output clock.
  2013. * This parameter must be a number between Min_Data = 192 and Max_Data = 432.
  2014. * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
  2015. * output frequency is between Min_Data = 192 and Max_Data = 432 MHz.
  2016. *
  2017. * @param __PLLSAIQ__: specifies the division factor for SAI clock
  2018. * This parameter must be a number between Min_Data = 2 and Max_Data = 15.
  2019. *
  2020. * @param __PLLSAIR__: specifies the division factor for LTDC clock
  2021. * This parameter must be a number between Min_Data = 2 and Max_Data = 7.
  2022. * @note the PLLI2SR parameter is only available with STM32F427/437/429/439xx Devices
  2023. */
  2024. #define __HAL_RCC_PLLSAI_CONFIG(__PLLSAIN__, __PLLSAIQ__, __PLLSAIR__) \
  2025. (RCC->PLLSAICFGR = (((__PLLSAIN__) << POSITION_VAL(RCC_PLLSAICFGR_PLLSAIN)) | \
  2026. ((__PLLSAIQ__) << POSITION_VAL(RCC_PLLSAICFGR_PLLSAIQ)) | \
  2027. ((__PLLSAIR__) << POSITION_VAL(RCC_PLLSAICFGR_PLLSAIR))))
  2028. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  2029. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx */
  2030. /*----------------------------------------------------------------------------------------------------------------------*/
  2031. /*----------------------------------------- PLLSAI/PLLI2S Dividers Configuration ---------------------------------------*/
  2032. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx)
  2033. /** @brief Macro to configure the SAI clock Divider coming from PLLI2S.
  2034. * @note This function must be called before enabling the PLLI2S.
  2035. * @param __PLLI2SDivQ__: specifies the PLLI2S division factor for SAI1 clock .
  2036. * This parameter must be a number between 1 and 32.
  2037. * SAI1 clock frequency = f(PLLI2SQ) / __PLLI2SDivQ__
  2038. */
  2039. #define __HAL_RCC_PLLI2S_PLLSAICLKDIVQ_CONFIG(__PLLI2SDivQ__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLI2SDIVQ, (__PLLI2SDivQ__)-1))
  2040. /** @brief Macro to configure the SAI clock Divider coming from PLLSAI.
  2041. * @note This function must be called before enabling the PLLSAI.
  2042. * @param __PLLSAIDivQ__: specifies the PLLSAI division factor for SAI1 clock .
  2043. * This parameter must be a number between Min_Data = 1 and Max_Data = 32.
  2044. * SAI1 clock frequency = f(PLLSAIQ) / __PLLSAIDivQ__
  2045. */
  2046. #define __HAL_RCC_PLLSAI_PLLSAICLKDIVQ_CONFIG(__PLLSAIDivQ__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVQ, ((__PLLSAIDivQ__)-1)<<8))
  2047. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx */
  2048. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  2049. /** @brief Macro to configure the LTDC clock Divider coming from PLLSAI.
  2050. *
  2051. * @note The LTDC peripheral is only available with STM32F427/437/429/439xx Devices.
  2052. * @note This function must be called before enabling the PLLSAI.
  2053. * @param __PLLSAIDivR__: specifies the PLLSAI division factor for LTDC clock .
  2054. * This parameter must be a number between Min_Data = 2 and Max_Data = 16.
  2055. * LTDC clock frequency = f(PLLSAIR) / __PLLSAIDivR__
  2056. */
  2057. #define __HAL_RCC_PLLSAI_PLLSAICLKDIVR_CONFIG(__PLLSAIDivR__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVR, (__PLLSAIDivR__)))
  2058. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  2059. /*-----------------------------------------------------------------------------------------------------------------------------------*/
  2060. /*-------------------------------------------------- Peripheral Clock selection -----------------------------------------------------*/
  2061. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
  2062. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  2063. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  2064. /** @brief Macro to configure the I2S clock source (I2SCLK).
  2065. * @note This function must be called before enabling the I2S APB clock.
  2066. * @param __SOURCE__: specifies the I2S clock source.
  2067. * This parameter can be one of the following values:
  2068. * @arg RCC_I2SCLKSOURCE_PLLI2S: PLLI2S clock used as I2S clock source.
  2069. * @arg RCC_I2SCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin
  2070. * used as I2S clock source.
  2071. */
  2072. #define __HAL_RCC_I2S_CONFIG(__SOURCE__) (*(__IO uint32_t *) RCC_CFGR_I2SSRC_BB = (__SOURCE__))
  2073. #endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx */
  2074. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  2075. /** @brief Macro to configure SAI1BlockA clock source selection.
  2076. * @note The SAI peripheral is only available with STM32F427/437/429/439xx Devices.
  2077. * @note This function must be called before enabling PLLSAI, PLLI2S and
  2078. * the SAI clock.
  2079. * @param __SOURCE__: specifies the SAI Block A clock source.
  2080. * This parameter can be one of the following values:
  2081. * @arg RCC_SAIACLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used
  2082. * as SAI1 Block A clock.
  2083. * @arg RCC_SAIACLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used
  2084. * as SAI1 Block A clock.
  2085. * @arg RCC_SAIACLKSOURCE_Ext: External clock mapped on the I2S_CKIN pin
  2086. * used as SAI1 Block A clock.
  2087. */
  2088. #define __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1ASRC, (__SOURCE__)))
  2089. /** @brief Macro to configure SAI1BlockB clock source selection.
  2090. * @note The SAI peripheral is only available with STM32F427/437/429/439xx Devices.
  2091. * @note This function must be called before enabling PLLSAI, PLLI2S and
  2092. * the SAI clock.
  2093. * @param __SOURCE__: specifies the SAI Block B clock source.
  2094. * This parameter can be one of the following values:
  2095. * @arg RCC_SAIBCLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used
  2096. * as SAI1 Block B clock.
  2097. * @arg RCC_SAIBCLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used
  2098. * as SAI1 Block B clock.
  2099. * @arg RCC_SAIBCLKSOURCE_Ext: External clock mapped on the I2S_CKIN pin
  2100. * used as SAI1 Block B clock.
  2101. */
  2102. #define __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1BSRC, (__SOURCE__)))
  2103. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  2104. #if defined(STM32F446xx)
  2105. /** @brief Macro to configure SAI1 clock source selection.
  2106. * @note This configuration is only available with STM32F446xx Devices.
  2107. * @note This function must be called before enabling PLL, PLLSAI, PLLI2S and
  2108. * the SAI clock.
  2109. * @param __SOURCE__: specifies the SAI1 clock source.
  2110. * This parameter can be one of the following values:
  2111. * @arg RCC_SAI1CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI1 clock.
  2112. * @arg RCC_SAI1CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI1 clock.
  2113. * @arg RCC_SAI1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  2114. * @arg RCC_SAI1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  2115. */
  2116. #define __HAL_RCC_SAI1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI1SRC, (__SOURCE__)))
  2117. /** @brief Macro to Get SAI1 clock source selection.
  2118. * @note This configuration is only available with STM32F446xx Devices.
  2119. * @retval The clock source can be one of the following values:
  2120. * @arg RCC_SAI1CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI1 clock.
  2121. * @arg RCC_SAI1CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI1 clock.
  2122. * @arg RCC_SAI1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  2123. * @arg RCC_SAI1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  2124. */
  2125. #define __HAL_RCC_GET_SAI1_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SAI1SRC))
  2126. /** @brief Macro to configure SAI2 clock source selection.
  2127. * @note This configuration is only available with STM32F446xx Devices.
  2128. * @note This function must be called before enabling PLL, PLLSAI, PLLI2S and
  2129. * the SAI clock.
  2130. * @param __SOURCE__: specifies the SAI2 clock source.
  2131. * This parameter can be one of the following values:
  2132. * @arg RCC_SAI2CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI2 clock.
  2133. * @arg RCC_SAI2CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI2 clock.
  2134. * @arg RCC_SAI2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI2 clock.
  2135. * @arg RCC_SAI2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL Source clock used as SAI2 clock.
  2136. */
  2137. #define __HAL_RCC_SAI2_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SAI2SRC, (__SOURCE__)))
  2138. /** @brief Macro to Get SAI2 clock source selection.
  2139. * @note This configuration is only available with STM32F446xx Devices.
  2140. * @retval The clock source can be one of the following values:
  2141. * @arg RCC_SAI2CLKSOURCE_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used as SAI2 clock.
  2142. * @arg RCC_SAI2CLKSOURCE_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used as SAI2 clock.
  2143. * @arg RCC_SAI2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI2 clock.
  2144. * @arg RCC_SAI2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL Source clock used as SAI2 clock.
  2145. */
  2146. #define __HAL_RCC_GET_SAI2_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SAI2SRC))
  2147. /** @brief Macro to configure I2S APB1 clock source selection.
  2148. * @note This configuration is only available with STM32F446xx Devices.
  2149. * @note This function must be called before enabling PLL, PLLI2S and the I2S clock.
  2150. * @param __SOURCE__: specifies the I2S APB1 clock source.
  2151. * This parameter can be one of the following values:
  2152. * @arg RCC_I2SAPB1CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  2153. * @arg RCC_I2SAPB1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  2154. * @arg RCC_I2SAPB1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  2155. * @arg RCC_I2SAPB1CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  2156. */
  2157. #define __HAL_RCC_I2S_APB1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_I2S1SRC, (__SOURCE__)))
  2158. /** @brief Macro to Get I2S APB1 clock source selection.
  2159. * @note This configuration is only available with STM32F446xx Devices.
  2160. * @retval The clock source can be one of the following values:
  2161. * @arg RCC_I2SAPB1CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  2162. * @arg RCC_I2SAPB1CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  2163. * @arg RCC_I2SAPB1CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  2164. * @arg RCC_I2SAPB1CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  2165. */
  2166. #define __HAL_RCC_GET_I2S_APB1_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_I2S1SRC))
  2167. /** @brief Macro to configure I2S APB2 clock source selection.
  2168. * @note This configuration is only available with STM32F446xx Devices.
  2169. * @note This function must be called before enabling PLL, PLLI2S and the I2S clock.
  2170. * @param __SOURCE__: specifies the SAI Block A clock source.
  2171. * This parameter can be one of the following values:
  2172. * @arg RCC_I2SAPB2CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  2173. * @arg RCC_I2SAPB2CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  2174. * @arg RCC_I2SAPB2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  2175. * @arg RCC_I2SAPB2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  2176. */
  2177. #define __HAL_RCC_I2S_APB2_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_I2S2SRC, (__SOURCE__)))
  2178. /** @brief Macro to Get I2S APB2 clock source selection.
  2179. * @note This configuration is only available with STM32F446xx Devices.
  2180. * @retval The clock source can be one of the following values:
  2181. * @arg RCC_I2SAPB2CLKSOURCE_PLLI2S: PLLI2S VCO output clock divided by PLLI2SR used as I2S clock.
  2182. * @arg RCC_I2SAPB2CLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin used as SAI1 clock.
  2183. * @arg RCC_I2SAPB2CLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SAI1 clock.
  2184. * @arg RCC_I2SAPB2CLKSOURCE_PLLSRC: HSI or HSE depending from PLL source Clock.
  2185. */
  2186. #define __HAL_RCC_GET_I2S_APB2_SOURCE() (READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_I2S2SRC))
  2187. /** @brief Macro to configure the CEC clock.
  2188. * @param __SOURCE__: specifies the CEC clock source.
  2189. * This parameter can be one of the following values:
  2190. * @arg RCC_CECCLKSOURCE_HSI: HSI selected as CEC clock
  2191. * @arg RCC_CECCLKSOURCE_LSE: LSE selected as CEC clock
  2192. */
  2193. #define __HAL_RCC_CEC_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CECSEL, (uint32_t)(__SOURCE__)))
  2194. /** @brief Macro to Get the CEC clock.
  2195. * @retval The clock source can be one of the following values:
  2196. * @arg RCC_CECCLKSOURCE_HSI488: HSI selected as CEC clock
  2197. * @arg RCC_CECCLKSOURCE_LSE: LSE selected as CEC clock
  2198. */
  2199. #define __HAL_RCC_GET_CEC_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CECSEL))
  2200. /** @brief Macro to configure the FMPI2C1 clock.
  2201. * @param __SOURCE__: specifies the FMPI2C1 clock source.
  2202. * This parameter can be one of the following values:
  2203. * @arg RCC_FMPI2C1CLKSOURCE_APB: APB selected as CEC clock
  2204. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as CEC clock
  2205. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as CEC clock
  2206. */
  2207. #define __HAL_RCC_FMPI2C1_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL, (uint32_t)(__SOURCE__)))
  2208. /** @brief Macro to Get the FMPI2C1 clock.
  2209. * @retval The clock source can be one of the following values:
  2210. * @arg RCC_FMPI2C1CLKSOURCE_APB: APB selected as CEC clock
  2211. * @arg RCC_FMPI2C1CLKSOURCE_SYSCLK: SYS clock selected as CEC clock
  2212. * @arg RCC_FMPI2C1CLKSOURCE_HSI: HSI selected as CEC clock
  2213. */
  2214. #define __HAL_RCC_GET_FMPI2C1_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL))
  2215. /** @brief Macro to configure the CLK48 clock.
  2216. * @param __SOURCE__: specifies the CK48 clock source.
  2217. * This parameter can be one of the following values:
  2218. * @arg RCC_CK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CK48 clock.
  2219. * @arg RCC_CK48CLKSOURCE_PLLSAIP: PLLSAI VCO Output divided by PLLSAIP used as CK48 clock.
  2220. */
  2221. #define __HAL_RCC_CLK48_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL, (uint32_t)(__SOURCE__)))
  2222. /** @brief Macro to Get the CLK48 clock.
  2223. * @retval The clock source can be one of the following values:
  2224. * @arg RCC_CK48CLKSOURCE_PLLQ: PLL VCO Output divided by PLLQ used as CK48 clock.
  2225. * @arg RCC_CK48CLKSOURCE_PLLSAIP: PLLSAI VCO Output divided by PLLSAIP used as CK48 clock.
  2226. */
  2227. #define __HAL_RCC_GET_CLK48_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL))
  2228. /** @brief Macro to configure the SDIO clock.
  2229. * @param __SOURCE__: specifies the SDIO clock source.
  2230. * This parameter can be one of the following values:
  2231. * @arg RCC_SDIOCLKSOURCE_CK48: CK48 output used as SDIO clock.
  2232. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  2233. */
  2234. #define __HAL_RCC_SDIO_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL, (uint32_t)(__SOURCE__)))
  2235. /** @brief Macro to Get the SDIO clock.
  2236. * @retval The clock source can be one of the following values:
  2237. * @arg RCC_SDIOCLKSOURCE_CK48: CK48 output used as SDIO clock.
  2238. * @arg RCC_SDIOCLKSOURCE_SYSCLK: System clock output used as SDIO clock.
  2239. */
  2240. #define __HAL_RCC_GET_SDIO_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL))
  2241. /** @brief Macro to configure the SPDIFRX clock.
  2242. * @param __SOURCE__: specifies the SPDIFRX clock source.
  2243. * This parameter can be one of the following values:
  2244. * @arg RCC_SPDIFRXCLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SPDIFRX clock.
  2245. * @arg RCC_SPDIFRXCLKSOURCE_PLLI2SP: PLLI2S VCO Output divided by PLLI2SP used as SPDIFRX clock.
  2246. */
  2247. #define __HAL_RCC_SPDIFRX_CONFIG(__SOURCE__) (MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SPDIFRXSEL, (uint32_t)(__SOURCE__)))
  2248. /** @brief Macro to Get the SPDIFRX clock.
  2249. * @retval The clock source can be one of the following values:
  2250. * @arg RCC_SPDIFRXCLKSOURCE_PLLR: PLL VCO Output divided by PLLR used as SPDIFRX clock.
  2251. * @arg RCC_SPDIFRXCLKSOURCE_PLLI2SP: PLLI2S VCO Output divided by PLLI2SP used as SPDIFRX clock.
  2252. */
  2253. #define __HAL_RCC_GET_SPDIFRX_SOURCE() (READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SPDIFRXSEL))
  2254. #endif /* STM32F446xx */
  2255. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  2256. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
  2257. /** @brief Macro to configure the Timers clocks prescalers
  2258. * @note This feature is only available with STM32F429x/439x Devices.
  2259. * @param __PRESC__ : specifies the Timers clocks prescalers selection
  2260. * This parameter can be one of the following values:
  2261. * @arg RCC_TIMPRES_DESACTIVATED: The Timers kernels clocks prescaler is
  2262. * equal to HPRE if PPREx is corresponding to division by 1 or 2,
  2263. * else it is equal to [(HPRE * PPREx) / 2] if PPREx is corresponding to
  2264. * division by 4 or more.
  2265. * @arg RCC_TIMPRES_ACTIVATED: The Timers kernels clocks prescaler is
  2266. * equal to HPRE if PPREx is corresponding to division by 1, 2 or 4,
  2267. * else it is equal to [(HPRE * PPREx) / 4] if PPREx is corresponding
  2268. * to division by 8 or more.
  2269. */
  2270. #define __HAL_RCC_TIMCLKPRESCALER(__PRESC__) (*(__IO uint32_t *) RCC_DCKCFGR_TIMPRE_BB = (__PRESC__))
  2271. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx) || STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx */
  2272. /*-------------------------------------------------------------------------------------------------------------------*/
  2273. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx)
  2274. /** @brief Enable PLLSAI_RDY interrupt.
  2275. */
  2276. #define __HAL_RCC_PLLSAI_ENABLE_IT() (RCC->CIR |= (RCC_CIR_PLLSAIRDYIE))
  2277. /** @brief Disable PLLSAI_RDY interrupt.
  2278. */
  2279. #define __HAL_RCC_PLLSAI_DISABLE_IT() (RCC->CIR &= ~(RCC_CIR_PLLSAIRDYIE))
  2280. /** @brief Clear the PLLSAI RDY interrupt pending bits.
  2281. */
  2282. #define __HAL_RCC_PLLSAI_CLEAR_IT() (RCC->CIR |= (RCC_CIR_PLLSAIRDYF))
  2283. /** @brief Check the PLLSAI RDY interrupt has occurred or not.
  2284. * @retval The new state (TRUE or FALSE).
  2285. */
  2286. #define __HAL_RCC_PLLSAI_GET_IT() ((RCC->CIR & (RCC_CIR_PLLSAIRDYIE)) == (RCC_CIR_PLLSAIRDYIE))
  2287. /** @brief Check PLLSAI RDY flag is set or not.
  2288. * @retval The new state (TRUE or FALSE).
  2289. */
  2290. #define __HAL_RCC_PLLSAI_GET_FLAG() ((RCC->CR & (RCC_CR_PLLSAIRDY)) == (RCC_CR_PLLSAIRDY))
  2291. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx */
  2292. /**
  2293. * @}
  2294. */
  2295. /* Exported functions --------------------------------------------------------*/
  2296. /** @addtogroup RCCEx_Exported_Functions
  2297. * @{
  2298. */
  2299. /** @addtogroup RCCEx_Exported_Functions_Group1
  2300. * @{
  2301. */
  2302. HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  2303. void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
  2304. #if defined(STM32F446xx)
  2305. uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk);
  2306. #endif /* STM32F446xx */
  2307. #if defined(STM32F411xE) || defined(STM32F446xx)
  2308. void HAL_RCCEx_SelectLSEMode(uint8_t Mode);
  2309. #endif /* STM32F411xE || STM32F446xx */
  2310. /**
  2311. * @}
  2312. */
  2313. /**
  2314. * @}
  2315. */
  2316. /* Private types -------------------------------------------------------------*/
  2317. /* Private variables ---------------------------------------------------------*/
  2318. /* Private constants ---------------------------------------------------------*/
  2319. /** @defgroup RCCEx_Private_Constants RCCEx Private Constants
  2320. * @{
  2321. */
  2322. /** @defgroup RCCEx_BitAddress_AliasRegion RCC BitAddress AliasRegion
  2323. * @brief RCC registers bit address in the alias region
  2324. * @{
  2325. */
  2326. /* --- CR Register ---*/
  2327. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx)
  2328. /* Alias word address of PLLSAION bit */
  2329. #define RCC_PLLSAION_BIT_NUMBER 0x1C
  2330. #define RCC_CR_PLLSAION_BB (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32) + (RCC_PLLSAION_BIT_NUMBER * 4))
  2331. /* --- DCKCFGR Register ---*/
  2332. /* Alias word address of TIMPRE bit */
  2333. #define RCC_DCKCFGR_OFFSET (RCC_OFFSET + 0x8C)
  2334. #define RCC_TIMPRE_BIT_NUMBER 0x18
  2335. #define RCC_DCKCFGR_TIMPRE_BB (PERIPH_BB_BASE + (RCC_DCKCFGR_OFFSET * 32) + (RCC_TIMPRE_BIT_NUMBER * 4))
  2336. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx */
  2337. #define PLL_TIMEOUT_VALUE ((uint32_t)100) /* 100 ms */
  2338. /**
  2339. * @}
  2340. */
  2341. /**
  2342. * @}
  2343. */
  2344. /* Private macros ------------------------------------------------------------*/
  2345. /** @addtogroup RCCEx_Private_Macros RCCEx Private Macros
  2346. * @{
  2347. */
  2348. /** @defgroup RCCEx_IS_RCC_Definitions RCC Private macros to check input parameters
  2349. * @{
  2350. */
  2351. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
  2352. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1 <= (SELECTION)) && ((SELECTION) <= 0x0000002F))
  2353. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  2354. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) ||\
  2355. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
  2356. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1 <= (SELECTION)) && ((SELECTION) <= 0x00000003))
  2357. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */
  2358. #if defined(STM32F446xx)
  2359. #define IS_RCC_PERIPHCLOCK(SELECTION) ((1 <= (SELECTION)) && ((SELECTION) <= 0x000007FF))
  2360. #endif /* STM32F446xx */
  2361. #define IS_RCC_PLLI2SN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
  2362. #define IS_RCC_PLLI2SR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
  2363. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F446xx)
  2364. #define IS_RCC_PLLI2SQ_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 15))
  2365. #define IS_RCC_PLLSAIN_VALUE(VALUE) ((49 <= (VALUE)) && ((VALUE) <= 432))
  2366. #define IS_RCC_PLLSAIQ_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 15))
  2367. #define IS_RCC_PLLSAIR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
  2368. #define IS_RCC_PLLSAI_DIVQ_VALUE(VALUE) ((1 <= (VALUE)) && ((VALUE) <= 32))
  2369. #define IS_RCC_PLLI2S_DIVQ_VALUE(VALUE) ((1 <= (VALUE)) && ((VALUE) <= 32))
  2370. #define IS_RCC_PLLSAI_DIVR_VALUE(VALUE) (((VALUE) == RCC_PLLSAIDIVR_2) ||\
  2371. ((VALUE) == RCC_PLLSAIDIVR_4) ||\
  2372. ((VALUE) == RCC_PLLSAIDIVR_8) ||\
  2373. ((VALUE) == RCC_PLLSAIDIVR_16))
  2374. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  2375. #if defined(STM32F446xx) || defined(STM32F411xE)
  2376. #define IS_RCC_PLLI2SM_VALUE(VALUE) ((VALUE) <= 63)
  2377. #define IS_RCC_LSE_MODE(MODE) (((MODE) == RCC_LSE_LOWPOWER_MODE) ||\
  2378. ((MODE) == RCC_LSE_HIGHDRIVE_MODE))
  2379. #endif /* STM32F446xx || STM32F411xE */
  2380. #if defined(STM32F446xx)
  2381. #define IS_RCC_PLLR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
  2382. #define IS_RCC_PLLI2SP_VALUE(VALUE) (((VALUE) == RCC_PLLI2SP_DIV2) ||\
  2383. ((VALUE) == RCC_PLLI2SP_DIV4) ||\
  2384. ((VALUE) == RCC_PLLI2SP_DIV6) ||\
  2385. ((VALUE) == RCC_PLLI2SP_DIV8))
  2386. #define IS_RCC_PLLSAIM_VALUE(VALUE) ((VALUE) <= 63)
  2387. #define IS_RCC_PLLSAIP_VALUE(VALUE) (((VALUE) == RCC_PLLSAIP_DIV2) ||\
  2388. ((VALUE) == RCC_PLLSAIP_DIV4) ||\
  2389. ((VALUE) == RCC_PLLSAIP_DIV6) ||\
  2390. ((VALUE) == RCC_PLLSAIP_DIV8))
  2391. #define IS_RCC_SAI1CLKSOURCE(SOURCE) (((SOURCE) == RCC_SAI1CLKSOURCE_PLLSAI) ||\
  2392. ((SOURCE) == RCC_SAI1CLKSOURCE_PLLI2S) ||\
  2393. ((SOURCE) == RCC_SAI1CLKSOURCE_PLLR) ||\
  2394. ((SOURCE) == RCC_SAI1CLKSOURCE_EXT))
  2395. #define IS_RCC_SAI2CLKSOURCE(SOURCE) (((SOURCE) == RCC_SAI2CLKSOURCE_PLLSAI) ||\
  2396. ((SOURCE) == RCC_SAI2CLKSOURCE_PLLI2S) ||\
  2397. ((SOURCE) == RCC_SAI2CLKSOURCE_PLLR) ||\
  2398. ((SOURCE) == RCC_SAI2CLKSOURCE_PLLSRC))
  2399. #define IS_RCC_I2SAPB1CLKSOURCE(SOURCE) (((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLI2S) ||\
  2400. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_EXT) ||\
  2401. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLR) ||\
  2402. ((SOURCE) == RCC_I2SAPB1CLKSOURCE_PLLSRC))
  2403. #define IS_RCC_I2SAPB2CLKSOURCE(SOURCE) (((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLI2S) ||\
  2404. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_EXT) ||\
  2405. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLR) ||\
  2406. ((SOURCE) == RCC_I2SAPB2CLKSOURCE_PLLSRC))
  2407. #define IS_RCC_FMPI2C1CLKSOURCE(SOURCE) (((SOURCE) == RCC_FMPI2C1CLKSOURCE_APB) ||\
  2408. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_SYSCLK) ||\
  2409. ((SOURCE) == RCC_FMPI2C1CLKSOURCE_HSI))
  2410. #define IS_RCC_CECCLKSOURCE(SOURCE) (((SOURCE) == RCC_CECCLKSOURCE_HSI) ||\
  2411. ((SOURCE) == RCC_CECCLKSOURCE_LSE))
  2412. #define IS_RCC_CK48CLKSOURCE(SOURCE) (((SOURCE) == RCC_CK48CLKSOURCE_PLLQ) ||\
  2413. ((SOURCE) == RCC_CK48CLKSOURCE_PLLSAIP))
  2414. #define IS_RCC_SDIOCLKSOURCE(SOURCE) (((SOURCE) == RCC_SDIOCLKSOURCE_CK48) ||\
  2415. ((SOURCE) == RCC_SDIOCLKSOURCE_SYSCLK))
  2416. #define IS_RCC_SPDIFRXCLKSOURCE(SOURCE) (((SOURCE) == RCC_SPDIFRXCLKSOURCE_PLLR) ||\
  2417. ((SOURCE) == RCC_SPDIFRXCLKSOURCE_PLLI2SP))
  2418. #endif /* STM32F446xx */
  2419. /**
  2420. * @}
  2421. */
  2422. /**
  2423. * @}
  2424. */
  2425. /**
  2426. * @}
  2427. */
  2428. /**
  2429. * @}
  2430. */
  2431. #ifdef __cplusplus
  2432. }
  2433. #endif
  2434. #endif /* __STM32F4xx_HAL_RCC_EX_H */
  2435. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/