stm32l4xx_ll_tim.h 221 KB

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