12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930 |
- /*
- ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- /**
- * @file STM32H7xx/hal_lld.h
- * @brief STM32H7xx HAL subsystem low level driver header.
- * @pre This module requires the following macros to be defined in the
- * @p board.h file:
- * - STM32_LSECLK.
- * - STM32_LSEDRV.
- * - STM32_LSE_BYPASS (optionally).
- * - STM32_HSECLK.
- * - STM32_HSE_BYPASS (optionally).
- * - STM32_VDD (as hundredths of Volt).
- * .
- * One of the following macros must also be defined:
- * - STM32H743xx, STM32H753xx very high-performance MCUs.
- * .
- *
- * @addtogroup HAL
- * @{
- */
- #ifndef HAL_LLD_H
- #define HAL_LLD_H
- #include "stm32_registry.h"
- /*===========================================================================*/
- /* Driver constants. */
- /*===========================================================================*/
- /**
- * @name Platform identification macros
- * @{
- */
- #if defined(STM32H743xx) || defined(__DOXYGEN__)
- #define PLATFORM_NAME "STM32H743 Very High Performance with DSP and FPU"
- #elif defined(STM32H753xx)
- #define PLATFORM_NAME "STM32H753 Very High Performance with DSP and FPU"
- #else
- #error "STM32H7xx device not specified"
- #endif
- /** @} */
- /**
- * @name Sub-family identifier
- */
- #if !defined(STM32H7XX) || defined(__DOXYGEN__)
- #define STM32H7XX
- #endif
- /** @} */
- /**
- * @name Absolute Maximum Ratings
- * @{
- */
- /**
- * @brief Absolute maximum system clock.
- */
- #define STM32_SYSCLK_MAX 400000000
- /**
- * @brief Absolute maximum HCLK clock.
- */
- #define STM32_HCLK_MAX 200000000
- /**
- * @brief Maximum HSE clock frequency.
- */
- #define STM32_HSECLK_MAX 48000000
- /**
- * @brief Maximum HSE clock frequency using an external source.
- */
- #define STM32_HSECLK_BYP_MAX 50000000
- /**
- * @brief Minimum HSE clock frequency.
- */
- #define STM32_HSECLK_MIN 4000000
- /**
- * @brief Minimum HSE clock frequency.
- */
- #define STM32_HSECLK_BYP_MIN 4000000
- /**
- * @brief Maximum LSE clock frequency.
- */
- #define STM32_LSE_CK_MAX 32768
- /**
- * @brief Maximum LSE clock frequency.
- */
- #define STM32_LSE_CK_BYP_MAX 1000000
- /**
- * @brief Minimum LSE clock frequency.
- */
- #define STM32_LSE_CK_MIN 32768
- /**
- * @brief Minimum PLLs input clock frequency..
- */
- #define STM32_PLLIN_MIN 1000000
- /**
- * @brief PLLs input threshold frequency 1.
- */
- #define STM32_PLLIN_THRESHOLD1 2000000
- /**
- * @brief PLLs input threshold frequency 2.
- */
- #define STM32_PLLIN_THRESHOLD2 4000000
- /**
- * @brief PLLs input threshold frequency 3.
- */
- #define STM32_PLLIN_THRESHOLD3 8000000
- /**
- * @brief Maximum PLLs input clock frequency.
- */
- #define STM32_PLLIN_MAX 16000000
- /**
- * @brief Minimum PLLs VCO clock frequency.
- */
- #define STM32_PLLVCO_MIN 150000000
- /**
- * @brief Threshold PLLs clock frequency.
- */
- #define STM32_PLLVCO_THRESHOLD 420000000
- /**
- * @brief Maximum PLLs VCOH clock frequency.
- */
- #define STM32_PLLVCO_MAX 836000000
- /**
- * @brief Maximum APB1 clock frequency.
- */
- #define STM32_PCLK1_MAX (STM32_HCLK_MAX / 2)
- /**
- * @brief Maximum APB2 clock frequency.
- */
- #define STM32_PCLK2_MAX (STM32_HCLK_MAX / 2)
- /**
- * @brief Maximum APB3 clock frequency.
- */
- #define STM32_PCLK3_MAX (STM32_HCLK_MAX / 2)
- /**
- * @brief Maximum APB4 clock frequency.
- */
- #define STM32_PCLK4_MAX (STM32_HCLK_MAX / 2)
- /**
- * @brief Maximum SPI1, SPI2 and SPI3 clock frequency.
- */
- #define STM32_SPI123_MAX 133000000
- /**
- * @brief Maximum SPI4, SPI5 and SPI6 clock frequency.
- */
- #define STM32_SPI456_MAX 100000000
- /**
- * @brief Maximum ADC clock frequency.
- */
- #define STM32_ADCCLK_MAX 36000000
- /** @} */
- /**
- * @name Internal clock sources frequencies
- * @{
- */
- #define STM32_HSI_OSC 64000000
- #define STM32_HSI48_OSC 48000000
- #define STM32_CSI_OSC 4000000
- #define STM32_LSI_OSC 32000
- /** @} */
- /**
- * @name Register helpers not found in ST headers
- * @{
- */
- #define RCC_CR_HSIDIV_VALUE(n) ((n) << 3U)
- #define RCC_CFGR_SW_VALUE(n) ((n) << 0U)
- #define RCC_CFGR_RTCPRE_VALUE(n) ((n) << 8U)
- #define RCC_CFGR_MCO1PRE_VALUE(n) ((n) << 18U)
- #define RCC_CFGR_MCO1_VALUE(n) ((n) << 22U)
- #define RCC_CFGR_MCO2PRE_VALUE(n) ((n) << 25U)
- #define RCC_CFGR_MCO2_VALUE(n) ((n) << 29U)
- #define RCC_D1CFGR_D1HPRE_VALUE(n) ((n) << RCC_D1CFGR_HPRE_Pos)
- #define RCC_D1CFGR_D1CPRE_VALUE(n) ((n) << RCC_D1CFGR_D1CPRE_Pos)
- #define RCC_D1CFGR_D1PPRE3_VALUE(n) ((n) << RCC_D1CFGR_D1PPRE_Pos)
- #define RCC_D2CFGR_D2PPRE1_VALUE(n) ((n) << RCC_D2CFGR_D2PPRE1_Pos)
- #define RCC_D2CFGR_D2PPRE2_VALUE(n) ((n) << RCC_D2CFGR_D2PPRE2_Pos)
- #define RCC_D3CFGR_D3PPRE4_VALUE(n) ((n) << RCC_D3CFGR_D3PPRE_Pos)
- #define RCC_PLLCKSELR_PLLSRC_VALUE(n) ((n) << RCC_PLLCKSELR_PLLSRC_Pos)
- #define RCC_PLLCKSELR_DIVM1_VALUE(n) ((n) << RCC_PLLCKSELR_DIVM1_Pos)
- #define RCC_PLLCKSELR_DIVM2_VALUE(n) ((n) << RCC_PLLCKSELR_DIVM2_Pos)
- #define RCC_PLLCKSELR_DIVM3_VALUE(n) ((n) << RCC_PLLCKSELR_DIVM3_Pos)
- #define RCC_PLL1DIVR_DIVN1_VALUE(n) ((n) << RCC_PLL1DIVR_N1)
- #define RCC_PLL1DIVR_DIVP1_VALUE(n) ((n) << RCC_PLL1DIVR_P1)
- #define RCC_PLL1DIVR_DIVQ1_VALUE(n) ((n) << RCC_PLL1DIVR_Q1)
- #define RCC_PLL1DIVR_DIVR1_VALUE(n) ((n) << RCC_PLL1DIVR_R1)
- #define RCC_PLL1FRACR_FRACN1_VALUE(n) ((n) << RCC_PLL1FRACR_FRACN1_Pos)
- #define RCC_PLL2DIVR_DIVN2_VALUE(n) ((n) << RCC_PLL2DIVR_N2)
- #define RCC_PLL2DIVR_DIVP2_VALUE(n) ((n) << RCC_PLL2DIVR_P2)
- #define RCC_PLL2DIVR_DIVQ2_VALUE(n) ((n) << RCC_PLL2DIVR_Q2)
- #define RCC_PLL2DIVR_DIVR2_VALUE(n) ((n) << RCC_PLL2DIVR_R2)
- #define RCC_PLL2FRACR_FRACN2_VALUE(n) ((n) << RCC_PLL2FRACR_FRACN2_Pos)
- #define RCC_PLL3DIVR_DIVN3_VALUE(n) ((n) << RCC_PLL3DIVR_N3)
- #define RCC_PLL3DIVR_DIVP3_VALUE(n) ((n) << RCC_PLL3DIVR_P3)
- #define RCC_PLL3DIVR_DIVQ3_VALUE(n) ((n) << RCC_PLL3DIVR_Q3)
- #define RCC_PLL3DIVR_DIVR3_VALUE(n) ((n) << RCC_PLL3DIVR_R3)
- #define RCC_PLL3FRACR_FRACN3_VALUE(n) ((n) << RCC_PLL3FRACR_FRACN3_Pos)
- #define RCC_D1CCIPR_CKPERSEL_VALUE(n) ((n) << RCC_D1CCIPR_CKPERSEL_Pos)
- #define RCC_D1CCIPR_SDMMCSEL_VALUE(n) ((n) << RCC_D1CCIPR_SDMMCSEL_Pos)
- #define RCC_D1CCIPR_QSPISEL_VALUE(n) ((n) << RCC_D1CCIPR_QSPISEL_Pos)
- #define RCC_D1CCIPR_FMCSEL_VALUE(n) ((n) << RCC_D1CCIPR_FMCSEL_Pos)
- #define RCC_D2CCIP1R_SWPSEL_VALUE(n) ((n) << RCC_D2CCIP1R_SWPSEL_Pos)
- #define RCC_D2CCIP1R_FDCANSEL_VALUE(n) ((n) << RCC_D2CCIP1R_FDCANSEL_Pos)
- #define RCC_D2CCIP1R_DFSDM1SEL_VALUE(n) ((n) << RCC_D2CCIP1R_DFSDM1SEL_Pos)
- #define RCC_D2CCIP1R_SPDIFSEL_VALUE(n) ((n) << RCC_D2CCIP1R_SPDIFSEL_Pos)
- #define RCC_D2CCIP1R_SPI45SEL_VALUE(n) ((n) << RCC_D2CCIP1R_SPI45SEL_Pos)
- #define RCC_D2CCIP1R_SPI123SEL_VALUE(n) ((n) << RCC_D2CCIP1R_SPI123SEL_Pos)
- #define RCC_D2CCIP1R_SAI23SEL_VALUE(n) ((n) << RCC_D2CCIP1R_SAI23SEL_Pos)
- #define RCC_D2CCIP1R_SAI1SEL_VALUE(n) ((n) << RCC_D2CCIP1R_SAI1SEL_Pos)
- #define RCC_D2CCIP2R_LPTIM1SEL_VALUE(n) ((n) << RCC_D2CCIP2R_LPTIM1SEL_Pos)
- #define RCC_D2CCIP2R_CECSEL_VALUE(n) ((n) << RCC_D2CCIP2R_CECSEL_Pos)
- #define RCC_D2CCIP2R_USBSEL_VALUE(n) ((n) << RCC_D2CCIP2R_USBSEL_Pos)
- #define RCC_D2CCIP2R_I2C123SEL_VALUE(n) ((n) << RCC_D2CCIP2R_I2C123SEL_Pos)
- #define RCC_D2CCIP2R_RNGSEL_VALUE(n) ((n) << RCC_D2CCIP2R_RNGSEL_Pos)
- #define RCC_D2CCIP2R_USART16SEL_VALUE(n) ((n) << RCC_D2CCIP2R_USART16SEL_Pos)
- #define RCC_D2CCIP2R_USART234578SEL_VALUE(n) ((n) << RCC_D2CCIP2R_USART28SEL_Pos)
- #define RCC_D3CCIPR_SPI6SEL_VALUE(n) ((n) << RCC_D3CCIPR_SPI6SEL_Pos)
- #define RCC_D3CCIPR_SAI4BSEL_VALUE(n) ((n) << RCC_D3CCIPR_SAI4BSEL_Pos)
- #define RCC_D3CCIPR_SAI4ASEL_VALUE(n) ((n) << RCC_D3CCIPR_SAI4ASEL_Pos)
- #define RCC_D3CCIPR_ADCSEL_VALUE(n) ((n) << RCC_D3CCIPR_ADCSEL_Pos)
- #define RCC_D3CCIPR_LPTIM345SEL_VALUE(n) ((n) << RCC_D3CCIPR_LPTIM345SEL_Pos)
- #define RCC_D3CCIPR_LPTIM2SEL_VALUE(n) ((n) << RCC_D3CCIPR_LPTIM2SEL_Pos)
- #define RCC_D3CCIPR_I2C4SEL_VALUE(n) ((n) << RCC_D3CCIPR_I2C4SEL_Pos)
- #define RCC_D3CCIPR_LPUART1SEL_VALUE(n) ((n) << RCC_D3CCIPR_LPUART1SEL_Pos)
- #define RCC_BDCR_RTCSEL_VALUE(n) ((n) << RCC_BDCR_RTCSEL_Pos)
- /** @} */
- /**
- * @name Configuration switches to be used in @p mcuconf.h
- * @{
- */
- #define STM32_VOS_SCALE3 (PWR_D3CR_VOS_0)
- #define STM32_VOS_SCALE2 (PWR_D3CR_VOS_1)
- #define STM32_VOS_SCALE1 (PWR_D3CR_VOS_1 | PWR_D3CR_VOS_0)
- #define STM32_SW_HSI_CK RCC_CFGR_SW_VALUE(0U)
- #define STM32_SW_CSI_CK RCC_CFGR_SW_VALUE(1U)
- #define STM32_SW_HSE_CK RCC_CFGR_SW_VALUE(2U)
- #define STM32_SW_PLL1_P_CK RCC_CFGR_SW_VALUE(3U)
- #define STM32_D1CPRE_DIV1 RCC_D1CFGR_D1CPRE_VALUE(0U)
- #define STM32_D1CPRE_DIV2 RCC_D1CFGR_D1CPRE_VALUE(8U)
- #define STM32_D1CPRE_DIV4 RCC_D1CFGR_D1CPRE_VALUE(9U)
- #define STM32_D1CPRE_DIV8 RCC_D1CFGR_D1CPRE_VALUE(10U)
- #define STM32_D1CPRE_DIV16 RCC_D1CFGR_D1CPRE_VALUE(11U)
- #define STM32_D1CPRE_DIV64 RCC_D1CFGR_D1CPRE_VALUE(12U)
- #define STM32_D1CPRE_DIV128 RCC_D1CFGR_D1CPRE_VALUE(13U)
- #define STM32_D1CPRE_DIV256 RCC_D1CFGR_D1CPRE_VALUE(14U)
- #define STM32_D1CPRE_DIV512 RCC_D1CFGR_D1CPRE_VALUE(15U)
- #define STM32_D1HPRE_DIV1 RCC_D1CFGR_D1HPRE_VALUE(0U)
- #define STM32_D1HPRE_DIV2 RCC_D1CFGR_D1HPRE_VALUE(8U)
- #define STM32_D1HPRE_DIV4 RCC_D1CFGR_D1HPRE_VALUE(9U)
- #define STM32_D1HPRE_DIV8 RCC_D1CFGR_D1HPRE_VALUE(10U)
- #define STM32_D1HPRE_DIV16 RCC_D1CFGR_D1HPRE_VALUE(11U)
- #define STM32_D1HPRE_DIV64 RCC_D1CFGR_D1HPRE_VALUE(12U)
- #define STM32_D1HPRE_DIV128 RCC_D1CFGR_D1HPRE_VALUE(13U)
- #define STM32_D1HPRE_DIV256 RCC_D1CFGR_D1HPRE_VALUE(14U)
- #define STM32_D1HPRE_DIV512 RCC_D1CFGR_D1HPRE_VALUE(15U)
- #define STM32_D1PPRE3_DIV1 RCC_D1CFGR_D1PPRE3_VALUE(0U)
- #define STM32_D1PPRE3_DIV2 RCC_D1CFGR_D1PPRE3_VALUE(4U)
- #define STM32_D1PPRE3_DIV4 RCC_D1CFGR_D1PPRE3_VALUE(5U)
- #define STM32_D1PPRE3_DIV8 RCC_D1CFGR_D1PPRE3_VALUE(6U)
- #define STM32_D1PPRE3_DIV16 RCC_D1CFGR_D1PPRE3_VALUE(7U)
- #define STM32_D2PPRE1_DIV1 RCC_D2CFGR_D2PPRE1_VALUE(0U)
- #define STM32_D2PPRE1_DIV2 RCC_D2CFGR_D2PPRE1_VALUE(4U)
- #define STM32_D2PPRE1_DIV4 RCC_D2CFGR_D2PPRE1_VALUE(5U)
- #define STM32_D2PPRE1_DIV8 RCC_D2CFGR_D2PPRE1_VALUE(6U)
- #define STM32_D2PPRE1_DIV16 RCC_D2CFGR_D2PPRE1_VALUE(7U)
- #define STM32_D2PPRE2_DIV1 RCC_D2CFGR_D2PPRE2_VALUE(0U)
- #define STM32_D2PPRE2_DIV2 RCC_D2CFGR_D2PPRE2_VALUE(4U)
- #define STM32_D2PPRE2_DIV4 RCC_D2CFGR_D2PPRE2_VALUE(5U)
- #define STM32_D2PPRE2_DIV8 RCC_D2CFGR_D2PPRE2_VALUE(6U)
- #define STM32_D2PPRE2_DIV16 RCC_D2CFGR_D2PPRE2_VALUE(7U)
- #define STM32_D3PPRE4_DIV1 RCC_D3CFGR_D3PPRE4_VALUE(0U)
- #define STM32_D3PPRE4_DIV2 RCC_D3CFGR_D3PPRE4_VALUE(4U)
- #define STM32_D3PPRE4_DIV4 RCC_D3CFGR_D3PPRE4_VALUE(5U)
- #define STM32_D3PPRE4_DIV8 RCC_D3CFGR_D3PPRE4_VALUE(6U)
- #define STM32_D3PPRE4_DIV16 RCC_D3CFGR_D3PPRE4_VALUE(7U)
- #define STM32_HSIDIV_DIV1 RCC_CR_HSIDIV_VALUE(0U)
- #define STM32_HSIDIV_DIV2 RCC_CR_HSIDIV_VALUE(1U)
- #define STM32_HSIDIV_DIV4 RCC_CR_HSIDIV_VALUE(2U)
- #define STM32_HSIDIV_DIV8 RCC_CR_HSIDIV_VALUE(3U)
- #define STM32_MCO1SEL_HSI_CK RCC_CFGR_MCO1_VALUE(0U)
- #define STM32_MCO1SEL_LSE_CK RCC_CFGR_MCO1_VALUE(1U)
- #define STM32_MCO1SEL_HSE_CK RCC_CFGR_MCO1_VALUE(2U)
- #define STM32_MCO1SEL_PLL1_Q_CK RCC_CFGR_MCO1_VALUE(3U)
- #define STM32_MCO1SEL_HSI48_CK RCC_CFGR_MCO1_VALUE(4U)
- #define STM32_MCO2SEL_SYS_CK RCC_CFGR_MCO2_VALUE(0U)
- #define STM32_MCO2SEL_PLL2_P_CK RCC_CFGR_MCO2_VALUE(1U)
- #define STM32_MCO2SEL_HSE_CK RCC_CFGR_MCO2_VALUE(2U)
- #define STM32_MCO2SEL_PLL1_P_CK RCC_CFGR_MCO2_VALUE(3U)
- #define STM32_MCO2SEL_CSI_CK RCC_CFGR_MCO2_VALUE(4U)
- #define STM32_MCO2SEL_LSI_CK RCC_CFGR_MCO2_VALUE(5U)
- #define STM32_RTCSEL_MASK RCC_BDCR_RTCSEL_Msk
- #define STM32_RTCSEL_NOCLK RCC_BDCR_RTCSEL_VALUE(0U)
- #define STM32_RTCSEL_LSE_CK RCC_BDCR_RTCSEL_VALUE(1U)
- #define STM32_RTCSEL_LSI_CK RCC_BDCR_RTCSEL_VALUE(2U)
- #define STM32_RTCSEL_HSE_1M_CK RCC_BDCR_RTCSEL_VALUE(3U)
- #define STM32_HRTIMSEL_C_CLK RCC_CFGR_HRTIMSEL
- #define STM32_STOPKERWUCK_ENABLED RCC_CFGR_STOPKERWUCK
- #define STM32_STOPWUCK_ENABLED RCC_CFGR_STOPKERWUCK
- #define STM32_PLLSRC_HSI_CK RCC_PLLCKSELR_PLLSRC_VALUE(0U)
- #define STM32_PLLSRC_CSI_CK RCC_PLLCKSELR_PLLSRC_VALUE(1U)
- #define STM32_PLLSRC_HSE_CK RCC_PLLCKSELR_PLLSRC_VALUE(2U)
- #define STM32_PLLSRC_DISABLE RCC_PLLCKSELR_PLLSRC_VALUE(23U)
- #define STM32_CKPERSEL_HSI_CK RCC_D1CCIPR_CKPERSEL_VALUE(0U)
- #define STM32_CKPERSEL_CSI_CK RCC_D1CCIPR_CKPERSEL_VALUE(1U)
- #define STM32_CKPERSEL_HSE_CK RCC_D1CCIPR_CKPERSEL_VALUE(2U)
- #define STM32_SDMMCSEL_PLL1_Q_CK RCC_D1CCIPR_SDMMCSEL_VALUE(0U)
- #define STM32_SDMMCSEL_PLL2_R_CK RCC_D1CCIPR_SDMMCSEL_VALUE(1U)
- #define STM32_QSPISEL_HCLK RCC_D1CCIPR_QSPISEL_VALUE(0U)
- #define STM32_QSPISEL_PLL1_Q_CK RCC_D1CCIPR_QSPISEL_VALUE(1U)
- #define STM32_QSPISEL_PLL2_R_CK RCC_D1CCIPR_QSPISEL_VALUE(2U)
- #define STM32_QSPISEL_PER_CK RCC_D1CCIPR_QSPISEL_VALUE(3U)
- #define STM32_FMCSEL_HCLK RCC_D1CCIPR_FMCSEL_VALUE(0U)
- #define STM32_FMCSEL_PLL1_Q_CK RCC_D1CCIPR_FMCSEL_VALUE(1U)
- #define STM32_FMCSEL_PLL2_R_CK RCC_D1CCIPR_FMCSEL_VALUE(2U)
- #define STM32_FMCSEL_PER_CK RCC_D1CCIPR_FMCSEL_VALUE(3U)
- #define STM32_SWPSEL_PCLK1 RCC_D2CCIP1R_SWPSEL_VALUE(0U)
- #define STM32_SWPSEL_HSI_KER_CK RCC_D2CCIP1R_SWPSEL_VALUE(1U)
- #define STM32_FDCANSEL_HSE_CK RCC_D2CCIP1R_FDCANSEL_VALUE(0U)
- #define STM32_FDCANSEL_PLL1_Q_CK RCC_D2CCIP1R_FDCANSEL_VALUE(1U)
- #define STM32_FDCANSEL_PLL2_Q_CK RCC_D2CCIP1R_FDCANSEL_VALUE(2U)
- #define STM32_DFSDM1SEL_PCLK2 RCC_D2CCIP1R_DFSDM1SEL_VALUE(0U)
- #define STM32_DFSDM1SEL_SYS_CK RCC_D2CCIP1R_DFSDM1SEL_VALUE(1U)
- #define STM32_SPDIFSEL_PLL1_Q_CK RCC_D2CCIP1R_SPDIFSEL_VALUE(0U)
- #define STM32_SPDIFSEL_PLL2_R_CK RCC_D2CCIP1R_SPDIFSEL_VALUE(1U)
- #define STM32_SPDIFSEL_PLL3_R_CK RCC_D2CCIP1R_SPDIFSEL_VALUE(2U)
- #define STM32_SPDIFSEL_HSI_KET_CLK RCC_D2CCIP1R_SPDIFSEL_VALUE(3U)
- #define STM32_SPI45SEL_PCLK2 RCC_D2CCIP1R_SPI45SEL_VALUE(0U)
- #define STM32_SPI45SEL_PLL2_Q_CK RCC_D2CCIP1R_SPI45SEL_VALUE(1U)
- #define STM32_SPI45SEL_PLL3_Q_CK RCC_D2CCIP1R_SPI45SEL_VALUE(2U)
- #define STM32_SPI45SEL_HSI_KER_CK RCC_D2CCIP1R_SPI45SEL_VALUE(3U)
- #define STM32_SPI45SEL_CSI_KER_CK RCC_D2CCIP1R_SPI45SEL_VALUE(4U)
- #define STM32_SPI45SEL_HSE_CK RCC_D2CCIP1R_SPI45SEL_VALUE(5U)
- #define STM32_SPI123SEL_PLL1_Q_CK RCC_D2CCIP1R_SPI123SEL_VALUE(0U)
- #define STM32_SPI123SEL_PLL2_P_CK RCC_D2CCIP1R_SPI123SEL_VALUE(1U)
- #define STM32_SPI123SEL_PLL3_P_CK RCC_D2CCIP1R_SPI123SEL_VALUE(2U)
- #define STM32_SPI123SEL_I2S_CKIN RCC_D2CCIP1R_SPI123SEL_VALUE(3U)
- #define STM32_SPI123SEL_PER_CK RCC_D2CCIP1R_SPI123SEL_VALUE(4U)
- #define STM32_SAI23SEL_PLL1_Q_CK RCC_D2CCIP1R_SAI23SEL_VALUE(0U)
- #define STM32_SAI23SEL_PLL2_P_CK RCC_D2CCIP1R_SAI23SEL_VALUE(1U)
- #define STM32_SAI23SEL_PLL3_P_CK RCC_D2CCIP1R_SAI23SEL_VALUE(2U)
- #define STM32_SAI23SEL_I2S_CKIN RCC_D2CCIP1R_SAI23SEL_VALUE(3U)
- #define STM32_SAI23SEL_PER_CK RCC_D2CCIP1R_SAI23SEL_VALUE(4U)
- #define STM32_SAI1SEL_PLL1_Q_CK RCC_D2CCIP1R_SAI1SEL_VALUE(0U)
- #define STM32_SAI1SEL_PLL2_P_CK RCC_D2CCIP1R_SAI1SEL_VALUE(1U)
- #define STM32_SAI1SEL_PLL3_P_CK RCC_D2CCIP1R_SAI1SEL_VALUE(2U)
- #define STM32_SAI1SEL_I2S_CKIN RCC_D2CCIP1R_SAI1SEL_VALUE(3U)
- #define STM32_SAI1SEL_PER_CK RCC_D2CCIP1R_SAI1SEL_VALUE(4U)
- #define STM32_LPTIM1SEL_PCLK1 RCC_D2CCIP2R_LPTIM1SEL_VALUE(0U)
- #define STM32_LPTIM1SEL_PLL2_P_CK RCC_D2CCIP2R_LPTIM1SEL_VALUE(1U)
- #define STM32_LPTIM1SEL_PLL3_R_CK RCC_D2CCIP2R_LPTIM1SEL_VALUE(2U)
- #define STM32_LPTIM1SEL_LSE_CK RCC_D2CCIP2R_LPTIM1SEL_VALUE(3U)
- #define STM32_LPTIM1SEL_LSI_CK RCC_D2CCIP2R_LPTIM1SEL_VALUE(4U)
- #define STM32_LPTIM1SEL_PER_CK RCC_D2CCIP2R_LPTIM1SEL_VALUE(5U)
- #define STM32_CECSEL_LSE_CK RCC_D2CCIP2R_CECSEL_VALUE(0U)
- #define STM32_CECSEL_LSI_CK RCC_D2CCIP2R_CECSEL_VALUE(1U)
- #define STM32_CECSEL_CSI_KER_CK RCC_D2CCIP2R_CECSEL_VALUE(2U)
- #define STM32_CECSEL_DISABLE RCC_D2CCIP2R_CECSEL_VALUE(3U)
- #define STM32_USBSEL_DISABLE RCC_D2CCIP2R_USBSEL_VALUE(0U)
- #define STM32_USBSEL_PLL1_Q_CK RCC_D2CCIP2R_USBSEL_VALUE(1U)
- #define STM32_USBSEL_PLL3_Q_CK RCC_D2CCIP2R_USBSEL_VALUE(2U)
- #define STM32_USBSEL_HSI48_CK RCC_D2CCIP2R_USBSEL_VALUE(3U)
- #define STM32_I2C123SEL_PCLK1 RCC_D2CCIP2R_I2C123SEL_VALUE(0U)
- #define STM32_I2C123SEL_PLL3_R_CK RCC_D2CCIP2R_I2C123SEL_VALUE(1U)
- #define STM32_I2C123SEL_HSI_KER_CK RCC_D2CCIP2R_I2C123SEL_VALUE(2U)
- #define STM32_I2C123SEL_CSI_KER_CK RCC_D2CCIP2R_I2C123SEL_VALUE(3U)
- #define STM32_RNGSEL_HSI48_CK RCC_D2CCIP2R_RNGSEL_VALUE(0U)
- #define STM32_RNGSEL_PLL1_Q_CK RCC_D2CCIP2R_RNGSEL_VALUE(1U)
- #define STM32_RNGSEL_LSE_CK RCC_D2CCIP2R_RNGSEL_VALUE(2U)
- #define STM32_RNGSEL_LSI_CK RCC_D2CCIP2R_RNGSEL_VALUE(3U)
- #define STM32_USART16SEL_PCLK2 RCC_D2CCIP2R_USART16SEL_VALUE(0U)
- #define STM32_USART16SEL_PLL2_Q_CK RCC_D2CCIP2R_USART16SEL_VALUE(1U)
- #define STM32_USART16SEL_PLL3_Q_CK RCC_D2CCIP2R_USART16SEL_VALUE(2U)
- #define STM32_USART16SEL_HSI_KER_CK RCC_D2CCIP2R_USART16SEL_VALUE(3U)
- #define STM32_USART16SEL_CSI_KER_CK RCC_D2CCIP2R_USART16SEL_VALUE(4U)
- #define STM32_USART16SEL_LSE_CK RCC_D2CCIP2R_USART16SEL_VALUE(5U)
- #define STM32_USART234578SEL_PCLK1 RCC_D2CCIP2R_USART234578SEL_VALUE(0U)
- #define STM32_USART234578SEL_PLL2_Q_CK RCC_D2CCIP2R_USART234578SEL_VALUE(1U)
- #define STM32_USART234578SEL_PLL3_Q_CK RCC_D2CCIP2R_USART234578SEL_VALUE(2U)
- #define STM32_USART234578SEL_HSI_KER_CK RCC_D2CCIP2R_USART234578SEL_VALUE(3U)
- #define STM32_USART234578SEL_CSI_KER_CK RCC_D2CCIP2R_USART234578SEL_VALUE(4U)
- #define STM32_USART234578SEL_LSE_CK RCC_D2CCIP2R_USART234578SEL_VALUE(5U)
- #define STM32_SPI6SEL_PCLK4 RCC_D3CCIPR_SPI6SEL_VALUE(0U)
- #define STM32_SPI6SEL_PLL2_Q_CK RCC_D3CCIPR_SPI6SEL_VALUE(1U)
- #define STM32_SPI6SEL_PLL3_Q_CK RCC_D3CCIPR_SPI6SEL_VALUE(2U)
- #define STM32_SPI6SEL_HSI_KER_CK RCC_D3CCIPR_SPI6SEL_VALUE(3U)
- #define STM32_SPI6SEL_CSI_KER_CK RCC_D3CCIPR_SPI6SEL_VALUE(4U)
- #define STM32_SPI6SEL_HSE_CK RCC_D3CCIPR_SPI6SEL_VALUE(5U)
- #define STM32_SAI4BSEL_PLL1_Q_CK RCC_D3CCIPR_SAI4BSEL_VALUE(0U)
- #define STM32_SAI4BSEL_PLL2_P_CK RCC_D3CCIPR_SAI4BSEL_VALUE(1U)
- #define STM32_SAI4BSEL_PLL3_P_CK RCC_D3CCIPR_SAI4BSEL_VALUE(2U)
- #define STM32_SAI4BSEL_I2S_CKIN RCC_D3CCIPR_SAI4BSEL_VALUE(3U)
- #define STM32_SAI4BSEL_PER_CK RCC_D3CCIPR_SAI4BSEL_VALUE(4U)
- #define STM32_SAI4ASEL_PLL1_Q_CK RCC_D3CCIPR_SAI4ASEL_VALUE(0U)
- #define STM32_SAI4ASEL_PLL2_P_CK RCC_D3CCIPR_SAI4ASEL_VALUE(1U)
- #define STM32_SAI4ASEL_PLL3_P_CK RCC_D3CCIPR_SAI4ASEL_VALUE(2U)
- #define STM32_SAI4ASEL_I2S_CKIN RCC_D3CCIPR_SAI4ASEL_VALUE(3U)
- #define STM32_SAI4ASEL_PER_CK RCC_D3CCIPR_SAI4ASEL_VALUE(4U)
- #define STM32_ADCSEL_PLL2_P_CK RCC_D3CCIPR_ADCSEL_VALUE(0U)
- #define STM32_ADCSEL_PLL3_R_CK RCC_D3CCIPR_ADCSEL_VALUE(1U)
- #define STM32_ADCSEL_PER_CK RCC_D3CCIPR_ADCSEL_VALUE(2U)
- #define STM32_ADCSEL_DISABLE RCC_D3CCIPR_ADCSEL_VALUE(0U)
- #define STM32_LPTIM345SEL_PCLK4 RCC_D3CCIPR_LPTIM345SEL_VALUE(0U)
- #define STM32_LPTIM345SEL_PLL2_P_CK RCC_D3CCIPR_LPTIM345SEL_VALUE(1U)
- #define STM32_LPTIM345SEL_PLL3_P_CK RCC_D3CCIPR_LPTIM345SEL_VALUE(2U)
- #define STM32_LPTIM345SEL_LSE_CK RCC_D3CCIPR_LPTIM345SEL_VALUE(3U)
- #define STM32_LPTIM345SEL_LSI_CK RCC_D3CCIPR_LPTIM345SEL_VALUE(4U)
- #define STM32_LPTIM345SEL_PER_CK RCC_D3CCIPR_LPTIM345SEL_VALUE(5U)
- #define STM32_LPTIM2SEL_PCLK4 RCC_D3CCIPR_LPTIM2SEL_VALUE(0U)
- #define STM32_LPTIM2SEL_PLL2_P_CK RCC_D3CCIPR_LPTIM2SEL_VALUE(1U)
- #define STM32_LPTIM2SEL_PLL3_P_CK RCC_D3CCIPR_LPTIM2SEL_VALUE(2U)
- #define STM32_LPTIM2SEL_LSE_CK RCC_D3CCIPR_LPTIM2SEL_VALUE(3U)
- #define STM32_LPTIM2SEL_LSI_CK RCC_D3CCIPR_LPTIM2SEL_VALUE(4U)
- #define STM32_LPTIM2SEL_PER_CK RCC_D3CCIPR_LPTIM2SEL_VALUE(5U)
- #define STM32_I2C4SEL_PCLK4 RCC_D3CCIPR_I2C4SEL_VALUE(0U)
- #define STM32_I2C4SEL_PLL3_R_CK RCC_D3CCIPR_I2C4SEL_VALUE(1U)
- #define STM32_I2C4SEL_HSI_KER_CK RCC_D3CCIPR_I2C4SEL_VALUE(2U)
- #define STM32_I2C4SEL_CSI_KER_CK RCC_D3CCIPR_I2C4SEL_VALUE(3U)
- #define STM32_LPUART1SEL_PCLK4 RCC_D3CCIPR_LPUART1SEL_VALUE(0U)
- #define STM32_LPUART1SEL_PLL2_Q_CK RCC_D3CCIPR_LPUART1SEL_VALUE(1U)
- #define STM32_LPUART1SEL_PLL3_Q_CK RCC_D3CCIPR_LPUART1SEL_VALUE(2U)
- #define STM32_LPUART1SEL_HSI_KER_CK RCC_D3CCIPR_LPUART1SEL_VALUE(3U)
- #define STM32_LPUART1SEL_CSI_KER_CK RCC_D3CCIPR_LPUART1SEL_VALUE(4U)
- #define STM32_LPUART1SEL_LSE_CK RCC_D3CCIPR_LPUART1SEL_VALUE(5U)
- /** @} */
- /*===========================================================================*/
- /* Driver pre-compile time settings. */
- /*===========================================================================*/
- /**
- * @name Configuration options
- * @{
- */
- /**
- * @brief Disables the PWR/RCC initialization in the HAL.
- */
- #if !defined(STM32_NO_INIT) || defined(__DOXYGEN__)
- #define STM32_NO_INIT FALSE
- #endif
- /**
- * @brief SYS_CK value assumed if @p STM32_NO_INIT is enabled.
- */
- #if !defined(STM32_SYS_CK_ENFORCED_VALUE) || defined(__DOXYGEN__)
- #define STM32_SYS_CK_ENFORCED_VALUE STM32_HSICLK
- #endif
- /**
- * @brief Add no-cache attribute to SRAM1 and SRAM2.
- * @note MPU region 7 is used if enabled.
- */
- #if !defined(STM32_NOCACHE_SRAM1_SRAM2) || defined(__DOXYGEN__)
- #define STM32_NOCACHE_SRAM1_SRAM2 FALSE
- #endif
- /**
- * @brief Add no-cache attribute to SRAM3.
- * @note MPU region 7 is used if enabled.
- */
- #if !defined(STM32_NOCACHE_SRAM3) || defined(__DOXYGEN__)
- #define STM32_NOCACHE_SRAM3 TRUE
- #endif
- /**
- * @brief PWR CR1 initializer.
- */
- #if !defined(STM32_PWR_CR1) || defined(__DOXYGEN__)
- #define STM32_PWR_CR1 (PWR_CR1_SVOS_1 | \
- PWR_CR1_SVOS_0)
- #endif
- /**
- * @brief PWR CR2 initializer.
- */
- #if !defined(STM32_PWR_CR2) || defined(__DOXYGEN__)
- #define STM32_PWR_CR2 (PWR_CR2_BREN)
- #endif
- /**
- * @brief PWR CR3 initializer.
- */
- #if !defined(STM32_PWR_CR3) || defined(__DOXYGEN__)
- #define STM32_PWR_CR3 (PWR_CR3_LDOEN | \
- PWR_CR3_USBREGEN | \
- PWR_CR3_USB33DEN)
- #endif
- /**
- * @brief PWR CPUCR initializer.
- */
- #if !defined(STM32_PWR_CPUCR) || defined(__DOXYGEN__)
- #define STM32_PWR_CPUCR 0
- #endif
- /**
- * @brief VOS setting.
- */
- #if !defined(STM32_VOS) || defined(__DOXYGEN__)
- #define STM32_VOS STM32_VOS_SCALE1
- #endif
- /**
- * @brief Enables or disables the HSI clock source.
- */
- #if !defined(STM32_HSI_ENABLED) || defined(__DOXYGEN__)
- #define STM32_HSI_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the LSI clock source.
- */
- #if !defined(STM32_LSI_ENABLED) || defined(__DOXYGEN__)
- #define STM32_LSI_ENABLED FALSE
- #endif
- /**
- * @brief Enables or disables the LSI clock source.
- */
- #if !defined(STM32_CSI_ENABLED) || defined(__DOXYGEN__)
- #define STM32_CSI_ENABLED FALSE
- #endif
- /**
- * @brief Enables or disables the HSI48 clock source.
- */
- #if !defined(STM32_HSI48_ENABLED) || defined(__DOXYGEN__)
- #define STM32_HSI48_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the HSE clock source.
- */
- #if !defined(STM32_HSE_ENABLED) || defined(__DOXYGEN__)
- #define STM32_HSE_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the LSE clock source.
- */
- #if !defined(STM32_LSE_ENABLED) || defined(__DOXYGEN__)
- #define STM32_LSE_ENABLED TRUE
- #endif
- /**
- * @brief HSI divider.
- */
- #if !defined(STM32_HSIDIV) || defined(__DOXYGEN__)
- #define STM32_HSIDIV STM32_HSIDIV_DIV1
- #endif
- /**
- * @brief Clock source for all PLLs.
- */
- #if !defined(STM32_PLLSRC) || defined(__DOXYGEN__)
- #define STM32_PLLSRC STM32_PLLSRC_HSE_CK
- #endif
- /**
- * @brief Masking of PLLCFGR register.
- * @note By default all options in PLLCFGR are enabled, this option
- * allows to mask specific bits for power saving reasons.
- * Use with caution.
- */
- #if !defined(STM32_PLLCFGR_MASK) || defined(__DOXYGEN__)
- #define STM32_PLLCFGR_MASK ~0
- #endif
- /**
- * @brief Enables or disables the PLL1.
- */
- #if !defined(STM32_PLL1_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL1_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL1 P output.
- */
- #if !defined(STM32_PLL1_P_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL1_P_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL1 Q output.
- */
- #if !defined(STM32_PLL1_Q_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL1_Q_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL1 R output.
- */
- #if !defined(STM32_PLL1_R_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL1_R_ENABLED TRUE
- #endif
- /**
- * @brief PLL1 DIVM divider.
- * @note The allowed values are 1..63.
- */
- #if !defined(STM32_PLL1_DIVM_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL1_DIVM_VALUE 4
- #endif
- /**
- * @brief PLL1 DIVN multiplier.
- * @note The allowed values are 4..512.
- */
- #if !defined(STM32_PLL1_DIVN_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL1_DIVN_VALUE 400
- #endif
- /**
- * @brief PLL1 FRACN multiplier, zero if no fractional part.
- * @note The allowed values are 0..8191.
- */
- #if !defined(STM32_PLL1_FRACN_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL1_FRACN_VALUE 0
- #endif
- /**
- * @brief PLL1 DIVP divider.
- * @note The allowed values are 2..128, odd values not allowed.
- */
- #if !defined(STM32_PLL1_DIVP_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL1_DIVP_VALUE 2
- #endif
- /**
- * @brief PLL1 DIVQ divider.
- * @note The allowed values are 1..128.
- */
- #if !defined(STM32_PLL1_DIVQ_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL1_DIVQ_VALUE 8
- #endif
- /**
- * @brief PLL1 DIVR divider.
- * @note The allowed values are 1..128.
- */
- #if !defined(STM32_PLL1_DIVR_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL1_DIVR_VALUE 8
- #endif
- /**
- * @brief Enables or disables the PLL2.
- */
- #if !defined(STM32_PLL2_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL2_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL2 P output.
- */
- #if !defined(STM32_PLL2_P_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL1_2_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL2 Q output.
- */
- #if !defined(STM32_PLL2_Q_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL2_Q_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL2 R output.
- */
- #if !defined(STM32_PLL2_R_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL2_R_ENABLED TRUE
- #endif
- /**
- * @brief PLL2 DIVM divider.
- * @note The allowed values are 1..63.
- */
- #if !defined(STM32_PLL2_DIVM_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL2_DIVM_VALUE 4
- #endif
- /**
- * @brief PLL2 DIVN multiplier.
- * @note The allowed values are 4..512.
- */
- #if !defined(STM32_PLL2_DIVN_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL2_DIVN_VALUE 400
- #endif
- /**
- * @brief PLL2 FRACN multiplier, zero if no fractional part.
- * @note The allowed values are 0..8191.
- */
- #if !defined(STM32_PLL2_FRACN_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL2_FRACN_VALUE 0
- #endif
- /**
- * @brief PLL2 DIVP divider.
- * @note The allowed values are 2..128, odd values not allowed.
- */
- #if !defined(STM32_PLL2_DIVP_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL2_DIVP_VALUE 40
- #endif
- /**
- * @brief PLL2 DIVQ divider.
- * @note The allowed values are 1..128.
- */
- #if !defined(STM32_PLL2_DIVQ_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL2_DIVQ_VALUE 8
- #endif
- /**
- * @brief PLL2 DIVR divider.
- * @note The allowed values are 1..128.
- */
- #if !defined(STM32_PLL2_DIVR_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL2_DIVR_VALUE 8
- #endif
- /**
- * @brief Enables or disables the PLL3.
- */
- #if !defined(STM32_PLL3_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL3_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL3 P output.
- */
- #if !defined(STM32_PLL3_P_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL3_P_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL3 Q output.
- */
- #if !defined(STM32_PLL3_Q_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL3_Q_ENABLED TRUE
- #endif
- /**
- * @brief Enables or disables the PLL3 R output.
- */
- #if !defined(STM32_PLL3_R_ENABLED) || defined(__DOXYGEN__)
- #define STM32_PLL3_R_ENABLED TRUE
- #endif
- /**
- * @brief PLL3 DIVM divider.
- * @note The allowed values are 1..63.
- */
- #if !defined(STM32_PLL3_DIVM_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL3_DIVM_VALUE 4
- #endif
- /**
- * @brief PLL3 DIVN multiplier.
- * @note The allowed values are 4..512.
- */
- #if !defined(STM32_PLL3_DIVN_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL3_DIVN_VALUE 400
- #endif
- /**
- * @brief PLL3 FRACN multiplier, zero if no fractional part.
- * @note The allowed values are 0..8191.
- */
- #if !defined(STM32_PLL3_FRACN_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL3_FRACN_VALUE 0
- #endif
- /**
- * @brief PLL3 DIVP divider.
- * @note The allowed values are 2..128, odd values not allowed.
- */
- #if !defined(STM32_PLL3_DIVP_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL3_DIVP_VALUE 8
- #endif
- /**
- * @brief PLL3 DIVQ divider.
- * @note The allowed values are 1..128.
- */
- #if !defined(STM32_PLL3_DIVQ_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL3_DIVQ_VALUE 8
- #endif
- /**
- * @brief PLL3 DIVR divider.
- * @note The allowed values are 1..128.
- */
- #if !defined(STM32_PLL3_DIVR_VALUE) || defined(__DOXYGEN__)
- #define STM32_PLL3_DIVR_VALUE 8
- #endif
- /**
- * @brief Peripherals clock selector.
- */
- #if !defined(STM32_CKPERSEL) || defined(__DOXYGEN__)
- #define STM32_CKPERSEL STM32_CKPERSEL_HSE_CK
- #endif
- /**
- * @brief MCO1 clock selector.
- */
- #if !defined(STM32_MCO1SEL) || defined(__DOXYGEN__)
- #define STM32_MCO1SEL STM32_MCO1SEL_HSI_CK
- #endif
- /**
- * @brief MCO1 clock prescaler.
- */
- #if !defined(STM32_MCO1PRE_VALUE) || defined(__DOXYGEN__)
- #define STM32_MCO1PRE_VALUE 4
- #endif
- /**
- * @brief MCO2 clock selector.
- */
- #if !defined(STM32_MCO2SEL) || defined(__DOXYGEN__)
- #define STM32_MCO2SEL STM32_MCO2SEL_SYS_CK
- #endif
- /**
- * @brief MCO2 clock prescaler.
- */
- #if !defined(STM32_MCO2PRE_VALUE) || defined(__DOXYGEN__)
- #define STM32_MCO2PRE_VALUE 4
- #endif
- /**
- * @brief TIM clock prescaler selection.
- */
- #if !defined(STM32_TIMPRE_ENABLE) || defined(__DOXYGEN__)
- #define STM32_TIMPRE_ENABLE FALSE
- #endif
- /**
- * @brief HRTIM clock prescaler selection.
- */
- #if !defined(STM32_HRTIMSEL) || defined(__DOXYGEN__)
- #define STM32_HRTIMSEL 0
- #endif
- /**
- * @brief Kernel clock selection after a wake up from system Stop.
- */
- #if !defined(STM32_STOPKERWUCK) || defined(__DOXYGEN__)
- #define STM32_STOPKERWUCK 0
- #endif
- /**
- * @brief System clock selection after a wake up from system Stop.
- */
- #if !defined(STM32_STOPWUCK) || defined(__DOXYGEN__)
- #define STM32_STOPWUCK 0
- #endif
- /**
- * @brief RTC HSE prescaler value.
- * @note The allowed values are 2..63.
- */
- #if !defined(STM32_RTCPRE_VALUE) || defined(__DOXYGEN__)
- #define STM32_RTCPRE_VALUE 8
- #endif
- /**
- * @brief Main clock source selection.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_SW) || defined(__DOXYGEN__)
- #define STM32_SW STM32_SW_PLL1_P_CK1_P_CK
- #endif
- /**
- * @brief RTC clock selector.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_RTCSEL) || defined(__DOXYGEN__)
- #define STM32_RTCSEL STM32_RTCSEL_LSE_CK
- #endif
- /**
- * @brief Clock domain 1 core bus prescaler.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_D1CPRE) || defined(__DOXYGEN__)
- #define STM32_D1CPRE STM32_D1CPRE_DIV1
- #endif
- /**
- * @brief Clock domain 1 HPRE prescaler.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_D1HPRE) || defined(__DOXYGEN__)
- #define STM32_D1HPRE STM32_D1HPRE_DIV4
- #endif
- /**
- * @brief Clock domain 1 peripherals bus prescaler.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_D1PPRE3) || defined(__DOXYGEN__)
- #define STM32_D1PPRE3 STM32_D1PPRE3_DIV1
- #endif
- /**
- * @brief Clock domain 2 peripherals bus 1 prescaler.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_D2PPRE1) || defined(__DOXYGEN__)
- #define STM32_D2PPRE1 STM32_D2PPRE1_DIV1
- #endif
- /**
- * @brief Clock domain 2 peripherals bus 2 prescaler.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_D2PPRE2) || defined(__DOXYGEN__)
- #define STM32_D2PPRE2 STM32_D2PPRE2_DIV1
- #endif
- /**
- * @brief Clock domain 3 peripherals bus prescaler.
- * @note This setting can be modified at runtime.
- */
- #if !defined(STM32_D3PPRE4) || defined(__DOXYGEN__)
- #define STM32_D3PPRE4 STM32_D3PPRE4_DIV1
- #endif
- /**
- * @brief QSPI clock source.
- */
- #if !defined(STM32_QSPISEL) || defined(__DOXYGEN__)
- #define STM32_QSPISEL STM32_QSPISEL_HCLK
- #endif
- /**
- * @brief FMC clock source.
- */
- #if !defined(STM32_FMCSEL) || defined(__DOXYGEN__)
- #define STM32_FMCSEL STM32_QSPISEL_HCLK
- #endif
- /**
- * @brief SWP clock source.
- */
- #if !defined(STM32_SWPSEL) || defined(__DOXYGEN__)
- #define STM32_SWPSEL STM32_SWPSEL_PCLK1
- #endif
- /**
- * @brief FDCAN clock source.
- */
- #if !defined(STM32_FDCANSEL) || defined(__DOXYGEN__)
- #define STM32_FDCANSEL STM32_FDCANSEL_HSE_CK
- #endif
- /**
- * @brief DFSDM1 clock source.
- */
- #if !defined(STM32_DFSDM1SEL) || defined(__DOXYGEN__)
- #define STM32_DFSDM1SEL STM32_DFSDM1SEL_PCLK2
- #endif
- /**
- * @brief SPDIF clock source.
- */
- #if !defined(STM32_SPDIFSEL) || defined(__DOXYGEN__)
- #define STM32_SPDIFSEL STM32_SPDIFSEL_PLL1_Q_CK
- #endif
- /**
- * @brief SPI45 clock source.
- */
- #if !defined(STM32_SPI45SEL) || defined(__DOXYGEN__)
- #define STM32_SPI45SEL STM32_SPI45SEL_PCLK2
- #endif
- /**
- * @brief SPI123 clock source.
- */
- #if !defined(STM32_SPI123SEL) || defined(__DOXYGEN__)
- #define STM32_SPI123SEL STM32_SPI123SEL_PLL1_Q_CK
- #endif
- /**
- * @brief SAI23 clock source.
- */
- #if !defined(STM32_SAI23SEL) || defined(__DOXYGEN__)
- #define STM32_SAI23SEL STM32_SAI23SEL_PLL1_Q_CK
- #endif
- /**
- * @brief SAI1 clock source.
- */
- #if !defined(STM32_SAI1SEL) || defined(__DOXYGEN__)
- #define STM32_SAI1SEL STM32_SAI1SEL_PLL1_Q_CK
- #endif
- /**
- * @brief LPTIM1 clock source.
- */
- #if !defined(STM32_LPTIM1SEL) || defined(__DOXYGEN__)
- #define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
- #endif
- /**
- * @brief CEC clock source.
- */
- #if !defined(STM32_CECSEL) || defined(__DOXYGEN__)
- #define STM32_CECSEL STM32_CECSEL_LSE_CK
- #endif
- /**
- * @brief USB clock source.
- */
- #if !defined(STM32_USBSEL) || defined(__DOXYGEN__)
- #define STM32_USBSEL STM32_USBSEL_PLL3_Q_CK
- #endif
- /**
- * @brief I2C123 clock source.
- */
- #if !defined(STM32_I2C123SEL) || defined(__DOXYGEN__)
- #define STM32_I2C123SEL STM32_I2C123SEL_PCLK1
- #endif
- /**
- * @brief RNG clock source.
- */
- #if !defined(STM32_RNGSEL) || defined(__DOXYGEN__)
- #define STM32_RNGSEL STM32_RNGSEL_HSI48_CK
- #endif
- /**
- * @brief USART16 clock source.
- */
- #if !defined(STM32_USART16SEL) || defined(__DOXYGEN__)
- #define STM32_USART16SEL STM32_USART16SEL_PCLK2
- #endif
- /**
- * @brief USART234578 clock source.
- */
- #if !defined(STM32_USART234578SEL) || defined(__DOXYGEN__)
- #define STM32_USART234578SEL STM32_USART234578SEL_PCLK1
- #endif
- /**
- * @brief SPI6SEL clock source.
- */
- #if !defined(STM32_SPI6SEL) || defined(__DOXYGEN__)
- #define STM32_SPI6SEL STM32_SPI6SEL_PCLK4
- #endif
- /**
- * @brief SAI4BSEL clock source.
- */
- #if !defined(STM32_SAI4BSEL) || defined(__DOXYGEN__)
- #define STM32_SAI4BSEL STM32_SAI4BSEL_PLL1_Q_CK
- #endif
- /**
- * @brief SAI4ASEL clock source.
- */
- #if !defined(STM32_SAI4ASEL) || defined(__DOXYGEN__)
- #define STM32_SAI4ASEL STM32_SAI4ASEL_PLL1_Q_CK
- #endif
- /**
- * @brief ADCSEL clock source.
- */
- #if !defined(STM32_ADCSEL) || defined(__DOXYGEN__)
- #define STM32_ADCSEL STM32_ADCSEL_PLL2_P_CK
- #endif
- /**
- * @brief LPTIM345SEL clock source.
- */
- #if !defined(STM32_LPTIM345SEL) || defined(__DOXYGEN__)
- #define STM32_LPTIM345SEL STM32_LPTIM345SEL_PCLK4
- #endif
- /**
- * @brief LPTIM2SEL clock source.
- */
- #if !defined(STM32_LPTIM2SEL) || defined(__DOXYGEN__)
- #define STM32_LPTIM2SEL STM32_LPTIM2SEL_PCLK4
- #endif
- /**
- * @brief I2C4SEL clock source.
- */
- #if !defined(STM32_I2C4SEL) || defined(__DOXYGEN__)
- #define STM32_I2C4SEL STM32_I2C4SEL_PCLK4
- #endif
- /**
- * @brief LPUART1SEL clock source.
- */
- #if !defined(STM32_LPUART1SEL) || defined(__DOXYGEN__)
- #define STM32_LPUART1SEL STM32_LPUART1SEL_PCLK4
- #endif
- /** @} */
- /*===========================================================================*/
- /* Derived constants and error checks. */
- /*===========================================================================*/
- /*
- * Configuration-related checks.
- */
- #if !defined(STM32H7xx_MCUCONF)
- #error "Using a wrong mcuconf.h file, STM32H7xx_MCUCONF not defined"
- #endif
- #if defined(STM32H743xx) && \
- !defined(STM32H743_MCUCONF)
- #error "Using a wrong mcuconf.h file, STM32H743_MCUCONF not defined"
- #endif
- #if defined(STM32H753xx) && \
- !defined(STM32H753_MCUCONF)
- #error "Using a wrong mcuconf.h file, STM32H753_MCUCONF not defined"
- #endif
- /*
- * Board file checks.
- */
- #if !defined(STM32_LSECLK)
- #error "STM32_LSECLK not defined in board.h"
- #endif
- #if !defined(STM32_LSEDRV)
- #error "STM32_LSEDRV not defined in board.h"
- #endif
- #if !defined(STM32_HSECLK)
- #error "STM32_HSECLK not defined in board.h"
- #endif
- /**
- * @name Constants depending on VOS setting
- * @{
- */
- #if (STM32_VOS == STM32_VOS_SCALE1) || defined(__DOXYGEN__)
- #define STM32_0WS_THRESHOLD 70000000U
- #define STM32_1WS_THRESHOLD 140000000U
- #define STM32_2WS_THRESHOLD 210000000U
- #define STM32_3WS_THRESHOLD 0U
- #define STM32_4WS_THRESHOLD 0U
- #define STM32_PLLOUT_MAX 400000000U
- #define STM32_PLLOUT_MIN 1500000U
- #elif STM32_VOS == STM32_VOS_SCALE2
- #define STM32_0WS_THRESHOLD 55000000U
- #define STM32_1WS_THRESHOLD 110000000U
- #define STM32_2WS_THRESHOLD 165000000U
- #define STM32_3WS_THRESHOLD 220000000U
- #define STM32_4WS_THRESHOLD 0U
- #define STM32_PLLOUT_MAX 300000000U
- #define STM32_PLLOUT_MIN 1500000U
- #elif STM32_VOS == STM32_VOS_SCALE3
- #define STM32_0WS_THRESHOLD 45000000U
- #define STM32_1WS_THRESHOLD 90000000U
- #define STM32_2WS_THRESHOLD 135000000U
- #define STM32_3WS_THRESHOLD 180000000U
- #define STM32_4WS_THRESHOLD 225000000U
- #define STM32_PLLOUT_MAX 200000000U
- #define STM32_PLLOUT_MIN 1500000U
- #else
- #error "invalid STM32_VOS setting specified"
- #endif
- /** @} */
- /*
- * HSI related checks.
- */
- #if STM32_HSI_ENABLED
- #define STM32_HSICLK STM32_HSI_OSC
- #else /* !STM32_HSI_ENABLED */
- #define STM32_HSICLK 0U
- #if STM32_SW == STM32_SW_HSI_CK
- #error "HSI not enabled, required by STM32_SW"
- #endif
- #if (STM32_PLLSRC == STM32_PLLSRC_HSI_CK) && \
- (STM32_PLL1_ENABLED || STM32_PLL2_ENABLED || STM32_PLL3_ENABLED)
- #error "HSI not enabled, required by STM32_PLLSRC and STM32_PLLx_ENABLED"
- #endif
- #if STM32_CKPERSEL == STM32_CKPERSEL_HSI_CK
- #error "HSI not enabled, required by STM32_CKPERSEL"
- #endif
- #if STM32_MCO1SEL == STM32_MCO1SEL_HSI_CK
- #error "HSI not enabled, required by STM32_MCO1SEL"
- #endif
- #endif /* !STM32_HSI_ENABLED */
- /*
- * HSI48 related checks.
- */
- #if STM32_HSI48_ENABLED
- #define STM32_HSI48_CK STM32_HSI48_OSC
- #else /* !STM32_HSI48_ENABLED */
- #define STM32_HSI48_CK 0U
- #if STM32_MCO1SEL == STM32_MCO1SEL_HSI48_CK
- #error "HSI48 not enabled, required by STM32_MCO1SEL"
- #endif
- #endif /* !STM32_HSI48_ENABLED */
- /*
- * CSI related checks.
- */
- #if STM32_CSI_ENABLED
- #define STM32_CSI_CK STM32_CSI_OSC
- #else /* !STM32_CSI_ENABLED */
- #define STM32_CSI_CK 0U
- #if STM32_SW == STM32_SW_CSI_CK
- #error "CSI not enabled, required by STM32_SW"
- #endif
- #if (STM32_PLLSRC == STM32_PLLSRC_CSI_CK) && \
- (STM32_PLL1_ENABLED || STM32_PLL2_ENABLED || STM32_PLL3_ENABLED)
- #error "CSI not enabled, required by STM32_PLLSRC and STM32_PLLx_ENABLED"
- #endif
- #if STM32_CKPERSEL == STM32_CKPERSEL_CSI_CK
- #error "CSI not enabled, required by STM32_CKPERSEL"
- #endif
- #if STM32_MCO2SEL == STM32_MCO2SEL_CSI_CK
- #error "CSI not enabled, required by STM32_MCO2SEL"
- #endif
- #endif /* !STM32_CSI_ENABLED */
- /*
- * HSE related checks.
- */
- #if STM32_HSE_ENABLED
- #if !defined(STM32_HSECLK)
- #error "HSE frequency not defined"
- #endif
- #define STM32_HSE_CK STM32_HSECLK
- #if STM32_HSECLK == 0
- #error "HSE oscllator not available"
- #else /* STM32_HSECLK != 0 */
- #if defined(STM32_HSE_BYPASS)
- #if (STM32_HSECLK < STM32_HSECLK_BYP_MIN) || (STM32_HSECLK > STM32_HSECLK_BYP_MAX)
- #error "STM32_HSECLK outside acceptable range (STM32_HSECLK_BYP_MIN..STM32_HSECLK_BYP_MAX)"
- #endif
- #else /* !defined(STM32_HSE_BYPASS) */
- #if (STM32_HSECLK < STM32_HSECLK_MIN) || (STM32_HSECLK > STM32_HSECLK_MAX)
- #error "STM32_HSECLK outside acceptable range (STM32_HSECLK_MIN..STM32_HSECLK_MAX)"
- #endif
- #endif /* !defined(STM32_HSE_BYPASS) */
- #endif /* STM32_HSECLK != 0 */
- #else /* !STM32_HSE_ENABLED */
- #if STM32_SW == STM32_SW_HSE_CK
- #error "HSE not enabled, required by STM32_SW"
- #endif
- #if (STM32_PLLSRC == STM32_PLLSRC_HSE_CK) && \
- (STM32_PLL1_ENABLED || STM32_PLL2_ENABLED || STM32_PLL3_ENABLED)
- #error "HSE not enabled, required by STM32_PLLSRC and STM32_PLLx_ENABLED"
- #endif
- #if STM32_MCO1SEL == STM32_MCO1SEL_HSE_CK
- #error "HSE not enabled, required by STM32_MCO1SEL"
- #endif
- #if STM32_MCO2SEL == STM32_MCO2SEL_HSE_CK
- #error "HSE not enabled, required by STM32_MCO2SEL"
- #endif
- #if STM32_RTCSEL == STM32_RTCSEL_HSE_1M_CK
- #error "HSE not enabled, required by STM32_RTCSEL"
- #endif
- #endif /* !STM32_HSE_ENABLED */
- /*
- * LSI related checks.
- */
- #if STM32_LSI_ENABLED
- #define STM32_LSI_CK STM32_LSI_OSC
- #else /* !STM32_LSI_ENABLED */
- #define STM32_LSI_CK 0U
- #if STM32_RTCSEL == STM32_RTCSEL_LSI_CK
- #error "LSI not enabled, required by STM32_RTCSEL"
- #endif
- #if STM32_MCO2SEL == STM32_MCO2SEL_LSI_CK
- #error "HSE not enabled, required by STM32_MCO2SEL"
- #endif
- #endif /* !STM32_LSI_ENABLED */
- /*
- * LSE related checks.
- */
- #if STM32_LSE_ENABLED
- #if !defined(STM32_LSECLK)
- #error "LSE frequency not defined"
- #endif
- #define STM32_LSE_CK STM32_LSECLK
- #if (STM32_LSE_CK == 0)
- #error "LSE oscillator not available"
- #endif
- #if defined(STM32_LSE_BYPASS)
- #if (STM32_LSE_CK < STM32_LSE_CK_MIN) || (STM32_LSE_CK > STM32_LSE_CK_BYP_MAX)
- #error "STM32_LSE_CK outside acceptable range (STM32_LSE_CK_MIN..STM32_LSE_CK_BYP_MAX)"
- #endif
- #else
- #if (STM32_LSE_CK < STM32_LSE_CK_MIN) || (STM32_LSE_CK > STM32_LSE_CK_MAX)
- #error "STM32_LSE_CK outside acceptable range (STM32_LSE_CK_MIN..STM32_LSE_CK_MAX)"
- #endif
- #endif
- #if !defined(STM32_LSEDRV)
- #error "STM32_LSEDRV not defined"
- #endif
- #if (STM32_LSEDRV >> 3) > 3
- #error "STM32_LSEDRV outside acceptable range ((0<<3)..(3<<3))"
- #endif
- #else /* !STM32_LSE_ENABLED */
- #if STM32_RTCSEL == STM32_RTCSEL_LSE_CK
- #error "LSE not enabled, required by STM32_RTCSEL"
- #endif
- #if STM32_MCO1SEL == STM32_MCO1SEL_LSE_CK
- #error "LSE not enabled, required by STM32_MCO1SEL"
- #endif
- #endif /* !STM32_LSE_ENABLED */
- /**
- * @brief HSI divided clock.
- */
- #if (STM32_HSIDIV == STM32_HSIDIV_DIV1) || defined(__DOXYGEN__)
- #define STM32_HSI_CK (STM32_HSICLK / 1U)
- #elif STM32_HSIDIV == STM32_HSIDIV_DIV2
- #define STM32_HSI_CK (STM32_HSICLK / 2U)
- #elif STM32_HSIDIV == STM32_HSIDIV_DIV4
- #define STM32_HSI_CK (STM32_HSICLK / 4U)
- #elif STM32_HSIDIV == STM32_HSIDIV_DIV8
- #define STM32_HSI_CK (STM32_HSICLK / 8U)
- #else
- #error "invalid STM32_HSIDIV value specified"
- #endif
- /**
- * @brief HSE divided clock for RTC.
- */
- #if ((STM32_RTCPRE_VALUE >= 2) && (STM32_RTCPRE_VALUE <= 63)) || \
- defined(__DOXYGEN__)
- #define STM32_HSE_1M_CK (STM32_HSE_CK / STM32_RTCPRE_VALUE)
- #else
- #error "invalid STM32_RTCPRE_VALUE value specified"
- #endif
- /**
- * @brief PLLs input clock frequency.
- */
- #if (STM32_PLLSRC == STM32_PLLSRC_HSE_CK) || defined(__DOXYGEN__)
- #define STM32_PLLCLKIN STM32_HSE_CK
- #elif STM32_PLLSRC == STM32_PLLSRC_HSI_CK
- #define STM32_PLLCLKIN STM32_HSI_CK
- #elif STM32_PLLSRC == STM32_PLLSRC_CSI_CK
- #define STM32_PLLCLKIN STM32_CSI_CK
- #else
- #error "invalid STM32_PLLSRC value specified"
- #endif
- /**
- * @brief PLL1 DIVM field.
- */
- #if ((STM32_PLL1_DIVM_VALUE >= 1) && (STM32_PLL1_DIVM_VALUE <= 63)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL1_DIVM (STM32_PLL1_DIVM_VALUE << 4)
- #define STM32_PLL1_REF_CK (STM32_PLLCLKIN / STM32_PLL1_DIVM_VALUE)
- #else
- #error "invalid STM32_PLL1_DIVM_VALUE value specified"
- #endif
- /*
- * PLL1 input frequency range check.
- */
- #if (STM32_PLL1_REF_CK < STM32_PLLIN_MIN) || (STM32_PLL1_REF_CK > STM32_PLLIN_MAX)
- #error "STM32_PLL1_REF_CK outside acceptable range (STM32_PLLIN_MIN..STM32_PLLIN_MAX)"
- #endif
- /**
- * @brief PLL1 input range selector.
- */
- #if (STM32_PLL1_REF_CK < STM32_PLLIN_THRESHOLD1) || defined(__DOXYGEN__)
- #define STM32_PLLCFGR_PLL1RGE RCC_PLLCFGR_PLL1RGE_0
- #elif STM32_PLL1_REF_CK < STM32_PLLIN_THRESHOLD2
- #define STM32_PLLCFGR_PLL1RGE RCC_PLLCFGR_PLL1RGE_1
- #elif STM32_PLL1_REF_CK < STM32_PLLIN_THRESHOLD3
- #define STM32_PLLCFGR_PLL1RGE RCC_PLLCFGR_PLL1RGE_2
- #else
- #define STM32_PLLCFGR_PLL1RGE RCC_PLLCFGR_PLL1RGE_3
- #endif
- /**
- * @brief PLL2 DIVM field.
- */
- #if ((STM32_PLL2_DIVM_VALUE >= 1) && (STM32_PLL2_DIVM_VALUE <= 63)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL2_DIVM (STM32_PLL2_DIVM_VALUE << 12)
- #define STM32_PLL2_REF_CK (STM32_PLLCLKIN / STM32_PLL2_DIVM_VALUE)
- #else
- #error "invalid STM32_PLL2_DIVM_VALUE value specified"
- #endif
- /*
- * PLL2 input frequency range check.
- */
- #if (STM32_PLL2_REF_CK < STM32_PLLIN_MIN) || (STM32_PLL2_REF_CK > STM32_PLLIN_MAX)
- #error "STM32_PLL2_REF_CK outside acceptable range (STM32_PLLIN_MIN..STM32_PLLIN_MAX)"
- #endif
- /**
- * @brief PLL2 input range selector.
- */
- #if (STM32_PLL2_REF_CK < STM32_PLLIN_THRESHOLD1) || defined(__DOXYGEN__)
- #define STM32_PLLCFGR_PLL2RGE RCC_PLLCFGR_PLL2RGE_0
- #elif STM32_PLL2_REF_CK < STM32_PLLIN_THRESHOLD2
- #define STM32_PLLCFGR_PLL2RGE RCC_PLLCFGR_PLL2RGE_1
- #elif STM32_PLL2_REF_CK < STM32_PLLIN_THRESHOLD3
- #define STM32_PLLCFGR_PLL2RGE RCC_PLLCFGR_PLL2RGE_2
- #else
- #define STM32_PLLCFGR_PLL2RGE RCC_PLLCFGR_PLL2RGE_3
- #endif
- /**
- * @brief PLL3 DIVM field.
- */
- #if ((STM32_PLL3_DIVM_VALUE >= 1) && (STM32_PLL3_DIVM_VALUE <= 63)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL3_DIVM (STM32_PLL3_DIVM_VALUE << 20)
- #define STM32_PLL3_REF_CK (STM32_PLLCLKIN / STM32_PLL3_DIVM_VALUE)
- #else
- #error "invalid STM32_PLL3_DIVM_VALUE value specified"
- #endif
- /*
- * PLL3 input frequency range check.
- */
- #if (STM32_PLL3_REF_CK < STM32_PLLIN_MIN) || (STM32_PLL3_REF_CK > STM32_PLLIN_MAX)
- #error "STM32_PLL3_REF_CK outside acceptable range (STM32_PLLIN_MIN..STM32_PLLIN_MAX)"
- #endif
- /**
- * @brief PLL3 input range selector.
- */
- #if (STM32_PLL3_REF_CK < STM32_PLLIN_THRESHOLD1) || defined(__DOXYGEN__)
- #define STM32_PLLCFGR_PLL3RGE RCC_PLLCFGR_PLL3RGE_0
- #elif STM32_PLL3_REF_CK < STM32_PLLIN_THRESHOLD2
- #define STM32_PLLCFGR_PLL3RGE RCC_PLLCFGR_PLL3RGE_1
- #elif STM32_PLL3_REF_CK < STM32_PLLIN_THRESHOLD3
- #define STM32_PLLCFGR_PLL3RGE RCC_PLLCFGR_PLL3RGE_2
- #else
- #define STM32_PLLCFGR_PLL3RGE RCC_PLLCFGR_PLL3RGE_3
- #endif
- /**
- * @brief PLL1 DIVN field.
- */
- #if ((STM32_PLL1_DIVN_VALUE >= 4) && (STM32_PLL1_DIVN_VALUE <= 512)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL1_DIVN ((STM32_PLL1_DIVN_VALUE - 1U) << 0U)
- #else
- #error "invalid STM32_PLL1_DIVN_VALUE value specified"
- #endif
- /**
- * @brief PLL2 DIVN field.
- */
- #if ((STM32_PLL2_DIVN_VALUE >= 4) && (STM32_PLL2_DIVN_VALUE <= 512)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL2_DIVN ((STM32_PLL2_DIVN_VALUE - 1U) << 0U)
- #else
- #error "invalid STM32_PLL2_DIVN_VALUE value specified"
- #endif
- /**
- * @brief PLL3 DIVN field.
- */
- #if ((STM32_PLL3_DIVN_VALUE >= 4) && (STM32_PLL3_DIVN_VALUE <= 512)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL3_DIVN ((STM32_PLL3_DIVN_VALUE - 1U) << 0U)
- #else
- #error "invalid STM32_PLL3_DIVN_VALUE value specified"
- #endif
- /**
- * @brief PLL1 FRACN field.
- */
- #if ((STM32_PLL1_FRACN_VALUE >= 0) && (STM32_PLL1_FRACN_VALUE <= 8191)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL1_FRACN (STM32_PLL1_FRACN_VALUE << 3U)
- #else
- #error "invalid STM32_PLL1_FRACN_VALUE value specified"
- #endif
- /**
- * @brief PLL2 FRACN field.
- */
- #if ((STM32_PLL2_FRACN_VALUE >= 0) && (STM32_PLL2_FRACN_VALUE <= 8191)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL2_FRACN (STM32_PLL2_FRACN_VALUE << 3U)
- #else
- #error "invalid STM32_PLL2_FRACN_VALUE value specified"
- #endif
- /**
- * @brief PLL3 FRACN field.
- */
- #if ((STM32_PLL3_FRACN_VALUE >= 0) && (STM32_PLL3_FRACN_VALUE <= 8191)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL3_FRACN (STM32_PLL3_FRACN_VALUE << 3U)
- #else
- #error "invalid STM32_PLL3_FRACN_VALUE value specified"
- #endif
- /**
- * @brief PLL1 DIVP field.
- */
- #if ((STM32_PLL1_DIVP_VALUE >= 2) && (STM32_PLL1_DIVP_VALUE <= 128) && \
- ((STM32_PLL1_DIVP_VALUE & 1U) == 0U)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL1_DIVP ((STM32_PLL1_DIVP_VALUE - 1U) << 9U)
- #else
- #error "invalid STM32_PLL1_DIVP_VALUE value specified"
- #endif
- /**
- * @brief PLL2 DIVP field.
- */
- #if ((STM32_PLL2_DIVP_VALUE >= 1) && (STM32_PLL2_DIVP_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL2_DIVP ((STM32_PLL2_DIVP_VALUE - 1U) << 9U)
- #else
- #error "invalid STM32_PLL2_DIVP_VALUE value specified"
- #endif
- /**
- * @brief PLL3 DIVP field.
- */
- #if ((STM32_PLL3_DIVP_VALUE >= 1) && (STM32_PLL3_DIVP_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL3_DIVP ((STM32_PLL3_DIVP_VALUE - 1U) << 9U)
- #else
- #error "invalid STM32_PLL3_DIVP_VALUE value specified"
- #endif
- /**
- * @brief PLL1 DIVQ field.
- */
- #if ((STM32_PLL1_DIVQ_VALUE >= 1) && (STM32_PLL1_DIVQ_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL1_DIVQ ((STM32_PLL1_DIVQ_VALUE - 1U) << 16U)
- #else
- #error "invalid STM32_PLL1_DIVQ_VALUE value specified"
- #endif
- /**
- * @brief PLL2 DIVQ field.
- */
- #if ((STM32_PLL2_DIVQ_VALUE >= 1) && (STM32_PLL2_DIVQ_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL2_DIVQ ((STM32_PLL2_DIVQ_VALUE - 1U) << 16U)
- #else
- #error "invalid STM32_PLL2_DIVQ_VALUE value specified"
- #endif
- /**
- * @brief PLL3 DIVQ field.
- */
- #if ((STM32_PLL3_DIVQ_VALUE >= 1) && (STM32_PLL3_DIVQ_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL3_DIVQ ((STM32_PLL3_DIVQ_VALUE - 1U) << 16U)
- #else
- #error "invalid STM32_PLL3_DIVQ_VALUE value specified"
- #endif
- /**
- * @brief PLL1 DIVR field.
- */
- #if ((STM32_PLL1_DIVR_VALUE >= 1) && (STM32_PLL1_DIVR_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL1_DIVR ((STM32_PLL1_DIVR_VALUE - 1U) << 24U)
- #else
- #error "invalid STM32_PLL1_DIVR_VALUE value specified"
- #endif
- /**
- * @brief PLL2 DIVR field.
- */
- #if ((STM32_PLL2_DIVR_VALUE >= 1) && (STM32_PLL2_DIVR_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL2_DIVR ((STM32_PLL2_DIVR_VALUE - 1U) << 24U)
- #else
- #error "invalid STM32_PLL2_DIVR_VALUE value specified"
- #endif
- /**
- * @brief PLL3 DIVR field.
- */
- #if ((STM32_PLL3_DIVR_VALUE >= 1) && (STM32_PLL3_DIVR_VALUE <= 128)) || \
- defined(__DOXYGEN__)
- #define STM32_PLL3_DIVR ((STM32_PLL3_DIVR_VALUE - 1U) << 24U)
- #else
- #error "invalid STM32_PLL3_DIVR_VALUE value specified"
- #endif
- /**
- * @brief PLL1 VCO frequency.
- */
- #define STM32_PLL1_VCO_CK (STM32_PLL1_REF_CK * STM32_PLL1_DIVN_VALUE)
- /*
- * PLL1 VCO frequency range check.
- */
- #if (STM32_PLL1_VCO_CK < STM32_PLLVCO_MIN) || (STM32_PLL1_VCO_CK > STM32_PLLVCO_MAX)
- #error "STM32_PLL1_VCO_CK outside acceptable range (STM32_PLLVCO_MIN..STM32_PLLVCO_MAX)"
- #endif
- /*
- * PLL1 VCO mode.
- */
- #if (STM32_PLL1_VCO_CK > STM32_PLLVCO_THRESHOLD) || defined(__DOXYGEN__)
- #define STM32_PLLCFGR_PLL1VCOSEL 0U
- #else
- #define STM32_PLLCFGR_PLL1VCOSEL RCC_PLLCFGR_PLL1VCOSEL
- #endif
- /**
- * @brief PLL2 VCO frequency.
- */
- #define STM32_PLL2_VCO_CK (STM32_PLL2_REF_CK * STM32_PLL2_DIVN_VALUE)
- /*
- * PLL2 VCO frequency range check.
- */
- #if (STM32_PLL2_VCO_CK < STM32_PLLVCO_MIN) || (STM32_PLL2_VCO_CK > STM32_PLLVCO_MAX)
- #error "STM32_PLL2_VCO_CK outside acceptable range (STM32_PLLVCO_MIN..STM32_PLLVCO_MAX)"
- #endif
- /*
- * PLL2 VCO mode.
- */
- #if (STM32_PLL2_VCO_CK > STM32_PLLVCO_THRESHOLD) || defined(__DOXYGEN__)
- #define STM32_PLLCFGR_PLL2VCOSEL 0U
- #else
- #define STM32_PLLCFGR_PLL2VCOSEL RCC_PLLCFGR_PLL2VCOSEL
- #endif
- /**
- * @brief PLL3 VCO frequency.
- */
- #define STM32_PLL3_VCO_CK (STM32_PLL3_REF_CK * STM32_PLL3_DIVN_VALUE)
- /*
- * PLL3 VCO frequency range check.
- */
- #if (STM32_PLL3_VCO_CK < STM32_PLLVCO_MIN) || (STM32_PLL3_VCO_CK > STM32_PLLVCO_MAX)
- #error "STM32_PLL3_VCO_CK outside acceptable range (STM32_PLLVCO_MIN..STM32_PLLVCO_MAX)"
- #endif
- /*
- * PLL3 VCO mode.
- */
- #if (STM32_PLL3_VCO_CK > STM32_PLLVCO_THRESHOLD) || defined(__DOXYGEN__)
- #define STM32_PLLCFGR_PLL3VCOSEL 0U
- #else
- #define STM32_PLLCFGR_PLL3VCOSEL RCC_PLLCFGR_PLL3VCOSEL
- #endif
- #if ((STM32_PLL1_ENABLED == TRUE) && (STM32_PLL1_P_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL1 P output clock frequency.
- */
- #define STM32_PLL1_P_CK (STM32_PLL1_VCO_CK / STM32_PLL1_DIVP_VALUE)
- /*
- * PLL1 P output frequency range check.
- */
- #if (STM32_PLL1_P_CK < STM32_PLLOUT_MIN) || (STM32_PLL1_P_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL1_P_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL1_P_CK 0U
- #endif
- #if ((STM32_PLL2_ENABLED == TRUE) && (STM32_PLL2_P_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL2 P output clock frequency.
- */
- #define STM32_PLL2_P_CK (STM32_PLL2_VCO_CK / STM32_PLL2_DIVP_VALUE)
- /*
- * PLL2 P output frequency range check.
- */
- #if (STM32_PLL2_P_CK < STM32_PLLOUT_MIN) || (STM32_PLL2_P_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL2_P_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL2_P_CK 0U
- #endif
- #if ((STM32_PLL3_ENABLED == TRUE) && (STM32_PLL3_P_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL3 P output clock frequency.
- */
- #define STM32_PLL3_P_CK (STM32_PLL3_VCO_CK / STM32_PLL3_DIVP_VALUE)
- /*
- * PLL3 P output frequency range check.
- */
- #if (STM32_PLL3_P_CK < STM32_PLLOUT_MIN) || (STM32_PLL3_P_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL3_P_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL3_P_CK 0U
- #endif
- #if ((STM32_PLL1_ENABLED == TRUE) && (STM32_PLL1_Q_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL1 Q output clock frequency.
- */
- #define STM32_PLL1_Q_CK (STM32_PLL1_VCO_CK / STM32_PLL1_DIVQ_VALUE)
- /*
- * PLL1 Q output frequency range check.
- */
- #if (STM32_PLL1_Q_CK < STM32_PLLOUT_MIN) || (STM32_PLL1_Q_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL1_Q_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL1_Q_CK 0U
- #endif
- #if ((STM32_PLL2_ENABLED == TRUE) && (STM32_PLL2_Q_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL2 Q output clock frequency.
- */
- #define STM32_PLL2_Q_CK (STM32_PLL2_VCO_CK / STM32_PLL2_DIVQ_VALUE)
- /*
- * PLL2 Q output frequency range check.
- */
- #if (STM32_PLL2_Q_CK < STM32_PLLOUT_MIN) || (STM32_PLL2_Q_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL2_Q_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL2_Q_CK 0U
- #endif
- #if ((STM32_PLL3_ENABLED == TRUE) && (STM32_PLL3_Q_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL3 Q output clock frequency.
- */
- #define STM32_PLL3_Q_CK (STM32_PLL3_VCO_CK / STM32_PLL3_DIVQ_VALUE)
- /*
- * PLL3 Q output frequency range check.
- */
- #if (STM32_PLL3_Q_CK < STM32_PLLOUT_MIN) || (STM32_PLL3_Q_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL3_Q_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL3_Q_CK 0U
- #endif
- #if ((STM32_PLL1_ENABLED == TRUE) && (STM32_PLL1_R_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL1 R output clock frequency.
- */
- #define STM32_PLL1_R_CK (STM32_PLL1_VCO_CK / STM32_PLL1_DIVR_VALUE)
- /*
- * PLL1 R output frequency range check.
- */
- #if (STM32_PLL1_R_CK < STM32_PLLOUT_MIN) || (STM32_PLL1_R_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL1_R_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL1_R_CK 0U
- #endif
- #if ((STM32_PLL2_ENABLED == TRUE) && (STM32_PLL2_R_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL2 R output clock frequency.
- */
- #define STM32_PLL2_R_CK (STM32_PLL2_VCO_CK / STM32_PLL2_DIVR_VALUE)
- /*
- * PLL2 R output frequency range check.
- */
- #if (STM32_PLL2_R_CK < STM32_PLLOUT_MIN) || (STM32_PLL2_R_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL2_R_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL2_R_CK 0U
- #endif
- #if ((STM32_PLL3_ENABLED == TRUE) && (STM32_PLL3_R_ENABLED == TRUE)) || \
- defined(__DOXYGEN__)
- /**
- * @brief PLL3 R output clock frequency.
- */
- #define STM32_PLL3_R_CK (STM32_PLL3_VCO_CK / STM32_PLL3_DIVR_VALUE)
- /*
- * PLL3 R output frequency range check.
- */
- #if (STM32_PLL3_R_CK < STM32_PLLOUT_MIN) || (STM32_PLL3_R_CK > STM32_PLLOUT_MAX)
- #error "STM32_PLL3_R_CLKOUT outside acceptable range (STM32_PLLOUT_MIN..STM32_PLLOUT_MAX)"
- #endif
- #else
- #define STM32_PLL3_R_CK 0U
- #endif
- /**
- * @brief System clock source.
- */
- #if STM32_NO_INIT || defined(__DOXYGEN__)
- #define STM32_SYS_CK STM32_SYS_CK_ENFORCED_VALUE
- #elif (STM32_SW == STM32_SW_HSI_CK)
- #define STM32_SYS_CK STM32_HSI_CK
- #elif (STM32_SW == STM32_SW_CSI_CK)
- #define STM32_SYS_CK STM32_CSI_CK
- #elif (STM32_SW == STM32_SW_HSE_CK)
- #define STM32_SYS_CK STM32_HSE_CK
- #elif (STM32_SW == STM32_SW_PLL1_P_CK)
- #define STM32_SYS_CK STM32_PLL1_P_CK
- #else
- #error "invalid STM32_SW value specified"
- #endif
- /*
- * Check on the system clock.
- */
- #if STM32_SW > STM32_SYSCLK_MAX
- #error "STM32_SYS_CK above maximum rated frequency (STM32_SYSCLK_MAX)"
- #endif
- /**
- * @brief Peripherals clock source.
- */
- #if (STM32_CKPERSEL == STM32_CKPERSEL_HSI_CK) || defined(__DOXYGEN__)
- #define STM32_PER_CK STM32_HSI_CK
- #elif (STM32_CKPERSEL == STM32_CKPERSEL_CSI_CK)
- #define STM32_PER_CK STM32_CSI_CK
- #elif (STM32_CKPERSEL == STM32_CKPERSEL_HSE_CK)
- #define STM32_PER_CK STM32_HSE_CK
- #else
- #error "invalid STM32_CKPERSEL value specified"
- #endif
- /*
- * Check on the peripherals clock.
- */
- #if STM32_PER_CK > STM32_HCLK_MAX
- #error "STM32_PER_CK above maximum rated frequency (STM32_HCLK_MAX)"
- #endif
- /**
- * @brief MCO1 divider clock.
- */
- #if (STM32_MCO1SEL == STM32_MCO1SEL_HSI_CK) || defined(__DOXYGEN__)
- #define STM32_MCO1DIVCLK STM32_HSI_CK
- #elif STM32_MCO1SEL == STM32_MCO1SEL_LSE_CK
- #define STM32_MCO1DIVCLK STM32_LSE_CK
- #elif STM32_MCO1SEL == STM32_MCO1SEL_HSE_CK
- #define STM32_MCO1DIVCLK STM32_HSE_CK
- #elif STM32_MCO1SEL == STM32_MCO1SEL_PLL1_Q_CK
- #define STM32_MCO1DIVCLK STM32_PLL1_P_CK
- #elif STM32_MCO1SEL == STM32_MCO1SEL_HSI48_CK
- #define STM32_MCO1DIVCLK STM32_HSI48_CK
- #else
- #error "invalid STM32_MCO1SEL value specified"
- #endif
- /**
- * @brief MCO1 output pin clock.
- */
- #if (STM32_MCO1PRE_VALUE < 1) || (STM32_MCO1PRE_VALUE > 15)
- #error "STM32_MCO1PRE_VALUE outside acceptable range (1..15)"
- #endif
- /**
- * @brief MCO2 divider clock.
- */
- #if (STM32_MCO2SEL == STM32_MCO2SEL_SYS_CK) || defined(__DOXYGEN__)
- #define STM32_MCO2DIVCLK STM32_SYS_CK
- #elif STM32_MCO2SEL == STM32_MCO2SEL_PLL1_P_CK
- #define STM32_MCO2DIVCLK STM32_PLL2_P_CK
- #elif STM32_MCO2SEL == STM32_MCO2SEL_HSE_CK
- #define STM32_MCO2DIVCLK STM32_HSE_CK
- #elif STM32_MCO2SEL == STM32_MCO2SEL_PLL2_P_CK
- #define STM32_MCO2DIVCLK STM32_PLL2_P_CK
- #elif STM32_MCO2SEL == STM32_MCO2SEL_CSI_CK
- #define STM32_MCO2DIVCLK STM32_CSI_CK
- #elif STM32_MCO2SEL == STM32_MCO2SEL_LSI_CK
- #define STM32_MCO2DIVCLK STM32_LSI_CK
- #else
- #error "invalid STM32_MCO2SEL value specified"
- #endif
- /**
- * @brief MCO2 output pin clock.
- */
- #if (STM32_MCO2PRE_VALUE < 1) || (STM32_MCO2PRE_VALUE > 15)
- #error "STM32_MCO2PRE_VALUE outside acceptable range (1..15)"
- #endif
- /**
- * @brief RTC clock.
- */
- #if (STM32_RTCSEL == STM32_RTCSEL_NOCLK) || defined(__DOXYGEN__)
- #define STM32_RTC_CK 0
- #elif STM32_RTCSEL == STM32_RTCSEL_LSE_CK
- #define STM32_RTC_CK STM32_LSE_CK
- #elif STM32_RTCSEL == STM32_RTCSEL_LSI_CK
- #define STM32_RTC_CK STM32_LSI_CK
- #elif STM32_RTCSEL == STM32_RTCSEL_HSE_1M_CK
- #define STM32_RTC_CK STM32_HSE_1M_CK
- #else
- #error "invalid STM32_RTCSEL value specified"
- #endif
- /*
- * Check on the RTC clock.
- */
- #if STM32_RTC_CK > 1000000
- #error "STM32_RTC_CK above maximum rated frequency (1000000)"
- #endif
- /**
- * @brief D1CPRE clock.
- */
- #if (STM32_D1CPRE == STM32_D1CPRE_DIV1) || defined(__DOXYGEN__)
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 1U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV2
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 2U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV4
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 4U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV8
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 8U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV16
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 16U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV64
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 64U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV128
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 128U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV256
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 256U)
- #elif STM32_D1CPRE == STM32_D1CPRE_DIV512
- #define STM32_SYS_D1CPRE_CK (STM32_SYS_CK / 512U)
- #else
- #error "invalid STM32_D1CPRE value specified"
- #endif
- /**
- * @brief Core clock.
- */
- #define STM32_CORE_CK STM32_SYS_D1CPRE_CK
- /**
- * @brief HCLK clock.
- */
- #if (STM32_D1HPRE == STM32_D1HPRE_DIV1) || defined(__DOXYGEN__)
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 1U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV2
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 2U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV4
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 4U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV8
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 8U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV16
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 16U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV64
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 64U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV128
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 128U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV256
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 256U)
- #elif STM32_D1HPRE == STM32_D1HPRE_DIV512
- #define STM32_HCLK (STM32_SYS_D1CPRE_CK / 512U)
- #else
- #error "invalid STM32_D1HPRE value specified"
- #endif
- /*
- * AHB frequency check.
- */
- #if STM32_HCLK > STM32_HCLK_MAX
- #error "STM32_HCLK exceeding maximum frequency (STM32_HCLK_MAX)"
- #endif
- /**
- * @brief D1 PCLK3 clock.
- */
- #if (STM32_D1PPRE3 == STM32_D1PPRE3_DIV1) || defined(__DOXYGEN__)
- #define STM32_PCLK3 (STM32_HCLK / 1U)
- #elif STM32_D1PPRE3 == STM32_D1PPRE3_DIV2
- #define STM32_PCLK3 (STM32_HCLK / 2U)
- #elif STM32_D1PPRE3 == STM32_D1PPRE3_DIV4
- #define STM32_PCLK3 (STM32_HCLK / 4U)
- #elif STM32_D1PPRE3 == STM32_D1PPRE3_DIV8
- #define STM32_PCLK3 (STM32_HCLK / 8U)
- #elif STM32_D1PPRE3 == STM32_D1PPRE3_DIV16
- #define STM32_PCLK3 (STM32_HCLK / 16U)
- #else
- #error "invalid STM32_D1PPRE3 value specified"
- #endif
- /*
- * D1 PCLK3 frequency check.
- */
- #if STM32_PCLK3 > STM32_PCLK3_MAX
- #error "STM32_PCLK3 exceeding maximum frequency (STM32_PCLK3_MAX)"
- #endif
- /**
- * @brief D2 PCLK1 clock.
- */
- #if (STM32_D2PPRE1 == STM32_D2PPRE1_DIV1) || defined(__DOXYGEN__)
- #define STM32_PCLK1 (STM32_HCLK / 1U)
- #elif STM32_D2PPRE1 == STM32_D2PPRE1_DIV2
- #define STM32_PCLK1 (STM32_HCLK / 2U)
- #elif STM32_D2PPRE1 == STM32_D2PPRE1_DIV4
- #define STM32_PCLK1 (STM32_HCLK / 4U)
- #elif STM32_D2PPRE1 == STM32_D2PPRE1_DIV8
- #define STM32_PCLK1 (STM32_HCLK / 8U)
- #elif STM32_D2PPRE1 == STM32_D2PPRE1_DIV16
- #define STM32_PCLK1 (STM32_HCLK / 16U)
- #else
- #error "invalid STM32_D2PPRE1 value specified"
- #endif
- /*
- * D2 PCLK1 frequency check.
- */
- #if STM32_PCLK1 > STM32_PCLK1_MAX
- #error "STM32_PCLK1 exceeding maximum frequency (STM32_PCLK1_MAX)"
- #endif
- /**
- * @brief D2 PCLK2 clock.
- */
- #if (STM32_D2PPRE2 == STM32_D2PPRE2_DIV1) || defined(__DOXYGEN__)
- #define STM32_PCLK2 (STM32_HCLK / 1U)
- #elif STM32_D2PPRE2 == STM32_D2PPRE2_DIV2
- #define STM32_PCLK2 (STM32_HCLK / 2U)
- #elif STM32_D2PPRE2 == STM32_D2PPRE2_DIV4
- #define STM32_PCLK2 (STM32_HCLK / 4U)
- #elif STM32_D2PPRE2 == STM32_D2PPRE2_DIV8
- #define STM32_PCLK2 (STM32_HCLK / 8U)
- #elif STM32_D2PPRE2 == STM32_D2PPRE2_DIV16
- #define STM32_PCLK2 (STM32_HCLK / 16U)
- #else
- #error "invalid STM32_D2PPRE2 value specified"
- #endif
- /*
- * D2 PCLK2 frequency check.
- */
- #if STM32_PCLK2 > STM32_PCLK2_MAX
- #error "STM32_PCLK2 exceeding maximum frequency (STM32_PCLK2_MAX)"
- #endif
- /**
- * @brief D3 PCLK4 clock.
- */
- #if (STM32_D3PPRE4 == STM32_D3PPRE4_DIV1) || defined(__DOXYGEN__)
- #define STM32_PCLK4 (STM32_HCLK / 1U)
- #elif STM32_D3PPRE4 == STM32_D3PPRE4_DIV2
- #define STM32_PCLK4 (STM32_HCLK / 2U)
- #elif STM32_D3PPRE4 == STM32_D3PPRE4_DIV4
- #define STM32_PCLK4 (STM32_HCLK / 4U)
- #elif STM32_D3PPRE4 == STM32_D3PPRE4_DIV8
- #define STM32_PCLK4 (STM32_HCLK / 8U)
- #elif STM32_D3PPRE4 == STM32_D3PPRE4_DIV16
- #define STM32_PCLK4 (STM32_HCLK / 16U)
- #else
- #error "invalid STM32_D3PPRE4 value specified"
- #endif
- /*
- * D3 PCLK4 frequency check.
- */
- #if STM32_PCLK4 > STM32_PCLK4_MAX
- #error "STM32_PCLK4 exceeding maximum frequency (STM32_PCLK4_MAX)"
- #endif
- /**
- * @brief Flash settings.
- */
- #if (STM32_HCLK <= STM32_0WS_THRESHOLD) || defined(__DOXYGEN__)
- #define STM32_FLASHBITS 0x00000000
- #elif STM32_HCLK <= STM32_1WS_THRESHOLD
- #define STM32_FLASHBITS 0x00000001
- #elif STM32_HCLK <= STM32_2WS_THRESHOLD
- #define STM32_FLASHBITS 0x00000002
- #elif STM32_HCLK <= STM32_3WS_THRESHOLD
- #define STM32_FLASHBITS 0x00000003
- #elif STM32_HCLK <= STM32_4WS_THRESHOLD
- #define STM32_FLASHBITS 0x00000004
- #else
- #define STM32_FLASHBITS 0x00000007
- #endif
- #if (STM32_D2PPRE1 == STM32_D2PPRE1_DIV1) || defined(__DOXYGEN__)
- /**
- * @brief Clock of timers connected to APB1
- */
- #define STM32_TIMCLK1 (STM32_PCLK1 * 1)
- #else
- #if (STM32_TIMPRE_ENABLE == FALSE) || (STM32_D2PPRE1 == STM32_D2PPRE1_DIV2)
- #define STM32_TIMCLK1 (STM32_PCLK1 * 2)
- #else
- #define STM32_TIMCLK1 (STM32_PCLK1 * 4)
- #endif
- #endif
- #if (STM32_D2PPRE2 == STM32_D2PPRE2_DIV1) || defined(__DOXYGEN__)
- /**
- * @brief Clock of timers connected to APB2.
- */
- #define STM32_TIMCLK2 (STM32_PCLK2 * 1)
- #else
- #if (STM32_TIMPRE_ENABLE == FALSE) || (STM32_D2PPRE2 == STM32_D2PPRE2_DIV2)
- #define STM32_TIMCLK2 (STM32_PCLK2 * 2)
- #else
- #define STM32_TIMCLK2 (STM32_PCLK2 * 4)
- #endif
- #endif
- #if (STM32_LPTIM1SEL == STM32_LPTIM1SEL_PCLK1) || defined(__DOXYGEN__)
- /**
- * @brief LPTIM1 clock.
- */
- #define STM32_LPTIM1CLK STM32_PCLK1
- #elif STM32_LPTIM1SEL == STM32_LPTIM1SEL_PLL2_P_CK
- #define STM32_LPTIM1CLK STM32_PLL2_P_CK
- #elif STM32_LPTIM1SEL == STM32_LPTIM1SEL_PLL3_R_CK
- #define STM32_LPTIM1CLK STM32_PLL3_R_CK
- #elif STM32_LPTIM1SEL == STM32_LPTIM1SEL_LSE_CK
- #define STM32_LPTIM1CLK STM32_LSE_CK
- #elif STM32_LPTIM1SEL == STM32_LPTIM1SEL_LSI_CK
- #define STM32_LPTIM1CLK STM32_LSI_CK
- #elif STM32_LPTIM1SEL == STM32_LPTIM1SEL_PER_CK
- #define STM32_LPTIM1CLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_LPTIM1SEL clock"
- #endif
- #if (STM32_LPTIM2SEL == STM32_LPTIM2SEL_PCLK4) || defined(__DOXYGEN__)
- /**
- * @brief LPTIM2 clock.
- */
- #define STM32_LPTIM2CLK STM32_PCLK4
- #elif STM32_LPTIM2SEL == STM32_LPTIM2SEL_PLL2_P_CK
- #define STM32_LPTIM2CLK STM32_PLL2_P_CK
- #elif STM32_LPTIM2SEL == STM32_LPTIM2SEL_PLL3_P_CK
- #define STM32_LPTIM2CLK STM32_PLL3_P_CK
- #elif STM32_LPTIM2SEL == STM32_LPTIM2SEL_LSE_CK
- #define STM32_LPTIM2CLK STM32_LSE_CK
- #elif STM32_LPTIM2SEL == STM32_LPTIM2SEL_LSI_CK
- #define STM32_LPTIM2CLK STM32_LSI_CK
- #elif STM32_LPTIM2SEL == STM32_LPTIM2SEL_PER_CK
- #define STM32_LPTIM2CLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_LPTIM2SEL clock"
- #endif
- #if (STM32_LPTIM345SEL == STM32_LPTIM345SEL_PCLK4) || defined(__DOXYGEN__)
- /**
- * @brief LPTIM3 clock.
- */
- #define STM32_LPTIM3CLK STM32_PCLK4
- /**
- * @brief LPTIM4 clock.
- */
- #define STM32_LPTIM4CLK STM32_PCLK4
- /**
- * @brief LPTIM5 clock.
- */
- #define STM32_LPTIM5CLK STM32_PCLK4
- #elif STM32_LPTIM345SEL == STM32_LPTIM345SEL_PLL2_P_CK
- #define STM32_LPTIM3CLK STM32_PLL2_P_CK
- #define STM32_LPTIM4CLK STM32_PLL2_P_CK
- #define STM32_LPTIM5CLK STM32_PLL2_P_CK
- #elif STM32_LPTIM345SEL == STM32_LPTIM345SEL_PLL3_P_CK
- #define STM32_LPTIM3CLK STM32_PLL3_P_CK
- #define STM32_LPTIM4CLK STM32_PLL3_P_CK
- #define STM32_LPTIM5CLK STM32_PLL3_P_CK
- #elif STM32_LPTIM345SEL == STM32_LPTIM345SEL_LSE_CK
- #define STM32_LPTIM3CLK STM32_LSE_CK
- #define STM32_LPTIM4CLK STM32_LSE_CK
- #define STM32_LPTIM5CLK STM32_LSE_CK
- #elif STM32_LPTIM345SEL == STM32_LPTIM345SEL_LSI_CK
- #define STM32_LPTIM3CLK STM32_LSI_CK
- #define STM32_LPTIM4CLK STM32_LSI_CK
- #define STM32_LPTIM5CLK STM32_LSI_CK
- #elif STM32_LPTIM345SEL == STM32_LPTIM345SEL_PER_CK
- #define STM32_LPTIM3CLK STM32_PER_CK
- #define STM32_LPTIM4CLK STM32_PER_CK
- #define STM32_LPTIM5CLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_LPTIM345SEL clock"
- #endif
- #if (STM32_USART16SEL == STM32_USART16SEL_PCLK2) || defined(__DOXYGEN__)
- /**
- * @brief USART1 clock.
- */
- #define STM32_USART1CLK STM32_PCLK2
- /**
- * @brief USART6 clock.
- */
- #define STM32_USART6CLK STM32_PCLK2
- #elif STM32_USART16SEL == STM32_USART16SEL_PLL2_Q_CK
- #define STM32_USART1CLK STM32_PLL2_Q_CK
- #define STM32_USART6CLK STM32_PLL2_Q_CK
- #elif STM32_USART16SEL == STM32_USART16SEL_PLL3_Q_CK
- #define STM32_USART1CLK STM32_PLL3_Q_CK
- #define STM32_USART6CLK STM32_PLL3_Q_CK
- #elif STM32_USART16SEL == STM32_USART16SEL_HSI_KER_CK
- #define STM32_USART1CLK STM32_HSI_CK
- #define STM32_USART6CLK STM32_HSI_CK
- #elif STM32_USART16SEL == STM32_USART16SEL_CSI_KER_CK
- #define STM32_USART1CLK STM32_CSI_CK
- #define STM32_USART6CLK STM32_CSI_CK
- #elif STM32_USART16SEL == STM32_USART16SEL_LSE_CK
- #define STM32_USART1CLK STM32_LSE_CK
- #define STM32_USART6CLK STM32_LSE_CK
- #else
- #error "invalid source selected for STM32_USART16SEL clock"
- #endif
- #if (STM32_USART234578SEL == STM32_USART234578SEL_PCLK1) || defined(__DOXYGEN__)
- /**
- * @brief USART2 clock.
- */
- #define STM32_USART2CLK STM32_PCLK1
- /**
- * @brief USART3 clock.
- */
- #define STM32_USART3CLK STM32_PCLK1
- /**
- * @brief USART4 clock.
- */
- #define STM32_USART4CLK STM32_PCLK1
- /**
- * @brief USART5 clock.
- */
- #define STM32_USART5CLK STM32_PCLK1
- /**
- * @brief USART7 clock.
- */
- #define STM32_USART7CLK STM32_PCLK1
- /**
- * @brief USART8 clock.
- */
- #define STM32_USART8CLK STM32_PCLK2
- #elif STM32_USART234578SEL == STM32_USART234578SEL_PLL2_Q_CK
- #define STM32_USART2CLK STM32_PLL2_Q_CK
- #define STM32_USART3CLK STM32_PLL2_Q_CK
- #define STM32_USART4CLK STM32_PLL2_Q_CK
- #define STM32_USART5CLK STM32_PLL2_Q_CK
- #define STM32_USART7CLK STM32_PLL2_Q_CK
- #define STM32_USART8CLK STM32_PLL2_Q_CK
- #elif STM32_USART234578SEL == STM32_USART234578SEL_PLL3_Q_CK
- #define STM32_USART2CLK STM32_PLL3_Q_CK
- #define STM32_USART3CLK STM32_PLL3_Q_CK
- #define STM32_USART4CLK STM32_PLL3_Q_CK
- #define STM32_USART5CLK STM32_PLL3_Q_CK
- #define STM32_USART7CLK STM32_PLL3_Q_CK
- #define STM32_USART8CLK STM32_PLL3_Q_CK
- #elif STM32_USART234578SEL == STM32_USART234578SEL_HSI_KER_CK
- #define STM32_USART2CLK STM32_HSI_CK
- #define STM32_USART3CLK STM32_HSI_CK
- #define STM32_USART4CLK STM32_HSI_CK
- #define STM32_USART5CLK STM32_HSI_CK
- #define STM32_USART7CLK STM32_HSI_CK
- #define STM32_USART8CLK STM32_HSI_CK
- #elif STM32_USART234578SEL == STM32_USART234578SEL_CSI_KER_CK
- #define STM32_USART2CLK STM32_CSI_CK
- #define STM32_USART3CLK STM32_CSI_CK
- #define STM32_USART4CLK STM32_CSI_CK
- #define STM32_USART5CLK STM32_CSI_CK
- #define STM32_USART7CLK STM32_CSI_CK
- #define STM32_USART8CLK STM32_CSI_CK
- #elif STM32_USART234578SEL == STM32_USART234578SEL_LSE_CK
- #define STM32_USART2CLK STM32_LSE_CK
- #define STM32_USART3CLK STM32_LSE_CK
- #define STM32_USART4CLK STM32_LSE_CK
- #define STM32_USART6CLK STM32_LSE_CK
- #define STM32_USART7CLK STM32_LSE_CK
- #define STM32_USART8CLK STM32_LSE_CK
- #else
- #error "invalid source selected for STM32_USART234578SEL clock"
- #endif
- #if (STM32_LPUART1SEL == STM32_LPUART1SEL_PCLK4) || defined(__DOXYGEN__)
- /**
- * @brief LPUART1 clock.
- */
- #define STM32_LPUART1CLK STM32_PCLK1
- #elif STM32_LPUART1SEL == STM32_LPUART1SEL_PLL2_Q_CK
- #define STM32_LPUART1CLK STM32_PLL2_Q_CK
- #elif STM32_LPUART1SEL == STM32_LPUART1SEL_PLL3_Q_CK
- #define STM32_LPUART1CLK STM32_PLL3_Q_CK
- #elif STM32_LPUART1SEL == STM32_LPUART1SEL_HSI_KER_CK
- #define STM32_LPUART1CLK STM32_HSI_CK
- #elif STM32_LPUART1SEL == STM32_LPUART1SEL_CSI_KER_CK
- #define STM32_LPUART1CLK STM32_CSI_CK
- #elif STM32_LPUART1SEL == STM32_LPUART1SEL_LSE_CK
- #define STM32_LPUART1CLK STM32_LSE_CK
- #else
- #error "invalid source selected for STM32_LPUART1SEL clock"
- #endif
- #if (STM32_SPI123SEL == STM32_SPI123SEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- /**
- * @brief SPI1 clock.
- */
- #define STM32_SPI1CLK STM32_PLL1_Q_CK
- /**
- * @brief SPI2 clock.
- */
- #define STM32_SPI2CLK STM32_PLL1_Q_CK
- /**
- * @brief SPI3 clock.
- */
- #define STM32_SPI3CLK STM32_PLL1_Q_CK
- #elif STM32_SPI123SEL == STM32_SPI123SEL_PLL2_P_CK
- #define STM32_SPI1CLK STM32_PLL2_P_CK
- #define STM32_SPI2CLK STM32_PLL2_P_CK
- #define STM32_SPI3CLK STM32_PLL2_P_CK
- #elif STM32_SPI123SEL == STM32_SPI123SEL_PLL3_P_CK
- #define STM32_SPI1CLK STM32_PLL3_P_CK
- #define STM32_SPI2CLK STM32_PLL3_P_CK
- #define STM32_SPI3CLK STM32_PLL3_P_CK
- #elif STM32_SPI123SEL == STM32_SPI123SEL_I2S_CKIN
- #define STM32_SPI1CLK 0 /* Unknown, would require a board value */
- #define STM32_SPI2CLK 0 /* Unknown, would require a board value */
- #define STM32_SPI3CLK 0 /* Unknown, would require a board value */
- #elif STM32_SPI123SEL == STM32_SPI123SEL_PER_CK
- #define STM32_SPI1CLK STM32_PER_CK
- #define STM32_SPI2CLK STM32_PER_CK
- #define STM32_SPI3CLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_SPI123SEL clock"
- #endif
- #if (STM32_SPI45SEL == STM32_SPI45SEL_PCLK2) || defined(__DOXYGEN__)
- /**
- * @brief SPI4 clock.
- */
- #define STM32_SPI4CLK STM32_PCLK2
- /**
- * @brief SPI5 clock.
- */
- #define STM32_SPI5CLK STM32_PCLK2
- #elif STM32_SPI45SEL == STM32_SPI45SEL_PLL2_Q_CK
- #define STM32_SPI4CLK STM32_PLL2_Q_CK
- #define STM32_SPI5CLK STM32_PLL2_Q_CK
- #elif STM32_SPI45SEL == STM32_SPI45SEL_PLL3_Q_CK
- #define STM32_SPI4CLK STM32_PLL3_Q_CK
- #define STM32_SPI5CLK STM32_PLL3_Q_CK
- #elif STM32_SPI45SEL == STM32_SPI45SEL_HSI_KER_CK
- #define STM32_SPI4CLK STM32_HSI_CK
- #define STM32_SPI5CLK STM32_HSI_CK
- #elif STM32_SPI45SEL == STM32_SPI45SEL_CSI_KER_CK
- #define STM32_SPI4CLK STM32_CSI_CK
- #define STM32_SPI5CLK STM32_CSI_CK
- #elif STM32_SPI45SEL == STM32_SPI45SEL_HSE_CK
- #define STM32_SPI4CLK STM32_HSE_CK
- #define STM32_SPI5CLK STM32_HSE_CK
- #else
- #error "invalid source selected for STM32_SPI45SEL clock"
- #endif
- #if (STM32_SPI6SEL == STM32_SPI6SEL_PCLK4) || defined(__DOXYGEN__)
- /**
- * @brief SPI6 clock.
- */
- #define STM32_SPI6CLK STM32_PCLK4
- #elif STM32_SPI6SEL == STM32_SPI6SEL_PLL2_Q_CK
- #define STM32_SPI6CLK STM32_PLL2_Q_CK
- #elif STM32_SPI6SEL == STM32_SPI6SEL_PLL3_Q_CK
- #define STM32_SPI6CLK STM32_PLL3_Q_CK
- #elif STM32_SPI6SEL == STM32_SPI6SEL_HSI_KER_CK
- #define STM32_SPI6CLK STM32_HSI_CK
- #elif STM32_SPI6SEL == STM32_SPI6SEL_CSI_KER_CK
- #define STM32_SPI6CLK STM32_CSI_CK
- #elif STM32_SPI6SEL == STM32_SPI6SEL_HSE_CK
- #define STM32_SPI6CLK STM32_HSE_CK
- #else
- #error "invalid source selected for STM32_SPI6SEL clock"
- #endif
- #if (STM32_I2C123SEL == STM32_I2C123SEL_PCLK1) || defined(__DOXYGEN__)
- /**
- * @brief I2C1 clock.
- */
- #define STM32_I2C1CLK STM32_PCLK1
- /**
- * @brief I2C2 clock.
- */
- #define STM32_I2C2CLK STM32_PCLK1
- /**
- * @brief I2C2 clock.
- */
- #define STM32_I2C2CLK STM32_PCLK1
- #elif STM32_I2C123SEL == STM32_I2C123SEL_PLL3_R_CK
- #define STM32_I2C1CLK STM32_PLL3_R_CK
- #define STM32_I2C2CLK STM32_PLL3_R_CK
- #define STM32_I2C2CLK STM32_PLL3_R_CK
- #elif STM32_I2C123SEL == STM32_I2C123SEL_HSI_KER_CK
- #define STM32_I2C1CLK STM32_HSI_CK
- #define STM32_I2C2CLK STM32_HSI_CK
- #define STM32_I2C2CLK STM32_HSI_CK
- #elif STM32_I2C123SEL == STM32_I2C123SEL_CSI_KER_CK
- #define STM32_I2C1CLK STM32_CSI_CK
- #define STM32_I2C2CLK STM32_CSI_CK
- #define STM32_I2C2CLK STM32_CSI_CK
- #else
- #error "invalid source selected for STM32_I2C123SEL clock"
- #endif
- #if (STM32_I2C4SEL == STM32_I2C4SEL_PCLK4) || defined(__DOXYGEN__)
- /**
- * @brief I2C1 clock.
- */
- #define STM32_I2C4CLK STM32_PCLK4
- #elif STM32_I2C4SEL == STM32_I2C4SEL_PLL3_R_CK
- #define STM32_I2C4CLK STM32_PLL3_R_CK
- #elif STM32_I2C4SEL == STM32_I2C4SEL_HSI_KER_CK
- #define STM32_I2C4CLK STM32_HSI_CK
- #elif STM32_I2C4SEL == STM32_I2C4SEL_CSI_KER_CK
- #define STM32_I2C4CLK STM32_CSI_CK
- #else
- #error "invalid source selected for STM32_I2C4SEL clock"
- #endif
- #if (STM32_SAI1SEL == STM32_SAI1SEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- /**
- * @brief SAI1 clock.
- */
- #define STM32_SAI1CLK STM32_PLL1_Q_CK
- #elif STM32_SAI1SEL == STM32_SAI1SEL_PLL2_P_CK
- #define STM32_SAI1CLK STM32_PLL2_P_CK
- #elif STM32_SAI1SEL == STM32_SAI1SEL_PLL3_P_CK
- #define STM32_SAI1CLK STM32_PLL3_P_CK
- #elif STM32_SAI1SEL == STM32_SAI1SEL_I2S_CKIN
- #define STM32_SAI1CLK 0 /* Unknown, would require a board value */
- #elif STM32_SAI1SEL == STM32_SAI1SEL_PER_CK
- #define STM32_SAI1CLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_SAI1SEL clock"
- #endif
- #if (STM32_SAI23SEL == STM32_SAI23SEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- /**
- * @brief SAI2 clock.
- */
- #define STM32_SAI2CLK STM32_PLL1_Q_CK
- /**
- * @brief SAI3 clock.
- */
- #define STM32_SAI3CLK STM32_PLL1_Q_CK
- #elif STM32_SAI23SEL == STM32_SAI23SEL_PLL2_P_CK
- #define STM32_SAI2CLK STM32_PLL2_P_CK
- #define STM32_SAI3CLK STM32_PLL2_P_CK
- #elif STM32_SAI23SEL == STM32_SAI23SEL_PLL3_P_CK
- #define STM32_SAI2CLK STM32_PLL3_P_CK
- #define STM32_SAI3CLK STM32_PLL3_P_CK
- #elif STM32_SAI23SEL == STM32_SAI23SEL_I2S_CKIN
- #define STM32_SAI2CLK 0 /* Unknown, would require a board value */
- #define STM32_SAI3CLK 0 /* Unknown, would require a board value */
- #elif STM32_SAI23SEL == STM32_SAI23SEL_PER_CK
- #define STM32_SAI2CLK STM32_PER_CK
- #define STM32_SAI3CLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_SAI23SEL clock"
- #endif
- #if (STM32_SAI4ASEL == STM32_SAI4ASEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- /**
- * @brief SAI4A clock.
- */
- #define STM32_SAI4ACLK STM32_PLL1_Q_CK
- #elif STM32_SAI4ASEL == STM32_SAI4ASEL_PLL2_P_CK
- #define STM32_SAI4ACLK STM32_PLL2_P_CK
- #elif STM32_SAI4ASEL == STM32_SAI4ASEL_PLL3_P_CK
- #define STM32_SAI4ACLK STM32_PLL3_P_CK
- #elif STM32_SAI4ASEL == STM32_SAI4ASEL_I2S_CKIN
- #define STM32_SAI4ACLK 0 /* Unknown, would require a board value */
- #elif STM32_SAI4ASEL == STM32_SAI4ASEL_PER_CK
- #define STM32_SAI4ACLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_SAI4ASEL clock"
- #endif
- #if (STM32_SAI4BSEL == STM32_SAI4BSEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- /**
- * @brief SAI4B clock.
- */
- #define STM32_SAI4BCLK STM32_PLL1_Q_CK
- #elif STM32_SAI4BSEL == STM32_SAI4BSEL_PLL2_P_CK
- #define STM32_SAI4BCLK STM32_PLL2_P_CK
- #elif STM32_SAI4BSEL == STM32_SAI4BSEL_PLL3_P_CK
- #define STM32_SAI4BCLK STM32_PLL3_P_CK
- #elif STM32_SAI4BSEL == STM32_SAI4BSEL_I2S_CKIN
- #define STM32_SAI4BCLK 0 /* Unknown, would require a board value */
- #elif STM32_SAI4BSEL == STM32_SAI4BSEL_PER_CK
- #define STM32_SAI4BCLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_SAI4BSEL clock"
- #endif
- #if (STM32_USBSEL == STM32_USBSEL_DISABLE) || defined(__DOXYGEN__)
- /**
- * @brief USB clock.
- */
- #define STM32_USBCLK 0
- #elif STM32_USBSEL == STM32_USBSEL_PLL1_Q_CK
- #define STM32_USBCLK STM32_PLL1_Q_CK
- #elif STM32_USBSEL == STM32_USBSEL_PLL3_Q_CK
- #define STM32_USBCLK STM32_PLL3_Q_CK
- #elif STM32_USBSEL == STM32_USBSEL_HSI48_CK
- #define STM32_USBCLK STM32_HSI48_CK
- #else
- #error "invalid source selected for STM32_USBSEL clock"
- #endif
- #if (STM32_SDMMCSEL == STM32_SDMMCSEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- /**
- * @brief SDMMC frequency.
- */
- #define STM32_SDMMCCLK STM32_PLL1_Q_CK
- #elif STM32_SDMMCSEL == STM32_SDMMCSEL_PLL2_R_CK
- #define STM32_SDMMCCLK STM32_PLL2_R_CK
- #else
- #error "invalid source selected for STM32_SDMMCSEL clock"
- #endif
- #if (STM32_QSPISEL == STM32_QSPISEL_HCLK) || defined(__DOXYGEN__)
- /**
- * @brief QSPI frequency.
- */
- #define STM32_QSPICLK STM32_HCLK
- #elif STM32_QSPISEL == STM32_QSPISEL_PLL1_Q_CK
- #define STM32_QSPICLK STM32_PLL1_Q_CK
- #elif STM32_QSPISEL == STM32_QSPISEL_PLL2_R_CK
- #define STM32_QSPICLK STM32_PLL2_R_CK
- #elif STM32_QSPISEL == STM32_QSPISEL_PER_CK
- #define STM32_QSPICLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_QSPISEL clock"
- #endif
- #if (STM32_FMCSEL == STM32_FMCSEL_HCLK) || defined(__DOXYGEN__)
- /**
- * @brief FMC frequency.
- */
- #define STM32_FMCCLK STM32_HCLK
- #elif STM32_FMCSEL == STM32_FMCSEL_PLL1_Q_CK
- #define STM32_FMCCLK STM32_PLL1_Q_CK
- #elif STM32_FMCSEL == STM32_FMCSEL_PLL2_R_CK
- #define STM32_FMCCLK STM32_PLL2_R_CK
- #elif STM32_FMCSEL == STM32_FMCSEL_PER_CK
- #define STM32_FMCCLK STM32_PER_CK
- #else
- #error "invalid source selected for STM32_FMCSEL clock"
- #endif
- #if (STM32_SWPSEL == STM32_SWPSEL_PCLK1) || defined(__DOXYGEN__)
- /**
- * @brief SDMMC frequency.
- */
- #define STM32_SWPCLK STM32_PCLK1
- #elif STM32_SWPSEL == STM32_SWPSEL_HSI_KER_CK
- #define STM32_SWPCLK STM32_HSI_CK
- #else
- #error "invalid source selected for STM32_SWPSEL clock"
- #endif
- #if (STM32_FDCANSEL == STM32_FDCANSEL_HSE_CK) || defined(__DOXYGEN__)
- /**
- * @brief FDCAN frequency.
- */
- #define STM32_FDCANCLK STM32_HSE_CK
- #elif STM32_FDCANSEL == STM32_FDCANSEL_PLL1_Q_CK
- #define STM32_FDCANCLK STM32_PLL1_Q_CK
- #elif STM32_FDCANSEL == STM32_FDCANSEL_PLL2_Q_CK
- #define STM32_FDCANCLK STM32_PLL2_Q_CK
- #else
- #error "invalid source selected for STM32_FDCANSEL clock"
- #endif
- #if (STM32_DFSDM1SEL == STM32_DFSDM1SEL_PCLK2) || defined(__DOXYGEN__)
- /**
- * @brief SDMMC frequency.
- */
- #define STM32_DFSDM1CLK STM32_PCLK2
- #elif STM32_DFSDM1SEL == STM32_DFSDM1SEL_SYS_CK
- #define STM32_DFSDM1CLK STM32_SYS_CK
- #else
- #error "invalid source selected for STM32_DFSDM1SEL clock"
- #endif
- #if (STM32_SPDIFSEL == STM32_SPDIFSEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- /**
- * @brief SPDIF frequency.
- */
- #define STM32_SPDIFCLK STM32_PLL1_Q_CK
- #elif STM32_SPDIFSEL == STM32_SPDIFSEL_PLL2_R_CK
- #define STM32_SPDIFCLK STM32_PLL2_R_CK
- #elif STM32_SPDIFSEL == STM32_SPDIFSEL_PLL3_R_CK
- #define STM32_SPDIFCLK STM32_PLL3_R_CK
- #elif STM32_SPDIFSEL == STM32_SPDIFSEL_HSI_KET_CLK
- #define STM32_SPDIFCLK STM32_HSI_CK
- #else
- #error "invalid source selected for STM32_SPDIFSEL clock"
- #endif
- #if (STM32_CECSEL == STM32_CECSEL_LSE_CK) || defined(__DOXYGEN__)
- /**
- * @brief CEC frequency.
- */
- #define STM32_CECCLK STM32_LSE_CK
- #elif STM32_CECSEL == STM32_CECSEL_LSI_CK
- #define STM32_CECCLK STM32_LSI_CK
- #elif STM32_CECSEL == STM32_CECSEL_CSI_KER_CK
- #define STM32_CECCLK STM32_CSI_CK
- #elif STM32_CECSEL == STM32_CECSEL_DISABLE
- #define STM32_CECCLK 0
- #else
- #error "invalid source selected for STM32_CECSEL clock"
- #endif
- #if (STM32_RNGSEL == STM32_RNGSEL_HSI48_CK) || defined(__DOXYGEN__)
- /**
- * @brief RNG frequency.
- */
- #define STM32_RNGCLK STM32_HSI48_CK
- #elif STM32_RNGSEL == STM32_RNGSEL_PLL1_Q_CK
- #define STM32_RNGCLK STM32_PLL1_Q_CK
- #elif STM32_RNGSEL == STM32_RNGSEL_LSE_CK
- #define STM32_RNGCLK STM32_LSE_CK
- #elif STM32_RNGSEL == STM32_RNGSEL_LSI_CK
- #define STM32_RNGCLK STM32_LSI_CK
- #else
- #error "invalid source selected for STM32_RNGSEL clock"
- #endif
- #if (STM32_ADCSEL == STM32_ADCSEL_PLL2_P_CK) || defined(__DOXYGEN__)
- /**
- * @brief ADC frequency.
- */
- #define STM32_ADCCLK STM32_PLL2_P_CK
- #elif STM32_ADCSEL == STM32_ADCSEL_PLL3_R_CK
- #define STM32_ADCCLK STM32_PLL3_R_CK
- #elif STM32_ADCSEL == STM32_ADCSEL_PER_CK
- #define STM32_ADCCLK STM32_PER_CK
- #elif STM32_ADCSEL == STM32_ADCSEL_DISABLE
- #define STM32_ADCCLK 0
- #else
- #error "invalid source selected for STM32_ADCSEL clock"
- #endif
- /**
- * @brief SDMMC frequency (applies to both SDMMC1 and SDMMC2)
- */
- #if (STM32_SDMMCSEL == STM32_SDMMCSEL_PLL1_Q_CK) || defined(__DOXYGEN__)
- #define STM32_SDMMCCLK STM32_PLL1_Q_CK
- #elif STM32_SDMMCSEL == STM32_SDMMCSEL_PLL2_R_CK
- #define STM32_SDMMCCLK STM32_PLL2_R_CK
- #else
- #error "invalid source selected for SDMMC clock"
- #endif
- /*===========================================================================*/
- /* Driver data structures and types. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver macros. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* External declarations. */
- /*===========================================================================*/
- /* Various helpers.*/
- #include "nvic.h"
- #include "cache.h"
- #include "mpu_v7m.h"
- #include "stm32_isr.h"
- #include "stm32_dma.h"
- #include "stm32_bdma.h"
- #include "stm32_rcc.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- void hal_lld_init(void);
- void stm32_clock_init(void);
- #ifdef __cplusplus
- }
- #endif
- #endif /* HAL_LLD_H */
- /** @} */
|