stm32f7xx_ll_tim.h 200 KB

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