stm32l4xx_ll_tim.h 219 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_tim.h
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-2017
  7. * @brief Header file of TIM LL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L4xx_LL_TIM_H
  39. #define __STM32L4xx_LL_TIM_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l4xx.h"
  45. /** @addtogroup STM32L4xx_LL_Driver
  46. * @{
  47. */
  48. #if defined (TIM1) || defined (TIM8) || defined (TIM2) || defined (TIM3) || defined (TIM4) || defined (TIM5) || defined (TIM15) || defined (TIM16) || defined (TIM17) || defined (TIM6) || defined (TIM7)
  49. /** @defgroup TIM_LL TIM
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /** @defgroup TIM_LL_Private_Variables TIM Private Variables
  55. * @{
  56. */
  57. static const uint8_t OFFSET_TAB_CCMRx[] =
  58. {
  59. 0x00U, /* 0: TIMx_CH1 */
  60. 0x00U, /* 1: TIMx_CH1N */
  61. 0x00U, /* 2: TIMx_CH2 */
  62. 0x00U, /* 3: TIMx_CH2N */
  63. 0x04U, /* 4: TIMx_CH3 */
  64. 0x04U, /* 5: TIMx_CH3N */
  65. 0x04U, /* 6: TIMx_CH4 */
  66. 0x3CU, /* 7: TIMx_CH5 */
  67. 0x3CU /* 8: TIMx_CH6 */
  68. };
  69. static const uint8_t SHIFT_TAB_OCxx[] =
  70. {
  71. 0U, /* 0: OC1M, OC1FE, OC1PE */
  72. 0U, /* 1: - NA */
  73. 8U, /* 2: OC2M, OC2FE, OC2PE */
  74. 0U, /* 3: - NA */
  75. 0U, /* 4: OC3M, OC3FE, OC3PE */
  76. 0U, /* 5: - NA */
  77. 8U, /* 6: OC4M, OC4FE, OC4PE */
  78. 0U, /* 7: OC5M, OC5FE, OC5PE */
  79. 8U /* 8: OC6M, OC6FE, OC6PE */
  80. };
  81. static const uint8_t SHIFT_TAB_ICxx[] =
  82. {
  83. 0U, /* 0: CC1S, IC1PSC, IC1F */
  84. 0U, /* 1: - NA */
  85. 8U, /* 2: CC2S, IC2PSC, IC2F */
  86. 0U, /* 3: - NA */
  87. 0U, /* 4: CC3S, IC3PSC, IC3F */
  88. 0U, /* 5: - NA */
  89. 8U, /* 6: CC4S, IC4PSC, IC4F */
  90. 0U, /* 7: - NA */
  91. 0U /* 8: - NA */
  92. };
  93. static const uint8_t SHIFT_TAB_CCxP[] =
  94. {
  95. 0U, /* 0: CC1P */
  96. 2U, /* 1: CC1NP */
  97. 4U, /* 2: CC2P */
  98. 6U, /* 3: CC2NP */
  99. 8U, /* 4: CC3P */
  100. 10U, /* 5: CC3NP */
  101. 12U, /* 6: CC4P */
  102. 16U, /* 7: CC5P */
  103. 20U /* 8: CC6P */
  104. };
  105. static const uint8_t SHIFT_TAB_OISx[] =
  106. {
  107. 0U, /* 0: OIS1 */
  108. 1U, /* 1: OIS1N */
  109. 2U, /* 2: OIS2 */
  110. 3U, /* 3: OIS2N */
  111. 4U, /* 4: OIS3 */
  112. 5U, /* 5: OIS3N */
  113. 6U, /* 6: OIS4 */
  114. 8U, /* 7: OIS5 */
  115. 10U /* 8: OIS6 */
  116. };
  117. /**
  118. * @}
  119. */
  120. /* Private constants ---------------------------------------------------------*/
  121. /** @defgroup TIM_LL_Private_Constants TIM Private Constants
  122. * @{
  123. */
  124. /* Defines used for the bit position in the register and perform offsets */
  125. #define TIM_POSITION_BRK_SOURCE POSITION_VAL(Source)
  126. /* Generic bit definitions for TIMx_OR2 register */
  127. #define TIMx_OR2_BKINE TIM1_OR2_BKINE /*!< BRK BKIN input enable */
  128. #define TIMx_OR2_BKCOMP1E TIM1_OR2_BKCMP1E /*!< BRK COMP1 enable */
  129. #define TIMx_OR2_BKCOMP2E TIM1_OR2_BKCMP2E /*!< BRK COMP2 enable */
  130. #if defined(DFSDM1_Channel0)
  131. #define TIMx_OR2_BKDF1BK0E TIM1_OR2_BKDF1BK0E /*!< BRK DFSDM1_BREAK[0] enable */
  132. #endif /* DFSDM1_Channel0 */
  133. #define TIMx_OR2_BKINP TIM1_OR2_BKINP /*!< BRK BKIN input polarity */
  134. #define TIMx_OR2_BKCOMP1P TIM1_OR2_BKCMP1P /*!< BRK COMP1 input polarity */
  135. #define TIMx_OR2_BKCOMP2P TIM1_OR2_BKCMP2P /*!< BRK COMP2 input polarity */
  136. #define TIMx_OR2_ETRSEL TIM1_OR2_ETRSEL /*!< TIMx ETR source selection */
  137. /* Generic bit definitions for TIMx_OR3 register */
  138. #define TIMx_OR3_BK2INE TIM1_OR3_BK2INE /*!< BRK2 BKIN2 input enable */
  139. #define TIMx_OR3_BK2COMP1E TIM1_OR3_BK2CMP1E /*!< BRK2 COMP1 enable */
  140. #define TIMx_OR3_BK2COMP2E TIM1_OR3_BK2CMP2E /*!< BRK2 COMP2 enable */
  141. #if defined(DFSDM1_Channel0)
  142. #define TIMx_OR3_BK2DF1BK1E TIM1_OR3_BK2DF1BK1E /*!< BRK2 DFSDM1_BREAK[1] enable */
  143. #endif /* DFSDM1_Channel0 */
  144. #define TIMx_OR3_BK2INP TIM1_OR3_BK2INP /*!< BRK2 BKIN2 input polarity */
  145. #define TIMx_OR3_BK2COMP1P TIM1_OR3_BK2CMP1P /*!< BRK2 COMP1 input polarity */
  146. #define TIMx_OR3_BK2COMP2P TIM1_OR3_BK2CMP2P /*!< BRK2 COMP2 input polarity */
  147. /* Remap mask definitions */
  148. #define TIMx_OR1_RMP_SHIFT 16U
  149. #define TIMx_OR1_RMP_MASK 0x0000FFFFU
  150. #if defined(ADC3)
  151. #define TIM1_OR1_RMP_MASK ((TIM1_OR1_ETR_ADC1_RMP | TIM1_OR1_ETR_ADC3_RMP | TIM1_OR1_TI1_RMP) << TIMx_OR1_RMP_SHIFT)
  152. #else
  153. #define TIM1_OR1_RMP_MASK ((TIM1_OR1_ETR_ADC1_RMP | TIM1_OR1_TI1_RMP) << TIMx_OR1_RMP_SHIFT)
  154. #endif /* ADC3 */
  155. #define TIM2_OR1_RMP_MASK ((TIM2_OR1_TI4_RMP | TIM2_OR1_ETR1_RMP | TIM2_OR1_ITR1_RMP) << TIMx_OR1_RMP_SHIFT)
  156. #define TIM3_OR1_RMP_MASK (TIM3_OR1_TI1_RMP << TIMx_OR1_RMP_SHIFT)
  157. #define TIM8_OR1_RMP_MASK ((TIM8_OR1_ETR_ADC2_RMP | TIM8_OR1_ETR_ADC3_RMP | TIM8_OR1_TI1_RMP) << TIMx_OR1_RMP_SHIFT)
  158. #define TIM15_OR1_RMP_MASK (TIM15_OR1_TI1_RMP << TIMx_OR1_RMP_SHIFT)
  159. #define TIM16_OR1_RMP_MASK (TIM16_OR1_TI1_RMP << TIMx_OR1_RMP_SHIFT)
  160. #define TIM17_OR1_RMP_MASK (TIM17_OR1_TI1_RMP << TIMx_OR1_RMP_SHIFT)
  161. /* Mask used to set the TDG[x:0] of the DTG bits of the TIMx_BDTR register */
  162. #define DT_DELAY_1 ((uint8_t)0x7FU)
  163. #define DT_DELAY_2 ((uint8_t)0x3FU)
  164. #define DT_DELAY_3 ((uint8_t)0x1FU)
  165. #define DT_DELAY_4 ((uint8_t)0x1FU)
  166. /* Mask used to set the DTG[7:5] bits of the DTG bits of the TIMx_BDTR register */
  167. #define DT_RANGE_1 ((uint8_t)0x00U)
  168. #define DT_RANGE_2 ((uint8_t)0x80U)
  169. #define DT_RANGE_3 ((uint8_t)0xC0U)
  170. #define DT_RANGE_4 ((uint8_t)0xE0U)
  171. /** Legacy definitions for compatibility purpose
  172. @cond 0
  173. */
  174. #if defined(DFSDM1_Channel0)
  175. #define TIMx_OR2_BKDFBK0E TIMx_OR2_BKDF1BK0E
  176. #define TIMx_OR3_BK2DFBK1E TIMx_OR3_BK2DF1BK1E
  177. #endif /* DFSDM1_Channel0 */
  178. /**
  179. @endcond
  180. */
  181. /**
  182. * @}
  183. */
  184. /* Private macros ------------------------------------------------------------*/
  185. /** @defgroup TIM_LL_Private_Macros TIM Private Macros
  186. * @{
  187. */
  188. /** @brief Convert channel id into channel index.
  189. * @param __CHANNEL__ This parameter can be one of the following values:
  190. * @arg @ref LL_TIM_CHANNEL_CH1
  191. * @arg @ref LL_TIM_CHANNEL_CH1N
  192. * @arg @ref LL_TIM_CHANNEL_CH2
  193. * @arg @ref LL_TIM_CHANNEL_CH2N
  194. * @arg @ref LL_TIM_CHANNEL_CH3
  195. * @arg @ref LL_TIM_CHANNEL_CH3N
  196. * @arg @ref LL_TIM_CHANNEL_CH4
  197. * @arg @ref LL_TIM_CHANNEL_CH5
  198. * @arg @ref LL_TIM_CHANNEL_CH6
  199. * @retval none
  200. */
  201. #define TIM_GET_CHANNEL_INDEX( __CHANNEL__) \
  202. (((__CHANNEL__) == LL_TIM_CHANNEL_CH1) ? 0U :\
  203. ((__CHANNEL__) == LL_TIM_CHANNEL_CH1N) ? 1U :\
  204. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2) ? 2U :\
  205. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2N) ? 3U :\
  206. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3) ? 4U :\
  207. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3N) ? 5U :\
  208. ((__CHANNEL__) == LL_TIM_CHANNEL_CH4) ? 6U :\
  209. ((__CHANNEL__) == LL_TIM_CHANNEL_CH5) ? 7U : 8U)
  210. /** @brief Calculate the deadtime sampling period(in ps).
  211. * @param __TIMCLK__ timer input clock frequency (in Hz).
  212. * @param __CKD__ This parameter can be one of the following values:
  213. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  214. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  215. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  216. * @retval none
  217. */
  218. #define TIM_CALC_DTS(__TIMCLK__, __CKD__) \
  219. (((__CKD__) == LL_TIM_CLOCKDIVISION_DIV1) ? ((uint64_t)1000000000000U/(__TIMCLK__)) : \
  220. ((__CKD__) == LL_TIM_CLOCKDIVISION_DIV2) ? ((uint64_t)1000000000000U/((__TIMCLK__) >> 1U)) : \
  221. ((uint64_t)1000000000000U/((__TIMCLK__) >> 2U)))
  222. /**
  223. * @}
  224. */
  225. /* Exported types ------------------------------------------------------------*/
  226. #if defined(USE_FULL_LL_DRIVER)
  227. /** @defgroup TIM_LL_ES_INIT TIM Exported Init structure
  228. * @{
  229. */
  230. /**
  231. * @brief TIM Time Base configuration structure definition.
  232. */
  233. typedef struct
  234. {
  235. uint16_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
  236. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  237. This feature can be modified afterwards using unitary function @ref LL_TIM_SetPrescaler().*/
  238. uint32_t CounterMode; /*!< Specifies the counter mode.
  239. This parameter can be a value of @ref TIM_LL_EC_COUNTERMODE.
  240. This feature can be modified afterwards using unitary function @ref LL_TIM_SetCounterMode().*/
  241. uint32_t Autoreload; /*!< Specifies the auto reload value to be loaded into the active
  242. Auto-Reload Register at the next update event.
  243. This parameter must be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  244. Some timer instances may support 32 bits counters. In that case this parameter must be a number between 0x0000 and 0xFFFFFFFF.
  245. This feature can be modified afterwards using unitary function @ref LL_TIM_SetAutoReload().*/
  246. uint32_t ClockDivision; /*!< Specifies the clock division.
  247. This parameter can be a value of @ref TIM_LL_EC_CLOCKDIVISION.
  248. This feature can be modified afterwards using unitary function @ref LL_TIM_SetClockDivision().*/
  249. uint8_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
  250. reaches zero, an update event is generated and counting restarts
  251. from the RCR value (N).
  252. This means in PWM mode that (N+1) corresponds to:
  253. - the number of PWM periods in edge-aligned mode
  254. - the number of half PWM period in center-aligned mode
  255. This parameter must be a number between 0x00 and 0xFF.
  256. This feature can be modified afterwards using unitary function @ref LL_TIM_SetRepetitionCounter().*/
  257. } LL_TIM_InitTypeDef;
  258. /**
  259. * @brief TIM Output Compare configuration structure definition.
  260. */
  261. typedef struct
  262. {
  263. uint32_t OCMode; /*!< Specifies the output mode.
  264. This parameter can be a value of @ref TIM_LL_EC_OCMODE.
  265. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetMode().*/
  266. uint32_t OCState; /*!< Specifies the TIM Output Compare state.
  267. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  268. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  269. uint32_t OCNState; /*!< Specifies the TIM complementary Output Compare state.
  270. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  271. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  272. uint32_t CompareValue; /*!< Specifies the Compare value to be loaded into the Capture Compare Register.
  273. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  274. This feature can be modified afterwards using unitary function LL_TIM_OC_SetCompareCHx (x=1..6).*/
  275. uint32_t OCPolarity; /*!< Specifies the output polarity.
  276. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  277. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  278. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  279. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  280. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  281. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  282. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  283. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  284. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  285. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  286. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  287. } LL_TIM_OC_InitTypeDef;
  288. /**
  289. * @brief TIM Input Capture configuration structure definition.
  290. */
  291. typedef struct
  292. {
  293. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  294. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  295. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  296. uint32_t ICActiveInput; /*!< Specifies the input.
  297. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  298. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  299. uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
  300. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  301. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  302. uint32_t ICFilter; /*!< Specifies the input capture filter.
  303. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  304. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  305. } LL_TIM_IC_InitTypeDef;
  306. /**
  307. * @brief TIM Encoder interface configuration structure definition.
  308. */
  309. typedef struct
  310. {
  311. uint32_t EncoderMode; /*!< Specifies the encoder resolution (x2 or x4).
  312. This parameter can be a value of @ref TIM_LL_EC_ENCODERMODE.
  313. This feature can be modified afterwards using unitary function @ref LL_TIM_SetEncoderMode().*/
  314. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  315. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  316. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  317. uint32_t IC1ActiveInput; /*!< Specifies the TI1 input source
  318. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  319. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  320. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  321. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  322. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  323. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  324. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  325. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  326. uint32_t IC2Polarity; /*!< Specifies the active edge of TI2 input.
  327. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  328. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  329. uint32_t IC2ActiveInput; /*!< Specifies the TI2 input source
  330. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  331. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  332. uint32_t IC2Prescaler; /*!< Specifies the TI2 input prescaler value.
  333. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  334. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  335. uint32_t IC2Filter; /*!< Specifies the TI2 input filter.
  336. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  337. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  338. } LL_TIM_ENCODER_InitTypeDef;
  339. /**
  340. * @brief TIM Hall sensor interface configuration structure definition.
  341. */
  342. typedef struct
  343. {
  344. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  345. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  346. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  347. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  348. Prescaler must be set to get a maximum counter period longer than the
  349. time interval between 2 consecutive changes on the Hall inputs.
  350. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  351. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  352. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  353. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  354. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  355. uint32_t CommutationDelay; /*!< Specifies the compare value to be loaded into the Capture Compare Register.
  356. A positive pulse (TRGO event) is generated with a programmable delay every time
  357. a change occurs on the Hall inputs.
  358. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.
  359. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetCompareCH2().*/
  360. } LL_TIM_HALLSENSOR_InitTypeDef;
  361. /**
  362. * @brief BDTR (Break and Dead Time) structure definition
  363. */
  364. typedef struct
  365. {
  366. uint32_t OSSRState; /*!< Specifies the Off-State selection used in Run mode.
  367. This parameter can be a value of @ref TIM_LL_EC_OSSR
  368. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  369. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  370. uint32_t OSSIState; /*!< Specifies the Off-State used in Idle state.
  371. This parameter can be a value of @ref TIM_LL_EC_OSSI
  372. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  373. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  374. uint32_t LockLevel; /*!< Specifies the LOCK level parameters.
  375. This parameter can be a value of @ref TIM_LL_EC_LOCKLEVEL
  376. @note The LOCK bits can be written only once after the reset. Once the TIMx_BDTR register
  377. has been written, their content is frozen until the next reset.*/
  378. uint8_t DeadTime; /*!< Specifies the delay time between the switching-off and the
  379. switching-on of the outputs.
  380. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF.
  381. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetDeadTime()
  382. @note This bit-field can not be modified as long as LOCK level 1, 2 or 3 has been programmed. */
  383. uint16_t BreakState; /*!< Specifies whether the TIM Break input is enabled or not.
  384. This parameter can be a value of @ref TIM_LL_EC_BREAK_ENABLE
  385. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK() or @ref LL_TIM_DisableBRK()
  386. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  387. uint32_t BreakPolarity; /*!< Specifies the TIM Break Input pin polarity.
  388. This parameter can be a value of @ref TIM_LL_EC_BREAK_POLARITY
  389. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
  390. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  391. uint32_t BreakFilter; /*!< Specifies the TIM Break Filter.
  392. This parameter can be a value of @ref TIM_LL_EC_BREAK_FILTER
  393. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
  394. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  395. uint32_t Break2State; /*!< Specifies whether the TIM Break2 input is enabled or not.
  396. This parameter can be a value of @ref TIM_LL_EC_BREAK2_ENABLE
  397. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK2() or @ref LL_TIM_DisableBRK2()
  398. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  399. uint32_t Break2Polarity; /*!< Specifies the TIM Break2 Input pin polarity.
  400. This parameter can be a value of @ref TIM_LL_EC_BREAK2_POLARITY
  401. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK2()
  402. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  403. uint32_t Break2Filter; /*!< Specifies the TIM Break2 Filter.
  404. This parameter can be a value of @ref TIM_LL_EC_BREAK2_FILTER
  405. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK2()
  406. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  407. uint32_t AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not.
  408. This parameter can be a value of @ref TIM_LL_EC_AUTOMATICOUTPUT_ENABLE
  409. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableAutomaticOutput() or @ref LL_TIM_DisableAutomaticOutput()
  410. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  411. } LL_TIM_BDTR_InitTypeDef;
  412. /**
  413. * @}
  414. */
  415. #endif /* USE_FULL_LL_DRIVER */
  416. /* Exported constants --------------------------------------------------------*/
  417. /** @defgroup TIM_LL_Exported_Constants TIM Exported Constants
  418. * @{
  419. */
  420. /** @defgroup TIM_LL_EC_GET_FLAG Get Flags Defines
  421. * @brief Flags defines which can be used with LL_TIM_ReadReg function.
  422. * @{
  423. */
  424. #define LL_TIM_SR_UIF TIM_SR_UIF /*!< Update interrupt flag */
  425. #define LL_TIM_SR_CC1IF TIM_SR_CC1IF /*!< Capture/compare 1 interrupt flag */
  426. #define LL_TIM_SR_CC2IF TIM_SR_CC2IF /*!< Capture/compare 2 interrupt flag */
  427. #define LL_TIM_SR_CC3IF TIM_SR_CC3IF /*!< Capture/compare 3 interrupt flag */
  428. #define LL_TIM_SR_CC4IF TIM_SR_CC4IF /*!< Capture/compare 4 interrupt flag */
  429. #define LL_TIM_SR_CC5IF TIM_SR_CC5IF /*!< Capture/compare 5 interrupt flag */
  430. #define LL_TIM_SR_CC6IF TIM_SR_CC6IF /*!< Capture/compare 6 interrupt flag */
  431. #define LL_TIM_SR_COMIF TIM_SR_COMIF /*!< COM interrupt flag */
  432. #define LL_TIM_SR_TIF TIM_SR_TIF /*!< Trigger interrupt flag */
  433. #define LL_TIM_SR_BIF TIM_SR_BIF /*!< Break interrupt flag */
  434. #define LL_TIM_SR_B2IF TIM_SR_B2IF /*!< Second break interrupt flag */
  435. #define LL_TIM_SR_CC1OF TIM_SR_CC1OF /*!< Capture/Compare 1 overcapture flag */
  436. #define LL_TIM_SR_CC2OF TIM_SR_CC2OF /*!< Capture/Compare 2 overcapture flag */
  437. #define LL_TIM_SR_CC3OF TIM_SR_CC3OF /*!< Capture/Compare 3 overcapture flag */
  438. #define LL_TIM_SR_CC4OF TIM_SR_CC4OF /*!< Capture/Compare 4 overcapture flag */
  439. #define LL_TIM_SR_SBIF TIM_SR_SBIF /*!< System Break interrupt flag */
  440. /**
  441. * @}
  442. */
  443. #if defined(USE_FULL_LL_DRIVER)
  444. /** @defgroup TIM_LL_EC_BREAK_ENABLE Break Enable
  445. * @{
  446. */
  447. #define LL_TIM_BREAK_DISABLE 0x00000000U /*!< Break function disabled */
  448. #define LL_TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break function enabled */
  449. /**
  450. * @}
  451. */
  452. /** @defgroup TIM_LL_EC_BREAK2_ENABLE Break2 Enable
  453. * @{
  454. */
  455. #define LL_TIM_BREAK2_DISABLE 0x00000000U /*!< Break2 function disabled */
  456. #define LL_TIM_BREAK2_ENABLE TIM_BDTR_BK2E /*!< Break2 function enabled */
  457. /**
  458. * @}
  459. */
  460. /** @defgroup TIM_LL_EC_AUTOMATICOUTPUT_ENABLE Automatic output enable
  461. * @{
  462. */
  463. #define LL_TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
  464. #define LL_TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event */
  465. /**
  466. * @}
  467. */
  468. #endif /* USE_FULL_LL_DRIVER */
  469. /** @defgroup TIM_LL_EC_IT IT Defines
  470. * @brief IT defines which can be used with LL_TIM_ReadReg and LL_TIM_WriteReg functions.
  471. * @{
  472. */
  473. #define LL_TIM_DIER_UIE TIM_DIER_UIE /*!< Update interrupt enable */
  474. #define LL_TIM_DIER_CC1IE TIM_DIER_CC1IE /*!< Capture/compare 1 interrupt enable */
  475. #define LL_TIM_DIER_CC2IE TIM_DIER_CC2IE /*!< Capture/compare 2 interrupt enable */
  476. #define LL_TIM_DIER_CC3IE TIM_DIER_CC3IE /*!< Capture/compare 3 interrupt enable */
  477. #define LL_TIM_DIER_CC4IE TIM_DIER_CC4IE /*!< Capture/compare 4 interrupt enable */
  478. #define LL_TIM_DIER_COMIE TIM_DIER_COMIE /*!< COM interrupt enable */
  479. #define LL_TIM_DIER_TIE TIM_DIER_TIE /*!< Trigger interrupt enable */
  480. #define LL_TIM_DIER_BIE TIM_DIER_BIE /*!< Break interrupt enable */
  481. /**
  482. * @}
  483. */
  484. /** @defgroup TIM_LL_EC_UPDATESOURCE Update Source
  485. * @{
  486. */
  487. #define LL_TIM_UPDATESOURCE_REGULAR 0x00000000U /*!< Counter overflow/underflow, Setting the UG bit or Update generation through the slave mode controller generates an update request */
  488. #define LL_TIM_UPDATESOURCE_COUNTER TIM_CR1_URS /*!< Only counter overflow/underflow generates an update request */
  489. /**
  490. * @}
  491. */
  492. /** @defgroup TIM_LL_EC_ONEPULSEMODE One Pulse Mode
  493. * @{
  494. */
  495. #define LL_TIM_ONEPULSEMODE_SINGLE TIM_CR1_OPM /*!< Counter is not stopped at update event */
  496. #define LL_TIM_ONEPULSEMODE_REPETITIVE 0x00000000U /*!< Counter stops counting at the next update event */
  497. /**
  498. * @}
  499. */
  500. /** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
  501. * @{
  502. */
  503. #define LL_TIM_COUNTERMODE_UP 0x00000000U /*!<Counter used as upcounter */
  504. #define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
  505. #define LL_TIM_COUNTERMODE_CENTER_UP TIM_CR1_CMS_0 /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting down. */
  506. #define LL_TIM_COUNTERMODE_CENTER_DOWN TIM_CR1_CMS_1 /*!<The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up */
  507. #define LL_TIM_COUNTERMODE_CENTER_UP_DOWN TIM_CR1_CMS /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up or down. */
  508. /**
  509. * @}
  510. */
  511. /** @defgroup TIM_LL_EC_CLOCKDIVISION Clock Division
  512. * @{
  513. */
  514. #define LL_TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< tDTS=tCK_INT */
  515. #define LL_TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< tDTS=2*tCK_INT */
  516. #define LL_TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< tDTS=4*tCK_INT */
  517. /**
  518. * @}
  519. */
  520. /** @defgroup TIM_LL_EC_COUNTERDIRECTION Counter Direction
  521. * @{
  522. */
  523. #define LL_TIM_COUNTERDIRECTION_UP 0x00000000U /*!< Timer counter counts up */
  524. #define LL_TIM_COUNTERDIRECTION_DOWN TIM_CR1_DIR /*!< Timer counter counts down */
  525. /**
  526. * @}
  527. */
  528. /** @defgroup TIM_LL_EC_CCUPDATESOURCE Capture Compare Update Source
  529. * @{
  530. */
  531. #define LL_TIM_CCUPDATESOURCE_COMG_ONLY 0x00000000U /*!< Capture/compare control bits are updated by setting the COMG bit only */
  532. #define LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI TIM_CR2_CCUS /*!< Capture/compare control bits are updated by setting the COMG bit or when a rising edge occurs on trigger input (TRGI) */
  533. /**
  534. * @}
  535. */
  536. /** @defgroup TIM_LL_EC_CCDMAREQUEST Capture Compare DMA Request
  537. * @{
  538. */
  539. #define LL_TIM_CCDMAREQUEST_CC 0x00000000U /*!< CCx DMA request sent when CCx event occurs */
  540. #define LL_TIM_CCDMAREQUEST_UPDATE TIM_CR2_CCDS /*!< CCx DMA requests sent when update event occurs */
  541. /**
  542. * @}
  543. */
  544. /** @defgroup TIM_LL_EC_LOCKLEVEL Lock Level
  545. * @{
  546. */
  547. #define LL_TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF - No bit is write protected */
  548. #define LL_TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
  549. #define LL_TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
  550. #define LL_TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
  551. /**
  552. * @}
  553. */
  554. /** @defgroup TIM_LL_EC_CHANNEL Channel
  555. * @{
  556. */
  557. #define LL_TIM_CHANNEL_CH1 TIM_CCER_CC1E /*!< Timer input/output channel 1 */
  558. #define LL_TIM_CHANNEL_CH1N TIM_CCER_CC1NE /*!< Timer complementary output channel 1 */
  559. #define LL_TIM_CHANNEL_CH2 TIM_CCER_CC2E /*!< Timer input/output channel 2 */
  560. #define LL_TIM_CHANNEL_CH2N TIM_CCER_CC2NE /*!< Timer complementary output channel 2 */
  561. #define LL_TIM_CHANNEL_CH3 TIM_CCER_CC3E /*!< Timer input/output channel 3 */
  562. #define LL_TIM_CHANNEL_CH3N TIM_CCER_CC3NE /*!< Timer complementary output channel 3 */
  563. #define LL_TIM_CHANNEL_CH4 TIM_CCER_CC4E /*!< Timer input/output channel 4 */
  564. #define LL_TIM_CHANNEL_CH5 TIM_CCER_CC5E /*!< Timer output channel 5 */
  565. #define LL_TIM_CHANNEL_CH6 TIM_CCER_CC6E /*!< Timer output channel 6 */
  566. /**
  567. * @}
  568. */
  569. #if defined(USE_FULL_LL_DRIVER)
  570. /** @defgroup TIM_LL_EC_OCSTATE Output Configuration State
  571. * @{
  572. */
  573. #define LL_TIM_OCSTATE_DISABLE 0x00000000U /*!< OCx is not active */
  574. #define LL_TIM_OCSTATE_ENABLE TIM_CCER_CC1E /*!< OCx signal is output on the corresponding output pin */
  575. /**
  576. * @}
  577. */
  578. #endif /* USE_FULL_LL_DRIVER */
  579. /** @defgroup TIM_LL_EC_OCMODE Output Configuration Mode
  580. * @{
  581. */
  582. #define LL_TIM_OCMODE_FROZEN 0x00000000U /*!<The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the output channel level */
  583. #define LL_TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!<OCyREF is forced high on compare match*/
  584. #define LL_TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!<OCyREF is forced low on compare match*/
  585. #define LL_TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<OCyREF toggles on compare match*/
  586. #define LL_TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!<OCyREF is forced low*/
  587. #define LL_TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!<OCyREF is forced high*/
  588. #define LL_TIM_OCMODE_PWM1 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1) /*!<In upcounting, channel y is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel y is inactive as long as TIMx_CNT>TIMx_CCRy else active.*/
  589. #define LL_TIM_OCMODE_PWM2 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<In upcounting, channel y is inactive as long as TIMx_CNT<TIMx_CCRy else active. In downcounting, channel y is active as long as TIMx_CNT>TIMx_CCRy else inactive*/
  590. #define LL_TIM_OCMODE_RETRIG_OPM1 TIM_CCMR1_OC1M_3 /*!<Retrigerrable OPM mode 1*/
  591. #define LL_TIM_OCMODE_RETRIG_OPM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0) /*!<Retrigerrable OPM mode 2*/
  592. #define LL_TIM_OCMODE_COMBINED_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 1*/
  593. #define LL_TIM_OCMODE_COMBINED_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 2*/
  594. #define LL_TIM_OCMODE_ASSYMETRIC_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2) /*!<Asymmetric PWM mode 1*/
  595. #define LL_TIM_OCMODE_ASSYMETRIC_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M) /*!<Asymmetric PWM mode 2*/
  596. /**
  597. * @}
  598. */
  599. /** @defgroup TIM_LL_EC_OCPOLARITY Output Configuration Polarity
  600. * @{
  601. */
  602. #define LL_TIM_OCPOLARITY_HIGH 0x00000000U /*!< OCxactive high*/
  603. #define LL_TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< OCxactive low*/
  604. /**
  605. * @}
  606. */
  607. /** @defgroup TIM_LL_EC_OCIDLESTATE Output Configuration Idle State
  608. * @{
  609. */
  610. #define LL_TIM_OCIDLESTATE_LOW 0x00000000U /*!<OCx=0 (after a dead-time if OC is implemented) when MOE=0*/
  611. #define LL_TIM_OCIDLESTATE_HIGH TIM_CR2_OIS1 /*!<OCx=1 (after a dead-time if OC is implemented) when MOE=0*/
  612. /**
  613. * @}
  614. */
  615. /** @defgroup TIM_LL_EC_GROUPCH5 GROUPCH5
  616. * @{
  617. */
  618. #define LL_TIM_GROUPCH5_NONE 0x00000000U /*!< No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC */
  619. #define LL_TIM_GROUPCH5_OC1REFC TIM_CCR5_GC5C1 /*!< OC1REFC is the logical AND of OC1REFC and OC5REF */
  620. #define LL_TIM_GROUPCH5_OC2REFC TIM_CCR5_GC5C2 /*!< OC2REFC is the logical AND of OC2REFC and OC5REF */
  621. #define LL_TIM_GROUPCH5_OC3REFC TIM_CCR5_GC5C3 /*!< OC3REFC is the logical AND of OC3REFC and OC5REF */
  622. /**
  623. * @}
  624. */
  625. /** @defgroup TIM_LL_EC_ACTIVEINPUT Active Input Selection
  626. * @{
  627. */
  628. #define LL_TIM_ACTIVEINPUT_DIRECTTI (TIM_CCMR1_CC1S_0 << 16U) /*!< ICx is mapped on TIx */
  629. #define LL_TIM_ACTIVEINPUT_INDIRECTTI (TIM_CCMR1_CC1S_1 << 16U) /*!< ICx is mapped on TIy */
  630. #define LL_TIM_ACTIVEINPUT_TRC (TIM_CCMR1_CC1S << 16U) /*!< ICx is mapped on TRC */
  631. /**
  632. * @}
  633. */
  634. /** @defgroup TIM_LL_EC_ICPSC Input Configuration Prescaler
  635. * @{
  636. */
  637. #define LL_TIM_ICPSC_DIV1 0x00000000U /*!< No prescaler, capture is done each time an edge is detected on the capture input */
  638. #define LL_TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0 << 16U) /*!< Capture is done once every 2 events */
  639. #define LL_TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1 << 16U) /*!< Capture is done once every 4 events */
  640. #define LL_TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC << 16U) /*!< Capture is done once every 8 events */
  641. /**
  642. * @}
  643. */
  644. /** @defgroup TIM_LL_EC_IC_FILTER Input Configuration Filter
  645. * @{
  646. */
  647. #define LL_TIM_IC_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  648. #define LL_TIM_IC_FILTER_FDIV1_N2 (TIM_CCMR1_IC1F_0 << 16U) /*!< fSAMPLING=fCK_INT, N=2 */
  649. #define LL_TIM_IC_FILTER_FDIV1_N4 (TIM_CCMR1_IC1F_1 << 16U) /*!< fSAMPLING=fCK_INT, N=4 */
  650. #define LL_TIM_IC_FILTER_FDIV1_N8 ((TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fCK_INT, N=8 */
  651. #define LL_TIM_IC_FILTER_FDIV2_N6 (TIM_CCMR1_IC1F_2 << 16U) /*!< fSAMPLING=fDTS/2, N=6 */
  652. #define LL_TIM_IC_FILTER_FDIV2_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/2, N=8 */
  653. #define LL_TIM_IC_FILTER_FDIV4_N6 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/4, N=6 */
  654. #define LL_TIM_IC_FILTER_FDIV4_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/4, N=8 */
  655. #define LL_TIM_IC_FILTER_FDIV8_N6 (TIM_CCMR1_IC1F_3 << 16U) /*!< fSAMPLING=fDTS/8, N=6 */
  656. #define LL_TIM_IC_FILTER_FDIV8_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/8, N=8 */
  657. #define LL_TIM_IC_FILTER_FDIV16_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/16, N=5 */
  658. #define LL_TIM_IC_FILTER_FDIV16_N6 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/16, N=6 */
  659. #define LL_TIM_IC_FILTER_FDIV16_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2) << 16U) /*!< fSAMPLING=fDTS/16, N=8 */
  660. #define LL_TIM_IC_FILTER_FDIV32_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/32, N=5 */
  661. #define LL_TIM_IC_FILTER_FDIV32_N6 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/32, N=6 */
  662. #define LL_TIM_IC_FILTER_FDIV32_N8 (TIM_CCMR1_IC1F << 16U) /*!< fSAMPLING=fDTS/32, N=8 */
  663. /**
  664. * @}
  665. */
  666. /** @defgroup TIM_LL_EC_IC_POLARITY Input Configuration Polarity
  667. * @{
  668. */
  669. #define LL_TIM_IC_POLARITY_RISING 0x00000000U /*!< The circuit is sensitive to TIxFP1 rising edge, TIxFP1 is not inverted */
  670. #define LL_TIM_IC_POLARITY_FALLING TIM_CCER_CC1P /*!< The circuit is sensitive to TIxFP1 falling edge, TIxFP1 is inverted */
  671. #define LL_TIM_IC_POLARITY_BOTHEDGE (TIM_CCER_CC1P | TIM_CCER_CC1NP) /*!< The circuit is sensitive to both TIxFP1 rising and falling edges, TIxFP1 is not inverted */
  672. /**
  673. * @}
  674. */
  675. /** @defgroup TIM_LL_EC_CLOCKSOURCE Clock Source
  676. * @{
  677. */
  678. #define LL_TIM_CLOCKSOURCE_INTERNAL 0x00000000U /*!< The timer is clocked by the internal clock provided from the RCC */
  679. #define LL_TIM_CLOCKSOURCE_EXT_MODE1 (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Counter counts at each rising or falling edge on a selected inpu t*/
  680. #define LL_TIM_CLOCKSOURCE_EXT_MODE2 TIM_SMCR_ECE /*!< Counter counts at each rising or falling edge on the external trigger input ETR */
  681. /**
  682. * @}
  683. */
  684. /** @defgroup TIM_LL_EC_ENCODERMODE Encoder Mode
  685. * @{
  686. */
  687. #define LL_TIM_ENCODERMODE_X2_TI1 TIM_SMCR_SMS_0 /*!< Encoder mode 1 - Counter counts up/down on TI2FP2 edge depending on TI1FP1 level */
  688. #define LL_TIM_ENCODERMODE_X2_TI2 TIM_SMCR_SMS_1 /*!< Encoder mode 2 - Counter counts up/down on TI1FP1 edge depending on TI2FP2 level */
  689. #define LL_TIM_ENCODERMODE_X4_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Encoder mode 3 - Counter counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input l */
  690. /**
  691. * @}
  692. */
  693. /** @defgroup TIM_LL_EC_TRGO Trigger Output
  694. * @{
  695. */
  696. #define LL_TIM_TRGO_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output */
  697. #define LL_TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output */
  698. #define LL_TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output */
  699. #define LL_TIM_TRGO_CC1IF (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< CC1 capture or a compare match is used as trigger output */
  700. #define LL_TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output */
  701. #define LL_TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output */
  702. #define LL_TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output */
  703. #define LL_TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output */
  704. /**
  705. * @}
  706. */
  707. /** @defgroup TIM_LL_EC_TRGO2 Trigger Output 2
  708. * @{
  709. */
  710. #define LL_TIM_TRGO2_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output 2 */
  711. #define LL_TIM_TRGO2_ENABLE TIM_CR2_MMS2_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output 2 */
  712. #define LL_TIM_TRGO2_UPDATE TIM_CR2_MMS2_1 /*!< Update event is used as trigger output 2 */
  713. #define LL_TIM_TRGO2_CC1F (TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< CC1 capture or a compare match is used as trigger output 2 */
  714. #define LL_TIM_TRGO2_OC1 TIM_CR2_MMS2_2 /*!< OC1REF signal is used as trigger output 2 */
  715. #define LL_TIM_TRGO2_OC2 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC2REF signal is used as trigger output 2 */
  716. #define LL_TIM_TRGO2_OC3 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1) /*!< OC3REF signal is used as trigger output 2 */
  717. #define LL_TIM_TRGO2_OC4 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC4REF signal is used as trigger output 2 */
  718. #define LL_TIM_TRGO2_OC5 TIM_CR2_MMS2_3 /*!< OC5REF signal is used as trigger output 2 */
  719. #define LL_TIM_TRGO2_OC6 (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0) /*!< OC6REF signal is used as trigger output 2 */
  720. #define LL_TIM_TRGO2_OC4_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1) /*!< OC4REF rising or falling edges are used as trigger output 2 */
  721. #define LL_TIM_TRGO2_OC6_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC6REF rising or falling edges are used as trigger output 2 */
  722. #define LL_TIM_TRGO2_OC4_RISING_OC6_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2) /*!< OC4REF or OC6REF rising edges are used as trigger output 2 */
  723. #define LL_TIM_TRGO2_OC4_RISING_OC6_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC4REF rising or OC6REF falling edges are used as trigger output 2 */
  724. #define LL_TIM_TRGO2_OC5_RISING_OC6_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 |TIM_CR2_MMS2_1) /*!< OC5REF or OC6REF rising edges are used as trigger output 2 */
  725. #define LL_TIM_TRGO2_OC5_RISING_OC6_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC5REF rising or OC6REF falling edges are used as trigger output 2 */
  726. /**
  727. * @}
  728. */
  729. /** @defgroup TIM_LL_EC_SLAVEMODE Slave Mode
  730. * @{
  731. */
  732. #define LL_TIM_SLAVEMODE_DISABLED 0x00000000U /*!< Slave mode disabled */
  733. #define LL_TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter */
  734. #define LL_TIM_SLAVEMODE_GATED (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0) /*!< Gated Mode - The counter clock is enabled when the trigger input (TRGI) is high */
  735. #define LL_TIM_SLAVEMODE_TRIGGER (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1) /*!< Trigger Mode - The counter starts at a rising edge of the trigger TRGI */
  736. #define LL_TIM_SLAVEMODE_COMBINED_RESETTRIGGER TIM_SMCR_SMS_3 /*!< Combined reset + trigger mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter, generates an update of the registers and starts the counter */
  737. /**
  738. * @}
  739. */
  740. /** @defgroup TIM_LL_EC_TS Trigger Selection
  741. * @{
  742. */
  743. #define LL_TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) is used as trigger input */
  744. #define LL_TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) is used as trigger input */
  745. #define LL_TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) is used as trigger input */
  746. #define LL_TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) is used as trigger input */
  747. #define LL_TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) is used as trigger input */
  748. #define LL_TIM_TS_TI1FP1 (TIM_SMCR_TS_2 | TIM_SMCR_TS_0) /*!< Filtered Timer Input 1 (TI1FP1) is used as trigger input */
  749. #define LL_TIM_TS_TI2FP2 (TIM_SMCR_TS_2 | TIM_SMCR_TS_1) /*!< Filtered Timer Input 2 (TI12P2) is used as trigger input */
  750. #define LL_TIM_TS_ETRF (TIM_SMCR_TS_2 | TIM_SMCR_TS_1 | TIM_SMCR_TS_0) /*!< Filtered external Trigger (ETRF) is used as trigger input */
  751. /**
  752. * @}
  753. */
  754. /** @defgroup TIM_LL_EC_ETR_POLARITY External Trigger Polarity
  755. * @{
  756. */
  757. #define LL_TIM_ETR_POLARITY_NONINVERTED 0x00000000U /*!< ETR is non-inverted, active at high level or rising edge */
  758. #define LL_TIM_ETR_POLARITY_INVERTED TIM_SMCR_ETP /*!< ETR is inverted, active at low level or falling edge */
  759. /**
  760. * @}
  761. */
  762. /** @defgroup TIM_LL_EC_ETR_PRESCALER External Trigger Prescaler
  763. * @{
  764. */
  765. #define LL_TIM_ETR_PRESCALER_DIV1 0x00000000U /*!< ETR prescaler OFF */
  766. #define LL_TIM_ETR_PRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR frequency is divided by 2 */
  767. #define LL_TIM_ETR_PRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR frequency is divided by 4 */
  768. #define LL_TIM_ETR_PRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR frequency is divided by 8 */
  769. /**
  770. * @}
  771. */
  772. /** @defgroup TIM_LL_EC_ETR_FILTER External Trigger Filter
  773. * @{
  774. */
  775. #define LL_TIM_ETR_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  776. #define LL_TIM_ETR_FILTER_FDIV1_N2 TIM_SMCR_ETF_0 /*!< fSAMPLING=fCK_INT, N=2 */
  777. #define LL_TIM_ETR_FILTER_FDIV1_N4 TIM_SMCR_ETF_1 /*!< fSAMPLING=fCK_INT, N=4 */
  778. #define LL_TIM_ETR_FILTER_FDIV1_N8 (TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fCK_INT, N=8 */
  779. #define LL_TIM_ETR_FILTER_FDIV2_N6 TIM_SMCR_ETF_2 /*!< fSAMPLING=fDTS/2, N=6 */
  780. #define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
  781. #define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
  782. #define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
  783. #define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=8 */
  784. #define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=5 */
  785. #define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=6 */
  786. #define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
  787. #define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=5 */
  788. #define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
  789. #define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
  790. #define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
  791. /**
  792. * @}
  793. */
  794. /** @defgroup TIM_LL_EC_ETRSOURCE External Trigger Source
  795. * @{
  796. */
  797. #define LL_TIM_ETRSOURCE_LEGACY 0x00000000U /*!< ETR legacy mode */
  798. #define LL_TIM_ETRSOURCE_COMP1 TIM1_OR2_ETRSEL_0 /*!< COMP1 output connected to ETR input */
  799. #define LL_TIM_ETRSOURCE_COMP2 TIM1_OR2_ETRSEL_1 /*!< COMP2 output connected to ETR input */
  800. /**
  801. * @}
  802. */
  803. /** @defgroup TIM_LL_EC_BREAK_POLARITY break polarity
  804. * @{
  805. */
  806. #define LL_TIM_BREAK_POLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
  807. #define LL_TIM_BREAK_POLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
  808. /**
  809. * @}
  810. */
  811. /** @defgroup TIM_LL_EC_BREAK_FILTER break filter
  812. * @{
  813. */
  814. #define LL_TIM_BREAK_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
  815. #define LL_TIM_BREAK_FILTER_FDIV1_N2 0x00010000U /*!< fSAMPLING=fCK_INT, N=2 */
  816. #define LL_TIM_BREAK_FILTER_FDIV1_N4 0x00020000U /*!< fSAMPLING=fCK_INT, N=4 */
  817. #define LL_TIM_BREAK_FILTER_FDIV1_N8 0x00030000U /*!< fSAMPLING=fCK_INT, N=8 */
  818. #define LL_TIM_BREAK_FILTER_FDIV2_N6 0x00040000U /*!< fSAMPLING=fDTS/2, N=6 */
  819. #define LL_TIM_BREAK_FILTER_FDIV2_N8 0x00050000U /*!< fSAMPLING=fDTS/2, N=8 */
  820. #define LL_TIM_BREAK_FILTER_FDIV4_N6 0x00060000U /*!< fSAMPLING=fDTS/4, N=6 */
  821. #define LL_TIM_BREAK_FILTER_FDIV4_N8 0x00070000U /*!< fSAMPLING=fDTS/4, N=8 */
  822. #define LL_TIM_BREAK_FILTER_FDIV8_N6 0x00080000U /*!< fSAMPLING=fDTS/8, N=6 */
  823. #define LL_TIM_BREAK_FILTER_FDIV8_N8 0x00090000U /*!< fSAMPLING=fDTS/8, N=8 */
  824. #define LL_TIM_BREAK_FILTER_FDIV16_N5 0x000A0000U /*!< fSAMPLING=fDTS/16, N=5 */
  825. #define LL_TIM_BREAK_FILTER_FDIV16_N6 0x000B0000U /*!< fSAMPLING=fDTS/16, N=6 */
  826. #define LL_TIM_BREAK_FILTER_FDIV16_N8 0x000C0000U /*!< fSAMPLING=fDTS/16, N=8 */
  827. #define LL_TIM_BREAK_FILTER_FDIV32_N5 0x000D0000U /*!< fSAMPLING=fDTS/32, N=5 */
  828. #define LL_TIM_BREAK_FILTER_FDIV32_N6 0x000E0000U /*!< fSAMPLING=fDTS/32, N=6 */
  829. #define LL_TIM_BREAK_FILTER_FDIV32_N8 0x000F0000U /*!< fSAMPLING=fDTS/32, N=8 */
  830. /**
  831. * @}
  832. */
  833. /** @defgroup TIM_LL_EC_BREAK2_POLARITY BREAK2 POLARITY
  834. * @{
  835. */
  836. #define LL_TIM_BREAK2_POLARITY_LOW 0x00000000U /*!< Break input BRK2 is active low */
  837. #define LL_TIM_BREAK2_POLARITY_HIGH TIM_BDTR_BK2P /*!< Break input BRK2 is active high */
  838. /**
  839. * @}
  840. */
  841. /** @defgroup TIM_LL_EC_BREAK2_FILTER BREAK2 FILTER
  842. * @{
  843. */
  844. #define LL_TIM_BREAK2_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
  845. #define LL_TIM_BREAK2_FILTER_FDIV1_N2 0x00100000U /*!< fSAMPLING=fCK_INT, N=2 */
  846. #define LL_TIM_BREAK2_FILTER_FDIV1_N4 0x00200000U /*!< fSAMPLING=fCK_INT, N=4 */
  847. #define LL_TIM_BREAK2_FILTER_FDIV1_N8 0x00300000U /*!< fSAMPLING=fCK_INT, N=8 */
  848. #define LL_TIM_BREAK2_FILTER_FDIV2_N6 0x00400000U /*!< fSAMPLING=fDTS/2, N=6 */
  849. #define LL_TIM_BREAK2_FILTER_FDIV2_N8 0x00500000U /*!< fSAMPLING=fDTS/2, N=8 */
  850. #define LL_TIM_BREAK2_FILTER_FDIV4_N6 0x00600000U /*!< fSAMPLING=fDTS/4, N=6 */
  851. #define LL_TIM_BREAK2_FILTER_FDIV4_N8 0x00700000U /*!< fSAMPLING=fDTS/4, N=8 */
  852. #define LL_TIM_BREAK2_FILTER_FDIV8_N6 0x00800000U /*!< fSAMPLING=fDTS/8, N=6 */
  853. #define LL_TIM_BREAK2_FILTER_FDIV8_N8 0x00900000U /*!< fSAMPLING=fDTS/8, N=8 */
  854. #define LL_TIM_BREAK2_FILTER_FDIV16_N5 0x00A00000U /*!< fSAMPLING=fDTS/16, N=5 */
  855. #define LL_TIM_BREAK2_FILTER_FDIV16_N6 0x00B00000U /*!< fSAMPLING=fDTS/16, N=6 */
  856. #define LL_TIM_BREAK2_FILTER_FDIV16_N8 0x00C00000U /*!< fSAMPLING=fDTS/16, N=8 */
  857. #define LL_TIM_BREAK2_FILTER_FDIV32_N5 0x00D00000U /*!< fSAMPLING=fDTS/32, N=5 */
  858. #define LL_TIM_BREAK2_FILTER_FDIV32_N6 0x00E00000U /*!< fSAMPLING=fDTS/32, N=6 */
  859. #define LL_TIM_BREAK2_FILTER_FDIV32_N8 0x00F00000U /*!< fSAMPLING=fDTS/32, N=8 */
  860. /**
  861. * @}
  862. */
  863. /** @defgroup TIM_LL_EC_OSSI OSSI
  864. * @{
  865. */
  866. #define LL_TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  867. #define LL_TIM_OSSI_ENABLE TIM_BDTR_OSSI /*!< When inactive, OxC/OCxN outputs are first forced with their inactive level then forced to their idle level after the deadtime */
  868. /**
  869. * @}
  870. */
  871. /** @defgroup TIM_LL_EC_OSSR OSSR
  872. * @{
  873. */
  874. #define LL_TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  875. #define LL_TIM_OSSR_ENABLE TIM_BDTR_OSSR /*!< When inactive, OC/OCN outputs are enabled with their inactive level as soon as CCxE=1 or CCxNE=1 */
  876. /**
  877. * @}
  878. */
  879. /** @defgroup TIM_LL_EC_BREAK_INPUT BREAK INPUT
  880. * @{
  881. */
  882. #define LL_TIM_BREAK_INPUT_BKIN 0x00000000U /*!< TIMx_BKIN input */
  883. #define LL_TIM_BREAK_INPUT_BKIN2 0x00000004U /*!< TIMx_BKIN2 input */
  884. /**
  885. * @}
  886. */
  887. /** @defgroup TIM_LL_EC_BKIN_SOURCE BKIN SOURCE
  888. * @{
  889. */
  890. #define LL_TIM_BKIN_SOURCE_BKIN TIM1_OR2_BKINE /*!< BKIN input from AF controller */
  891. #define LL_TIM_BKIN_SOURCE_BKCOMP1 TIM1_OR2_BKCMP1E /*!< internal signal: COMP1 output */
  892. #define LL_TIM_BKIN_SOURCE_BKCOMP2 TIM1_OR2_BKCMP2E /*!< internal signal: COMP2 output */
  893. #define LL_TIM_BKIN_SOURCE_DF1BK TIM1_OR2_BKDF1BK0E /*!< internal signal: DFSDM1 break output */
  894. /**
  895. * @}
  896. */
  897. /** @defgroup TIM_LL_EC_BKIN_POLARITY BKIN POLARITY
  898. * @{
  899. */
  900. #define LL_TIM_BKIN_POLARITY_LOW TIM1_OR2_BKINP /*!< BRK BKIN input is active low */
  901. #define LL_TIM_BKIN_POLARITY_HIGH 0x00000000U /*!< BRK BKIN input is active high */
  902. /**
  903. * @}
  904. */
  905. /** @defgroup TIM_LL_EC_DMABURST_BASEADDR DMA Burst Base Address
  906. * @{
  907. */
  908. #define LL_TIM_DMABURST_BASEADDR_CR1 0x00000000U /*!< TIMx_CR1 register is the DMA base address for DMA burst */
  909. #define LL_TIM_DMABURST_BASEADDR_CR2 TIM_DCR_DBA_0 /*!< TIMx_CR2 register is the DMA base address for DMA burst */
  910. #define LL_TIM_DMABURST_BASEADDR_SMCR TIM_DCR_DBA_1 /*!< TIMx_SMCR register is the DMA base address for DMA burst */
  911. #define LL_TIM_DMABURST_BASEADDR_DIER (TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_DIER register is the DMA base address for DMA burst */
  912. #define LL_TIM_DMABURST_BASEADDR_SR TIM_DCR_DBA_2 /*!< TIMx_SR register is the DMA base address for DMA burst */
  913. #define LL_TIM_DMABURST_BASEADDR_EGR (TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_EGR register is the DMA base address for DMA burst */
  914. #define LL_TIM_DMABURST_BASEADDR_CCMR1 (TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCMR1 register is the DMA base address for DMA burst */
  915. #define LL_TIM_DMABURST_BASEADDR_CCMR2 (TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCMR2 register is the DMA base address for DMA burst */
  916. #define LL_TIM_DMABURST_BASEADDR_CCER TIM_DCR_DBA_3 /*!< TIMx_CCER register is the DMA base address for DMA burst */
  917. #define LL_TIM_DMABURST_BASEADDR_CNT (TIM_DCR_DBA_3 | TIM_DCR_DBA_0) /*!< TIMx_CNT register is the DMA base address for DMA burst */
  918. #define LL_TIM_DMABURST_BASEADDR_PSC (TIM_DCR_DBA_3 | TIM_DCR_DBA_1) /*!< TIMx_PSC register is the DMA base address for DMA burst */
  919. #define LL_TIM_DMABURST_BASEADDR_ARR (TIM_DCR_DBA_3 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_ARR register is the DMA base address for DMA burst */
  920. #define LL_TIM_DMABURST_BASEADDR_RCR (TIM_DCR_DBA_3 | TIM_DCR_DBA_2) /*!< TIMx_RCR register is the DMA base address for DMA burst */
  921. #define LL_TIM_DMABURST_BASEADDR_CCR1 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_CCR1 register is the DMA base address for DMA burst */
  922. #define LL_TIM_DMABURST_BASEADDR_CCR2 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCR2 register is the DMA base address for DMA burst */
  923. #define LL_TIM_DMABURST_BASEADDR_CCR3 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCR3 register is the DMA base address for DMA burst */
  924. #define LL_TIM_DMABURST_BASEADDR_CCR4 TIM_DCR_DBA_4 /*!< TIMx_CCR4 register is the DMA base address for DMA burst */
  925. #define LL_TIM_DMABURST_BASEADDR_BDTR (TIM_DCR_DBA_4 | TIM_DCR_DBA_0) /*!< TIMx_BDTR register is the DMA base address for DMA burst */
  926. #define LL_TIM_DMABURST_BASEADDR_CCMR3 (TIM_DCR_DBA_4 | TIM_DCR_DBA_1) /*!< TIMx_CCMR3 register is the DMA base address for DMA burst */
  927. #define LL_TIM_DMABURST_BASEADDR_CCR5 (TIM_DCR_DBA_4 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCR5 register is the DMA base address for DMA burst */
  928. #define LL_TIM_DMABURST_BASEADDR_CCR6 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2) /*!< TIMx_CCR6 register is the DMA base address for DMA burst */
  929. #define LL_TIM_DMABURST_BASEADDR_OR1 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_OR1 register is the DMA base address for DMA burst */
  930. #define LL_TIM_DMABURST_BASEADDR_OR2 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_OR2 register is the DMA base address for DMA burst */
  931. #define LL_TIM_DMABURST_BASEADDR_OR3 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_OR3 register is the DMA base address for DMA burst */
  932. /**
  933. * @}
  934. */
  935. /** @defgroup TIM_LL_EC_DMABURST_LENGTH DMA Burst Length
  936. * @{
  937. */
  938. #define LL_TIM_DMABURST_LENGTH_1TRANSFER 0x00000000U /*!< Transfer is done to 1 register starting from the DMA burst base address */
  939. #define LL_TIM_DMABURST_LENGTH_2TRANSFERS TIM_DCR_DBL_0 /*!< Transfer is done to 2 registers starting from the DMA burst base address */
  940. #define LL_TIM_DMABURST_LENGTH_3TRANSFERS TIM_DCR_DBL_1 /*!< Transfer is done to 3 registers starting from the DMA burst base address */
  941. #define LL_TIM_DMABURST_LENGTH_4TRANSFERS (TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 4 registers starting from the DMA burst base address */
  942. #define LL_TIM_DMABURST_LENGTH_5TRANSFERS TIM_DCR_DBL_2 /*!< Transfer is done to 5 registers starting from the DMA burst base address */
  943. #define LL_TIM_DMABURST_LENGTH_6TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_0) /*!< Transfer is done to 6 registers starting from the DMA burst base address */
  944. #define LL_TIM_DMABURST_LENGTH_7TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_1) /*!< Transfer is done to 7 registers starting from the DMA burst base address */
  945. #define LL_TIM_DMABURST_LENGTH_8TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 1 registers starting from the DMA burst base address */
  946. #define LL_TIM_DMABURST_LENGTH_9TRANSFERS TIM_DCR_DBL_3 /*!< Transfer is done to 9 registers starting from the DMA burst base address */
  947. #define LL_TIM_DMABURST_LENGTH_10TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_0) /*!< Transfer is done to 10 registers starting from the DMA burst base address */
  948. #define LL_TIM_DMABURST_LENGTH_11TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_1) /*!< Transfer is done to 11 registers starting from the DMA burst base address */
  949. #define LL_TIM_DMABURST_LENGTH_12TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 12 registers starting from the DMA burst base address */
  950. #define LL_TIM_DMABURST_LENGTH_13TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2) /*!< Transfer is done to 13 registers starting from the DMA burst base address */
  951. #define LL_TIM_DMABURST_LENGTH_14TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_0) /*!< Transfer is done to 14 registers starting from the DMA burst base address */
  952. #define LL_TIM_DMABURST_LENGTH_15TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1) /*!< Transfer is done to 15 registers starting from the DMA burst base address */
  953. #define LL_TIM_DMABURST_LENGTH_16TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 16 registers starting from the DMA burst base address */
  954. #define LL_TIM_DMABURST_LENGTH_17TRANSFERS TIM_DCR_DBL_4 /*!< Transfer is done to 17 registers starting from the DMA burst base address */
  955. #define LL_TIM_DMABURST_LENGTH_18TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_0) /*!< Transfer is done to 18 registers starting from the DMA burst base address */
  956. /**
  957. * @}
  958. */
  959. /** @defgroup TIM_LL_EC_TIM1_ETR_ADC1_RMP TIM1 External Trigger ADC1 Remap
  960. * @{
  961. */
  962. #define LL_TIM_TIM1_ETR_ADC1_RMP_NC TIM1_OR1_RMP_MASK /*!< TIM1_ETR is not connected to ADC1 analog watchdog x */
  963. #define LL_TIM_TIM1_ETR_ADC1_RMP_AWD1 (TIM1_OR1_ETR_ADC1_RMP_0 | TIM1_OR1_RMP_MASK) /*!< TIM1_ETR is connected to ADC1 analog watchdog 1 */
  964. #define LL_TIM_TIM1_ETR_ADC1_RMP_AWD2 (TIM1_OR1_ETR_ADC1_RMP_1 | TIM1_OR1_RMP_MASK) /*!< TIM1_ETR is connected to ADC1 analog watchdog 2 */
  965. #define LL_TIM_TIM1_ETR_ADC1_RMP_AWD3 (TIM1_OR1_ETR_ADC1_RMP | TIM1_OR1_RMP_MASK) /*!< TIM1_ETR is connected to ADC1 analog watchdog 3 */
  966. /**
  967. * @}
  968. */
  969. #if defined(ADC3)
  970. /** @defgroup TIM_LL_EC_TIM1_ETR_ADC3_RMP TIM1 External Trigger ADC3 Remap
  971. * @{
  972. */
  973. #define LL_TIM_TIM1_ETR_ADC3_RMP_NC TIM1_OR1_RMP_MASK /*!< TIM1_ETR is not connected to ADC3 analog watchdog x*/
  974. #define LL_TIM_TIM1_ETR_ADC3_RMP_AWD1 (TIM1_OR1_ETR_ADC3_RMP_0 | TIM1_OR1_RMP_MASK) /*!< TIM1_ETR is connected to ADC3 analog watchdog 1 */
  975. #define LL_TIM_TIM1_ETR_ADC3_RMP_AWD2 (TIM1_OR1_ETR_ADC3_RMP_1 | TIM1_OR1_RMP_MASK) /*!< TIM1_ETR is connected to ADC3 analog watchdog 2 */
  976. #define LL_TIM_TIM1_ETR_ADC3_RMP_AWD3 (TIM1_OR1_ETR_ADC3_RMP | TIM1_OR1_RMP_MASK) /*!< TIM1_ETR is connected to ADC3 analog watchdog 3 */
  977. /**
  978. * @}
  979. */
  980. #endif /* ADC3 */
  981. /** @defgroup TIM_LL_EC_TIM1_TI1_RMP TIM1 External Input Ch1 Remap
  982. * @{
  983. */
  984. #define LL_TIM_TIM1_TI1_RMP_GPIO TIM1_OR1_RMP_MASK /*!< TIM1 input capture 1 is connected to GPIO */
  985. #define LL_TIM_TIM1_TI1_RMP_COMP1 (TIM1_OR1_TI1_RMP | TIM1_OR1_RMP_MASK) /*!< TIM1 input capture 1 is connected to COMP1 output */
  986. /**
  987. * @}
  988. */
  989. /** @defgroup TIM_LL_EC_TIM2_ITR1_RMP TIM2 Internal Trigger1 Remap
  990. * @{
  991. */
  992. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx)
  993. #define LL_TIM_TIM2_ITR1_RMP_TIM8_TRGO TIM2_OR1_RMP_MASK /*!< TIM2_ITR1 is connected to TIM8_TRGO */
  994. #define LL_TIM_TIM2_ITR1_RMP_OTG_FS_SOF (TIM2_OR1_ITR1_RMP | TIM2_OR1_RMP_MASK) /*!< TIM2_ITR1 is connected to OTG_FS SOF */
  995. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  996. /* STM32L496xx || STM32L4A6xx */
  997. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
  998. #define LL_TIM_TIM2_ITR1_RMP_NONE 0x00000000U /* !< No internal trigger on TIM2_ITR1 */
  999. #define LL_TIM_TIM2_ITR1_RMP_USB_SOF TIM2_OR1_ITR1_RMP /* !< TIM2_ITR1 is connected to USB SOF */
  1000. #endif /* STM32L431xx || STM32L432xx || STM32L442xx || STM32L433xx || STM32L443xx || */
  1001. /* STM32L451xx || STM32L452xx || STM32L462xx */
  1002. #define LL_TIM_TIM2_ETR_RMP_GPIO TIM2_OR1_RMP_MASK /*!< TIM2_ETR is connected to GPIO */
  1003. #define LL_TIM_TIM2_ETR_RMP_LSE (TIM2_OR1_ETR1_RMP | TIM2_OR1_RMP_MASK) /*!< TIM2_ETR is connected to LSE */
  1004. /**
  1005. * @}
  1006. */
  1007. /** @defgroup TIM_LL_EC_TIM2_TI4_RMP TIM2 External Input Ch4 Remap
  1008. * @{
  1009. */
  1010. #define LL_TIM_TIM2_TI4_RMP_GPIO TIM2_OR1_RMP_MASK /*!< TIM2 input capture 4 is connected to GPIO */
  1011. #define LL_TIM_TIM2_TI4_RMP_COMP1 (TIM2_OR1_TI4_RMP_0 | TIM2_OR1_RMP_MASK) /*!< TIM2 input capture 4 is connected to COMP1_OUT */
  1012. #define LL_TIM_TIM2_TI4_RMP_COMP2 (TIM2_OR1_TI4_RMP_1 | TIM2_OR1_RMP_MASK) /*!< TIM2 input capture 4 is connected to COMP2_OUT */
  1013. #define LL_TIM_TIM2_TI4_RMP_COMP1_COMP2 (TIM2_OR1_TI4_RMP | TIM2_OR1_RMP_MASK) /*!< TIM2 input capture 4 is connected to logical OR between COMP1_OUT and COMP2_OUT */
  1014. /**
  1015. * @}
  1016. */
  1017. #if defined(TIM3)
  1018. /** @defgroup TIM_LL_EC_TIM3_TI1_RMP TIM3 External Input Ch1 Remap
  1019. * @{
  1020. */
  1021. #define LL_TIM_TIM3_TI1_RMP_GPIO TIM3_OR1_RMP_MASK /*!< TIM3 input capture 1 is connected to GPIO */
  1022. #define LL_TIM_TIM3_TI1_RMP_COMP1 (TIM3_OR1_TI1_RMP_0 | TIM3_OR1_RMP_MASK) /*!< TIM3 input capture 1 is connected to COMP1_OUT */
  1023. #define LL_TIM_TIM3_TI1_RMP_COMP2 (TIM3_OR1_TI1_RMP_1 | TIM3_OR1_RMP_MASK) /*!< TIM3 input capture 1 is connected to COMP2_OUT */
  1024. #define LL_TIM_TIM3_TI1_RMP_COMP1_COMP2 (TIM3_OR1_TI1_RMP | TIM3_OR1_RMP_MASK) /*!< TIM3 input capture 1 is connected to logical OR between COMP1_OUT and COMP2_OUT */
  1025. /**
  1026. * @}
  1027. */
  1028. #endif /* TIM3 */
  1029. #if defined(TIM8)
  1030. /** @defgroup TIM_LL_EC_TIM8_ETR_ADC2_RMP TIM8 External Trigger ADC2 Remap
  1031. * @{
  1032. */
  1033. #define LL_TIM_TIM8_ETR_ADC2_RMP_NC TIM8_OR1_RMP_MASK /*!< TIM8_ETR is not connected to ADC2 analog watchdog x */
  1034. #define LL_TIM_TIM8_ETR_ADC2_RMP_AWD1 (TIM8_OR1_ETR_ADC2_RMP_0 | TIM8_OR1_RMP_MASK) /*!< TIM8_ETR is connected to ADC2 analog watchdog */
  1035. #define LL_TIM_TIM8_ETR_ADC2_RMP_AWD2 (TIM8_OR1_ETR_ADC2_RMP_1 | TIM8_OR1_RMP_MASK) /*!< TIM8_ETR is connected to ADC2 analog watchdog 2 */
  1036. #define LL_TIM_TIM8_ETR_ADC2_RMP_AWD3 (TIM8_OR1_ETR_ADC2_RMP | TIM8_OR1_RMP_MASK) /*!< TIM8_ETR is connected to ADC2 analog watchdog 3 */
  1037. /**
  1038. * @}
  1039. */
  1040. /** @defgroup TIM_LL_EC_TIM8_ETR_ADC3_RMP TIM8 External Trigger ADC3 Remap
  1041. * @{
  1042. */
  1043. #define LL_TIM_TIM8_ETR_ADC3_RMP_NC TIM8_OR1_RMP_MASK /*!< TIM8_ETR is not connected to ADC3 analog watchdog x */
  1044. #define LL_TIM_TIM8_ETR_ADC3_RMP_AWD1 (TIM8_OR1_ETR_ADC3_RMP_0 | TIM8_OR1_RMP_MASK) /*!< TIM8_ETR is connected to ADC3 analog watchdog 1 */
  1045. #define LL_TIM_TIM8_ETR_ADC3_RMP_AWD2 (TIM8_OR1_ETR_ADC3_RMP_1 | TIM8_OR1_RMP_MASK) /*!< TIM8_ETR is connected to ADC3 analog watchdog 2 */
  1046. #define LL_TIM_TIM8_ETR_ADC3_RMP_AWD3 (TIM8_OR1_ETR_ADC3_RMP | TIM8_OR1_RMP_MASK) /*!< TIM8_ETR is connected to ADC3 analog watchdog 3 */
  1047. /**
  1048. * @}
  1049. */
  1050. /** @defgroup TIM_LL_EC_TIM8_TI1_RMP TIM8 External Input Ch1 Remap
  1051. * @{
  1052. */
  1053. #define LL_TIM_TIM8_TI1_RMP_GPIO TIM8_OR1_RMP_MASK /*!< TIM8 input capture 1 is connected to GPIO */
  1054. #define LL_TIM_TIM8_TI1_RMP_COMP2 (TIM8_OR1_TI1_RMP | TIM8_OR1_RMP_MASK) /*!< TIM8 input capture 1 is connected to COMP2 output */
  1055. /**
  1056. * @}
  1057. */
  1058. #endif /* TIM8 */
  1059. /** @defgroup TIM_LL_EC_TIM15_TI1_RMP TIM15 External Input Ch1 Remap
  1060. * @{
  1061. */
  1062. #define LL_TIM_TIM15_TI1_RMP_GPIO TIM15_OR1_RMP_MASK /*!< TIM15 input capture 1 is connected to GPIO */
  1063. #define LL_TIM_TIM15_TI1_RMP_LSE (TIM15_OR1_TI1_RMP | TIM15_OR1_RMP_MASK) /*!< TIM15 input capture 1 is connected to LSE */
  1064. /**
  1065. * @}
  1066. */
  1067. /** @defgroup TIM_LL_EC_TIM15_ENCODERMODE TIM15 ENCODERMODE
  1068. * @{
  1069. */
  1070. #define LL_TIM_TIM15_ENCODERMODE_NOREDIRECTION TIM15_OR1_RMP_MASK /*!< No redirection*/
  1071. #define LL_TIM_TIM15_ENCODERMODE_TIM2 (TIM15_OR1_ENCODER_MODE_0 | TIM15_OR1_RMP_MASK) /*!< TIM2 IC1 and TIM2 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively */
  1072. #define LL_TIM_TIM15_ENCODERMODE_TIM3 (TIM15_OR1_ENCODER_MODE_1 | TIM15_OR1_RMP_MASK) /*!< TIM3 IC1 and TIM3 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectivel y*/
  1073. #define LL_TIM_TIM15_ENCODERMODE_TIM4 (TIM15_OR1_ENCODER_MODE | TIM15_OR1_RMP_MASK) /*!< TIM4 IC1 and TIM4 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively */
  1074. /**
  1075. * @}
  1076. */
  1077. /** @defgroup TIM_LL_EC_TIM16_TI1_RMP TIM16 External Input Ch1 Remap
  1078. * @{
  1079. */
  1080. #define LL_TIM_TIM16_TI1_RMP_GPIO TIM16_OR1_RMP_MASK /*!< TIM16 input capture 1 is connected to GPIO */
  1081. #define LL_TIM_TIM16_TI1_RMP_LSI (TIM16_OR1_TI1_RMP_0 | TIM16_OR1_RMP_MASK) /*!< TIM16 input capture 1 is connected to LSI */
  1082. #define LL_TIM_TIM16_TI1_RMP_LSE (TIM16_OR1_TI1_RMP_1 | TIM16_OR1_RMP_MASK) /*!< TIM16 input capture 1 is connected to LSE */
  1083. #define LL_TIM_TIM16_TI1_RMP_RTC (TIM16_OR1_TI1_RMP_1 | TIM16_OR1_TI1_RMP_0 | TIM16_OR1_RMP_MASK) /*!< TIM16 input capture 1 is connected to RTC wakeup interrupt */
  1084. #if defined TIM16_OR1_TI1_RMP_2
  1085. #define LL_TIM_TIM16_TI1_RMP_MSI (TIM16_OR1_TI1_RMP_2 | TIM16_OR1_RMP_MASK) /*!< TIM16 input capture 1 is connected to MSI */
  1086. #define LL_TIM_TIM16_TI1_RMP_HSE_32 (TIM16_OR1_TI1_RMP_2 | TIM16_OR1_TI1_RMP_0 | TIM16_OR1_RMP_MASK) /*!< TIM16 input capture 1 is connected to HSE/32 */
  1087. #define LL_TIM_TIM16_TI1_RMP_MCO (TIM16_OR1_TI1_RMP_2 | TIM16_OR1_TI1_RMP_1 | TIM16_OR1_RMP_MASK) /*!< TIM16 input capture 1 is connected to MCO */
  1088. #endif
  1089. /**
  1090. * @}
  1091. */
  1092. #if defined(TIM17)
  1093. /** @defgroup TIM_LL_EC_TIM17_TI1_RMP TIM17 Timer Input Ch1 Remap
  1094. * @{
  1095. */
  1096. #define LL_TIM_TIM17_TI1_RMP_GPIO TIM17_OR1_RMP_MASK /*!< TIM17 input capture 1 is connected to GPIO */
  1097. #define LL_TIM_TIM17_TI1_RMP_MSI (TIM17_OR1_TI1_RMP_0 | TIM17_OR1_RMP_MASK) /*!< TIM17 input capture 1 is connected to MSI */
  1098. #define LL_TIM_TIM17_TI1_RMP_HSE_32 (TIM17_OR1_TI1_RMP_1 | TIM17_OR1_RMP_MASK) /*!< TIM17 input capture 1 is connected to HSE/32 */
  1099. #define LL_TIM_TIM17_TI1_RMP_MCO (TIM17_OR1_TI1_RMP | TIM17_OR1_RMP_MASK) /*!< TIM17 input capture 1 is connected to MCO */
  1100. /**
  1101. * @}
  1102. */
  1103. #endif /* TIM17 */
  1104. /** @defgroup TIM_LL_EC_OCREF_CLR_INT OCREF clear input selection
  1105. * @{
  1106. */
  1107. #define LL_TIM_OCREF_CLR_INT_NC 0x00000000U /*!< OCREF_CLR_INT is not connected */
  1108. #define LL_TIM_OCREF_CLR_INT_ETR TIM_SMCR_OCCS /*!< OCREF_CLR_INT is connected to ETRF */
  1109. /**
  1110. * @}
  1111. */
  1112. /** Legacy definitions for compatibility purpose
  1113. @cond 0
  1114. */
  1115. #define LL_TIM_BKIN_SOURCE_DFBK LL_TIM_BKIN_SOURCE_DF1BK
  1116. /**
  1117. @endcond
  1118. */
  1119. /**
  1120. * @}
  1121. */
  1122. /* Exported macro ------------------------------------------------------------*/
  1123. /** @defgroup TIM_LL_Exported_Macros TIM Exported Macros
  1124. * @{
  1125. */
  1126. /** @defgroup TIM_LL_EM_WRITE_READ Common Write and read registers Macros
  1127. * @{
  1128. */
  1129. /**
  1130. * @brief Write a value in TIM register.
  1131. * @param __INSTANCE__ TIM Instance
  1132. * @param __REG__ Register to be written
  1133. * @param __VALUE__ Value to be written in the register
  1134. * @retval None
  1135. */
  1136. #define LL_TIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1137. /**
  1138. * @brief Read a value in TIM register.
  1139. * @param __INSTANCE__ TIM Instance
  1140. * @param __REG__ Register to be read
  1141. * @retval Register value
  1142. */
  1143. #define LL_TIM_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1144. /**
  1145. * @}
  1146. */
  1147. /** @defgroup TIM_LL_EM_Exported_Macros Exported_Macros
  1148. * @{
  1149. */
  1150. /**
  1151. * @brief HELPER macro retrieving the UIFCPY flag from the counter value.
  1152. * @note ex: @ref __LL_TIM_GETFLAG_UIFCPY (@ref LL_TIM_GetCounter ());
  1153. * @note Relevant only if UIF flag remapping has been enabled (UIF status bit is copied
  1154. * to TIMx_CNT register bit 31)
  1155. * @param __CNT__ Counter value
  1156. * @retval UIF status bit
  1157. */
  1158. #define __LL_TIM_GETFLAG_UIFCPY(__CNT__) \
  1159. (READ_BIT((__CNT__), TIM_CNT_UIFCPY) >> TIM_CNT_UIFCPY_Pos)
  1160. /**
  1161. * @brief HELPER macro calculating DTG[0:7] in the TIMx_BDTR register to achieve the requested dead time duration.
  1162. * @note ex: @ref __LL_TIM_CALC_DEADTIME (80000000, @ref LL_TIM_GetClockDivision (), 120);
  1163. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1164. * @param __CKD__ This parameter can be one of the following values:
  1165. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1166. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1167. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1168. * @param __DT__ deadtime duration (in ns)
  1169. * @retval DTG[0:7]
  1170. */
  1171. #define __LL_TIM_CALC_DEADTIME(__TIMCLK__, __CKD__, __DT__) \
  1172. ( (((uint64_t)((__DT__)*1000U)) < ((DT_DELAY_1+1U) * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(((uint64_t)((__DT__)*1000U) / TIM_CALC_DTS((__TIMCLK__), (__CKD__))) & DT_DELAY_1) : \
  1173. (((uint64_t)((__DT__)*1000U)) < (64U + (DT_DELAY_2+1U)) * 2U * TIM_CALC_DTS((__TIMCLK__), (__CKD__))) ? (uint8_t)(DT_RANGE_2 | ((uint8_t)((uint8_t)((((uint64_t)((__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 1U) - (uint8_t) 64U) & DT_DELAY_2)) :\
  1174. (((uint64_t)((__DT__)*1000U)) < (32U + (DT_DELAY_3+1U)) * 8U * TIM_CALC_DTS((__TIMCLK__), (__CKD__))) ? (uint8_t)(DT_RANGE_3 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 3U) - (uint8_t) 32U) & DT_DELAY_3)) :\
  1175. (((uint64_t)((__DT__)*1000U)) < (32U + (DT_DELAY_4+1U)) * 16U * TIM_CALC_DTS((__TIMCLK__), (__CKD__))) ? (uint8_t)(DT_RANGE_4 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 4U) - (uint8_t) 32U) & DT_DELAY_4)) :\
  1176. 0U)
  1177. /**
  1178. * @brief HELPER macro calculating the prescaler value to achieve the required counter clock frequency.
  1179. * @note ex: @ref __LL_TIM_CALC_PSC (80000000, 1000000);
  1180. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1181. * @param __CNTCLK__ counter clock frequency (in Hz)
  1182. * @retval Prescaler value (between Min_Data=0 and Max_Data=65535)
  1183. */
  1184. #define __LL_TIM_CALC_PSC(__TIMCLK__, __CNTCLK__) \
  1185. ((__TIMCLK__) >= (__CNTCLK__)) ? (uint32_t)((__TIMCLK__)/(__CNTCLK__) - 1U) : 0U
  1186. /**
  1187. * @brief HELPER macro calculating the auto-reload value to achieve the required output signal frequency.
  1188. * @note ex: @ref __LL_TIM_CALC_ARR (1000000, @ref LL_TIM_GetPrescaler (), 10000);
  1189. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1190. * @param __PSC__ prescaler
  1191. * @param __FREQ__ output signal frequency (in Hz)
  1192. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1193. */
  1194. #define __LL_TIM_CALC_ARR(__TIMCLK__, __PSC__, __FREQ__) \
  1195. (((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? ((__TIMCLK__)/((__FREQ__) * ((__PSC__) + 1U)) - 1U) : 0U
  1196. /**
  1197. * @brief HELPER macro calculating the compare value required to achieve the required timer output compare active/inactive delay.
  1198. * @note ex: @ref __LL_TIM_CALC_DELAY (1000000, @ref LL_TIM_GetPrescaler (), 10);
  1199. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1200. * @param __PSC__ prescaler
  1201. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1202. * @retval Compare value (between Min_Data=0 and Max_Data=65535)
  1203. */
  1204. #define __LL_TIM_CALC_DELAY(__TIMCLK__, __PSC__, __DELAY__) \
  1205. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__)) \
  1206. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  1207. /**
  1208. * @brief HELPER macro calculating the auto-reload value to achieve the required pulse duration (when the timer operates in one pulse mode).
  1209. * @note ex: @ref __LL_TIM_CALC_PULSE (1000000, @ref LL_TIM_GetPrescaler (), 10, 20);
  1210. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1211. * @param __PSC__ prescaler
  1212. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1213. * @param __PULSE__ pulse duration (in us)
  1214. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1215. */
  1216. #define __LL_TIM_CALC_PULSE(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  1217. ((uint32_t)(__LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__PULSE__)) \
  1218. + __LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__DELAY__))))
  1219. /**
  1220. * @brief HELPER macro retrieving the ratio of the input capture prescaler
  1221. * @note ex: @ref __LL_TIM_GET_ICPSC_RATIO (@ref LL_TIM_IC_GetPrescaler ());
  1222. * @param __ICPSC__ This parameter can be one of the following values:
  1223. * @arg @ref LL_TIM_ICPSC_DIV1
  1224. * @arg @ref LL_TIM_ICPSC_DIV2
  1225. * @arg @ref LL_TIM_ICPSC_DIV4
  1226. * @arg @ref LL_TIM_ICPSC_DIV8
  1227. * @retval Input capture prescaler ratio (1, 2, 4 or 8)
  1228. */
  1229. #define __LL_TIM_GET_ICPSC_RATIO(__ICPSC__) \
  1230. ((uint32_t)(0x01U << (((__ICPSC__) >> 16U) >> TIM_CCMR1_IC1PSC_Pos)))
  1231. /**
  1232. * @}
  1233. */
  1234. /**
  1235. * @}
  1236. */
  1237. /* Exported functions --------------------------------------------------------*/
  1238. /** @defgroup TIM_LL_Exported_Functions TIM Exported Functions
  1239. * @{
  1240. */
  1241. /** @defgroup TIM_LL_EF_Time_Base Time Base configuration
  1242. * @{
  1243. */
  1244. /**
  1245. * @brief Enable timer counter.
  1246. * @rmtoll CR1 CEN LL_TIM_EnableCounter
  1247. * @param TIMx Timer instance
  1248. * @retval None
  1249. */
  1250. __STATIC_INLINE void LL_TIM_EnableCounter(TIM_TypeDef *TIMx)
  1251. {
  1252. SET_BIT(TIMx->CR1, TIM_CR1_CEN);
  1253. }
  1254. /**
  1255. * @brief Disable timer counter.
  1256. * @rmtoll CR1 CEN LL_TIM_DisableCounter
  1257. * @param TIMx Timer instance
  1258. * @retval None
  1259. */
  1260. __STATIC_INLINE void LL_TIM_DisableCounter(TIM_TypeDef *TIMx)
  1261. {
  1262. CLEAR_BIT(TIMx->CR1, TIM_CR1_CEN);
  1263. }
  1264. /**
  1265. * @brief Indicates whether the timer counter is enabled.
  1266. * @rmtoll CR1 CEN LL_TIM_IsEnabledCounter
  1267. * @param TIMx Timer instance
  1268. * @retval State of bit (1 or 0).
  1269. */
  1270. __STATIC_INLINE uint32_t LL_TIM_IsEnabledCounter(TIM_TypeDef *TIMx)
  1271. {
  1272. return (READ_BIT(TIMx->CR1, TIM_CR1_CEN) == (TIM_CR1_CEN));
  1273. }
  1274. /**
  1275. * @brief Enable update event generation.
  1276. * @rmtoll CR1 UDIS LL_TIM_EnableUpdateEvent
  1277. * @param TIMx Timer instance
  1278. * @retval None
  1279. */
  1280. __STATIC_INLINE void LL_TIM_EnableUpdateEvent(TIM_TypeDef *TIMx)
  1281. {
  1282. CLEAR_BIT(TIMx->CR1, TIM_CR1_UDIS);
  1283. }
  1284. /**
  1285. * @brief Disable update event generation.
  1286. * @rmtoll CR1 UDIS LL_TIM_DisableUpdateEvent
  1287. * @param TIMx Timer instance
  1288. * @retval None
  1289. */
  1290. __STATIC_INLINE void LL_TIM_DisableUpdateEvent(TIM_TypeDef *TIMx)
  1291. {
  1292. SET_BIT(TIMx->CR1, TIM_CR1_UDIS);
  1293. }
  1294. /**
  1295. * @brief Indicates whether update event generation is enabled.
  1296. * @rmtoll CR1 UDIS LL_TIM_IsEnabledUpdateEvent
  1297. * @param TIMx Timer instance
  1298. * @retval Inverted state of bit (0 or 1).
  1299. */
  1300. __STATIC_INLINE uint32_t LL_TIM_IsEnabledUpdateEvent(TIM_TypeDef *TIMx)
  1301. {
  1302. return (READ_BIT(TIMx->CR1, TIM_CR1_UDIS) == RESET);
  1303. }
  1304. /**
  1305. * @brief Set update event source
  1306. * @note Update event source set to LL_TIM_UPDATESOURCE_REGULAR: any of the following events
  1307. * generate an update interrupt or DMA request if enabled:
  1308. * - Counter overflow/underflow
  1309. * - Setting the UG bit
  1310. * - Update generation through the slave mode controller
  1311. * @note Update event source set to LL_TIM_UPDATESOURCE_COUNTER: only counter
  1312. * overflow/underflow generates an update interrupt or DMA request if enabled.
  1313. * @rmtoll CR1 URS LL_TIM_SetUpdateSource
  1314. * @param TIMx Timer instance
  1315. * @param UpdateSource This parameter can be one of the following values:
  1316. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  1317. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  1318. * @retval None
  1319. */
  1320. __STATIC_INLINE void LL_TIM_SetUpdateSource(TIM_TypeDef *TIMx, uint32_t UpdateSource)
  1321. {
  1322. MODIFY_REG(TIMx->CR1, TIM_CR1_URS, UpdateSource);
  1323. }
  1324. /**
  1325. * @brief Get actual event update source
  1326. * @rmtoll CR1 URS LL_TIM_GetUpdateSource
  1327. * @param TIMx Timer instance
  1328. * @retval Returned value can be one of the following values:
  1329. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  1330. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  1331. */
  1332. __STATIC_INLINE uint32_t LL_TIM_GetUpdateSource(TIM_TypeDef *TIMx)
  1333. {
  1334. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_URS));
  1335. }
  1336. /**
  1337. * @brief Set one pulse mode (one shot v.s. repetitive).
  1338. * @rmtoll CR1 OPM LL_TIM_SetOnePulseMode
  1339. * @param TIMx Timer instance
  1340. * @param OnePulseMode This parameter can be one of the following values:
  1341. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  1342. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  1343. * @retval None
  1344. */
  1345. __STATIC_INLINE void LL_TIM_SetOnePulseMode(TIM_TypeDef *TIMx, uint32_t OnePulseMode)
  1346. {
  1347. MODIFY_REG(TIMx->CR1, TIM_CR1_OPM, OnePulseMode);
  1348. }
  1349. /**
  1350. * @brief Get actual one pulse mode.
  1351. * @rmtoll CR1 OPM LL_TIM_GetOnePulseMode
  1352. * @param TIMx Timer instance
  1353. * @retval Returned value can be one of the following values:
  1354. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  1355. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  1356. */
  1357. __STATIC_INLINE uint32_t LL_TIM_GetOnePulseMode(TIM_TypeDef *TIMx)
  1358. {
  1359. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_OPM));
  1360. }
  1361. /**
  1362. * @brief Set the timer counter counting mode.
  1363. * @note Macro @ref IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1364. * check whether or not the counter mode selection feature is supported
  1365. * by a timer instance.
  1366. * @rmtoll CR1 DIR LL_TIM_SetCounterMode\n
  1367. * CR1 CMS LL_TIM_SetCounterMode
  1368. * @param TIMx Timer instance
  1369. * @param CounterMode This parameter can be one of the following values:
  1370. * @arg @ref LL_TIM_COUNTERMODE_UP
  1371. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1372. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1373. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1374. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1375. * @retval None
  1376. */
  1377. __STATIC_INLINE void LL_TIM_SetCounterMode(TIM_TypeDef *TIMx, uint32_t CounterMode)
  1378. {
  1379. MODIFY_REG(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS, CounterMode);
  1380. }
  1381. /**
  1382. * @brief Get actual counter mode.
  1383. * @note Macro @ref IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1384. * check whether or not the counter mode selection feature is supported
  1385. * by a timer instance.
  1386. * @rmtoll CR1 DIR LL_TIM_GetCounterMode\n
  1387. * CR1 CMS LL_TIM_GetCounterMode
  1388. * @param TIMx Timer instance
  1389. * @retval Returned value can be one of the following values:
  1390. * @arg @ref LL_TIM_COUNTERMODE_UP
  1391. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1392. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1393. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1394. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1395. */
  1396. __STATIC_INLINE uint32_t LL_TIM_GetCounterMode(TIM_TypeDef *TIMx)
  1397. {
  1398. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS));
  1399. }
  1400. /**
  1401. * @brief Enable auto-reload (ARR) preload.
  1402. * @rmtoll CR1 ARPE LL_TIM_EnableARRPreload
  1403. * @param TIMx Timer instance
  1404. * @retval None
  1405. */
  1406. __STATIC_INLINE void LL_TIM_EnableARRPreload(TIM_TypeDef *TIMx)
  1407. {
  1408. SET_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1409. }
  1410. /**
  1411. * @brief Disable auto-reload (ARR) preload.
  1412. * @rmtoll CR1 ARPE LL_TIM_DisableARRPreload
  1413. * @param TIMx Timer instance
  1414. * @retval None
  1415. */
  1416. __STATIC_INLINE void LL_TIM_DisableARRPreload(TIM_TypeDef *TIMx)
  1417. {
  1418. CLEAR_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1419. }
  1420. /**
  1421. * @brief Indicates whether auto-reload (ARR) preload is enabled.
  1422. * @rmtoll CR1 ARPE LL_TIM_IsEnabledARRPreload
  1423. * @param TIMx Timer instance
  1424. * @retval State of bit (1 or 0).
  1425. */
  1426. __STATIC_INLINE uint32_t LL_TIM_IsEnabledARRPreload(TIM_TypeDef *TIMx)
  1427. {
  1428. return (READ_BIT(TIMx->CR1, TIM_CR1_ARPE) == (TIM_CR1_ARPE));
  1429. }
  1430. /**
  1431. * @brief Set the division ratio between the timer clock and the sampling clock used by the dead-time generators (when supported) and the digital filters.
  1432. * @note Macro @ref IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1433. * whether or not the clock division feature is supported by the timer
  1434. * instance.
  1435. * @rmtoll CR1 CKD LL_TIM_SetClockDivision
  1436. * @param TIMx Timer instance
  1437. * @param ClockDivision This parameter can be one of the following values:
  1438. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1439. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1440. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1441. * @retval None
  1442. */
  1443. __STATIC_INLINE void LL_TIM_SetClockDivision(TIM_TypeDef *TIMx, uint32_t ClockDivision)
  1444. {
  1445. MODIFY_REG(TIMx->CR1, TIM_CR1_CKD, ClockDivision);
  1446. }
  1447. /**
  1448. * @brief Get the actual division ratio between the timer clock and the sampling clock used by the dead-time generators (when supported) and the digital filters.
  1449. * @note Macro @ref IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1450. * whether or not the clock division feature is supported by the timer
  1451. * instance.
  1452. * @rmtoll CR1 CKD LL_TIM_GetClockDivision
  1453. * @param TIMx Timer instance
  1454. * @retval Returned value can be one of the following values:
  1455. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1456. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1457. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1458. */
  1459. __STATIC_INLINE uint32_t LL_TIM_GetClockDivision(TIM_TypeDef *TIMx)
  1460. {
  1461. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_CKD));
  1462. }
  1463. /**
  1464. * @brief Set the counter value.
  1465. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1466. * whether or not a timer instance supports a 32 bits counter.
  1467. * @rmtoll CNT CNT LL_TIM_SetCounter
  1468. * @param TIMx Timer instance
  1469. * @param Counter Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  1470. * @retval None
  1471. */
  1472. __STATIC_INLINE void LL_TIM_SetCounter(TIM_TypeDef *TIMx, uint32_t Counter)
  1473. {
  1474. WRITE_REG(TIMx->CNT, Counter);
  1475. }
  1476. /**
  1477. * @brief Get the counter value.
  1478. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1479. * whether or not a timer instance supports a 32 bits counter.
  1480. * @rmtoll CNT CNT LL_TIM_GetCounter
  1481. * @param TIMx Timer instance
  1482. * @retval Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  1483. */
  1484. __STATIC_INLINE uint32_t LL_TIM_GetCounter(TIM_TypeDef *TIMx)
  1485. {
  1486. return (uint32_t)(READ_REG(TIMx->CNT));
  1487. }
  1488. /**
  1489. * @brief Get the current direction of the counter
  1490. * @rmtoll CR1 DIR LL_TIM_GetDirection
  1491. * @param TIMx Timer instance
  1492. * @retval Returned value can be one of the following values:
  1493. * @arg @ref LL_TIM_COUNTERDIRECTION_UP
  1494. * @arg @ref LL_TIM_COUNTERDIRECTION_DOWN
  1495. */
  1496. __STATIC_INLINE uint32_t LL_TIM_GetDirection(TIM_TypeDef *TIMx)
  1497. {
  1498. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR));
  1499. }
  1500. /**
  1501. * @brief Set the prescaler value.
  1502. * @note The counter clock frequency CK_CNT is equal to fCK_PSC / (PSC[15:0] + 1).
  1503. * @note The prescaler can be changed on the fly as this control register is buffered. The new
  1504. * prescaler ratio is taken into account at the next update event.
  1505. * @note Helper macro @ref __LL_TIM_CALC_PSC can be used to calculate the Prescaler parameter
  1506. * @rmtoll PSC PSC LL_TIM_SetPrescaler
  1507. * @param TIMx Timer instance
  1508. * @param Prescaler between Min_Data=0 and Max_Data=65535
  1509. * @retval None
  1510. */
  1511. __STATIC_INLINE void LL_TIM_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Prescaler)
  1512. {
  1513. WRITE_REG(TIMx->PSC, Prescaler);
  1514. }
  1515. /**
  1516. * @brief Get the prescaler value.
  1517. * @rmtoll PSC PSC LL_TIM_GetPrescaler
  1518. * @param TIMx Timer instance
  1519. * @retval Prescaler value between Min_Data=0 and Max_Data=65535
  1520. */
  1521. __STATIC_INLINE uint32_t LL_TIM_GetPrescaler(TIM_TypeDef *TIMx)
  1522. {
  1523. return (uint32_t)(READ_REG(TIMx->PSC));
  1524. }
  1525. /**
  1526. * @brief Set the auto-reload value.
  1527. * @note The counter is blocked while the auto-reload value is null.
  1528. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1529. * whether or not a timer instance supports a 32 bits counter.
  1530. * @note Helper macro @ref __LL_TIM_CALC_ARR can be used to calculate the AutoReload parameter
  1531. * @rmtoll ARR ARR LL_TIM_SetAutoReload
  1532. * @param TIMx Timer instance
  1533. * @param AutoReload between Min_Data=0 and Max_Data=65535
  1534. * @retval None
  1535. */
  1536. __STATIC_INLINE void LL_TIM_SetAutoReload(TIM_TypeDef *TIMx, uint32_t AutoReload)
  1537. {
  1538. WRITE_REG(TIMx->ARR, AutoReload);
  1539. }
  1540. /**
  1541. * @brief Get the auto-reload value.
  1542. * @rmtoll ARR ARR LL_TIM_GetAutoReload
  1543. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1544. * whether or not a timer instance supports a 32 bits counter.
  1545. * @param TIMx Timer instance
  1546. * @retval Auto-reload value
  1547. */
  1548. __STATIC_INLINE uint32_t LL_TIM_GetAutoReload(TIM_TypeDef *TIMx)
  1549. {
  1550. return (uint32_t)(READ_REG(TIMx->ARR));
  1551. }
  1552. /**
  1553. * @brief Set the repetition counter value.
  1554. * @note For advanced timer instances RepetitionCounter can be up to 65535.
  1555. * @note Macro @ref IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1556. * whether or not a timer instance supports a repetition counter.
  1557. * @rmtoll RCR REP LL_TIM_SetRepetitionCounter
  1558. * @param TIMx Timer instance
  1559. * @param RepetitionCounter between Min_Data=0 and Max_Data=255
  1560. * @retval None
  1561. */
  1562. __STATIC_INLINE void LL_TIM_SetRepetitionCounter(TIM_TypeDef *TIMx, uint32_t RepetitionCounter)
  1563. {
  1564. WRITE_REG(TIMx->RCR, RepetitionCounter);
  1565. }
  1566. /**
  1567. * @brief Get the repetition counter value.
  1568. * @note Macro @ref IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1569. * whether or not a timer instance supports a repetition counter.
  1570. * @rmtoll RCR REP LL_TIM_GetRepetitionCounter
  1571. * @param TIMx Timer instance
  1572. * @retval Repetition counter value
  1573. */
  1574. __STATIC_INLINE uint32_t LL_TIM_GetRepetitionCounter(TIM_TypeDef *TIMx)
  1575. {
  1576. return (uint32_t)(READ_REG(TIMx->RCR));
  1577. }
  1578. /**
  1579. * @brief Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
  1580. * @note This allows both the counter value and a potential roll-over condition signalled by the UIFCPY flag to be read in an atomic way.
  1581. * @rmtoll CR1 UIFREMAP LL_TIM_EnableUIFRemap
  1582. * @param TIMx Timer instance
  1583. * @retval None
  1584. */
  1585. __STATIC_INLINE void LL_TIM_EnableUIFRemap(TIM_TypeDef *TIMx)
  1586. {
  1587. SET_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
  1588. }
  1589. /**
  1590. * @brief Disable update interrupt flag (UIF) remapping.
  1591. * @rmtoll CR1 UIFREMAP LL_TIM_DisableUIFRemap
  1592. * @param TIMx Timer instance
  1593. * @retval None
  1594. */
  1595. __STATIC_INLINE void LL_TIM_DisableUIFRemap(TIM_TypeDef *TIMx)
  1596. {
  1597. CLEAR_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
  1598. }
  1599. /**
  1600. * @}
  1601. */
  1602. /** @defgroup TIM_LL_EF_Capture_Compare Capture Compare configuration
  1603. * @{
  1604. */
  1605. /**
  1606. * @brief Enable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1607. * @note CCxE, CCxNE and OCxM bits are preloaded, after having been written,
  1608. * they are updated only when a commutation event (COM) occurs.
  1609. * @note Only on channels that have a complementary output.
  1610. * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1611. * whether or not a timer instance is able to generate a commutation event.
  1612. * @rmtoll CR2 CCPC LL_TIM_CC_EnablePreload
  1613. * @param TIMx Timer instance
  1614. * @retval None
  1615. */
  1616. __STATIC_INLINE void LL_TIM_CC_EnablePreload(TIM_TypeDef *TIMx)
  1617. {
  1618. SET_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1619. }
  1620. /**
  1621. * @brief Disable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1622. * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1623. * whether or not a timer instance is able to generate a commutation event.
  1624. * @rmtoll CR2 CCPC LL_TIM_CC_DisablePreload
  1625. * @param TIMx Timer instance
  1626. * @retval None
  1627. */
  1628. __STATIC_INLINE void LL_TIM_CC_DisablePreload(TIM_TypeDef *TIMx)
  1629. {
  1630. CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1631. }
  1632. /**
  1633. * @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
  1634. * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1635. * whether or not a timer instance is able to generate a commutation event.
  1636. * @rmtoll CR2 CCUS LL_TIM_CC_SetUpdate
  1637. * @param TIMx Timer instance
  1638. * @param CCUpdateSource This parameter can be one of the following values:
  1639. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_ONLY
  1640. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI
  1641. * @retval None
  1642. */
  1643. __STATIC_INLINE void LL_TIM_CC_SetUpdate(TIM_TypeDef *TIMx, uint32_t CCUpdateSource)
  1644. {
  1645. MODIFY_REG(TIMx->CR2, TIM_CR2_CCUS, CCUpdateSource);
  1646. }
  1647. /**
  1648. * @brief Set the trigger of the capture/compare DMA request.
  1649. * @rmtoll CR2 CCDS LL_TIM_CC_SetDMAReqTrigger
  1650. * @param TIMx Timer instance
  1651. * @param DMAReqTrigger This parameter can be one of the following values:
  1652. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1653. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1654. * @retval None
  1655. */
  1656. __STATIC_INLINE void LL_TIM_CC_SetDMAReqTrigger(TIM_TypeDef *TIMx, uint32_t DMAReqTrigger)
  1657. {
  1658. MODIFY_REG(TIMx->CR2, TIM_CR2_CCDS, DMAReqTrigger);
  1659. }
  1660. /**
  1661. * @brief Get actual trigger of the capture/compare DMA request.
  1662. * @rmtoll CR2 CCDS LL_TIM_CC_GetDMAReqTrigger
  1663. * @param TIMx Timer instance
  1664. * @retval Returned value can be one of the following values:
  1665. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1666. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1667. */
  1668. __STATIC_INLINE uint32_t LL_TIM_CC_GetDMAReqTrigger(TIM_TypeDef *TIMx)
  1669. {
  1670. return (uint32_t)(READ_BIT(TIMx->CR2, TIM_CR2_CCDS));
  1671. }
  1672. /**
  1673. * @brief Set the lock level to freeze the
  1674. * configuration of several capture/compare parameters.
  1675. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  1676. * the lock mechanism is supported by a timer instance.
  1677. * @rmtoll BDTR LOCK LL_TIM_CC_SetLockLevel
  1678. * @param TIMx Timer instance
  1679. * @param LockLevel This parameter can be one of the following values:
  1680. * @arg @ref LL_TIM_LOCKLEVEL_OFF
  1681. * @arg @ref LL_TIM_LOCKLEVEL_1
  1682. * @arg @ref LL_TIM_LOCKLEVEL_2
  1683. * @arg @ref LL_TIM_LOCKLEVEL_3
  1684. * @retval None
  1685. */
  1686. __STATIC_INLINE void LL_TIM_CC_SetLockLevel(TIM_TypeDef *TIMx, uint32_t LockLevel)
  1687. {
  1688. MODIFY_REG(TIMx->BDTR, TIM_BDTR_LOCK, LockLevel);
  1689. }
  1690. /**
  1691. * @brief Enable capture/compare channels.
  1692. * @rmtoll CCER CC1E LL_TIM_CC_EnableChannel\n
  1693. * CCER CC1NE LL_TIM_CC_EnableChannel\n
  1694. * CCER CC2E LL_TIM_CC_EnableChannel\n
  1695. * CCER CC2NE LL_TIM_CC_EnableChannel\n
  1696. * CCER CC3E LL_TIM_CC_EnableChannel\n
  1697. * CCER CC3NE LL_TIM_CC_EnableChannel\n
  1698. * CCER CC4E LL_TIM_CC_EnableChannel\n
  1699. * CCER CC5E LL_TIM_CC_EnableChannel\n
  1700. * CCER CC6E LL_TIM_CC_EnableChannel
  1701. * @param TIMx Timer instance
  1702. * @param Channels This parameter can be a combination of the following values:
  1703. * @arg @ref LL_TIM_CHANNEL_CH1
  1704. * @arg @ref LL_TIM_CHANNEL_CH1N
  1705. * @arg @ref LL_TIM_CHANNEL_CH2
  1706. * @arg @ref LL_TIM_CHANNEL_CH2N
  1707. * @arg @ref LL_TIM_CHANNEL_CH3
  1708. * @arg @ref LL_TIM_CHANNEL_CH3N
  1709. * @arg @ref LL_TIM_CHANNEL_CH4
  1710. * @arg @ref LL_TIM_CHANNEL_CH5
  1711. * @arg @ref LL_TIM_CHANNEL_CH6
  1712. * @retval None
  1713. */
  1714. __STATIC_INLINE void LL_TIM_CC_EnableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1715. {
  1716. SET_BIT(TIMx->CCER, Channels);
  1717. }
  1718. /**
  1719. * @brief Disable capture/compare channels.
  1720. * @rmtoll CCER CC1E LL_TIM_CC_DisableChannel\n
  1721. * CCER CC1NE LL_TIM_CC_DisableChannel\n
  1722. * CCER CC2E LL_TIM_CC_DisableChannel\n
  1723. * CCER CC2NE LL_TIM_CC_DisableChannel\n
  1724. * CCER CC3E LL_TIM_CC_DisableChannel\n
  1725. * CCER CC3NE LL_TIM_CC_DisableChannel\n
  1726. * CCER CC4E LL_TIM_CC_DisableChannel\n
  1727. * CCER CC5E LL_TIM_CC_DisableChannel\n
  1728. * CCER CC6E LL_TIM_CC_DisableChannel
  1729. * @param TIMx Timer instance
  1730. * @param Channels This parameter can be a combination of the following values:
  1731. * @arg @ref LL_TIM_CHANNEL_CH1
  1732. * @arg @ref LL_TIM_CHANNEL_CH1N
  1733. * @arg @ref LL_TIM_CHANNEL_CH2
  1734. * @arg @ref LL_TIM_CHANNEL_CH2N
  1735. * @arg @ref LL_TIM_CHANNEL_CH3
  1736. * @arg @ref LL_TIM_CHANNEL_CH3N
  1737. * @arg @ref LL_TIM_CHANNEL_CH4
  1738. * @arg @ref LL_TIM_CHANNEL_CH5
  1739. * @arg @ref LL_TIM_CHANNEL_CH6
  1740. * @retval None
  1741. */
  1742. __STATIC_INLINE void LL_TIM_CC_DisableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1743. {
  1744. CLEAR_BIT(TIMx->CCER, Channels);
  1745. }
  1746. /**
  1747. * @brief Indicate whether channel(s) is(are) enabled.
  1748. * @rmtoll CCER CC1E LL_TIM_CC_IsEnabledChannel\n
  1749. * CCER CC1NE LL_TIM_CC_IsEnabledChannel\n
  1750. * CCER CC2E LL_TIM_CC_IsEnabledChannel\n
  1751. * CCER CC2NE LL_TIM_CC_IsEnabledChannel\n
  1752. * CCER CC3E LL_TIM_CC_IsEnabledChannel\n
  1753. * CCER CC3NE LL_TIM_CC_IsEnabledChannel\n
  1754. * CCER CC4E LL_TIM_CC_IsEnabledChannel\n
  1755. * CCER CC5E LL_TIM_CC_IsEnabledChannel\n
  1756. * CCER CC6E LL_TIM_CC_IsEnabledChannel
  1757. * @param TIMx Timer instance
  1758. * @param Channels This parameter can be a combination of the following values:
  1759. * @arg @ref LL_TIM_CHANNEL_CH1
  1760. * @arg @ref LL_TIM_CHANNEL_CH1N
  1761. * @arg @ref LL_TIM_CHANNEL_CH2
  1762. * @arg @ref LL_TIM_CHANNEL_CH2N
  1763. * @arg @ref LL_TIM_CHANNEL_CH3
  1764. * @arg @ref LL_TIM_CHANNEL_CH3N
  1765. * @arg @ref LL_TIM_CHANNEL_CH4
  1766. * @arg @ref LL_TIM_CHANNEL_CH5
  1767. * @arg @ref LL_TIM_CHANNEL_CH6
  1768. * @retval State of bit (1 or 0).
  1769. */
  1770. __STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1771. {
  1772. return (READ_BIT(TIMx->CCER, Channels) == (Channels));
  1773. }
  1774. /**
  1775. * @}
  1776. */
  1777. /** @defgroup TIM_LL_EF_Output_Channel Output channel configuration
  1778. * @{
  1779. */
  1780. /**
  1781. * @brief Configure an output channel.
  1782. * @rmtoll CCMR1 CC1S LL_TIM_OC_ConfigOutput\n
  1783. * CCMR1 CC2S LL_TIM_OC_ConfigOutput\n
  1784. * CCMR2 CC3S LL_TIM_OC_ConfigOutput\n
  1785. * CCMR2 CC4S LL_TIM_OC_ConfigOutput\n
  1786. * CCMR3 CC5S LL_TIM_OC_ConfigOutput\n
  1787. * CCMR3 CC6S LL_TIM_OC_ConfigOutput\n
  1788. * CCER CC1P LL_TIM_OC_ConfigOutput\n
  1789. * CCER CC2P LL_TIM_OC_ConfigOutput\n
  1790. * CCER CC3P LL_TIM_OC_ConfigOutput\n
  1791. * CCER CC4P LL_TIM_OC_ConfigOutput\n
  1792. * CCER CC5P LL_TIM_OC_ConfigOutput\n
  1793. * CCER CC6P LL_TIM_OC_ConfigOutput\n
  1794. * CR2 OIS1 LL_TIM_OC_ConfigOutput\n
  1795. * CR2 OIS2 LL_TIM_OC_ConfigOutput\n
  1796. * CR2 OIS3 LL_TIM_OC_ConfigOutput\n
  1797. * CR2 OIS4 LL_TIM_OC_ConfigOutput\n
  1798. * CR2 OIS5 LL_TIM_OC_ConfigOutput\n
  1799. * CR2 OIS6 LL_TIM_OC_ConfigOutput
  1800. * @param TIMx Timer instance
  1801. * @param Channel This parameter can be one of the following values:
  1802. * @arg @ref LL_TIM_CHANNEL_CH1
  1803. * @arg @ref LL_TIM_CHANNEL_CH2
  1804. * @arg @ref LL_TIM_CHANNEL_CH3
  1805. * @arg @ref LL_TIM_CHANNEL_CH4
  1806. * @arg @ref LL_TIM_CHANNEL_CH5
  1807. * @arg @ref LL_TIM_CHANNEL_CH6
  1808. * @param Configuration This parameter must be a combination of all the following values:
  1809. * @arg @ref LL_TIM_OCPOLARITY_HIGH or @ref LL_TIM_OCPOLARITY_LOW
  1810. * @arg @ref LL_TIM_OCIDLESTATE_LOW or @ref LL_TIM_OCIDLESTATE_HIGH
  1811. * @retval None
  1812. */
  1813. __STATIC_INLINE void LL_TIM_OC_ConfigOutput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  1814. {
  1815. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1816. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1817. CLEAR_BIT(*pReg, (TIM_CCMR1_CC1S << SHIFT_TAB_OCxx[iChannel]));
  1818. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]),
  1819. (Configuration & TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]);
  1820. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]),
  1821. (Configuration & TIM_CR2_OIS1) << SHIFT_TAB_OISx[iChannel]);
  1822. }
  1823. /**
  1824. * @brief Define the behavior of the output reference signal OCxREF from which
  1825. * OCx and OCxN (when relevant) are derived.
  1826. * @rmtoll CCMR1 OC1M LL_TIM_OC_SetMode\n
  1827. * CCMR1 OC2M LL_TIM_OC_SetMode\n
  1828. * CCMR2 OC3M LL_TIM_OC_SetMode\n
  1829. * CCMR2 OC4M LL_TIM_OC_SetMode\n
  1830. * CCMR3 OC5M LL_TIM_OC_SetMode\n
  1831. * CCMR3 OC6M LL_TIM_OC_SetMode
  1832. * @param TIMx Timer instance
  1833. * @param Channel This parameter can be one of the following values:
  1834. * @arg @ref LL_TIM_CHANNEL_CH1
  1835. * @arg @ref LL_TIM_CHANNEL_CH2
  1836. * @arg @ref LL_TIM_CHANNEL_CH3
  1837. * @arg @ref LL_TIM_CHANNEL_CH4
  1838. * @arg @ref LL_TIM_CHANNEL_CH5
  1839. * @arg @ref LL_TIM_CHANNEL_CH6
  1840. * @param Mode This parameter can be one of the following values:
  1841. * @arg @ref LL_TIM_OCMODE_FROZEN
  1842. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1843. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1844. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1845. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1846. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1847. * @arg @ref LL_TIM_OCMODE_PWM1
  1848. * @arg @ref LL_TIM_OCMODE_PWM2
  1849. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
  1850. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
  1851. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
  1852. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
  1853. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM1
  1854. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM2
  1855. * @retval None
  1856. */
  1857. __STATIC_INLINE void LL_TIM_OC_SetMode(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Mode)
  1858. {
  1859. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1860. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1861. MODIFY_REG(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel]), Mode << SHIFT_TAB_OCxx[iChannel]);
  1862. }
  1863. /**
  1864. * @brief Get the output compare mode of an output channel.
  1865. * @rmtoll CCMR1 OC1M LL_TIM_OC_GetMode\n
  1866. * CCMR1 OC2M LL_TIM_OC_GetMode\n
  1867. * CCMR2 OC3M LL_TIM_OC_GetMode\n
  1868. * CCMR2 OC4M LL_TIM_OC_GetMode\n
  1869. * CCMR3 OC5M LL_TIM_OC_GetMode\n
  1870. * CCMR3 OC6M LL_TIM_OC_GetMode
  1871. * @param TIMx Timer instance
  1872. * @param Channel This parameter can be one of the following values:
  1873. * @arg @ref LL_TIM_CHANNEL_CH1
  1874. * @arg @ref LL_TIM_CHANNEL_CH2
  1875. * @arg @ref LL_TIM_CHANNEL_CH3
  1876. * @arg @ref LL_TIM_CHANNEL_CH4
  1877. * @arg @ref LL_TIM_CHANNEL_CH5
  1878. * @arg @ref LL_TIM_CHANNEL_CH6
  1879. * @retval Returned value can be one of the following values:
  1880. * @arg @ref LL_TIM_OCMODE_FROZEN
  1881. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1882. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1883. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1884. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1885. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1886. * @arg @ref LL_TIM_OCMODE_PWM1
  1887. * @arg @ref LL_TIM_OCMODE_PWM2
  1888. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
  1889. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
  1890. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
  1891. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
  1892. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM1
  1893. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM2
  1894. */
  1895. __STATIC_INLINE uint32_t LL_TIM_OC_GetMode(TIM_TypeDef *TIMx, uint32_t Channel)
  1896. {
  1897. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1898. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1899. return (READ_BIT(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel])) >> SHIFT_TAB_OCxx[iChannel]);
  1900. }
  1901. /**
  1902. * @brief Set the polarity of an output channel.
  1903. * @rmtoll CCER CC1P LL_TIM_OC_SetPolarity\n
  1904. * CCER CC1NP LL_TIM_OC_SetPolarity\n
  1905. * CCER CC2P LL_TIM_OC_SetPolarity\n
  1906. * CCER CC2NP LL_TIM_OC_SetPolarity\n
  1907. * CCER CC3P LL_TIM_OC_SetPolarity\n
  1908. * CCER CC3NP LL_TIM_OC_SetPolarity\n
  1909. * CCER CC4P LL_TIM_OC_SetPolarity\n
  1910. * CCER CC5P LL_TIM_OC_SetPolarity\n
  1911. * CCER CC6P LL_TIM_OC_SetPolarity
  1912. * @param TIMx Timer instance
  1913. * @param Channel This parameter can be one of the following values:
  1914. * @arg @ref LL_TIM_CHANNEL_CH1
  1915. * @arg @ref LL_TIM_CHANNEL_CH1N
  1916. * @arg @ref LL_TIM_CHANNEL_CH2
  1917. * @arg @ref LL_TIM_CHANNEL_CH2N
  1918. * @arg @ref LL_TIM_CHANNEL_CH3
  1919. * @arg @ref LL_TIM_CHANNEL_CH3N
  1920. * @arg @ref LL_TIM_CHANNEL_CH4
  1921. * @arg @ref LL_TIM_CHANNEL_CH5
  1922. * @arg @ref LL_TIM_CHANNEL_CH6
  1923. * @param Polarity This parameter can be one of the following values:
  1924. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1925. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1926. * @retval None
  1927. */
  1928. __STATIC_INLINE void LL_TIM_OC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Polarity)
  1929. {
  1930. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1931. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]), Polarity << SHIFT_TAB_CCxP[iChannel]);
  1932. }
  1933. /**
  1934. * @brief Get the polarity of an output channel.
  1935. * @rmtoll CCER CC1P LL_TIM_OC_GetPolarity\n
  1936. * CCER CC1NP LL_TIM_OC_GetPolarity\n
  1937. * CCER CC2P LL_TIM_OC_GetPolarity\n
  1938. * CCER CC2NP LL_TIM_OC_GetPolarity\n
  1939. * CCER CC3P LL_TIM_OC_GetPolarity\n
  1940. * CCER CC3NP LL_TIM_OC_GetPolarity\n
  1941. * CCER CC4P LL_TIM_OC_GetPolarity\n
  1942. * CCER CC5P LL_TIM_OC_GetPolarity\n
  1943. * CCER CC6P LL_TIM_OC_GetPolarity
  1944. * @param TIMx Timer instance
  1945. * @param Channel This parameter can be one of the following values:
  1946. * @arg @ref LL_TIM_CHANNEL_CH1
  1947. * @arg @ref LL_TIM_CHANNEL_CH1N
  1948. * @arg @ref LL_TIM_CHANNEL_CH2
  1949. * @arg @ref LL_TIM_CHANNEL_CH2N
  1950. * @arg @ref LL_TIM_CHANNEL_CH3
  1951. * @arg @ref LL_TIM_CHANNEL_CH3N
  1952. * @arg @ref LL_TIM_CHANNEL_CH4
  1953. * @arg @ref LL_TIM_CHANNEL_CH5
  1954. * @arg @ref LL_TIM_CHANNEL_CH6
  1955. * @retval Returned value can be one of the following values:
  1956. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1957. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1958. */
  1959. __STATIC_INLINE uint32_t LL_TIM_OC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  1960. {
  1961. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1962. return (READ_BIT(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel])) >> SHIFT_TAB_CCxP[iChannel]);
  1963. }
  1964. /**
  1965. * @brief Set the IDLE state of an output channel
  1966. * @note This function is significant only for the timer instances
  1967. * supporting the break feature. Macro @ref IS_TIM_BREAK_INSTANCE(TIMx)
  1968. * can be used to check whether or not a timer instance provides
  1969. * a break input.
  1970. * @rmtoll CR2 OIS1 LL_TIM_OC_SetIdleState\n
  1971. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  1972. * CR2 OIS2 LL_TIM_OC_SetIdleState\n
  1973. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  1974. * CR2 OIS3 LL_TIM_OC_SetIdleState\n
  1975. * CR2 OIS3N LL_TIM_OC_SetIdleState\n
  1976. * CR2 OIS4 LL_TIM_OC_SetIdleState\n
  1977. * CR2 OIS5 LL_TIM_OC_SetIdleState\n
  1978. * CR2 OIS6 LL_TIM_OC_SetIdleState
  1979. * @param TIMx Timer instance
  1980. * @param Channel This parameter can be one of the following values:
  1981. * @arg @ref LL_TIM_CHANNEL_CH1
  1982. * @arg @ref LL_TIM_CHANNEL_CH1N
  1983. * @arg @ref LL_TIM_CHANNEL_CH2
  1984. * @arg @ref LL_TIM_CHANNEL_CH2N
  1985. * @arg @ref LL_TIM_CHANNEL_CH3
  1986. * @arg @ref LL_TIM_CHANNEL_CH3N
  1987. * @arg @ref LL_TIM_CHANNEL_CH4
  1988. * @arg @ref LL_TIM_CHANNEL_CH5
  1989. * @arg @ref LL_TIM_CHANNEL_CH6
  1990. * @param IdleState This parameter can be one of the following values:
  1991. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  1992. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  1993. * @retval None
  1994. */
  1995. __STATIC_INLINE void LL_TIM_OC_SetIdleState(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t IdleState)
  1996. {
  1997. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1998. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]), IdleState << SHIFT_TAB_OISx[iChannel]);
  1999. }
  2000. /**
  2001. * @brief Get the IDLE state of an output channel
  2002. * @rmtoll CR2 OIS1 LL_TIM_OC_GetIdleState\n
  2003. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  2004. * CR2 OIS2 LL_TIM_OC_GetIdleState\n
  2005. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  2006. * CR2 OIS3 LL_TIM_OC_GetIdleState\n
  2007. * CR2 OIS3N LL_TIM_OC_GetIdleState\n
  2008. * CR2 OIS4 LL_TIM_OC_GetIdleState\n
  2009. * CR2 OIS5 LL_TIM_OC_GetIdleState\n
  2010. * CR2 OIS6 LL_TIM_OC_GetIdleState
  2011. * @param TIMx Timer instance
  2012. * @param Channel This parameter can be one of the following values:
  2013. * @arg @ref LL_TIM_CHANNEL_CH1
  2014. * @arg @ref LL_TIM_CHANNEL_CH1N
  2015. * @arg @ref LL_TIM_CHANNEL_CH2
  2016. * @arg @ref LL_TIM_CHANNEL_CH2N
  2017. * @arg @ref LL_TIM_CHANNEL_CH3
  2018. * @arg @ref LL_TIM_CHANNEL_CH3N
  2019. * @arg @ref LL_TIM_CHANNEL_CH4
  2020. * @arg @ref LL_TIM_CHANNEL_CH5
  2021. * @arg @ref LL_TIM_CHANNEL_CH6
  2022. * @retval Returned value can be one of the following values:
  2023. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  2024. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  2025. */
  2026. __STATIC_INLINE uint32_t LL_TIM_OC_GetIdleState(TIM_TypeDef *TIMx, uint32_t Channel)
  2027. {
  2028. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2029. return (READ_BIT(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel])) >> SHIFT_TAB_OISx[iChannel]);
  2030. }
  2031. /**
  2032. * @brief Enable fast mode for the output channel.
  2033. * @note Acts only if the channel is configured in PWM1 or PWM2 mode.
  2034. * @rmtoll CCMR1 OC1FE LL_TIM_OC_EnableFast\n
  2035. * CCMR1 OC2FE LL_TIM_OC_EnableFast\n
  2036. * CCMR2 OC3FE LL_TIM_OC_EnableFast\n
  2037. * CCMR2 OC4FE LL_TIM_OC_EnableFast\n
  2038. * CCMR3 OC5FE LL_TIM_OC_EnableFast\n
  2039. * CCMR3 OC6FE LL_TIM_OC_EnableFast
  2040. * @param TIMx Timer instance
  2041. * @param Channel This parameter can be one of the following values:
  2042. * @arg @ref LL_TIM_CHANNEL_CH1
  2043. * @arg @ref LL_TIM_CHANNEL_CH2
  2044. * @arg @ref LL_TIM_CHANNEL_CH3
  2045. * @arg @ref LL_TIM_CHANNEL_CH4
  2046. * @arg @ref LL_TIM_CHANNEL_CH5
  2047. * @arg @ref LL_TIM_CHANNEL_CH6
  2048. * @retval None
  2049. */
  2050. __STATIC_INLINE void LL_TIM_OC_EnableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2051. {
  2052. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2053. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2054. SET_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  2055. }
  2056. /**
  2057. * @brief Disable fast mode for the output channel.
  2058. * @rmtoll CCMR1 OC1FE LL_TIM_OC_DisableFast\n
  2059. * CCMR1 OC2FE LL_TIM_OC_DisableFast\n
  2060. * CCMR2 OC3FE LL_TIM_OC_DisableFast\n
  2061. * CCMR2 OC4FE LL_TIM_OC_DisableFast\n
  2062. * CCMR3 OC5FE LL_TIM_OC_DisableFast\n
  2063. * CCMR3 OC6FE LL_TIM_OC_DisableFast
  2064. * @param TIMx Timer instance
  2065. * @param Channel This parameter can be one of the following values:
  2066. * @arg @ref LL_TIM_CHANNEL_CH1
  2067. * @arg @ref LL_TIM_CHANNEL_CH2
  2068. * @arg @ref LL_TIM_CHANNEL_CH3
  2069. * @arg @ref LL_TIM_CHANNEL_CH4
  2070. * @arg @ref LL_TIM_CHANNEL_CH5
  2071. * @arg @ref LL_TIM_CHANNEL_CH6
  2072. * @retval None
  2073. */
  2074. __STATIC_INLINE void LL_TIM_OC_DisableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2075. {
  2076. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2077. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2078. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  2079. }
  2080. /**
  2081. * @brief Indicates whether fast mode is enabled for the output channel.
  2082. * @rmtoll CCMR1 OC1FE LL_TIM_OC_IsEnabledFast\n
  2083. * CCMR1 OC2FE LL_TIM_OC_IsEnabledFast\n
  2084. * CCMR2 OC3FE LL_TIM_OC_IsEnabledFast\n
  2085. * CCMR2 OC4FE LL_TIM_OC_IsEnabledFast\n
  2086. * CCMR3 OC5FE LL_TIM_OC_IsEnabledFast\n
  2087. * CCMR3 OC6FE LL_TIM_OC_IsEnabledFast
  2088. * @param TIMx Timer instance
  2089. * @param Channel This parameter can be one of the following values:
  2090. * @arg @ref LL_TIM_CHANNEL_CH1
  2091. * @arg @ref LL_TIM_CHANNEL_CH2
  2092. * @arg @ref LL_TIM_CHANNEL_CH3
  2093. * @arg @ref LL_TIM_CHANNEL_CH4
  2094. * @arg @ref LL_TIM_CHANNEL_CH5
  2095. * @arg @ref LL_TIM_CHANNEL_CH6
  2096. * @retval State of bit (1 or 0).
  2097. */
  2098. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2099. {
  2100. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2101. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2102. register uint32_t bitfield = TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel];
  2103. return (READ_BIT(*pReg, bitfield) == bitfield);
  2104. }
  2105. /**
  2106. * @brief Enable compare register (TIMx_CCRx) preload for the output channel.
  2107. * @rmtoll CCMR1 OC1PE LL_TIM_OC_EnablePreload\n
  2108. * CCMR1 OC2PE LL_TIM_OC_EnablePreload\n
  2109. * CCMR2 OC3PE LL_TIM_OC_EnablePreload\n
  2110. * CCMR2 OC4PE LL_TIM_OC_EnablePreload\n
  2111. * CCMR3 OC5PE LL_TIM_OC_EnablePreload\n
  2112. * CCMR3 OC6PE LL_TIM_OC_EnablePreload
  2113. * @param TIMx Timer instance
  2114. * @param Channel This parameter can be one of the following values:
  2115. * @arg @ref LL_TIM_CHANNEL_CH1
  2116. * @arg @ref LL_TIM_CHANNEL_CH2
  2117. * @arg @ref LL_TIM_CHANNEL_CH3
  2118. * @arg @ref LL_TIM_CHANNEL_CH4
  2119. * @arg @ref LL_TIM_CHANNEL_CH5
  2120. * @arg @ref LL_TIM_CHANNEL_CH6
  2121. * @retval None
  2122. */
  2123. __STATIC_INLINE void LL_TIM_OC_EnablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2124. {
  2125. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2126. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2127. SET_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  2128. }
  2129. /**
  2130. * @brief Disable compare register (TIMx_CCRx) preload for the output channel.
  2131. * @rmtoll CCMR1 OC1PE LL_TIM_OC_DisablePreload\n
  2132. * CCMR1 OC2PE LL_TIM_OC_DisablePreload\n
  2133. * CCMR2 OC3PE LL_TIM_OC_DisablePreload\n
  2134. * CCMR2 OC4PE LL_TIM_OC_DisablePreload\n
  2135. * CCMR3 OC5PE LL_TIM_OC_DisablePreload\n
  2136. * CCMR3 OC6PE LL_TIM_OC_DisablePreload
  2137. * @param TIMx Timer instance
  2138. * @param Channel This parameter can be one of the following values:
  2139. * @arg @ref LL_TIM_CHANNEL_CH1
  2140. * @arg @ref LL_TIM_CHANNEL_CH2
  2141. * @arg @ref LL_TIM_CHANNEL_CH3
  2142. * @arg @ref LL_TIM_CHANNEL_CH4
  2143. * @arg @ref LL_TIM_CHANNEL_CH5
  2144. * @arg @ref LL_TIM_CHANNEL_CH6
  2145. * @retval None
  2146. */
  2147. __STATIC_INLINE void LL_TIM_OC_DisablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2148. {
  2149. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2150. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2151. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  2152. }
  2153. /**
  2154. * @brief Indicates whether compare register (TIMx_CCRx) preload is enabled for the output channel.
  2155. * @rmtoll CCMR1 OC1PE LL_TIM_OC_IsEnabledPreload\n
  2156. * CCMR1 OC2PE LL_TIM_OC_IsEnabledPreload\n
  2157. * CCMR2 OC3PE LL_TIM_OC_IsEnabledPreload\n
  2158. * CCMR2 OC4PE LL_TIM_OC_IsEnabledPreload\n
  2159. * CCMR3 OC5PE LL_TIM_OC_IsEnabledPreload\n
  2160. * CCMR3 OC6PE LL_TIM_OC_IsEnabledPreload
  2161. * @param TIMx Timer instance
  2162. * @param Channel This parameter can be one of the following values:
  2163. * @arg @ref LL_TIM_CHANNEL_CH1
  2164. * @arg @ref LL_TIM_CHANNEL_CH2
  2165. * @arg @ref LL_TIM_CHANNEL_CH3
  2166. * @arg @ref LL_TIM_CHANNEL_CH4
  2167. * @arg @ref LL_TIM_CHANNEL_CH5
  2168. * @arg @ref LL_TIM_CHANNEL_CH6
  2169. * @retval State of bit (1 or 0).
  2170. */
  2171. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledPreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2172. {
  2173. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2174. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2175. register uint32_t bitfield = TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel];
  2176. return (READ_BIT(*pReg, bitfield) == bitfield);
  2177. }
  2178. /**
  2179. * @brief Enable clearing the output channel on an external event.
  2180. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  2181. * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2182. * or not a timer instance can clear the OCxREF signal on an external event.
  2183. * @rmtoll CCMR1 OC1CE LL_TIM_OC_EnableClear\n
  2184. * CCMR1 OC2CE LL_TIM_OC_EnableClear\n
  2185. * CCMR2 OC3CE LL_TIM_OC_EnableClear\n
  2186. * CCMR2 OC4CE LL_TIM_OC_EnableClear\n
  2187. * CCMR3 OC5CE LL_TIM_OC_EnableClear\n
  2188. * CCMR3 OC6CE LL_TIM_OC_EnableClear
  2189. * @param TIMx Timer instance
  2190. * @param Channel This parameter can be one of the following values:
  2191. * @arg @ref LL_TIM_CHANNEL_CH1
  2192. * @arg @ref LL_TIM_CHANNEL_CH2
  2193. * @arg @ref LL_TIM_CHANNEL_CH3
  2194. * @arg @ref LL_TIM_CHANNEL_CH4
  2195. * @arg @ref LL_TIM_CHANNEL_CH5
  2196. * @arg @ref LL_TIM_CHANNEL_CH6
  2197. * @retval None
  2198. */
  2199. __STATIC_INLINE void LL_TIM_OC_EnableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2200. {
  2201. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2202. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2203. SET_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  2204. }
  2205. /**
  2206. * @brief Disable clearing the output channel on an external event.
  2207. * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2208. * or not a timer instance can clear the OCxREF signal on an external event.
  2209. * @rmtoll CCMR1 OC1CE LL_TIM_OC_DisableClear\n
  2210. * CCMR1 OC2CE LL_TIM_OC_DisableClear\n
  2211. * CCMR2 OC3CE LL_TIM_OC_DisableClear\n
  2212. * CCMR2 OC4CE LL_TIM_OC_DisableClear\n
  2213. * CCMR3 OC5CE LL_TIM_OC_DisableClear\n
  2214. * CCMR3 OC6CE LL_TIM_OC_DisableClear
  2215. * @param TIMx Timer instance
  2216. * @param Channel This parameter can be one of the following values:
  2217. * @arg @ref LL_TIM_CHANNEL_CH1
  2218. * @arg @ref LL_TIM_CHANNEL_CH2
  2219. * @arg @ref LL_TIM_CHANNEL_CH3
  2220. * @arg @ref LL_TIM_CHANNEL_CH4
  2221. * @arg @ref LL_TIM_CHANNEL_CH5
  2222. * @arg @ref LL_TIM_CHANNEL_CH6
  2223. * @retval None
  2224. */
  2225. __STATIC_INLINE void LL_TIM_OC_DisableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2226. {
  2227. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2228. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2229. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  2230. }
  2231. /**
  2232. * @brief Indicates clearing the output channel on an external event is enabled for the output channel.
  2233. * @note This function enables clearing the output channel on an external event.
  2234. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  2235. * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2236. * or not a timer instance can clear the OCxREF signal on an external event.
  2237. * @rmtoll CCMR1 OC1CE LL_TIM_OC_IsEnabledClear\n
  2238. * CCMR1 OC2CE LL_TIM_OC_IsEnabledClear\n
  2239. * CCMR2 OC3CE LL_TIM_OC_IsEnabledClear\n
  2240. * CCMR2 OC4CE LL_TIM_OC_IsEnabledClear\n
  2241. * CCMR3 OC5CE LL_TIM_OC_IsEnabledClear\n
  2242. * CCMR3 OC6CE LL_TIM_OC_IsEnabledClear
  2243. * @param TIMx Timer instance
  2244. * @param Channel This parameter can be one of the following values:
  2245. * @arg @ref LL_TIM_CHANNEL_CH1
  2246. * @arg @ref LL_TIM_CHANNEL_CH2
  2247. * @arg @ref LL_TIM_CHANNEL_CH3
  2248. * @arg @ref LL_TIM_CHANNEL_CH4
  2249. * @arg @ref LL_TIM_CHANNEL_CH5
  2250. * @arg @ref LL_TIM_CHANNEL_CH6
  2251. * @retval State of bit (1 or 0).
  2252. */
  2253. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2254. {
  2255. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2256. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2257. register uint32_t bitfield = TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel];
  2258. return (READ_BIT(*pReg, bitfield) == bitfield);
  2259. }
  2260. /**
  2261. * @brief Set the dead-time delay (delay inserted between the rising edge of the OCxREF signal and the rising edge if the Ocx and OCxN signals).
  2262. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2263. * dead-time insertion feature is supported by a timer instance.
  2264. * @note Helper macro @ref __LL_TIM_CALC_DEADTIME can be used to calculate the DeadTime parameter
  2265. * @rmtoll BDTR DTG LL_TIM_OC_SetDeadTime
  2266. * @param TIMx Timer instance
  2267. * @param DeadTime between Min_Data=0 and Max_Data=255
  2268. * @retval None
  2269. */
  2270. __STATIC_INLINE void LL_TIM_OC_SetDeadTime(TIM_TypeDef *TIMx, uint32_t DeadTime)
  2271. {
  2272. MODIFY_REG(TIMx->BDTR, TIM_BDTR_DTG, DeadTime);
  2273. }
  2274. /**
  2275. * @brief Set compare value for output channel 1 (TIMx_CCR1).
  2276. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2277. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2278. * whether or not a timer instance supports a 32 bits counter.
  2279. * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2280. * output channel 1 is supported by a timer instance.
  2281. * @rmtoll CCR1 CCR1 LL_TIM_OC_SetCompareCH1
  2282. * @param TIMx Timer instance
  2283. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2284. * @retval None
  2285. */
  2286. __STATIC_INLINE void LL_TIM_OC_SetCompareCH1(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2287. {
  2288. WRITE_REG(TIMx->CCR1, CompareValue);
  2289. }
  2290. /**
  2291. * @brief Set compare value for output channel 2 (TIMx_CCR2).
  2292. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2293. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2294. * whether or not a timer instance supports a 32 bits counter.
  2295. * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2296. * output channel 2 is supported by a timer instance.
  2297. * @rmtoll CCR2 CCR2 LL_TIM_OC_SetCompareCH2
  2298. * @param TIMx Timer instance
  2299. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2300. * @retval None
  2301. */
  2302. __STATIC_INLINE void LL_TIM_OC_SetCompareCH2(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2303. {
  2304. WRITE_REG(TIMx->CCR2, CompareValue);
  2305. }
  2306. /**
  2307. * @brief Set compare value for output channel 3 (TIMx_CCR3).
  2308. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2309. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2310. * whether or not a timer instance supports a 32 bits counter.
  2311. * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2312. * output channel is supported by a timer instance.
  2313. * @rmtoll CCR3 CCR3 LL_TIM_OC_SetCompareCH3
  2314. * @param TIMx Timer instance
  2315. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2316. * @retval None
  2317. */
  2318. __STATIC_INLINE void LL_TIM_OC_SetCompareCH3(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2319. {
  2320. WRITE_REG(TIMx->CCR3, CompareValue);
  2321. }
  2322. /**
  2323. * @brief Set compare value for output channel 4 (TIMx_CCR4).
  2324. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2325. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2326. * whether or not a timer instance supports a 32 bits counter.
  2327. * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2328. * output channel 4 is supported by a timer instance.
  2329. * @rmtoll CCR4 CCR4 LL_TIM_OC_SetCompareCH4
  2330. * @param TIMx Timer instance
  2331. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2332. * @retval None
  2333. */
  2334. __STATIC_INLINE void LL_TIM_OC_SetCompareCH4(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2335. {
  2336. WRITE_REG(TIMx->CCR4, CompareValue);
  2337. }
  2338. /**
  2339. * @brief Set compare value for output channel 5 (TIMx_CCR5).
  2340. * @note Macro @ref IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
  2341. * output channel 5 is supported by a timer instance.
  2342. * @rmtoll CCR5 CCR5 LL_TIM_OC_SetCompareCH5
  2343. * @param TIMx Timer instance
  2344. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2345. * @retval None
  2346. */
  2347. __STATIC_INLINE void LL_TIM_OC_SetCompareCH5(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2348. {
  2349. WRITE_REG(TIMx->CCR5, CompareValue);
  2350. }
  2351. /**
  2352. * @brief Set compare value for output channel 6 (TIMx_CCR6).
  2353. * @note Macro @ref IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
  2354. * output channel 6 is supported by a timer instance.
  2355. * @rmtoll CCR6 CCR6 LL_TIM_OC_SetCompareCH6
  2356. * @param TIMx Timer instance
  2357. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2358. * @retval None
  2359. */
  2360. __STATIC_INLINE void LL_TIM_OC_SetCompareCH6(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2361. {
  2362. WRITE_REG(TIMx->CCR6, CompareValue);
  2363. }
  2364. /**
  2365. * @brief Get compare value (TIMx_CCR1) set for output channel 1.
  2366. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2367. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2368. * whether or not a timer instance supports a 32 bits counter.
  2369. * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2370. * output channel 1 is supported by a timer instance.
  2371. * @rmtoll CCR1 CCR1 LL_TIM_OC_GetCompareCH1
  2372. * @param TIMx Timer instance
  2373. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2374. */
  2375. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH1(TIM_TypeDef *TIMx)
  2376. {
  2377. return (uint32_t)(READ_REG(TIMx->CCR1));
  2378. }
  2379. /**
  2380. * @brief Get compare value (TIMx_CCR2) set for output channel 2.
  2381. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2382. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2383. * whether or not a timer instance supports a 32 bits counter.
  2384. * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2385. * output channel 2 is supported by a timer instance.
  2386. * @rmtoll CCR2 CCR2 LL_TIM_OC_GetCompareCH2
  2387. * @param TIMx Timer instance
  2388. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2389. */
  2390. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH2(TIM_TypeDef *TIMx)
  2391. {
  2392. return (uint32_t)(READ_REG(TIMx->CCR2));
  2393. }
  2394. /**
  2395. * @brief Get compare value (TIMx_CCR3) set for output channel 3.
  2396. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2397. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2398. * whether or not a timer instance supports a 32 bits counter.
  2399. * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2400. * output channel 3 is supported by a timer instance.
  2401. * @rmtoll CCR3 CCR3 LL_TIM_OC_GetCompareCH3
  2402. * @param TIMx Timer instance
  2403. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2404. */
  2405. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH3(TIM_TypeDef *TIMx)
  2406. {
  2407. return (uint32_t)(READ_REG(TIMx->CCR3));
  2408. }
  2409. /**
  2410. * @brief Get compare value (TIMx_CCR4) set for output channel 4.
  2411. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2412. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2413. * whether or not a timer instance supports a 32 bits counter.
  2414. * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2415. * output channel 4 is supported by a timer instance.
  2416. * @rmtoll CCR4 CCR4 LL_TIM_OC_GetCompareCH4
  2417. * @param TIMx Timer instance
  2418. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2419. */
  2420. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH4(TIM_TypeDef *TIMx)
  2421. {
  2422. return (uint32_t)(READ_REG(TIMx->CCR4));
  2423. }
  2424. /**
  2425. * @brief Get compare value (TIMx_CCR5) set for output channel 5.
  2426. * @note Macro @ref IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
  2427. * output channel 5 is supported by a timer instance.
  2428. * @rmtoll CCR5 CCR5 LL_TIM_OC_GetCompareCH5
  2429. * @param TIMx Timer instance
  2430. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2431. */
  2432. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH5(TIM_TypeDef *TIMx)
  2433. {
  2434. return (uint32_t)(READ_REG(TIMx->CCR5));
  2435. }
  2436. /**
  2437. * @brief Get compare value (TIMx_CCR6) set for output channel 6.
  2438. * @note Macro @ref IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
  2439. * output channel 6 is supported by a timer instance.
  2440. * @rmtoll CCR6 CCR6 LL_TIM_OC_GetCompareCH6
  2441. * @param TIMx Timer instance
  2442. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2443. */
  2444. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH6(TIM_TypeDef *TIMx)
  2445. {
  2446. return (uint32_t)(READ_REG(TIMx->CCR6));
  2447. }
  2448. /**
  2449. * @brief Select on which reference signal the OC5REF is combined to.
  2450. * @note Macro @ref IS_TIM_COMBINED3PHASEPWM_INSTANCE(TIMx) can be used to check
  2451. * whether or not a timer instance supports the combined 3-phase PWM mode.
  2452. * @rmtoll CCR5 GC5C3 LL_TIM_SetCH5CombinedChannels\n
  2453. * CCR5 GC5C2 LL_TIM_SetCH5CombinedChannels\n
  2454. * CCR5 GC5C1 LL_TIM_SetCH5CombinedChannels
  2455. * @param TIMx Timer instance
  2456. * @param GroupCH5 This parameter can be one of the following values:
  2457. * @arg @ref LL_TIM_GROUPCH5_NONE
  2458. * @arg @ref LL_TIM_GROUPCH5_OC1REFC
  2459. * @arg @ref LL_TIM_GROUPCH5_OC2REFC
  2460. * @arg @ref LL_TIM_GROUPCH5_OC3REFC
  2461. * @retval None
  2462. */
  2463. __STATIC_INLINE void LL_TIM_SetCH5CombinedChannels(TIM_TypeDef *TIMx, uint32_t GroupCH5)
  2464. {
  2465. MODIFY_REG(TIMx->CCR5, TIM_CCR5_CCR5, GroupCH5);
  2466. }
  2467. /**
  2468. * @}
  2469. */
  2470. /** @defgroup TIM_LL_EF_Input_Channel Input channel configuration
  2471. * @{
  2472. */
  2473. /**
  2474. * @brief Configure input channel.
  2475. * @rmtoll CCMR1 CC1S LL_TIM_IC_Config\n
  2476. * CCMR1 IC1PSC LL_TIM_IC_Config\n
  2477. * CCMR1 IC1F LL_TIM_IC_Config\n
  2478. * CCMR1 CC2S LL_TIM_IC_Config\n
  2479. * CCMR1 IC2PSC LL_TIM_IC_Config\n
  2480. * CCMR1 IC2F LL_TIM_IC_Config\n
  2481. * CCMR2 CC3S LL_TIM_IC_Config\n
  2482. * CCMR2 IC3PSC LL_TIM_IC_Config\n
  2483. * CCMR2 IC3F LL_TIM_IC_Config\n
  2484. * CCMR2 CC4S LL_TIM_IC_Config\n
  2485. * CCMR2 IC4PSC LL_TIM_IC_Config\n
  2486. * CCMR2 IC4F LL_TIM_IC_Config\n
  2487. * CCER CC1P LL_TIM_IC_Config\n
  2488. * CCER CC1NP LL_TIM_IC_Config\n
  2489. * CCER CC2P LL_TIM_IC_Config\n
  2490. * CCER CC2NP LL_TIM_IC_Config\n
  2491. * CCER CC3P LL_TIM_IC_Config\n
  2492. * CCER CC3NP LL_TIM_IC_Config\n
  2493. * CCER CC4P LL_TIM_IC_Config\n
  2494. * CCER CC4NP LL_TIM_IC_Config
  2495. * @param TIMx Timer instance
  2496. * @param Channel This parameter can be one of the following values:
  2497. * @arg @ref LL_TIM_CHANNEL_CH1
  2498. * @arg @ref LL_TIM_CHANNEL_CH2
  2499. * @arg @ref LL_TIM_CHANNEL_CH3
  2500. * @arg @ref LL_TIM_CHANNEL_CH4
  2501. * @param Configuration This parameter must be a combination of all the following values:
  2502. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI or @ref LL_TIM_ACTIVEINPUT_INDIRECTTI or @ref LL_TIM_ACTIVEINPUT_TRC
  2503. * @arg @ref LL_TIM_ICPSC_DIV1 or ... or @ref LL_TIM_ICPSC_DIV8
  2504. * @arg @ref LL_TIM_IC_FILTER_FDIV1 or ... or @ref LL_TIM_IC_FILTER_FDIV32_N8
  2505. * @arg @ref LL_TIM_IC_POLARITY_RISING or @ref LL_TIM_IC_POLARITY_FALLING or @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2506. * @retval None
  2507. */
  2508. __STATIC_INLINE void LL_TIM_IC_Config(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  2509. {
  2510. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2511. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2512. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]),
  2513. ((Configuration >> 16U) & (TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S)) << SHIFT_TAB_ICxx[iChannel]);
  2514. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  2515. (Configuration & (TIM_CCER_CC1NP | TIM_CCER_CC1P)) << SHIFT_TAB_CCxP[iChannel]);
  2516. }
  2517. /**
  2518. * @brief Set the active input.
  2519. * @rmtoll CCMR1 CC1S LL_TIM_IC_SetActiveInput\n
  2520. * CCMR1 CC2S LL_TIM_IC_SetActiveInput\n
  2521. * CCMR2 CC3S LL_TIM_IC_SetActiveInput\n
  2522. * CCMR2 CC4S LL_TIM_IC_SetActiveInput
  2523. * @param TIMx Timer instance
  2524. * @param Channel This parameter can be one of the following values:
  2525. * @arg @ref LL_TIM_CHANNEL_CH1
  2526. * @arg @ref LL_TIM_CHANNEL_CH2
  2527. * @arg @ref LL_TIM_CHANNEL_CH3
  2528. * @arg @ref LL_TIM_CHANNEL_CH4
  2529. * @param ICActiveInput This parameter can be one of the following values:
  2530. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  2531. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  2532. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  2533. * @retval None
  2534. */
  2535. __STATIC_INLINE void LL_TIM_IC_SetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICActiveInput)
  2536. {
  2537. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2538. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2539. MODIFY_REG(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]), (ICActiveInput >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2540. }
  2541. /**
  2542. * @brief Get the current active input.
  2543. * @rmtoll CCMR1 CC1S LL_TIM_IC_GetActiveInput\n
  2544. * CCMR1 CC2S LL_TIM_IC_GetActiveInput\n
  2545. * CCMR2 CC3S LL_TIM_IC_GetActiveInput\n
  2546. * CCMR2 CC4S LL_TIM_IC_GetActiveInput
  2547. * @param TIMx Timer instance
  2548. * @param Channel This parameter can be one of the following values:
  2549. * @arg @ref LL_TIM_CHANNEL_CH1
  2550. * @arg @ref LL_TIM_CHANNEL_CH2
  2551. * @arg @ref LL_TIM_CHANNEL_CH3
  2552. * @arg @ref LL_TIM_CHANNEL_CH4
  2553. * @retval Returned value can be one of the following values:
  2554. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  2555. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  2556. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  2557. */
  2558. __STATIC_INLINE uint32_t LL_TIM_IC_GetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel)
  2559. {
  2560. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2561. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2562. return ((READ_BIT(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2563. }
  2564. /**
  2565. * @brief Set the prescaler of input channel.
  2566. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_SetPrescaler\n
  2567. * CCMR1 IC2PSC LL_TIM_IC_SetPrescaler\n
  2568. * CCMR2 IC3PSC LL_TIM_IC_SetPrescaler\n
  2569. * CCMR2 IC4PSC LL_TIM_IC_SetPrescaler
  2570. * @param TIMx Timer instance
  2571. * @param Channel This parameter can be one of the following values:
  2572. * @arg @ref LL_TIM_CHANNEL_CH1
  2573. * @arg @ref LL_TIM_CHANNEL_CH2
  2574. * @arg @ref LL_TIM_CHANNEL_CH3
  2575. * @arg @ref LL_TIM_CHANNEL_CH4
  2576. * @param ICPrescaler This parameter can be one of the following values:
  2577. * @arg @ref LL_TIM_ICPSC_DIV1
  2578. * @arg @ref LL_TIM_ICPSC_DIV2
  2579. * @arg @ref LL_TIM_ICPSC_DIV4
  2580. * @arg @ref LL_TIM_ICPSC_DIV8
  2581. * @retval None
  2582. */
  2583. __STATIC_INLINE void LL_TIM_IC_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPrescaler)
  2584. {
  2585. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2586. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2587. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel]), (ICPrescaler >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2588. }
  2589. /**
  2590. * @brief Get the current prescaler value acting on an input channel.
  2591. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_GetPrescaler\n
  2592. * CCMR1 IC2PSC LL_TIM_IC_GetPrescaler\n
  2593. * CCMR2 IC3PSC LL_TIM_IC_GetPrescaler\n
  2594. * CCMR2 IC4PSC LL_TIM_IC_GetPrescaler
  2595. * @param TIMx Timer instance
  2596. * @param Channel This parameter can be one of the following values:
  2597. * @arg @ref LL_TIM_CHANNEL_CH1
  2598. * @arg @ref LL_TIM_CHANNEL_CH2
  2599. * @arg @ref LL_TIM_CHANNEL_CH3
  2600. * @arg @ref LL_TIM_CHANNEL_CH4
  2601. * @retval Returned value can be one of the following values:
  2602. * @arg @ref LL_TIM_ICPSC_DIV1
  2603. * @arg @ref LL_TIM_ICPSC_DIV2
  2604. * @arg @ref LL_TIM_ICPSC_DIV4
  2605. * @arg @ref LL_TIM_ICPSC_DIV8
  2606. */
  2607. __STATIC_INLINE uint32_t LL_TIM_IC_GetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel)
  2608. {
  2609. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2610. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2611. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2612. }
  2613. /**
  2614. * @brief Set the input filter duration.
  2615. * @rmtoll CCMR1 IC1F LL_TIM_IC_SetFilter\n
  2616. * CCMR1 IC2F LL_TIM_IC_SetFilter\n
  2617. * CCMR2 IC3F LL_TIM_IC_SetFilter\n
  2618. * CCMR2 IC4F LL_TIM_IC_SetFilter
  2619. * @param TIMx Timer instance
  2620. * @param Channel This parameter can be one of the following values:
  2621. * @arg @ref LL_TIM_CHANNEL_CH1
  2622. * @arg @ref LL_TIM_CHANNEL_CH2
  2623. * @arg @ref LL_TIM_CHANNEL_CH3
  2624. * @arg @ref LL_TIM_CHANNEL_CH4
  2625. * @param ICFilter This parameter can be one of the following values:
  2626. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2627. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2628. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2629. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2630. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2631. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2632. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2633. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2634. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2635. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2636. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2637. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2638. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2639. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2640. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2641. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2642. * @retval None
  2643. */
  2644. __STATIC_INLINE void LL_TIM_IC_SetFilter(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICFilter)
  2645. {
  2646. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2647. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2648. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel]), (ICFilter >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2649. }
  2650. /**
  2651. * @brief Get the input filter duration.
  2652. * @rmtoll CCMR1 IC1F LL_TIM_IC_GetFilter\n
  2653. * CCMR1 IC2F LL_TIM_IC_GetFilter\n
  2654. * CCMR2 IC3F LL_TIM_IC_GetFilter\n
  2655. * CCMR2 IC4F LL_TIM_IC_GetFilter
  2656. * @param TIMx Timer instance
  2657. * @param Channel This parameter can be one of the following values:
  2658. * @arg @ref LL_TIM_CHANNEL_CH1
  2659. * @arg @ref LL_TIM_CHANNEL_CH2
  2660. * @arg @ref LL_TIM_CHANNEL_CH3
  2661. * @arg @ref LL_TIM_CHANNEL_CH4
  2662. * @retval Returned value can be one of the following values:
  2663. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2664. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2665. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2666. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2667. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2668. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2669. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2670. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2671. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2672. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2673. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2674. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2675. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2676. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2677. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2678. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2679. */
  2680. __STATIC_INLINE uint32_t LL_TIM_IC_GetFilter(TIM_TypeDef *TIMx, uint32_t Channel)
  2681. {
  2682. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2683. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2684. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2685. }
  2686. /**
  2687. * @brief Set the input channel polarity.
  2688. * @rmtoll CCER CC1P LL_TIM_IC_SetPolarity\n
  2689. * CCER CC1NP LL_TIM_IC_SetPolarity\n
  2690. * CCER CC2P LL_TIM_IC_SetPolarity\n
  2691. * CCER CC2NP LL_TIM_IC_SetPolarity\n
  2692. * CCER CC3P LL_TIM_IC_SetPolarity\n
  2693. * CCER CC3NP LL_TIM_IC_SetPolarity\n
  2694. * CCER CC4P LL_TIM_IC_SetPolarity\n
  2695. * CCER CC4NP LL_TIM_IC_SetPolarity
  2696. * @param TIMx Timer instance
  2697. * @param Channel This parameter can be one of the following values:
  2698. * @arg @ref LL_TIM_CHANNEL_CH1
  2699. * @arg @ref LL_TIM_CHANNEL_CH2
  2700. * @arg @ref LL_TIM_CHANNEL_CH3
  2701. * @arg @ref LL_TIM_CHANNEL_CH4
  2702. * @param ICPolarity This parameter can be one of the following values:
  2703. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2704. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2705. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2706. * @retval None
  2707. */
  2708. __STATIC_INLINE void LL_TIM_IC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPolarity)
  2709. {
  2710. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2711. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  2712. ICPolarity << SHIFT_TAB_CCxP[iChannel]);
  2713. }
  2714. /**
  2715. * @brief Get the current input channel polarity.
  2716. * @rmtoll CCER CC1P LL_TIM_IC_GetPolarity\n
  2717. * CCER CC1NP LL_TIM_IC_GetPolarity\n
  2718. * CCER CC2P LL_TIM_IC_GetPolarity\n
  2719. * CCER CC2NP LL_TIM_IC_GetPolarity\n
  2720. * CCER CC3P LL_TIM_IC_GetPolarity\n
  2721. * CCER CC3NP LL_TIM_IC_GetPolarity\n
  2722. * CCER CC4P LL_TIM_IC_GetPolarity\n
  2723. * CCER CC4NP LL_TIM_IC_GetPolarity
  2724. * @param TIMx Timer instance
  2725. * @param Channel This parameter can be one of the following values:
  2726. * @arg @ref LL_TIM_CHANNEL_CH1
  2727. * @arg @ref LL_TIM_CHANNEL_CH2
  2728. * @arg @ref LL_TIM_CHANNEL_CH3
  2729. * @arg @ref LL_TIM_CHANNEL_CH4
  2730. * @retval Returned value can be one of the following values:
  2731. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2732. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2733. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2734. */
  2735. __STATIC_INLINE uint32_t LL_TIM_IC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  2736. {
  2737. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2738. return (READ_BIT(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel])) >>
  2739. SHIFT_TAB_CCxP[iChannel]);
  2740. }
  2741. /**
  2742. * @brief Connect the TIMx_CH1, CH2 and CH3 pins to the TI1 input (XOR combination).
  2743. * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2744. * a timer instance provides an XOR input.
  2745. * @rmtoll CR2 TI1S LL_TIM_IC_EnableXORCombination
  2746. * @param TIMx Timer instance
  2747. * @retval None
  2748. */
  2749. __STATIC_INLINE void LL_TIM_IC_EnableXORCombination(TIM_TypeDef *TIMx)
  2750. {
  2751. SET_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2752. }
  2753. /**
  2754. * @brief Disconnect the TIMx_CH1, CH2 and CH3 pins from the TI1 input.
  2755. * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2756. * a timer instance provides an XOR input.
  2757. * @rmtoll CR2 TI1S LL_TIM_IC_DisableXORCombination
  2758. * @param TIMx Timer instance
  2759. * @retval None
  2760. */
  2761. __STATIC_INLINE void LL_TIM_IC_DisableXORCombination(TIM_TypeDef *TIMx)
  2762. {
  2763. CLEAR_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2764. }
  2765. /**
  2766. * @brief Indicates whether the TIMx_CH1, CH2 and CH3 pins are connectected to the TI1 input.
  2767. * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2768. * a timer instance provides an XOR input.
  2769. * @rmtoll CR2 TI1S LL_TIM_IC_IsEnabledXORCombination
  2770. * @param TIMx Timer instance
  2771. * @retval State of bit (1 or 0).
  2772. */
  2773. __STATIC_INLINE uint32_t LL_TIM_IC_IsEnabledXORCombination(TIM_TypeDef *TIMx)
  2774. {
  2775. return (READ_BIT(TIMx->CR2, TIM_CR2_TI1S) == (TIM_CR2_TI1S));
  2776. }
  2777. /**
  2778. * @brief Get captured value for input channel 1.
  2779. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2780. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2781. * whether or not a timer instance supports a 32 bits counter.
  2782. * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2783. * input channel 1 is supported by a timer instance.
  2784. * @rmtoll CCR1 CCR1 LL_TIM_IC_GetCaptureCH1
  2785. * @param TIMx Timer instance
  2786. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2787. */
  2788. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH1(TIM_TypeDef *TIMx)
  2789. {
  2790. return (uint32_t)(READ_REG(TIMx->CCR1));
  2791. }
  2792. /**
  2793. * @brief Get captured value for input channel 2.
  2794. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2795. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2796. * whether or not a timer instance supports a 32 bits counter.
  2797. * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2798. * input channel 2 is supported by a timer instance.
  2799. * @rmtoll CCR2 CCR2 LL_TIM_IC_GetCaptureCH2
  2800. * @param TIMx Timer instance
  2801. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2802. */
  2803. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH2(TIM_TypeDef *TIMx)
  2804. {
  2805. return (uint32_t)(READ_REG(TIMx->CCR2));
  2806. }
  2807. /**
  2808. * @brief Get captured value for input channel 3.
  2809. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2810. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2811. * whether or not a timer instance supports a 32 bits counter.
  2812. * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2813. * input channel 3 is supported by a timer instance.
  2814. * @rmtoll CCR3 CCR3 LL_TIM_IC_GetCaptureCH3
  2815. * @param TIMx Timer instance
  2816. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2817. */
  2818. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH3(TIM_TypeDef *TIMx)
  2819. {
  2820. return (uint32_t)(READ_REG(TIMx->CCR3));
  2821. }
  2822. /**
  2823. * @brief Get captured value for input channel 4.
  2824. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2825. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2826. * whether or not a timer instance supports a 32 bits counter.
  2827. * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2828. * input channel 4 is supported by a timer instance.
  2829. * @rmtoll CCR4 CCR4 LL_TIM_IC_GetCaptureCH4
  2830. * @param TIMx Timer instance
  2831. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2832. */
  2833. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH4(TIM_TypeDef *TIMx)
  2834. {
  2835. return (uint32_t)(READ_REG(TIMx->CCR4));
  2836. }
  2837. /**
  2838. * @}
  2839. */
  2840. /** @defgroup TIM_LL_EF_Clock_Selection Counter clock selection
  2841. * @{
  2842. */
  2843. /**
  2844. * @brief Enable external clock mode 2.
  2845. * @note When external clock mode 2 is enabled the counter is clocked by any active edge on the ETRF signal.
  2846. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2847. * whether or not a timer instance supports external clock mode2.
  2848. * @rmtoll SMCR ECE LL_TIM_EnableExternalClock
  2849. * @param TIMx Timer instance
  2850. * @retval None
  2851. */
  2852. __STATIC_INLINE void LL_TIM_EnableExternalClock(TIM_TypeDef *TIMx)
  2853. {
  2854. SET_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2855. }
  2856. /**
  2857. * @brief Disable external clock mode 2.
  2858. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2859. * whether or not a timer instance supports external clock mode2.
  2860. * @rmtoll SMCR ECE LL_TIM_DisableExternalClock
  2861. * @param TIMx Timer instance
  2862. * @retval None
  2863. */
  2864. __STATIC_INLINE void LL_TIM_DisableExternalClock(TIM_TypeDef *TIMx)
  2865. {
  2866. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2867. }
  2868. /**
  2869. * @brief Indicate whether external clock mode 2 is enabled.
  2870. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2871. * whether or not a timer instance supports external clock mode2.
  2872. * @rmtoll SMCR ECE LL_TIM_IsEnabledExternalClock
  2873. * @param TIMx Timer instance
  2874. * @retval State of bit (1 or 0).
  2875. */
  2876. __STATIC_INLINE uint32_t LL_TIM_IsEnabledExternalClock(TIM_TypeDef *TIMx)
  2877. {
  2878. return (READ_BIT(TIMx->SMCR, TIM_SMCR_ECE) == (TIM_SMCR_ECE));
  2879. }
  2880. /**
  2881. * @brief Set the clock source of the counter clock.
  2882. * @note when selected clock source is external clock mode 1, the timer input
  2883. * the external clock is applied is selected by calling the @ref LL_TIM_SetTriggerInput()
  2884. * function. This timer input must be configured by calling
  2885. * the @ref LL_TIM_IC_Config() function.
  2886. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(TIMx) can be used to check
  2887. * whether or not a timer instance supports external clock mode1.
  2888. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2889. * whether or not a timer instance supports external clock mode2.
  2890. * @rmtoll SMCR SMS LL_TIM_SetClockSource\n
  2891. * SMCR ECE LL_TIM_SetClockSource
  2892. * @param TIMx Timer instance
  2893. * @param ClockSource This parameter can be one of the following values:
  2894. * @arg @ref LL_TIM_CLOCKSOURCE_INTERNAL
  2895. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE1
  2896. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE2
  2897. * @retval None
  2898. */
  2899. __STATIC_INLINE void LL_TIM_SetClockSource(TIM_TypeDef *TIMx, uint32_t ClockSource)
  2900. {
  2901. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS | TIM_SMCR_ECE, ClockSource);
  2902. }
  2903. /**
  2904. * @brief Set the encoder interface mode.
  2905. * @note Macro @ref IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx) can be used to check
  2906. * whether or not a timer instance supports the encoder mode.
  2907. * @rmtoll SMCR SMS LL_TIM_SetEncoderMode
  2908. * @param TIMx Timer instance
  2909. * @param EncoderMode This parameter can be one of the following values:
  2910. * @arg @ref LL_TIM_ENCODERMODE_X2_TI1
  2911. * @arg @ref LL_TIM_ENCODERMODE_X2_TI2
  2912. * @arg @ref LL_TIM_ENCODERMODE_X4_TI12
  2913. * @retval None
  2914. */
  2915. __STATIC_INLINE void LL_TIM_SetEncoderMode(TIM_TypeDef *TIMx, uint32_t EncoderMode)
  2916. {
  2917. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, EncoderMode);
  2918. }
  2919. /**
  2920. * @}
  2921. */
  2922. /** @defgroup TIM_LL_EF_Timer_Synchronization Timer synchronisation configuration
  2923. * @{
  2924. */
  2925. /**
  2926. * @brief Set the trigger output (TRGO) used for timer synchronization .
  2927. * @note Macro @ref IS_TIM_MASTER_INSTANCE(TIMx) can be used to check
  2928. * whether or not a timer instance can operate as a master timer.
  2929. * @rmtoll CR2 MMS LL_TIM_SetTriggerOutput
  2930. * @param TIMx Timer instance
  2931. * @param TimerSynchronization This parameter can be one of the following values:
  2932. * @arg @ref LL_TIM_TRGO_RESET
  2933. * @arg @ref LL_TIM_TRGO_ENABLE
  2934. * @arg @ref LL_TIM_TRGO_UPDATE
  2935. * @arg @ref LL_TIM_TRGO_CC1IF
  2936. * @arg @ref LL_TIM_TRGO_OC1REF
  2937. * @arg @ref LL_TIM_TRGO_OC2REF
  2938. * @arg @ref LL_TIM_TRGO_OC3REF
  2939. * @arg @ref LL_TIM_TRGO_OC4REF
  2940. * @retval None
  2941. */
  2942. __STATIC_INLINE void LL_TIM_SetTriggerOutput(TIM_TypeDef *TIMx, uint32_t TimerSynchronization)
  2943. {
  2944. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS, TimerSynchronization);
  2945. }
  2946. /**
  2947. * @brief Set the trigger output 2 (TRGO2) used for ADC synchronization .
  2948. * @note Macro @ref IS_TIM_TRGO2_INSTANCE(TIMx) can be used to check
  2949. * whether or not a timer instance can be used for ADC synchronization.
  2950. * @rmtoll CR2 MMS2 LL_TIM_SetTriggerOutput2
  2951. * @param TIMx Timer Instance
  2952. * @param ADCSynchronization This parameter can be one of the following values:
  2953. * @arg @ref LL_TIM_TRGO2_RESET
  2954. * @arg @ref LL_TIM_TRGO2_ENABLE
  2955. * @arg @ref LL_TIM_TRGO2_UPDATE
  2956. * @arg @ref LL_TIM_TRGO2_CC1F
  2957. * @arg @ref LL_TIM_TRGO2_OC1
  2958. * @arg @ref LL_TIM_TRGO2_OC2
  2959. * @arg @ref LL_TIM_TRGO2_OC3
  2960. * @arg @ref LL_TIM_TRGO2_OC4
  2961. * @arg @ref LL_TIM_TRGO2_OC5
  2962. * @arg @ref LL_TIM_TRGO2_OC6
  2963. * @arg @ref LL_TIM_TRGO2_OC4_RISINGFALLING
  2964. * @arg @ref LL_TIM_TRGO2_OC6_RISINGFALLING
  2965. * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_RISING
  2966. * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_FALLING
  2967. * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_RISING
  2968. * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_FALLING
  2969. * @retval None
  2970. */
  2971. __STATIC_INLINE void LL_TIM_SetTriggerOutput2(TIM_TypeDef *TIMx, uint32_t ADCSynchronization)
  2972. {
  2973. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS2, ADCSynchronization);
  2974. }
  2975. /**
  2976. * @brief Set the synchronization mode of a slave timer.
  2977. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2978. * a timer instance can operate as a slave timer.
  2979. * @rmtoll SMCR SMS LL_TIM_SetSlaveMode
  2980. * @param TIMx Timer instance
  2981. * @param SlaveMode This parameter can be one of the following values:
  2982. * @arg @ref LL_TIM_SLAVEMODE_DISABLED
  2983. * @arg @ref LL_TIM_SLAVEMODE_RESET
  2984. * @arg @ref LL_TIM_SLAVEMODE_GATED
  2985. * @arg @ref LL_TIM_SLAVEMODE_TRIGGER
  2986. * @arg @ref LL_TIM_SLAVEMODE_COMBINED_RESETTRIGGER
  2987. * @retval None
  2988. */
  2989. __STATIC_INLINE void LL_TIM_SetSlaveMode(TIM_TypeDef *TIMx, uint32_t SlaveMode)
  2990. {
  2991. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, SlaveMode);
  2992. }
  2993. /**
  2994. * @brief Set the selects the trigger input to be used to synchronize the counter.
  2995. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2996. * a timer instance can operate as a slave timer.
  2997. * @rmtoll SMCR TS LL_TIM_SetTriggerInput
  2998. * @param TIMx Timer instance
  2999. * @param TriggerInput This parameter can be one of the following values:
  3000. * @arg @ref LL_TIM_TS_ITR0
  3001. * @arg @ref LL_TIM_TS_ITR1
  3002. * @arg @ref LL_TIM_TS_ITR2
  3003. * @arg @ref LL_TIM_TS_ITR3
  3004. * @arg @ref LL_TIM_TS_TI1F_ED
  3005. * @arg @ref LL_TIM_TS_TI1FP1
  3006. * @arg @ref LL_TIM_TS_TI2FP2
  3007. * @arg @ref LL_TIM_TS_ETRF
  3008. * @retval None
  3009. */
  3010. __STATIC_INLINE void LL_TIM_SetTriggerInput(TIM_TypeDef *TIMx, uint32_t TriggerInput)
  3011. {
  3012. MODIFY_REG(TIMx->SMCR, TIM_SMCR_TS, TriggerInput);
  3013. }
  3014. /**
  3015. * @brief Enable the Master/Slave mode.
  3016. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3017. * a timer instance can operate as a slave timer.
  3018. * @rmtoll SMCR MSM LL_TIM_EnableMasterSlaveMode
  3019. * @param TIMx Timer instance
  3020. * @retval None
  3021. */
  3022. __STATIC_INLINE void LL_TIM_EnableMasterSlaveMode(TIM_TypeDef *TIMx)
  3023. {
  3024. SET_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  3025. }
  3026. /**
  3027. * @brief Disable the Master/Slave mode.
  3028. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3029. * a timer instance can operate as a slave timer.
  3030. * @rmtoll SMCR MSM LL_TIM_DisableMasterSlaveMode
  3031. * @param TIMx Timer instance
  3032. * @retval None
  3033. */
  3034. __STATIC_INLINE void LL_TIM_DisableMasterSlaveMode(TIM_TypeDef *TIMx)
  3035. {
  3036. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  3037. }
  3038. /**
  3039. * @brief Indicates whether the Master/Slave mode is enabled.
  3040. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3041. * a timer instance can operate as a slave timer.
  3042. * @rmtoll SMCR MSM LL_TIM_IsEnabledMasterSlaveMode
  3043. * @param TIMx Timer instance
  3044. * @retval State of bit (1 or 0).
  3045. */
  3046. __STATIC_INLINE uint32_t LL_TIM_IsEnabledMasterSlaveMode(TIM_TypeDef *TIMx)
  3047. {
  3048. return (READ_BIT(TIMx->SMCR, TIM_SMCR_MSM) == (TIM_SMCR_MSM));
  3049. }
  3050. /**
  3051. * @brief Configure the external trigger (ETR) input.
  3052. * @note Macro @ref IS_TIM_ETR_INSTANCE(TIMx) can be used to check whether or not
  3053. * a timer instance provides an external trigger input.
  3054. * @rmtoll SMCR ETP LL_TIM_ConfigETR\n
  3055. * SMCR ETPS LL_TIM_ConfigETR\n
  3056. * SMCR ETF LL_TIM_ConfigETR
  3057. * @param TIMx Timer instance
  3058. * @param ETRPolarity This parameter can be one of the following values:
  3059. * @arg @ref LL_TIM_ETR_POLARITY_NONINVERTED
  3060. * @arg @ref LL_TIM_ETR_POLARITY_INVERTED
  3061. * @param ETRPrescaler This parameter can be one of the following values:
  3062. * @arg @ref LL_TIM_ETR_PRESCALER_DIV1
  3063. * @arg @ref LL_TIM_ETR_PRESCALER_DIV2
  3064. * @arg @ref LL_TIM_ETR_PRESCALER_DIV4
  3065. * @arg @ref LL_TIM_ETR_PRESCALER_DIV8
  3066. * @param ETRFilter This parameter can be one of the following values:
  3067. * @arg @ref LL_TIM_ETR_FILTER_FDIV1
  3068. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N2
  3069. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N4
  3070. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N8
  3071. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N6
  3072. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N8
  3073. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N6
  3074. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N8
  3075. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N6
  3076. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N8
  3077. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N5
  3078. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N6
  3079. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N8
  3080. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N5
  3081. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N6
  3082. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N8
  3083. * @retval None
  3084. */
  3085. __STATIC_INLINE void LL_TIM_ConfigETR(TIM_TypeDef *TIMx, uint32_t ETRPolarity, uint32_t ETRPrescaler,
  3086. uint32_t ETRFilter)
  3087. {
  3088. MODIFY_REG(TIMx->SMCR, TIM_SMCR_ETP | TIM_SMCR_ETPS | TIM_SMCR_ETF, ETRPolarity | ETRPrescaler | ETRFilter);
  3089. }
  3090. /**
  3091. * @brief Select the external trigger (ETR) input source.
  3092. * @note Macro @ref IS_TIM_ETRSEL_INSTANCE(TIMx) can be used to check whether or
  3093. * not a timer instance supports ETR source selection.
  3094. * @rmtoll OR2 ETRSEL LL_TIM_SetETRSource
  3095. * @param TIMx Timer instance
  3096. * @param ETRSource This parameter can be one of the following values:
  3097. * @arg @ref LL_TIM_ETRSOURCE_LEGACY
  3098. * @arg @ref LL_TIM_ETRSOURCE_COMP1
  3099. * @arg @ref LL_TIM_ETRSOURCE_COMP2
  3100. * @retval None
  3101. */
  3102. __STATIC_INLINE void LL_TIM_SetETRSource(TIM_TypeDef *TIMx, uint32_t ETRSource)
  3103. {
  3104. MODIFY_REG(TIMx->OR2, TIMx_OR2_ETRSEL, ETRSource);
  3105. }
  3106. /**
  3107. * @}
  3108. */
  3109. /** @defgroup TIM_LL_EF_Break_Function Break function configuration
  3110. * @{
  3111. */
  3112. /**
  3113. * @brief Enable the break function.
  3114. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3115. * a timer instance provides a break input.
  3116. * @rmtoll BDTR BKE LL_TIM_EnableBRK
  3117. * @param TIMx Timer instance
  3118. * @retval None
  3119. */
  3120. __STATIC_INLINE void LL_TIM_EnableBRK(TIM_TypeDef *TIMx)
  3121. {
  3122. SET_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  3123. }
  3124. /**
  3125. * @brief Disable the break function.
  3126. * @rmtoll BDTR BKE LL_TIM_DisableBRK
  3127. * @param TIMx Timer instance
  3128. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3129. * a timer instance provides a break input.
  3130. * @retval None
  3131. */
  3132. __STATIC_INLINE void LL_TIM_DisableBRK(TIM_TypeDef *TIMx)
  3133. {
  3134. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  3135. }
  3136. /**
  3137. * @brief Configure the break input.
  3138. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3139. * a timer instance provides a break input.
  3140. * @rmtoll BDTR BKP LL_TIM_ConfigBRK\n
  3141. * BDTR BKF LL_TIM_ConfigBRK
  3142. * @param TIMx Timer instance
  3143. * @param BreakPolarity This parameter can be one of the following values:
  3144. * @arg @ref LL_TIM_BREAK_POLARITY_LOW
  3145. * @arg @ref LL_TIM_BREAK_POLARITY_HIGH
  3146. * @param BreakFilter This parameter can be one of the following values:
  3147. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1
  3148. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N2
  3149. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N4
  3150. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N8
  3151. * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N6
  3152. * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N8
  3153. * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N6
  3154. * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N8
  3155. * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N6
  3156. * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N8
  3157. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N5
  3158. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N6
  3159. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N8
  3160. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N5
  3161. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N6
  3162. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N8
  3163. * @retval None
  3164. */
  3165. __STATIC_INLINE void LL_TIM_ConfigBRK(TIM_TypeDef *TIMx, uint32_t BreakPolarity, uint32_t BreakFilter)
  3166. {
  3167. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BKP | TIM_BDTR_BKF, BreakPolarity | BreakFilter);
  3168. }
  3169. /**
  3170. * @brief Enable the break 2 function.
  3171. * @note Macro @ref IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  3172. * a timer instance provides a second break input.
  3173. * @rmtoll BDTR BK2E LL_TIM_EnableBRK2
  3174. * @param TIMx Timer instance
  3175. * @retval None
  3176. */
  3177. __STATIC_INLINE void LL_TIM_EnableBRK2(TIM_TypeDef *TIMx)
  3178. {
  3179. SET_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
  3180. }
  3181. /**
  3182. * @brief Disable the break 2 function.
  3183. * @note Macro @ref IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  3184. * a timer instance provides a second break input.
  3185. * @rmtoll BDTR BK2E LL_TIM_DisableBRK2
  3186. * @param TIMx Timer instance
  3187. * @retval None
  3188. */
  3189. __STATIC_INLINE void LL_TIM_DisableBRK2(TIM_TypeDef *TIMx)
  3190. {
  3191. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
  3192. }
  3193. /**
  3194. * @brief Configure the break 2 input.
  3195. * @note Macro @ref IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  3196. * a timer instance provides a second break input.
  3197. * @rmtoll BDTR BK2P LL_TIM_ConfigBRK2\n
  3198. * BDTR BK2F LL_TIM_ConfigBRK2
  3199. * @param TIMx Timer instance
  3200. * @param Break2Polarity This parameter can be one of the following values:
  3201. * @arg @ref LL_TIM_BREAK2_POLARITY_LOW
  3202. * @arg @ref LL_TIM_BREAK2_POLARITY_HIGH
  3203. * @param Break2Filter This parameter can be one of the following values:
  3204. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1
  3205. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N2
  3206. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N4
  3207. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N8
  3208. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N6
  3209. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N8
  3210. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N6
  3211. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N8
  3212. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N6
  3213. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N8
  3214. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N5
  3215. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N6
  3216. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N8
  3217. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N5
  3218. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N6
  3219. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N8
  3220. * @retval None
  3221. */
  3222. __STATIC_INLINE void LL_TIM_ConfigBRK2(TIM_TypeDef *TIMx, uint32_t Break2Polarity, uint32_t Break2Filter)
  3223. {
  3224. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BK2P | TIM_BDTR_BK2F, Break2Polarity | Break2Filter);
  3225. }
  3226. /**
  3227. * @brief Select the outputs off state (enabled v.s. disabled) in Idle and Run modes.
  3228. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3229. * a timer instance provides a break input.
  3230. * @rmtoll BDTR OSSI LL_TIM_SetOffStates\n
  3231. * BDTR OSSR LL_TIM_SetOffStates
  3232. * @param TIMx Timer instance
  3233. * @param OffStateIdle This parameter can be one of the following values:
  3234. * @arg @ref LL_TIM_OSSI_DISABLE
  3235. * @arg @ref LL_TIM_OSSI_ENABLE
  3236. * @param OffStateRun This parameter can be one of the following values:
  3237. * @arg @ref LL_TIM_OSSR_DISABLE
  3238. * @arg @ref LL_TIM_OSSR_ENABLE
  3239. * @retval None
  3240. */
  3241. __STATIC_INLINE void LL_TIM_SetOffStates(TIM_TypeDef *TIMx, uint32_t OffStateIdle, uint32_t OffStateRun)
  3242. {
  3243. MODIFY_REG(TIMx->BDTR, TIM_BDTR_OSSI | TIM_BDTR_OSSR, OffStateIdle | OffStateRun);
  3244. }
  3245. /**
  3246. * @brief Enable automatic output (MOE can be set by software or automatically when a break input is active).
  3247. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3248. * a timer instance provides a break input.
  3249. * @rmtoll BDTR AOE LL_TIM_EnableAutomaticOutput
  3250. * @param TIMx Timer instance
  3251. * @retval None
  3252. */
  3253. __STATIC_INLINE void LL_TIM_EnableAutomaticOutput(TIM_TypeDef *TIMx)
  3254. {
  3255. SET_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  3256. }
  3257. /**
  3258. * @brief Disable automatic output (MOE can be set only by software).
  3259. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3260. * a timer instance provides a break input.
  3261. * @rmtoll BDTR AOE LL_TIM_DisableAutomaticOutput
  3262. * @param TIMx Timer instance
  3263. * @retval None
  3264. */
  3265. __STATIC_INLINE void LL_TIM_DisableAutomaticOutput(TIM_TypeDef *TIMx)
  3266. {
  3267. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  3268. }
  3269. /**
  3270. * @brief Indicate whether automatic output is enabled.
  3271. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3272. * a timer instance provides a break input.
  3273. * @rmtoll BDTR AOE LL_TIM_IsEnabledAutomaticOutput
  3274. * @param TIMx Timer instance
  3275. * @retval State of bit (1 or 0).
  3276. */
  3277. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAutomaticOutput(TIM_TypeDef *TIMx)
  3278. {
  3279. return (READ_BIT(TIMx->BDTR, TIM_BDTR_AOE) == (TIM_BDTR_AOE));
  3280. }
  3281. /**
  3282. * @brief Enable the outputs (set the MOE bit in TIMx_BDTR register).
  3283. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  3284. * software and is reset in case of break or break2 event
  3285. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3286. * a timer instance provides a break input.
  3287. * @rmtoll BDTR MOE LL_TIM_EnableAllOutputs
  3288. * @param TIMx Timer instance
  3289. * @retval None
  3290. */
  3291. __STATIC_INLINE void LL_TIM_EnableAllOutputs(TIM_TypeDef *TIMx)
  3292. {
  3293. SET_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  3294. }
  3295. /**
  3296. * @brief Disable the outputs (reset the MOE bit in TIMx_BDTR register).
  3297. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  3298. * software and is reset in case of break or break2 event.
  3299. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3300. * a timer instance provides a break input.
  3301. * @rmtoll BDTR MOE LL_TIM_DisableAllOutputs
  3302. * @param TIMx Timer instance
  3303. * @retval None
  3304. */
  3305. __STATIC_INLINE void LL_TIM_DisableAllOutputs(TIM_TypeDef *TIMx)
  3306. {
  3307. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  3308. }
  3309. /**
  3310. * @brief Indicates whether outputs are enabled.
  3311. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3312. * a timer instance provides a break input.
  3313. * @rmtoll BDTR MOE LL_TIM_IsEnabledAllOutputs
  3314. * @param TIMx Timer instance
  3315. * @retval State of bit (1 or 0).
  3316. */
  3317. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAllOutputs(TIM_TypeDef *TIMx)
  3318. {
  3319. return (READ_BIT(TIMx->BDTR, TIM_BDTR_MOE) == (TIM_BDTR_MOE));
  3320. }
  3321. /**
  3322. * @brief Enable the signals connected to the designated timer break input.
  3323. * @note Macro @ref IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  3324. * or not a timer instance allows for break input selection.
  3325. * @rmtoll OR2 BKINE LL_TIM_EnableBreakInputSource\n
  3326. * OR2 BKCMP1E LL_TIM_EnableBreakInputSource\n
  3327. * OR2 BKCMP2E LL_TIM_EnableBreakInputSource\n
  3328. * OR2 BKDFBK0E LL_TIM_EnableBreakInputSource\n
  3329. * OR3 BKINE LL_TIM_EnableBreakInputSource\n
  3330. * OR3 BKCMP1E LL_TIM_EnableBreakInputSource\n
  3331. * OR3 BKCMP2E LL_TIM_EnableBreakInputSource\n
  3332. * OR3 BKDFBK0E LL_TIM_EnableBreakInputSource
  3333. * @param TIMx Timer instance
  3334. * @param BreakInput This parameter can be one of the following values:
  3335. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  3336. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  3337. * @param Source This parameter can be one of the following values:
  3338. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  3339. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  3340. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  3341. * @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
  3342. * @retval None
  3343. */
  3344. __STATIC_INLINE void LL_TIM_EnableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
  3345. {
  3346. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->OR2) + BreakInput));
  3347. SET_BIT(*pReg , Source);
  3348. }
  3349. /**
  3350. * @brief Disable the signals connected to the designated timer break input.
  3351. * @note Macro @ref IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  3352. * or not a timer instance allows for break input selection.
  3353. * @rmtoll OR2 BKINE LL_TIM_DisableBreakInputSource\n
  3354. * OR2 BKCMP1E LL_TIM_DisableBreakInputSource\n
  3355. * OR2 BKCMP2E LL_TIM_DisableBreakInputSource\n
  3356. * OR2 BKDFBK0E LL_TIM_DisableBreakInputSource\n
  3357. * OR3 BKINE LL_TIM_DisableBreakInputSource\n
  3358. * OR3 BKCMP1E LL_TIM_DisableBreakInputSource\n
  3359. * OR3 BKCMP2E LL_TIM_DisableBreakInputSource\n
  3360. * OR3 BKDFBK0E LL_TIM_DisableBreakInputSource
  3361. * @param TIMx Timer instance
  3362. * @param BreakInput This parameter can be one of the following values:
  3363. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  3364. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  3365. * @param Source This parameter can be one of the following values:
  3366. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  3367. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  3368. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  3369. * @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
  3370. * @retval None
  3371. */
  3372. __STATIC_INLINE void LL_TIM_DisableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
  3373. {
  3374. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->OR2) + BreakInput));
  3375. CLEAR_BIT(*pReg, Source);
  3376. }
  3377. /**
  3378. * @brief Set the polarity of the break signal for the timer break input.
  3379. * @note Macro @ref IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  3380. * or not a timer instance allows for break input selection.
  3381. * @rmtoll OR2 BKINE LL_TIM_SetBreakInputSourcePolarity\n
  3382. * OR2 BKCMP1E LL_TIM_SetBreakInputSourcePolarity\n
  3383. * OR2 BKCMP2E LL_TIM_SetBreakInputSourcePolarity\n
  3384. * OR2 BKINP LL_TIM_SetBreakInputSourcePolarity\n
  3385. * OR3 BKINE LL_TIM_SetBreakInputSourcePolarity\n
  3386. * OR3 BKCMP1E LL_TIM_SetBreakInputSourcePolarity\n
  3387. * OR3 BKCMP2E LL_TIM_SetBreakInputSourcePolarity\n
  3388. * OR3 BKINP LL_TIM_SetBreakInputSourcePolarity
  3389. * @param TIMx Timer instance
  3390. * @param BreakInput This parameter can be one of the following values:
  3391. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  3392. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  3393. * @param Source This parameter can be one of the following values:
  3394. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  3395. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  3396. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  3397. * @param Polarity This parameter can be one of the following values:
  3398. * @arg @ref LL_TIM_BKIN_POLARITY_LOW
  3399. * @arg @ref LL_TIM_BKIN_POLARITY_HIGH
  3400. * @retval None
  3401. */
  3402. __STATIC_INLINE void LL_TIM_SetBreakInputSourcePolarity(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source,
  3403. uint32_t Polarity)
  3404. {
  3405. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->OR2) + BreakInput));
  3406. MODIFY_REG(*pReg, (TIMx_OR2_BKINP << (TIM_POSITION_BRK_SOURCE)) , (Polarity << (TIM_POSITION_BRK_SOURCE)));
  3407. }
  3408. /**
  3409. * @}
  3410. */
  3411. /** @defgroup TIM_LL_EF_DMA_Burst_Mode DMA burst mode configuration
  3412. * @{
  3413. */
  3414. /**
  3415. * @brief Configures the timer DMA burst feature.
  3416. * @note Macro @ref IS_TIM_DMABURST_INSTANCE(TIMx) can be used to check whether or
  3417. * not a timer instance supports the DMA burst mode.
  3418. * @rmtoll DCR DBL LL_TIM_ConfigDMABurst\n
  3419. * DCR DBA LL_TIM_ConfigDMABurst
  3420. * @param TIMx Timer instance
  3421. * @param DMABurstBaseAddress This parameter can be one of the following values:
  3422. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR1
  3423. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR2
  3424. * @arg @ref LL_TIM_DMABURST_BASEADDR_SMCR
  3425. * @arg @ref LL_TIM_DMABURST_BASEADDR_DIER
  3426. * @arg @ref LL_TIM_DMABURST_BASEADDR_SR
  3427. * @arg @ref LL_TIM_DMABURST_BASEADDR_EGR
  3428. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR1
  3429. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR2
  3430. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCER
  3431. * @arg @ref LL_TIM_DMABURST_BASEADDR_CNT
  3432. * @arg @ref LL_TIM_DMABURST_BASEADDR_PSC
  3433. * @arg @ref LL_TIM_DMABURST_BASEADDR_ARR
  3434. * @arg @ref LL_TIM_DMABURST_BASEADDR_RCR
  3435. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR1
  3436. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR2
  3437. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR3
  3438. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR4
  3439. * @arg @ref LL_TIM_DMABURST_BASEADDR_BDTR
  3440. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR3
  3441. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR5
  3442. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR6
  3443. * @arg @ref LL_TIM_DMABURST_BASEADDR_OR1
  3444. * @arg @ref LL_TIM_DMABURST_BASEADDR_OR2
  3445. * @arg @ref LL_TIM_DMABURST_BASEADDR_OR3
  3446. * @param DMABurstLength This parameter can be one of the following values:
  3447. * @arg @ref LL_TIM_DMABURST_LENGTH_1TRANSFER
  3448. * @arg @ref LL_TIM_DMABURST_LENGTH_2TRANSFERS
  3449. * @arg @ref LL_TIM_DMABURST_LENGTH_3TRANSFERS
  3450. * @arg @ref LL_TIM_DMABURST_LENGTH_4TRANSFERS
  3451. * @arg @ref LL_TIM_DMABURST_LENGTH_5TRANSFERS
  3452. * @arg @ref LL_TIM_DMABURST_LENGTH_6TRANSFERS
  3453. * @arg @ref LL_TIM_DMABURST_LENGTH_7TRANSFERS
  3454. * @arg @ref LL_TIM_DMABURST_LENGTH_8TRANSFERS
  3455. * @arg @ref LL_TIM_DMABURST_LENGTH_9TRANSFERS
  3456. * @arg @ref LL_TIM_DMABURST_LENGTH_10TRANSFERS
  3457. * @arg @ref LL_TIM_DMABURST_LENGTH_11TRANSFERS
  3458. * @arg @ref LL_TIM_DMABURST_LENGTH_12TRANSFERS
  3459. * @arg @ref LL_TIM_DMABURST_LENGTH_13TRANSFERS
  3460. * @arg @ref LL_TIM_DMABURST_LENGTH_14TRANSFERS
  3461. * @arg @ref LL_TIM_DMABURST_LENGTH_15TRANSFERS
  3462. * @arg @ref LL_TIM_DMABURST_LENGTH_16TRANSFERS
  3463. * @arg @ref LL_TIM_DMABURST_LENGTH_17TRANSFERS
  3464. * @arg @ref LL_TIM_DMABURST_LENGTH_18TRANSFERS
  3465. * @retval None
  3466. */
  3467. __STATIC_INLINE void LL_TIM_ConfigDMABurst(TIM_TypeDef *TIMx, uint32_t DMABurstBaseAddress, uint32_t DMABurstLength)
  3468. {
  3469. MODIFY_REG(TIMx->DCR, TIM_DCR_DBL | TIM_DCR_DBA, DMABurstBaseAddress | DMABurstLength);
  3470. }
  3471. /**
  3472. * @}
  3473. */
  3474. /** @defgroup TIM_LL_EF_Timer_Inputs_Remapping Timer input remapping
  3475. * @{
  3476. */
  3477. /**
  3478. * @brief Remap TIM inputs (input channel, internal/external triggers).
  3479. * @note Macro @ref IS_TIM_REMAP_INSTANCE(TIMx) can be used to check whether or not
  3480. * a some timer inputs can be remapped.
  3481. @if STM32L486xx
  3482. * @rmtoll TIM1_OR1 ETR_ADC1_RMP LL_TIM_SetRemap\n
  3483. * TIM1_OR1 ETR_ADC3_RMP LL_TIM_SetRemap\n
  3484. * TIM1_OR1 TI1_RMP LL_TIM_SetRemap\n
  3485. * TIM8_OR1 ETR_ADC2_RMP LL_TIM_SetRemap\n
  3486. * TIM8_OR1 ETR_ADC3_RMP LL_TIM_SetRemap\n
  3487. * TIM8_OR1 TI1_RMP LL_TIM_SetRemap\n
  3488. * TIM2_OR1 ITR1_RMP LL_TIM_SetRemap\n
  3489. * TIM2_OR1 TI4_RMP LL_TIM_SetRemap\n
  3490. * TIM2_OR1 TI1_RMP LL_TIM_SetRemap\n
  3491. * TIM3_OR1 TI1_RMP LL_TIM_SetRemap\n
  3492. * TIM15_OR1 TI1_RMP LL_TIM_SetRemap\n
  3493. * TIM15_OR1 ENCODER_MODE LL_TIM_SetRemap\n
  3494. * TIM16_OR1 TI1_RMP LL_TIM_SetRemap\n
  3495. * TIM17_OR1 TI1_RMP LL_TIM_SetRemap
  3496. @endif
  3497. @if STM32L443xx
  3498. * @rmtoll TIM1_OR1 ETR_ADC1_RMP LL_TIM_SetRemap\n
  3499. * TIM1_OR1 ETR_ADC3_RMP LL_TIM_SetRemap\n
  3500. * TIM1_OR1 TI1_RMP LL_TIM_SetRemap\n
  3501. * TIM2_OR1 ITR1_RMP LL_TIM_SetRemap\n
  3502. * TIM2_OR1 TI4_RMP LL_TIM_SetRemap\n
  3503. * TIM2_OR1 TI1_RMP LL_TIM_SetRemap\n
  3504. * TIM15_OR1 TI1_RMP LL_TIM_SetRemap\n
  3505. * TIM15_OR1 ENCODER_MODE LL_TIM_SetRemap\n
  3506. * TIM16_OR1 TI1_RMP LL_TIM_SetRemap\n
  3507. @endif
  3508. * @param TIMx Timer instance
  3509. * @param Remap Remap param depends on the TIMx. Description available only
  3510. * in CHM version of the User Manual (not in .pdf).
  3511. * Otherwise see Reference Manual description of OR registers.
  3512. *
  3513. * Below description summarizes "Timer Instance" and "Remap" param combinations:
  3514. *
  3515. @if STM32L486xx
  3516. * TIM1: any combination of TI1_RMP, ADC3_RMP, ADC1_RMP where
  3517. *
  3518. * . . ADC1_RMP can be one of the following values
  3519. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_NC
  3520. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_AWD1
  3521. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_AWD2
  3522. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_AWD3
  3523. *
  3524. * . . ADC3_RMP can be one of the following values
  3525. * @arg @ref LL_TIM_TIM1_ETR_ADC3_RMP_NC
  3526. * @arg @ref LL_TIM_TIM1_ETR_ADC3_RMP_AWD1
  3527. * @arg @ref LL_TIM_TIM1_ETR_ADC3_RMP_AWD2
  3528. * @arg @ref LL_TIM_TIM1_ETR_ADC3_RMP_AWD3
  3529. *
  3530. * . . TI1_RMP can be one of the following values
  3531. * @arg @ref LL_TIM_TIM1_TI1_RMP_GPIO
  3532. * @arg @ref LL_TIM_TIM1_TI1_RMP_COMP1
  3533. *
  3534. * TIM2: any combination of ITR1_RMP, ETR1_RMP, TI4_RMP where
  3535. *
  3536. * ITR1_RMP can be one of the following values
  3537. * @arg @ref LL_TIM_TIM2_ITR1_RMP_TIM8_TRGO
  3538. * @arg @ref LL_TIM_TIM2_ITR1_RMP_OTG_FS_SOF
  3539. *
  3540. * . . ETR1_RMP can be one of the following values
  3541. * @arg @ref LL_TIM_TIM2_ETR_RMP_GPIO
  3542. * @arg @ref LL_TIM_TIM2_ETR_RMP_LSE
  3543. *
  3544. * . . TI4_RMP can be one of the following values
  3545. * @arg @ref LL_TIM_TIM2_TI4_RMP_GPIO
  3546. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP1
  3547. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP2
  3548. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP1_COMP2
  3549. *
  3550. * TIM3: one of the following values
  3551. *
  3552. * @arg @ref LL_TIM_TIM3_TI1_RMP_GPIO
  3553. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP1
  3554. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP2
  3555. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP1_COMP2
  3556. *
  3557. * TIM8: any combination of TI1_RMP, ADC3_RMP, ADC1_RMP where
  3558. *
  3559. * . . ADC1_RMP can be one of the following values
  3560. * @arg @ref LL_TIM_TIM8_ETR_ADC2_RMP_NC
  3561. * @arg @ref LL_TIM_TIM8_ETR_ADC2_RMP_AWD1
  3562. * @arg @ref LL_TIM_TIM8_ETR_ADC2_RMP_AWD2
  3563. * @arg @ref LL_TIM_TIM8_ETR_ADC2_RMP_AWD3
  3564. *
  3565. * . . ADC3_RMP can be one of the following values
  3566. * @arg @ref LL_TIM_TIM8_ETR_ADC3_RMP_NC
  3567. * @arg @ref LL_TIM_TIM8_ETR_ADC3_RMP_AWD1
  3568. * @arg @ref LL_TIM_TIM8_ETR_ADC3_RMP_AWD2
  3569. * @arg @ref LL_TIM_TIM8_ETR_ADC3_RMP_AWD3
  3570. *
  3571. * . . TI1_RMP can be one of the following values
  3572. * @arg @ref LL_TIM_TIM8_TI1_RMP_GPIO
  3573. * @arg @ref LL_TIM_TIM8_TI1_RMP_COMP2
  3574. *
  3575. * TIM15: any combination of TI1_RMP, ENCODER_MODE where
  3576. *
  3577. * . . TI1_RMP can be one of the following values
  3578. * @arg @ref LL_TIM_TIM15_TI1_RMP_GPIO
  3579. * @arg @ref LL_TIM_TIM15_TI1_RMP_LSE
  3580. *
  3581. * . . ENCODER_MODE can be one of the following values
  3582. * @arg @ref LL_TIM_TIM15_ENCODERMODE_NOREDIRECTION
  3583. * @arg @ref LL_TIM_TIM15_ENCODERMODE_TIM2
  3584. * @arg @ref LL_TIM_TIM15_ENCODERMODE_TIM3
  3585. * @arg @ref LL_TIM_TIM15_ENCODERMODE_TIM4
  3586. *
  3587. * TIM16: one of the following values
  3588. *
  3589. * @arg @ref LL_TIM_TIM16_TI1_RMP_GPIO
  3590. * @arg @ref LL_TIM_TIM16_TI1_RMP_LSI
  3591. * @arg @ref LL_TIM_TIM16_TI1_RMP_LSE
  3592. * @arg @ref LL_TIM_TIM16_TI1_RMP_RTC
  3593. * @arg @ref LL_TIM_TIM16_TI1_RMP_MSI
  3594. * @arg @ref LL_TIM_TIM16_TI1_RMP_HSE_32
  3595. * @arg @ref LL_TIM_TIM16_TI1_RMP_MCO
  3596. *
  3597. * TIM17: one of the following values
  3598. *
  3599. * @arg @ref LL_TIM_TIM17_TI1_RMP_GPIO
  3600. * @arg @ref LL_TIM_TIM17_TI1_RMP_MSI
  3601. * @arg @ref LL_TIM_TIM17_TI1_RMP_HSE_32
  3602. * @arg @ref LL_TIM_TIM17_TI1_RMP_MCO
  3603. @endif
  3604. @if STM32L443xx
  3605. * TIM1: any combination of TI1_RMP, ADC3_RMP, ADC1_RMP where
  3606. *
  3607. * . . ADC1_RMP can be one of the following values
  3608. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_NC
  3609. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_AWD1
  3610. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_AWD2
  3611. * @arg @ref LL_TIM_TIM1_ETR_ADC1_RMP_AWD3
  3612. *
  3613. * . . TI1_RMP can be one of the following values
  3614. * @arg @ref LL_TIM_TIM1_TI1_RMP_GPIO
  3615. * @arg @ref LL_TIM_TIM1_TI1_RMP_COMP1
  3616. *
  3617. * TIM2: any combination of ITR1_RMP, ETR1_RMP, TI4_RMP where
  3618. *
  3619. * ITR1_RMP can be one of the following values
  3620. * @arg @ref LL_TIM_TIM2_ITR1_RMP_NONE
  3621. * @arg @ref LL_TIM_TIM2_ITR1_RMP_USB_SOF
  3622. *
  3623. * . . ETR1_RMP can be one of the following values
  3624. * @arg @ref LL_TIM_TIM2_ETR_RMP_GPIO
  3625. * @arg @ref LL_TIM_TIM2_ETR_RMP_LSE
  3626. *
  3627. * . . TI4_RMP can be one of the following values
  3628. * @arg @ref LL_TIM_TIM2_TI4_RMP_GPIO
  3629. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP1
  3630. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP2
  3631. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP1_COMP2
  3632. *
  3633. * TIM15: any combination of TI1_RMP, ENCODER_MODE where
  3634. *
  3635. * . . TI1_RMP can be one of the following values
  3636. * @arg @ref LL_TIM_TIM15_TI1_RMP_GPIO
  3637. * @arg @ref LL_TIM_TIM15_TI1_RMP_LSE
  3638. *
  3639. * . . ENCODER_MODE can be one of the following values
  3640. * @arg @ref LL_TIM_TIM15_ENCODERMODE_NOREDIRECTION
  3641. * @arg @ref LL_TIM_TIM15_ENCODERMODE_TIM2
  3642. * @arg @ref LL_TIM_TIM15_ENCODERMODE_TIM3
  3643. * @arg @ref LL_TIM_TIM15_ENCODERMODE_TIM4
  3644. *
  3645. * TIM16: one of the following values
  3646. *
  3647. * @arg @ref LL_TIM_TIM16_TI1_RMP_GPIO
  3648. * @arg @ref LL_TIM_TIM16_TI1_RMP_LSI
  3649. * @arg @ref LL_TIM_TIM16_TI1_RMP_LSE
  3650. * @arg @ref LL_TIM_TIM16_TI1_RMP_RTC
  3651. * @arg @ref LL_TIM_TIM16_TI1_RMP_MSI
  3652. * @arg @ref LL_TIM_TIM16_TI1_RMP_HSE_32
  3653. * @arg @ref LL_TIM_TIM16_TI1_RMP_MCO
  3654. @endif
  3655. * @retval None
  3656. */
  3657. __STATIC_INLINE void LL_TIM_SetRemap(TIM_TypeDef *TIMx, uint32_t Remap)
  3658. {
  3659. MODIFY_REG(TIMx->OR1, (Remap >> TIMx_OR1_RMP_SHIFT), (Remap & TIMx_OR1_RMP_MASK));
  3660. }
  3661. /**
  3662. * @}
  3663. */
  3664. /** @defgroup TIM_LL_EF_OCREF_Clear OCREF_Clear_Management
  3665. * @{
  3666. */
  3667. /**
  3668. * @brief Set the OCREF clear input source
  3669. * @note The OCxREF signal of a given channel can be cleared when a high level is applied on the OCREF_CLR_INPUT
  3670. * @note This function can only be used in Output compare and PWM modes.
  3671. * @rmtoll SMCR OCCS LL_TIM_SetOCRefClearInputSource
  3672. * @param TIMx Timer instance
  3673. * @param OCRefClearInputSource This parameter can be one of the following values:
  3674. * @arg @ref LL_TIM_OCREF_CLR_INT_NC
  3675. * @arg @ref LL_TIM_OCREF_CLR_INT_ETR
  3676. * @retval None
  3677. */
  3678. __STATIC_INLINE void LL_TIM_SetOCRefClearInputSource(TIM_TypeDef *TIMx, uint32_t OCRefClearInputSource)
  3679. {
  3680. MODIFY_REG(TIMx->SMCR, TIM_SMCR_OCCS, OCRefClearInputSource);
  3681. }
  3682. /**
  3683. * @}
  3684. */
  3685. /** @defgroup TIM_LL_EF_FLAG_Management FLAG-Management
  3686. * @{
  3687. */
  3688. /**
  3689. * @brief Clear the update interrupt flag (UIF).
  3690. * @rmtoll SR UIF LL_TIM_ClearFlag_UPDATE
  3691. * @param TIMx Timer instance
  3692. * @retval None
  3693. */
  3694. __STATIC_INLINE void LL_TIM_ClearFlag_UPDATE(TIM_TypeDef *TIMx)
  3695. {
  3696. WRITE_REG(TIMx->SR, ~(TIM_SR_UIF));
  3697. }
  3698. /**
  3699. * @brief Indicate whether update interrupt flag (UIF) is set (update interrupt is pending).
  3700. * @rmtoll SR UIF LL_TIM_IsActiveFlag_UPDATE
  3701. * @param TIMx Timer instance
  3702. * @retval State of bit (1 or 0).
  3703. */
  3704. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_UPDATE(TIM_TypeDef *TIMx)
  3705. {
  3706. return (READ_BIT(TIMx->SR, TIM_SR_UIF) == (TIM_SR_UIF));
  3707. }
  3708. /**
  3709. * @brief Clear the Capture/Compare 1 interrupt flag (CC1F).
  3710. * @rmtoll SR CC1IF LL_TIM_ClearFlag_CC1
  3711. * @param TIMx Timer instance
  3712. * @retval None
  3713. */
  3714. __STATIC_INLINE void LL_TIM_ClearFlag_CC1(TIM_TypeDef *TIMx)
  3715. {
  3716. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1IF));
  3717. }
  3718. /**
  3719. * @brief Indicate whether Capture/Compare 1 interrupt flag (CC1F) is set (Capture/Compare 1 interrupt is pending).
  3720. * @rmtoll SR CC1IF LL_TIM_IsActiveFlag_CC1
  3721. * @param TIMx Timer instance
  3722. * @retval State of bit (1 or 0).
  3723. */
  3724. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1(TIM_TypeDef *TIMx)
  3725. {
  3726. return (READ_BIT(TIMx->SR, TIM_SR_CC1IF) == (TIM_SR_CC1IF));
  3727. }
  3728. /**
  3729. * @brief Clear the Capture/Compare 2 interrupt flag (CC2F).
  3730. * @rmtoll SR CC2IF LL_TIM_ClearFlag_CC2
  3731. * @param TIMx Timer instance
  3732. * @retval None
  3733. */
  3734. __STATIC_INLINE void LL_TIM_ClearFlag_CC2(TIM_TypeDef *TIMx)
  3735. {
  3736. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2IF));
  3737. }
  3738. /**
  3739. * @brief Indicate whether Capture/Compare 2 interrupt flag (CC2F) is set (Capture/Compare 2 interrupt is pending).
  3740. * @rmtoll SR CC2IF LL_TIM_IsActiveFlag_CC2
  3741. * @param TIMx Timer instance
  3742. * @retval State of bit (1 or 0).
  3743. */
  3744. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2(TIM_TypeDef *TIMx)
  3745. {
  3746. return (READ_BIT(TIMx->SR, TIM_SR_CC2IF) == (TIM_SR_CC2IF));
  3747. }
  3748. /**
  3749. * @brief Clear the Capture/Compare 3 interrupt flag (CC3F).
  3750. * @rmtoll SR CC3IF LL_TIM_ClearFlag_CC3
  3751. * @param TIMx Timer instance
  3752. * @retval None
  3753. */
  3754. __STATIC_INLINE void LL_TIM_ClearFlag_CC3(TIM_TypeDef *TIMx)
  3755. {
  3756. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3IF));
  3757. }
  3758. /**
  3759. * @brief Indicate whether Capture/Compare 3 interrupt flag (CC3F) is set (Capture/Compare 3 interrupt is pending).
  3760. * @rmtoll SR CC3IF LL_TIM_IsActiveFlag_CC3
  3761. * @param TIMx Timer instance
  3762. * @retval State of bit (1 or 0).
  3763. */
  3764. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3(TIM_TypeDef *TIMx)
  3765. {
  3766. return (READ_BIT(TIMx->SR, TIM_SR_CC3IF) == (TIM_SR_CC3IF));
  3767. }
  3768. /**
  3769. * @brief Clear the Capture/Compare 4 interrupt flag (CC4F).
  3770. * @rmtoll SR CC4IF LL_TIM_ClearFlag_CC4
  3771. * @param TIMx Timer instance
  3772. * @retval None
  3773. */
  3774. __STATIC_INLINE void LL_TIM_ClearFlag_CC4(TIM_TypeDef *TIMx)
  3775. {
  3776. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4IF));
  3777. }
  3778. /**
  3779. * @brief Indicate whether Capture/Compare 4 interrupt flag (CC4F) is set (Capture/Compare 4 interrupt is pending).
  3780. * @rmtoll SR CC4IF LL_TIM_IsActiveFlag_CC4
  3781. * @param TIMx Timer instance
  3782. * @retval State of bit (1 or 0).
  3783. */
  3784. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4(TIM_TypeDef *TIMx)
  3785. {
  3786. return (READ_BIT(TIMx->SR, TIM_SR_CC4IF) == (TIM_SR_CC4IF));
  3787. }
  3788. /**
  3789. * @brief Clear the Capture/Compare 5 interrupt flag (CC5F).
  3790. * @rmtoll SR CC5IF LL_TIM_ClearFlag_CC5
  3791. * @param TIMx Timer instance
  3792. * @retval None
  3793. */
  3794. __STATIC_INLINE void LL_TIM_ClearFlag_CC5(TIM_TypeDef *TIMx)
  3795. {
  3796. WRITE_REG(TIMx->SR, ~(TIM_SR_CC5IF));
  3797. }
  3798. /**
  3799. * @brief Indicate whether Capture/Compare 5 interrupt flag (CC5F) is set (Capture/Compare 5 interrupt is pending).
  3800. * @rmtoll SR CC5IF LL_TIM_IsActiveFlag_CC5
  3801. * @param TIMx Timer instance
  3802. * @retval State of bit (1 or 0).
  3803. */
  3804. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC5(TIM_TypeDef *TIMx)
  3805. {
  3806. return (READ_BIT(TIMx->SR, TIM_SR_CC5IF) == (TIM_SR_CC5IF));
  3807. }
  3808. /**
  3809. * @brief Clear the Capture/Compare 6 interrupt flag (CC6F).
  3810. * @rmtoll SR CC6IF LL_TIM_ClearFlag_CC6
  3811. * @param TIMx Timer instance
  3812. * @retval None
  3813. */
  3814. __STATIC_INLINE void LL_TIM_ClearFlag_CC6(TIM_TypeDef *TIMx)
  3815. {
  3816. WRITE_REG(TIMx->SR, ~(TIM_SR_CC6IF));
  3817. }
  3818. /**
  3819. * @brief Indicate whether Capture/Compare 6 interrupt flag (CC6F) is set (Capture/Compare 6 interrupt is pending).
  3820. * @rmtoll SR CC6IF LL_TIM_IsActiveFlag_CC6
  3821. * @param TIMx Timer instance
  3822. * @retval State of bit (1 or 0).
  3823. */
  3824. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC6(TIM_TypeDef *TIMx)
  3825. {
  3826. return (READ_BIT(TIMx->SR, TIM_SR_CC6IF) == (TIM_SR_CC6IF));
  3827. }
  3828. /**
  3829. * @brief Clear the commutation interrupt flag (COMIF).
  3830. * @rmtoll SR COMIF LL_TIM_ClearFlag_COM
  3831. * @param TIMx Timer instance
  3832. * @retval None
  3833. */
  3834. __STATIC_INLINE void LL_TIM_ClearFlag_COM(TIM_TypeDef *TIMx)
  3835. {
  3836. WRITE_REG(TIMx->SR, ~(TIM_SR_COMIF));
  3837. }
  3838. /**
  3839. * @brief Indicate whether commutation interrupt flag (COMIF) is set (commutation interrupt is pending).
  3840. * @rmtoll SR COMIF LL_TIM_IsActiveFlag_COM
  3841. * @param TIMx Timer instance
  3842. * @retval State of bit (1 or 0).
  3843. */
  3844. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_COM(TIM_TypeDef *TIMx)
  3845. {
  3846. return (READ_BIT(TIMx->SR, TIM_SR_COMIF) == (TIM_SR_COMIF));
  3847. }
  3848. /**
  3849. * @brief Clear the trigger interrupt flag (TIF).
  3850. * @rmtoll SR TIF LL_TIM_ClearFlag_TRIG
  3851. * @param TIMx Timer instance
  3852. * @retval None
  3853. */
  3854. __STATIC_INLINE void LL_TIM_ClearFlag_TRIG(TIM_TypeDef *TIMx)
  3855. {
  3856. WRITE_REG(TIMx->SR, ~(TIM_SR_TIF));
  3857. }
  3858. /**
  3859. * @brief Indicate whether trigger interrupt flag (TIF) is set (trigger interrupt is pending).
  3860. * @rmtoll SR TIF LL_TIM_IsActiveFlag_TRIG
  3861. * @param TIMx Timer instance
  3862. * @retval State of bit (1 or 0).
  3863. */
  3864. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_TRIG(TIM_TypeDef *TIMx)
  3865. {
  3866. return (READ_BIT(TIMx->SR, TIM_SR_TIF) == (TIM_SR_TIF));
  3867. }
  3868. /**
  3869. * @brief Clear the break interrupt flag (BIF).
  3870. * @rmtoll SR BIF LL_TIM_ClearFlag_BRK
  3871. * @param TIMx Timer instance
  3872. * @retval None
  3873. */
  3874. __STATIC_INLINE void LL_TIM_ClearFlag_BRK(TIM_TypeDef *TIMx)
  3875. {
  3876. WRITE_REG(TIMx->SR, ~(TIM_SR_BIF));
  3877. }
  3878. /**
  3879. * @brief Indicate whether break interrupt flag (BIF) is set (break interrupt is pending).
  3880. * @rmtoll SR BIF LL_TIM_IsActiveFlag_BRK
  3881. * @param TIMx Timer instance
  3882. * @retval State of bit (1 or 0).
  3883. */
  3884. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK(TIM_TypeDef *TIMx)
  3885. {
  3886. return (READ_BIT(TIMx->SR, TIM_SR_BIF) == (TIM_SR_BIF));
  3887. }
  3888. /**
  3889. * @brief Clear the break 2 interrupt flag (B2IF).
  3890. * @rmtoll SR B2IF LL_TIM_ClearFlag_BRK2
  3891. * @param TIMx Timer instance
  3892. * @retval None
  3893. */
  3894. __STATIC_INLINE void LL_TIM_ClearFlag_BRK2(TIM_TypeDef *TIMx)
  3895. {
  3896. WRITE_REG(TIMx->SR, ~(TIM_SR_B2IF));
  3897. }
  3898. /**
  3899. * @brief Indicate whether break 2 interrupt flag (B2IF) is set (break 2 interrupt is pending).
  3900. * @rmtoll SR B2IF LL_TIM_IsActiveFlag_BRK2
  3901. * @param TIMx Timer instance
  3902. * @retval State of bit (1 or 0).
  3903. */
  3904. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK2(TIM_TypeDef *TIMx)
  3905. {
  3906. return (READ_BIT(TIMx->SR, TIM_SR_B2IF) == (TIM_SR_B2IF));
  3907. }
  3908. /**
  3909. * @brief Clear the Capture/Compare 1 over-capture interrupt flag (CC1OF).
  3910. * @rmtoll SR CC1OF LL_TIM_ClearFlag_CC1OVR
  3911. * @param TIMx Timer instance
  3912. * @retval None
  3913. */
  3914. __STATIC_INLINE void LL_TIM_ClearFlag_CC1OVR(TIM_TypeDef *TIMx)
  3915. {
  3916. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1OF));
  3917. }
  3918. /**
  3919. * @brief Indicate whether Capture/Compare 1 over-capture interrupt flag (CC1OF) is set (Capture/Compare 1 interrupt is pending).
  3920. * @rmtoll SR CC1OF LL_TIM_IsActiveFlag_CC1OVR
  3921. * @param TIMx Timer instance
  3922. * @retval State of bit (1 or 0).
  3923. */
  3924. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1OVR(TIM_TypeDef *TIMx)
  3925. {
  3926. return (READ_BIT(TIMx->SR, TIM_SR_CC1OF) == (TIM_SR_CC1OF));
  3927. }
  3928. /**
  3929. * @brief Clear the Capture/Compare 2 over-capture interrupt flag (CC2OF).
  3930. * @rmtoll SR CC2OF LL_TIM_ClearFlag_CC2OVR
  3931. * @param TIMx Timer instance
  3932. * @retval None
  3933. */
  3934. __STATIC_INLINE void LL_TIM_ClearFlag_CC2OVR(TIM_TypeDef *TIMx)
  3935. {
  3936. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2OF));
  3937. }
  3938. /**
  3939. * @brief Indicate whether Capture/Compare 2 over-capture interrupt flag (CC2OF) is set (Capture/Compare 2 over-capture interrupt is pending).
  3940. * @rmtoll SR CC2OF LL_TIM_IsActiveFlag_CC2OVR
  3941. * @param TIMx Timer instance
  3942. * @retval State of bit (1 or 0).
  3943. */
  3944. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2OVR(TIM_TypeDef *TIMx)
  3945. {
  3946. return (READ_BIT(TIMx->SR, TIM_SR_CC2OF) == (TIM_SR_CC2OF));
  3947. }
  3948. /**
  3949. * @brief Clear the Capture/Compare 3 over-capture interrupt flag (CC3OF).
  3950. * @rmtoll SR CC3OF LL_TIM_ClearFlag_CC3OVR
  3951. * @param TIMx Timer instance
  3952. * @retval None
  3953. */
  3954. __STATIC_INLINE void LL_TIM_ClearFlag_CC3OVR(TIM_TypeDef *TIMx)
  3955. {
  3956. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3OF));
  3957. }
  3958. /**
  3959. * @brief Indicate whether Capture/Compare 3 over-capture interrupt flag (CC3OF) is set (Capture/Compare 3 over-capture interrupt is pending).
  3960. * @rmtoll SR CC3OF LL_TIM_IsActiveFlag_CC3OVR
  3961. * @param TIMx Timer instance
  3962. * @retval State of bit (1 or 0).
  3963. */
  3964. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3OVR(TIM_TypeDef *TIMx)
  3965. {
  3966. return (READ_BIT(TIMx->SR, TIM_SR_CC3OF) == (TIM_SR_CC3OF));
  3967. }
  3968. /**
  3969. * @brief Clear the Capture/Compare 4 over-capture interrupt flag (CC4OF).
  3970. * @rmtoll SR CC4OF LL_TIM_ClearFlag_CC4OVR
  3971. * @param TIMx Timer instance
  3972. * @retval None
  3973. */
  3974. __STATIC_INLINE void LL_TIM_ClearFlag_CC4OVR(TIM_TypeDef *TIMx)
  3975. {
  3976. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4OF));
  3977. }
  3978. /**
  3979. * @brief Indicate whether Capture/Compare 4 over-capture interrupt flag (CC4OF) is set (Capture/Compare 4 over-capture interrupt is pending).
  3980. * @rmtoll SR CC4OF LL_TIM_IsActiveFlag_CC4OVR
  3981. * @param TIMx Timer instance
  3982. * @retval State of bit (1 or 0).
  3983. */
  3984. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4OVR(TIM_TypeDef *TIMx)
  3985. {
  3986. return (READ_BIT(TIMx->SR, TIM_SR_CC4OF) == (TIM_SR_CC4OF));
  3987. }
  3988. /**
  3989. * @brief Clear the system break interrupt flag (SBIF).
  3990. * @rmtoll SR SBIF LL_TIM_ClearFlag_SYSBRK
  3991. * @param TIMx Timer instance
  3992. * @retval None
  3993. */
  3994. __STATIC_INLINE void LL_TIM_ClearFlag_SYSBRK(TIM_TypeDef *TIMx)
  3995. {
  3996. WRITE_REG(TIMx->SR, ~(TIM_SR_SBIF));
  3997. }
  3998. /**
  3999. * @brief Indicate whether system break interrupt flag (SBIF) is set (system break interrupt is pending).
  4000. * @rmtoll SR SBIF LL_TIM_IsActiveFlag_SYSBRK
  4001. * @param TIMx Timer instance
  4002. * @retval State of bit (1 or 0).
  4003. */
  4004. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_SYSBRK(TIM_TypeDef *TIMx)
  4005. {
  4006. return (READ_BIT(TIMx->SR, TIM_SR_SBIF) == (TIM_SR_SBIF));
  4007. }
  4008. /**
  4009. * @}
  4010. */
  4011. /** @defgroup TIM_LL_EF_IT_Management IT-Management
  4012. * @{
  4013. */
  4014. /**
  4015. * @brief Enable update interrupt (UIE).
  4016. * @rmtoll DIER UIE LL_TIM_EnableIT_UPDATE
  4017. * @param TIMx Timer instance
  4018. * @retval None
  4019. */
  4020. __STATIC_INLINE void LL_TIM_EnableIT_UPDATE(TIM_TypeDef *TIMx)
  4021. {
  4022. SET_BIT(TIMx->DIER, TIM_DIER_UIE);
  4023. }
  4024. /**
  4025. * @brief Disable update interrupt (UIE).
  4026. * @rmtoll DIER UIE LL_TIM_DisableIT_UPDATE
  4027. * @param TIMx Timer instance
  4028. * @retval None
  4029. */
  4030. __STATIC_INLINE void LL_TIM_DisableIT_UPDATE(TIM_TypeDef *TIMx)
  4031. {
  4032. CLEAR_BIT(TIMx->DIER, TIM_DIER_UIE);
  4033. }
  4034. /**
  4035. * @brief Indicates whether the update interrupt (UIE) is enabled.
  4036. * @rmtoll DIER UIE LL_TIM_IsEnabledIT_UPDATE
  4037. * @param TIMx Timer instance
  4038. * @retval State of bit (1 or 0).
  4039. */
  4040. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_UPDATE(TIM_TypeDef *TIMx)
  4041. {
  4042. return (READ_BIT(TIMx->DIER, TIM_DIER_UIE) == (TIM_DIER_UIE));
  4043. }
  4044. /**
  4045. * @brief Enable capture/compare 1 interrupt (CC1IE).
  4046. * @rmtoll DIER CC1IE LL_TIM_EnableIT_CC1
  4047. * @param TIMx Timer instance
  4048. * @retval None
  4049. */
  4050. __STATIC_INLINE void LL_TIM_EnableIT_CC1(TIM_TypeDef *TIMx)
  4051. {
  4052. SET_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  4053. }
  4054. /**
  4055. * @brief Disable capture/compare 1 interrupt (CC1IE).
  4056. * @rmtoll DIER CC1IE LL_TIM_DisableIT_CC1
  4057. * @param TIMx Timer instance
  4058. * @retval None
  4059. */
  4060. __STATIC_INLINE void LL_TIM_DisableIT_CC1(TIM_TypeDef *TIMx)
  4061. {
  4062. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  4063. }
  4064. /**
  4065. * @brief Indicates whether the capture/compare 1 interrupt (CC1IE) is enabled.
  4066. * @rmtoll DIER CC1IE LL_TIM_IsEnabledIT_CC1
  4067. * @param TIMx Timer instance
  4068. * @retval State of bit (1 or 0).
  4069. */
  4070. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC1(TIM_TypeDef *TIMx)
  4071. {
  4072. return (READ_BIT(TIMx->DIER, TIM_DIER_CC1IE) == (TIM_DIER_CC1IE));
  4073. }
  4074. /**
  4075. * @brief Enable capture/compare 2 interrupt (CC2IE).
  4076. * @rmtoll DIER CC2IE LL_TIM_EnableIT_CC2
  4077. * @param TIMx Timer instance
  4078. * @retval None
  4079. */
  4080. __STATIC_INLINE void LL_TIM_EnableIT_CC2(TIM_TypeDef *TIMx)
  4081. {
  4082. SET_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  4083. }
  4084. /**
  4085. * @brief Disable capture/compare 2 interrupt (CC2IE).
  4086. * @rmtoll DIER CC2IE LL_TIM_DisableIT_CC2
  4087. * @param TIMx Timer instance
  4088. * @retval None
  4089. */
  4090. __STATIC_INLINE void LL_TIM_DisableIT_CC2(TIM_TypeDef *TIMx)
  4091. {
  4092. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  4093. }
  4094. /**
  4095. * @brief Indicates whether the capture/compare 2 interrupt (CC2IE) is enabled.
  4096. * @rmtoll DIER CC2IE LL_TIM_IsEnabledIT_CC2
  4097. * @param TIMx Timer instance
  4098. * @retval State of bit (1 or 0).
  4099. */
  4100. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC2(TIM_TypeDef *TIMx)
  4101. {
  4102. return (READ_BIT(TIMx->DIER, TIM_DIER_CC2IE) == (TIM_DIER_CC2IE));
  4103. }
  4104. /**
  4105. * @brief Enable capture/compare 3 interrupt (CC3IE).
  4106. * @rmtoll DIER CC3IE LL_TIM_EnableIT_CC3
  4107. * @param TIMx Timer instance
  4108. * @retval None
  4109. */
  4110. __STATIC_INLINE void LL_TIM_EnableIT_CC3(TIM_TypeDef *TIMx)
  4111. {
  4112. SET_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  4113. }
  4114. /**
  4115. * @brief Disable capture/compare 3 interrupt (CC3IE).
  4116. * @rmtoll DIER CC3IE LL_TIM_DisableIT_CC3
  4117. * @param TIMx Timer instance
  4118. * @retval None
  4119. */
  4120. __STATIC_INLINE void LL_TIM_DisableIT_CC3(TIM_TypeDef *TIMx)
  4121. {
  4122. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  4123. }
  4124. /**
  4125. * @brief Indicates whether the capture/compare 3 interrupt (CC3IE) is enabled.
  4126. * @rmtoll DIER CC3IE LL_TIM_IsEnabledIT_CC3
  4127. * @param TIMx Timer instance
  4128. * @retval State of bit (1 or 0).
  4129. */
  4130. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC3(TIM_TypeDef *TIMx)
  4131. {
  4132. return (READ_BIT(TIMx->DIER, TIM_DIER_CC3IE) == (TIM_DIER_CC3IE));
  4133. }
  4134. /**
  4135. * @brief Enable capture/compare 4 interrupt (CC4IE).
  4136. * @rmtoll DIER CC4IE LL_TIM_EnableIT_CC4
  4137. * @param TIMx Timer instance
  4138. * @retval None
  4139. */
  4140. __STATIC_INLINE void LL_TIM_EnableIT_CC4(TIM_TypeDef *TIMx)
  4141. {
  4142. SET_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  4143. }
  4144. /**
  4145. * @brief Disable capture/compare 4 interrupt (CC4IE).
  4146. * @rmtoll DIER CC4IE LL_TIM_DisableIT_CC4
  4147. * @param TIMx Timer instance
  4148. * @retval None
  4149. */
  4150. __STATIC_INLINE void LL_TIM_DisableIT_CC4(TIM_TypeDef *TIMx)
  4151. {
  4152. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  4153. }
  4154. /**
  4155. * @brief Indicates whether the capture/compare 4 interrupt (CC4IE) is enabled.
  4156. * @rmtoll DIER CC4IE LL_TIM_IsEnabledIT_CC4
  4157. * @param TIMx Timer instance
  4158. * @retval State of bit (1 or 0).
  4159. */
  4160. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC4(TIM_TypeDef *TIMx)
  4161. {
  4162. return (READ_BIT(TIMx->DIER, TIM_DIER_CC4IE) == (TIM_DIER_CC4IE));
  4163. }
  4164. /**
  4165. * @brief Enable commutation interrupt (COMIE).
  4166. * @rmtoll DIER COMIE LL_TIM_EnableIT_COM
  4167. * @param TIMx Timer instance
  4168. * @retval None
  4169. */
  4170. __STATIC_INLINE void LL_TIM_EnableIT_COM(TIM_TypeDef *TIMx)
  4171. {
  4172. SET_BIT(TIMx->DIER, TIM_DIER_COMIE);
  4173. }
  4174. /**
  4175. * @brief Disable commutation interrupt (COMIE).
  4176. * @rmtoll DIER COMIE LL_TIM_DisableIT_COM
  4177. * @param TIMx Timer instance
  4178. * @retval None
  4179. */
  4180. __STATIC_INLINE void LL_TIM_DisableIT_COM(TIM_TypeDef *TIMx)
  4181. {
  4182. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMIE);
  4183. }
  4184. /**
  4185. * @brief Indicates whether the commutation interrupt (COMIE) is enabled.
  4186. * @rmtoll DIER COMIE LL_TIM_IsEnabledIT_COM
  4187. * @param TIMx Timer instance
  4188. * @retval State of bit (1 or 0).
  4189. */
  4190. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_COM(TIM_TypeDef *TIMx)
  4191. {
  4192. return (READ_BIT(TIMx->DIER, TIM_DIER_COMIE) == (TIM_DIER_COMIE));
  4193. }
  4194. /**
  4195. * @brief Enable trigger interrupt (TIE).
  4196. * @rmtoll DIER TIE LL_TIM_EnableIT_TRIG
  4197. * @param TIMx Timer instance
  4198. * @retval None
  4199. */
  4200. __STATIC_INLINE void LL_TIM_EnableIT_TRIG(TIM_TypeDef *TIMx)
  4201. {
  4202. SET_BIT(TIMx->DIER, TIM_DIER_TIE);
  4203. }
  4204. /**
  4205. * @brief Disable trigger interrupt (TIE).
  4206. * @rmtoll DIER TIE LL_TIM_DisableIT_TRIG
  4207. * @param TIMx Timer instance
  4208. * @retval None
  4209. */
  4210. __STATIC_INLINE void LL_TIM_DisableIT_TRIG(TIM_TypeDef *TIMx)
  4211. {
  4212. CLEAR_BIT(TIMx->DIER, TIM_DIER_TIE);
  4213. }
  4214. /**
  4215. * @brief Indicates whether the trigger interrupt (TIE) is enabled.
  4216. * @rmtoll DIER TIE LL_TIM_IsEnabledIT_TRIG
  4217. * @param TIMx Timer instance
  4218. * @retval State of bit (1 or 0).
  4219. */
  4220. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_TRIG(TIM_TypeDef *TIMx)
  4221. {
  4222. return (READ_BIT(TIMx->DIER, TIM_DIER_TIE) == (TIM_DIER_TIE));
  4223. }
  4224. /**
  4225. * @brief Enable break interrupt (BIE).
  4226. * @rmtoll DIER BIE LL_TIM_EnableIT_BRK
  4227. * @param TIMx Timer instance
  4228. * @retval None
  4229. */
  4230. __STATIC_INLINE void LL_TIM_EnableIT_BRK(TIM_TypeDef *TIMx)
  4231. {
  4232. SET_BIT(TIMx->DIER, TIM_DIER_BIE);
  4233. }
  4234. /**
  4235. * @brief Disable break interrupt (BIE).
  4236. * @rmtoll DIER BIE LL_TIM_DisableIT_BRK
  4237. * @param TIMx Timer instance
  4238. * @retval None
  4239. */
  4240. __STATIC_INLINE void LL_TIM_DisableIT_BRK(TIM_TypeDef *TIMx)
  4241. {
  4242. CLEAR_BIT(TIMx->DIER, TIM_DIER_BIE);
  4243. }
  4244. /**
  4245. * @brief Indicates whether the break interrupt (BIE) is enabled.
  4246. * @rmtoll DIER BIE LL_TIM_IsEnabledIT_BRK
  4247. * @param TIMx Timer instance
  4248. * @retval State of bit (1 or 0).
  4249. */
  4250. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_BRK(TIM_TypeDef *TIMx)
  4251. {
  4252. return (READ_BIT(TIMx->DIER, TIM_DIER_BIE) == (TIM_DIER_BIE));
  4253. }
  4254. /**
  4255. * @}
  4256. */
  4257. /** @defgroup TIM_LL_EF_DMA_Management DMA-Management
  4258. * @{
  4259. */
  4260. /**
  4261. * @brief Enable update DMA request (UDE).
  4262. * @rmtoll DIER UDE LL_TIM_EnableDMAReq_UPDATE
  4263. * @param TIMx Timer instance
  4264. * @retval None
  4265. */
  4266. __STATIC_INLINE void LL_TIM_EnableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  4267. {
  4268. SET_BIT(TIMx->DIER, TIM_DIER_UDE);
  4269. }
  4270. /**
  4271. * @brief Disable update DMA request (UDE).
  4272. * @rmtoll DIER UDE LL_TIM_DisableDMAReq_UPDATE
  4273. * @param TIMx Timer instance
  4274. * @retval None
  4275. */
  4276. __STATIC_INLINE void LL_TIM_DisableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  4277. {
  4278. CLEAR_BIT(TIMx->DIER, TIM_DIER_UDE);
  4279. }
  4280. /**
  4281. * @brief Indicates whether the update DMA request (UDE) is enabled.
  4282. * @rmtoll DIER UDE LL_TIM_IsEnabledDMAReq_UPDATE
  4283. * @param TIMx Timer instance
  4284. * @retval State of bit (1 or 0).
  4285. */
  4286. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_UPDATE(TIM_TypeDef *TIMx)
  4287. {
  4288. return (READ_BIT(TIMx->DIER, TIM_DIER_UDE) == (TIM_DIER_UDE));
  4289. }
  4290. /**
  4291. * @brief Enable capture/compare 1 DMA request (CC1DE).
  4292. * @rmtoll DIER CC1DE LL_TIM_EnableDMAReq_CC1
  4293. * @param TIMx Timer instance
  4294. * @retval None
  4295. */
  4296. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC1(TIM_TypeDef *TIMx)
  4297. {
  4298. SET_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  4299. }
  4300. /**
  4301. * @brief Disable capture/compare 1 DMA request (CC1DE).
  4302. * @rmtoll DIER CC1DE LL_TIM_DisableDMAReq_CC1
  4303. * @param TIMx Timer instance
  4304. * @retval None
  4305. */
  4306. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC1(TIM_TypeDef *TIMx)
  4307. {
  4308. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  4309. }
  4310. /**
  4311. * @brief Indicates whether the capture/compare 1 DMA request (CC1DE) is enabled.
  4312. * @rmtoll DIER CC1DE LL_TIM_IsEnabledDMAReq_CC1
  4313. * @param TIMx Timer instance
  4314. * @retval State of bit (1 or 0).
  4315. */
  4316. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC1(TIM_TypeDef *TIMx)
  4317. {
  4318. return (READ_BIT(TIMx->DIER, TIM_DIER_CC1DE) == (TIM_DIER_CC1DE));
  4319. }
  4320. /**
  4321. * @brief Enable capture/compare 2 DMA request (CC2DE).
  4322. * @rmtoll DIER CC2DE LL_TIM_EnableDMAReq_CC2
  4323. * @param TIMx Timer instance
  4324. * @retval None
  4325. */
  4326. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC2(TIM_TypeDef *TIMx)
  4327. {
  4328. SET_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  4329. }
  4330. /**
  4331. * @brief Disable capture/compare 2 DMA request (CC2DE).
  4332. * @rmtoll DIER CC2DE LL_TIM_DisableDMAReq_CC2
  4333. * @param TIMx Timer instance
  4334. * @retval None
  4335. */
  4336. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC2(TIM_TypeDef *TIMx)
  4337. {
  4338. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  4339. }
  4340. /**
  4341. * @brief Indicates whether the capture/compare 2 DMA request (CC2DE) is enabled.
  4342. * @rmtoll DIER CC2DE LL_TIM_IsEnabledDMAReq_CC2
  4343. * @param TIMx Timer instance
  4344. * @retval State of bit (1 or 0).
  4345. */
  4346. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC2(TIM_TypeDef *TIMx)
  4347. {
  4348. return (READ_BIT(TIMx->DIER, TIM_DIER_CC2DE) == (TIM_DIER_CC2DE));
  4349. }
  4350. /**
  4351. * @brief Enable capture/compare 3 DMA request (CC3DE).
  4352. * @rmtoll DIER CC3DE LL_TIM_EnableDMAReq_CC3
  4353. * @param TIMx Timer instance
  4354. * @retval None
  4355. */
  4356. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC3(TIM_TypeDef *TIMx)
  4357. {
  4358. SET_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  4359. }
  4360. /**
  4361. * @brief Disable capture/compare 3 DMA request (CC3DE).
  4362. * @rmtoll DIER CC3DE LL_TIM_DisableDMAReq_CC3
  4363. * @param TIMx Timer instance
  4364. * @retval None
  4365. */
  4366. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC3(TIM_TypeDef *TIMx)
  4367. {
  4368. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  4369. }
  4370. /**
  4371. * @brief Indicates whether the capture/compare 3 DMA request (CC3DE) is enabled.
  4372. * @rmtoll DIER CC3DE LL_TIM_IsEnabledDMAReq_CC3
  4373. * @param TIMx Timer instance
  4374. * @retval State of bit (1 or 0).
  4375. */
  4376. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC3(TIM_TypeDef *TIMx)
  4377. {
  4378. return (READ_BIT(TIMx->DIER, TIM_DIER_CC3DE) == (TIM_DIER_CC3DE));
  4379. }
  4380. /**
  4381. * @brief Enable capture/compare 4 DMA request (CC4DE).
  4382. * @rmtoll DIER CC4DE LL_TIM_EnableDMAReq_CC4
  4383. * @param TIMx Timer instance
  4384. * @retval None
  4385. */
  4386. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC4(TIM_TypeDef *TIMx)
  4387. {
  4388. SET_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  4389. }
  4390. /**
  4391. * @brief Disable capture/compare 4 DMA request (CC4DE).
  4392. * @rmtoll DIER CC4DE LL_TIM_DisableDMAReq_CC4
  4393. * @param TIMx Timer instance
  4394. * @retval None
  4395. */
  4396. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC4(TIM_TypeDef *TIMx)
  4397. {
  4398. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  4399. }
  4400. /**
  4401. * @brief Indicates whether the capture/compare 4 DMA request (CC4DE) is enabled.
  4402. * @rmtoll DIER CC4DE LL_TIM_IsEnabledDMAReq_CC4
  4403. * @param TIMx Timer instance
  4404. * @retval State of bit (1 or 0).
  4405. */
  4406. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC4(TIM_TypeDef *TIMx)
  4407. {
  4408. return (READ_BIT(TIMx->DIER, TIM_DIER_CC4DE) == (TIM_DIER_CC4DE));
  4409. }
  4410. /**
  4411. * @brief Enable commutation DMA request (COMDE).
  4412. * @rmtoll DIER COMDE LL_TIM_EnableDMAReq_COM
  4413. * @param TIMx Timer instance
  4414. * @retval None
  4415. */
  4416. __STATIC_INLINE void LL_TIM_EnableDMAReq_COM(TIM_TypeDef *TIMx)
  4417. {
  4418. SET_BIT(TIMx->DIER, TIM_DIER_COMDE);
  4419. }
  4420. /**
  4421. * @brief Disable commutation DMA request (COMDE).
  4422. * @rmtoll DIER COMDE LL_TIM_DisableDMAReq_COM
  4423. * @param TIMx Timer instance
  4424. * @retval None
  4425. */
  4426. __STATIC_INLINE void LL_TIM_DisableDMAReq_COM(TIM_TypeDef *TIMx)
  4427. {
  4428. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMDE);
  4429. }
  4430. /**
  4431. * @brief Indicates whether the commutation DMA request (COMDE) is enabled.
  4432. * @rmtoll DIER COMDE LL_TIM_IsEnabledDMAReq_COM
  4433. * @param TIMx Timer instance
  4434. * @retval State of bit (1 or 0).
  4435. */
  4436. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_COM(TIM_TypeDef *TIMx)
  4437. {
  4438. return (READ_BIT(TIMx->DIER, TIM_DIER_COMDE) == (TIM_DIER_COMDE));
  4439. }
  4440. /**
  4441. * @brief Enable trigger interrupt (TDE).
  4442. * @rmtoll DIER TDE LL_TIM_EnableDMAReq_TRIG
  4443. * @param TIMx Timer instance
  4444. * @retval None
  4445. */
  4446. __STATIC_INLINE void LL_TIM_EnableDMAReq_TRIG(TIM_TypeDef *TIMx)
  4447. {
  4448. SET_BIT(TIMx->DIER, TIM_DIER_TDE);
  4449. }
  4450. /**
  4451. * @brief Disable trigger interrupt (TDE).
  4452. * @rmtoll DIER TDE LL_TIM_DisableDMAReq_TRIG
  4453. * @param TIMx Timer instance
  4454. * @retval None
  4455. */
  4456. __STATIC_INLINE void LL_TIM_DisableDMAReq_TRIG(TIM_TypeDef *TIMx)
  4457. {
  4458. CLEAR_BIT(TIMx->DIER, TIM_DIER_TDE);
  4459. }
  4460. /**
  4461. * @brief Indicates whether the trigger interrupt (TDE) is enabled.
  4462. * @rmtoll DIER TDE LL_TIM_IsEnabledDMAReq_TRIG
  4463. * @param TIMx Timer instance
  4464. * @retval State of bit (1 or 0).
  4465. */
  4466. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_TRIG(TIM_TypeDef *TIMx)
  4467. {
  4468. return (READ_BIT(TIMx->DIER, TIM_DIER_TDE) == (TIM_DIER_TDE));
  4469. }
  4470. /**
  4471. * @}
  4472. */
  4473. /** @defgroup TIM_LL_EF_EVENT_Management EVENT-Management
  4474. * @{
  4475. */
  4476. /**
  4477. * @brief Generate an update event.
  4478. * @rmtoll EGR UG LL_TIM_GenerateEvent_UPDATE
  4479. * @param TIMx Timer instance
  4480. * @retval None
  4481. */
  4482. __STATIC_INLINE void LL_TIM_GenerateEvent_UPDATE(TIM_TypeDef *TIMx)
  4483. {
  4484. SET_BIT(TIMx->EGR, TIM_EGR_UG);
  4485. }
  4486. /**
  4487. * @brief Generate Capture/Compare 1 event.
  4488. * @rmtoll EGR CC1G LL_TIM_GenerateEvent_CC1
  4489. * @param TIMx Timer instance
  4490. * @retval None
  4491. */
  4492. __STATIC_INLINE void LL_TIM_GenerateEvent_CC1(TIM_TypeDef *TIMx)
  4493. {
  4494. SET_BIT(TIMx->EGR, TIM_EGR_CC1G);
  4495. }
  4496. /**
  4497. * @brief Generate Capture/Compare 2 event.
  4498. * @rmtoll EGR CC2G LL_TIM_GenerateEvent_CC2
  4499. * @param TIMx Timer instance
  4500. * @retval None
  4501. */
  4502. __STATIC_INLINE void LL_TIM_GenerateEvent_CC2(TIM_TypeDef *TIMx)
  4503. {
  4504. SET_BIT(TIMx->EGR, TIM_EGR_CC2G);
  4505. }
  4506. /**
  4507. * @brief Generate Capture/Compare 3 event.
  4508. * @rmtoll EGR CC3G LL_TIM_GenerateEvent_CC3
  4509. * @param TIMx Timer instance
  4510. * @retval None
  4511. */
  4512. __STATIC_INLINE void LL_TIM_GenerateEvent_CC3(TIM_TypeDef *TIMx)
  4513. {
  4514. SET_BIT(TIMx->EGR, TIM_EGR_CC3G);
  4515. }
  4516. /**
  4517. * @brief Generate Capture/Compare 4 event.
  4518. * @rmtoll EGR CC4G LL_TIM_GenerateEvent_CC4
  4519. * @param TIMx Timer instance
  4520. * @retval None
  4521. */
  4522. __STATIC_INLINE void LL_TIM_GenerateEvent_CC4(TIM_TypeDef *TIMx)
  4523. {
  4524. SET_BIT(TIMx->EGR, TIM_EGR_CC4G);
  4525. }
  4526. /**
  4527. * @brief Generate commutation event.
  4528. * @rmtoll EGR COMG LL_TIM_GenerateEvent_COM
  4529. * @param TIMx Timer instance
  4530. * @retval None
  4531. */
  4532. __STATIC_INLINE void LL_TIM_GenerateEvent_COM(TIM_TypeDef *TIMx)
  4533. {
  4534. SET_BIT(TIMx->EGR, TIM_EGR_COMG);
  4535. }
  4536. /**
  4537. * @brief Generate trigger event.
  4538. * @rmtoll EGR TG LL_TIM_GenerateEvent_TRIG
  4539. * @param TIMx Timer instance
  4540. * @retval None
  4541. */
  4542. __STATIC_INLINE void LL_TIM_GenerateEvent_TRIG(TIM_TypeDef *TIMx)
  4543. {
  4544. SET_BIT(TIMx->EGR, TIM_EGR_TG);
  4545. }
  4546. /**
  4547. * @brief Generate break event.
  4548. * @rmtoll EGR BG LL_TIM_GenerateEvent_BRK
  4549. * @param TIMx Timer instance
  4550. * @retval None
  4551. */
  4552. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK(TIM_TypeDef *TIMx)
  4553. {
  4554. SET_BIT(TIMx->EGR, TIM_EGR_BG);
  4555. }
  4556. /**
  4557. * @brief Generate break 2 event.
  4558. * @rmtoll EGR B2G LL_TIM_GenerateEvent_BRK2
  4559. * @param TIMx Timer instance
  4560. * @retval None
  4561. */
  4562. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK2(TIM_TypeDef *TIMx)
  4563. {
  4564. SET_BIT(TIMx->EGR, TIM_EGR_B2G);
  4565. }
  4566. /**
  4567. * @}
  4568. */
  4569. #if defined(USE_FULL_LL_DRIVER)
  4570. /** @defgroup TIM_LL_EF_Init Initialisation and deinitialisation functions
  4571. * @{
  4572. */
  4573. ErrorStatus LL_TIM_DeInit(TIM_TypeDef *TIMx);
  4574. void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct);
  4575. ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct);
  4576. void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  4577. ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  4578. void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
  4579. ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct);
  4580. void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  4581. ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  4582. void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  4583. ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  4584. void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  4585. ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  4586. /**
  4587. * @}
  4588. */
  4589. #endif /* USE_FULL_LL_DRIVER */
  4590. /**
  4591. * @}
  4592. */
  4593. /**
  4594. * @}
  4595. */
  4596. #endif /* TIM1 || TIM8 || TIM2 || TIM3 || TIM4 || TIM5 || TIM15 || TIM16 || TIM17 || TIM6 || TIM7 */
  4597. /**
  4598. * @}
  4599. */
  4600. #ifdef __cplusplus
  4601. }
  4602. #endif
  4603. #endif /* __STM32L4xx_LL_TIM_H */
  4604. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/