stm32g0xx_ll_tim.h 224 KB

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