stm32g0xx_ll_tim.h 230 KB

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